diff --git a/common/ManagementTestShared/Temp/ModelReaderWriterImplementationValidation.cs b/common/ManagementTestShared/Temp/ModelReaderWriterImplementationValidation.cs new file mode 100644 index 0000000000000..a3eab10b84f74 --- /dev/null +++ b/common/ManagementTestShared/Temp/ModelReaderWriterImplementationValidation.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using NUnit.Framework; + +namespace Azure.ResourceManager.TestFramework +{ + public sealed partial class ModelReaderWriterImplementationValidation + { + private string[] ExceptionList { get; set; } + + private const string ModelNamespaceSuffix = ".Models"; + private const string AssemblyPrefix = "Azure.ResourceManager."; + private const string ResourceManagerAssemblyName = "Azure.ResourceManager"; + private const string TestAssemblySuffix = ".Tests"; + + [Test] + public void ValidateModelReaderWriterPattern() + { + var testAssembly = Assembly.GetExecutingAssembly(); + var assemblyName = testAssembly.GetName().Name; + Assert.IsTrue(assemblyName.EndsWith(TestAssemblySuffix), $"The test assembly should end with {TestAssemblySuffix}"); + var rpNamespace = assemblyName.Substring(0, assemblyName.Length - TestAssemblySuffix.Length); + + TestContext.WriteLine($"Testing assembly {rpNamespace}"); + + if (!rpNamespace.StartsWith(AssemblyPrefix) && rpNamespace != ResourceManagerAssemblyName) + { + // this is not a MPG project + return; + } + + // find the SDK assembly by filtering the assemblies in the current domain, or load it if not found (when there is no test case) + var sdkAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == rpNamespace) ?? Assembly.Load(rpNamespace); + + Assert.IsNotNull(sdkAssembly, $"The SDK assembly {rpNamespace} not found"); + + List violatedTypes = new(); + var exceptionList = ExceptionList == null ? new HashSet() : new HashSet(ExceptionList); + foreach (var type in sdkAssembly.GetTypes()) + { + if (IsModelType(type, exceptionList)) + { + TestContext.WriteLine($"Verifying class {type}"); + CheckModelType(type, violatedTypes); + } + } + + if (violatedTypes.Count > 0) + { + var builder = new StringBuilder(); + builder.AppendLine($"The following type should either implement {typeof(IJsonModel<>)} or {typeof(IPersistableModel<>)}:"); + foreach (var type in violatedTypes) + { + builder.AppendLine(type.ToString()); + } + Assert.Fail(builder.ToString()); + } + } + + private static bool IsModelType(Type type, HashSet exceptionList) + { + if (!type.IsPublic || type.IsInterface || IsStaticType(type) || !type.IsClass) + return false; + + if (exceptionList.Contains($"{type.Namespace}.{type.Name}")) + return false; + + // if the type is in the Models namespace, it is a model + if (type.Namespace.EndsWith(ModelNamespaceSuffix)) + return true; + + return false; + } + + private static void CheckModelType(Type type, List violatedTypes) + { + var interfaces = type.GetInterfaces(); + var iJsonModelType = typeof(IJsonModel<>).MakeGenericType(type); + var iPersistableModelType = typeof(IPersistableModel<>).MakeGenericType(type); + // check the type implements the IJsonModel interface + if (interfaces.Contains(iJsonModelType)) + return; + // if not, it should implements the IPersistableModel interface + if (interfaces.Contains(iPersistableModelType)) + return; + + violatedTypes.Add(type); + } + + private static bool IsStaticType(Type type) => type.IsSealed && type.IsAbstract; // CLR uses sealed and abstract to represent static classes + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/Azure.ResourceManager.sln b/sdk/resourcemanager/Azure.ResourceManager/Azure.ResourceManager.sln index 9cf6e1762a845..305326f0be670 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/Azure.ResourceManager.sln +++ b/sdk/resourcemanager/Azure.ResourceManager/Azure.ResourceManager.sln @@ -21,12 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{4E159B41-7 docs\Sample3_CreatingAVirtualNetwork.md = docs\Sample3_CreatingAVirtualNetwork.md EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core", "..\..\core\Azure.Core\src\Azure.Core.csproj", "{E0F3952A-D1C7-4CE4-B2A8-5C34945EBED8}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Perf", "perf\Azure.ResourceManager.Perf.csproj", "{138A2FF1-F1AB-480A-9588-136FB875026E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Test.Perf", "..\..\..\common\Perf\Azure.Test.Perf\Azure.Test.Perf.csproj", "{AD397048-D114-4A32-8F35-64E5C72A4697}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Samples", "samples\Azure.ResourceManager.Samples.csproj", "{0D3137B9-8FB5-46E3-9033-84EF6DBE8D1E}" EndProject Global diff --git a/sdk/resourcemanager/Azure.ResourceManager/api/Azure.ResourceManager.netstandard2.0.cs b/sdk/resourcemanager/Azure.ResourceManager/api/Azure.ResourceManager.netstandard2.0.cs index 017dfaa5133c0..e9b5aa9716d36 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/api/Azure.ResourceManager.netstandard2.0.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/api/Azure.ResourceManager.netstandard2.0.cs @@ -143,13 +143,18 @@ protected ManagementGroupCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class ManagementGroupData : Azure.ResourceManager.Models.ResourceData + public partial class ManagementGroupData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ManagementGroupData() { } public System.Collections.Generic.IReadOnlyList Children { get { throw null; } } public Azure.ResourceManager.ManagementGroups.Models.ManagementGroupInfo Details { get { throw null; } } public string DisplayName { get { throw null; } } public System.Guid? TenantId { get { throw null; } } + Azure.ResourceManager.ManagementGroups.ManagementGroupData 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.ManagementGroups.ManagementGroupData 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 ManagementGroupResource : Azure.ResourceManager.ArmResource { @@ -176,21 +181,31 @@ protected ManagementGroupResource() { } } namespace Azure.ResourceManager.ManagementGroups.Models { - public partial class CreateManagementGroupDetails + public partial class CreateManagementGroupDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CreateManagementGroupDetails() { } public Azure.ResourceManager.ManagementGroups.Models.ManagementGroupParentCreateOptions Parent { get { throw null; } set { } } public string UpdatedBy { get { throw null; } } public System.DateTimeOffset? UpdatedOn { get { throw null; } } public int? Version { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.CreateManagementGroupDetails 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.ManagementGroups.Models.CreateManagementGroupDetails 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 DescendantData : Azure.ResourceManager.Models.ResourceData + public partial class DescendantData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DescendantData() { } public string DisplayName { get { throw null; } } public Azure.Core.ResourceIdentifier ParentId { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.DescendantData 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.ManagementGroups.Models.DescendantData 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 ManagementGroupChildInfo + public partial class ManagementGroupChildInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ManagementGroupChildInfo() { } public System.Collections.Generic.IReadOnlyList Children { get { throw null; } } @@ -198,8 +213,13 @@ internal ManagementGroupChildInfo() { } public string DisplayName { get { throw null; } } public string Id { get { throw null; } } public string Name { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildInfo 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.ManagementGroups.Models.ManagementGroupChildInfo 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 ManagementGroupChildOptions + public partial class ManagementGroupChildOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ManagementGroupChildOptions() { } public System.Collections.Generic.IReadOnlyList Children { get { throw null; } } @@ -207,6 +227,11 @@ internal ManagementGroupChildOptions() { } public string DisplayName { get { throw null; } } public string Id { get { throw null; } } public string Name { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildOptions 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.ManagementGroups.Models.ManagementGroupChildOptions 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 ManagementGroupChildType : System.IEquatable @@ -226,7 +251,7 @@ internal ManagementGroupChildOptions() { } public static bool operator !=(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType left, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType right) { throw null; } public override string ToString() { throw null; } } - public partial class ManagementGroupCreateOrUpdateContent + public partial class ManagementGroupCreateOrUpdateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagementGroupCreateOrUpdateContent() { } public System.Collections.Generic.IReadOnlyList Children { get { throw null; } } @@ -236,6 +261,11 @@ public ManagementGroupCreateOrUpdateContent() { } public string Name { get { throw null; } set { } } public Azure.Core.ResourceType? ResourceType { get { throw null; } } public System.Guid? TenantId { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupCreateOrUpdateContent 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.ManagementGroups.Models.ManagementGroupCreateOrUpdateContent 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 ManagementGroupExpandType : System.IEquatable @@ -256,7 +286,7 @@ public ManagementGroupCreateOrUpdateContent() { } public static bool operator !=(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType left, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType right) { throw null; } public override string ToString() { throw null; } } - public partial class ManagementGroupInfo + public partial class ManagementGroupInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ManagementGroupInfo() { } public System.Collections.Generic.IReadOnlyList ManagementGroupAncestorChain { get { throw null; } } @@ -266,55 +296,90 @@ internal ManagementGroupInfo() { } public string UpdatedBy { get { throw null; } } public System.DateTimeOffset? UpdatedOn { get { throw null; } } public int? Version { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupInfo 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.ManagementGroups.Models.ManagementGroupInfo 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 ManagementGroupNameAvailabilityContent + public partial class ManagementGroupNameAvailabilityContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagementGroupNameAvailabilityContent() { } public string Name { get { throw null; } set { } } public Azure.Core.ResourceType? ResourceType { get { throw null; } set { } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupNameAvailabilityContent 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.ManagementGroups.Models.ManagementGroupNameAvailabilityContent 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 ManagementGroupNameAvailabilityResult + public partial class ManagementGroupNameAvailabilityResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ManagementGroupNameAvailabilityResult() { } public string Message { get { throw null; } } public bool? NameAvailable { get { throw null; } } public Azure.ResourceManager.ManagementGroups.Models.ManagementGroupNameUnavailableReason? Reason { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupNameAvailabilityResult 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.ManagementGroups.Models.ManagementGroupNameAvailabilityResult 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 enum ManagementGroupNameUnavailableReason { Invalid = 0, AlreadyExists = 1, } - public partial class ManagementGroupParentCreateOptions + public partial class ManagementGroupParentCreateOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagementGroupParentCreateOptions() { } public string DisplayName { get { throw null; } } public string Id { get { throw null; } set { } } public string Name { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupParentCreateOptions 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.ManagementGroups.Models.ManagementGroupParentCreateOptions 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 ManagementGroupPatch + public partial class ManagementGroupPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagementGroupPatch() { } public string DisplayName { get { throw null; } set { } } public string ParentGroupId { get { throw null; } set { } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupPatch 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.ManagementGroups.Models.ManagementGroupPatch 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 ManagementGroupPathElement + public partial class ManagementGroupPathElement : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ManagementGroupPathElement() { } public string DisplayName { get { throw null; } } public string Name { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.ManagementGroupPathElement 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.ManagementGroups.Models.ManagementGroupPathElement 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 ParentManagementGroupInfo + public partial class ParentManagementGroupInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ParentManagementGroupInfo() { } public string DisplayName { get { throw null; } } public string Id { get { throw null; } } public string Name { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.ParentManagementGroupInfo 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.ManagementGroups.Models.ParentManagementGroupInfo 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; } } } namespace Azure.ResourceManager.Models { - public sealed partial class ArmPlan : System.IEquatable + public sealed partial class ArmPlan : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel, System.IEquatable { public ArmPlan(string name, string publisher, string product) { } public string Name { get { throw null; } set { } } @@ -329,8 +394,13 @@ public ArmPlan(string name, string publisher, string product) { } public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.Models.ArmPlan left, Azure.ResourceManager.Models.ArmPlan right) { throw null; } public static bool operator !=(Azure.ResourceManager.Models.ArmPlan left, Azure.ResourceManager.Models.ArmPlan right) { throw null; } + Azure.ResourceManager.Models.ArmPlan 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.Models.ArmPlan 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 sealed partial class ArmSku : System.IEquatable + public sealed partial class ArmSku : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel, System.IEquatable { public ArmSku(string name) { } public int? Capacity { get { throw null; } set { } } @@ -345,6 +415,11 @@ public ArmSku(string name) { } public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.Models.ArmSku left, Azure.ResourceManager.Models.ArmSku right) { throw null; } public static bool operator !=(Azure.ResourceManager.Models.ArmSku left, Azure.ResourceManager.Models.ArmSku right) { throw null; } + Azure.ResourceManager.Models.ArmSku 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.Models.ArmSku 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 enum ArmSkuTier { @@ -375,11 +450,16 @@ public enum ArmSkuTier } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This type is obsolete and will be removed in a future release.", false)] - public partial class EncryptionProperties + public partial class EncryptionProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EncryptionProperties() { } public Azure.ResourceManager.Models.KeyVaultProperties KeyVaultProperties { get { throw null; } set { } } public Azure.ResourceManager.Models.EncryptionStatus? Status { get { throw null; } set { } } + Azure.ResourceManager.Models.EncryptionProperties 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.Models.EncryptionProperties 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.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This type is obsolete and will be removed in a future release.", false)] @@ -403,19 +483,29 @@ public EncryptionProperties() { } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This type is obsolete and will be removed in a future release.", false)] - public partial class KeyVaultProperties + public partial class KeyVaultProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeyVaultProperties() { } public string Identity { get { throw null; } set { } } public string KeyIdentifier { get { throw null; } set { } } + Azure.ResourceManager.Models.KeyVaultProperties 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.Models.KeyVaultProperties 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 ManagedServiceIdentity + public partial class ManagedServiceIdentity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagedServiceIdentity(Azure.ResourceManager.Models.ManagedServiceIdentityType managedServiceIdentityType) { } public Azure.ResourceManager.Models.ManagedServiceIdentityType ManagedServiceIdentityType { get { throw null; } set { } } public System.Guid? PrincipalId { get { throw null; } } public System.Guid? TenantId { get { throw null; } } public System.Collections.Generic.IDictionary UserAssignedIdentities { get { throw null; } } + Azure.ResourceManager.Models.ManagedServiceIdentity 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.Models.ManagedServiceIdentity 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 ManagedServiceIdentityType : System.IEquatable @@ -437,7 +527,7 @@ public ManagedServiceIdentity(Azure.ResourceManager.Models.ManagedServiceIdentit public static bool operator !=(Azure.ResourceManager.Models.ManagedServiceIdentityType left, Azure.ResourceManager.Models.ManagedServiceIdentityType right) { throw null; } public override string ToString() { throw null; } } - public partial class OperationStatusResult + public partial class OperationStatusResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected OperationStatusResult(Azure.Core.ResourceIdentifier id, string name, string status, float? percentComplete, System.DateTimeOffset? startOn, System.DateTimeOffset? endOn, System.Collections.Generic.IReadOnlyList operations, Azure.ResponseError error) { } public OperationStatusResult(string status) { } @@ -449,6 +539,11 @@ public OperationStatusResult(string status) { } public float? PercentComplete { get { throw null; } } public System.DateTimeOffset? StartOn { get { throw null; } } public string Status { get { throw null; } } + Azure.ResourceManager.Models.OperationStatusResult 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.Models.OperationStatusResult 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 abstract partial class ResourceData { @@ -464,6 +559,7 @@ public static partial class ResourceManagerModelFactory public static Azure.ResourceManager.Resources.Models.ApiProfile ApiProfile(string profileVersion = null, string apiVersion = null) { throw null; } public static Azure.ResourceManager.Resources.Models.AvailabilityZoneMappings AvailabilityZoneMappings(string logicalZone = null, string physicalZone = null) { throw null; } public static Azure.ResourceManager.Resources.Models.AzureRoleDefinition AzureRoleDefinition(string id = null, string name = null, bool? isServiceRole = default(bool?), System.Collections.Generic.IEnumerable permissions = null, System.Collections.Generic.IEnumerable scopes = null) { throw null; } + public static Azure.ResourceManager.ManagementGroups.Models.CreateManagementGroupDetails CreateManagementGroupDetails(int? version = default(int?), System.DateTimeOffset? updatedOn = default(System.DateTimeOffset?), string updatedBy = null, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupParentCreateOptions parent = null) { throw null; } public static Azure.ResourceManager.Resources.Models.DataManifestCustomResourceFunctionDefinition DataManifestCustomResourceFunctionDefinition(string name = null, Azure.Core.ResourceType? fullyQualifiedResourceType = default(Azure.Core.ResourceType?), System.Collections.Generic.IEnumerable defaultProperties = null, bool? allowCustomProperties = default(bool?)) { throw null; } public static Azure.ResourceManager.Resources.DataPolicyManifestData DataPolicyManifestData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IEnumerable namespaces = null, string policyMode = null, bool? isBuiltInOnly = default(bool?), System.Collections.Generic.IEnumerable resourceTypeAliases = null, System.Collections.Generic.IEnumerable effects = null, System.Collections.Generic.IEnumerable fieldValues = null, System.Collections.Generic.IEnumerable standard = null, System.Collections.Generic.IEnumerable customDefinitions = null) { throw null; } public static Azure.ResourceManager.Resources.Models.DataPolicyManifestEffect DataPolicyManifestEffect(string name = null, System.BinaryData detailsSchema = null) { throw null; } @@ -474,10 +570,14 @@ public static partial class ResourceManagerModelFactory public static Azure.ResourceManager.Resources.Models.LocationExpanded LocationExpanded(string id = null, string subscriptionId = null, string name = null, Azure.ResourceManager.Resources.Models.LocationType? locationType = default(Azure.ResourceManager.Resources.Models.LocationType?), string displayName = null, string regionalDisplayName = null, Azure.ResourceManager.Resources.Models.LocationMetadata metadata = null, System.Collections.Generic.IEnumerable availabilityZoneMappings = null) { throw null; } public static Azure.ResourceManager.Resources.Models.LocationMetadata LocationMetadata(Azure.ResourceManager.Resources.Models.RegionType? regionType = default(Azure.ResourceManager.Resources.Models.RegionType?), Azure.ResourceManager.Resources.Models.RegionCategory? regionCategory = default(Azure.ResourceManager.Resources.Models.RegionCategory?), string geography = null, string geographyGroup = null, double? longitude = default(double?), double? latitude = default(double?), string physicalLocation = null, System.Collections.Generic.IEnumerable pairedRegions = null, string homeLocation = null) { throw null; } public static Azure.ResourceManager.Resources.Models.ManagedByTenant ManagedByTenant(System.Guid? tenantId = default(System.Guid?)) { throw null; } + public static Azure.ResourceManager.Models.ManagedServiceIdentity ManagedServiceIdentity(System.Guid? principalId, System.Guid? tenantId, Azure.ResourceManager.Models.ManagedServiceIdentityType managedServiceIdentityType, System.Collections.Generic.IDictionary userAssignedIdentities) { throw null; } public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildInfo ManagementGroupChildInfo(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType? childType = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType?), string id = null, string name = null, string displayName = null, System.Collections.Generic.IEnumerable children = null) { throw null; } + public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildOptions ManagementGroupChildOptions(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType? childType = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType?), string id = null, string name = null, string displayName = null, System.Collections.Generic.IEnumerable children = null) { throw null; } + public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupCreateOrUpdateContent ManagementGroupCreateOrUpdateContent(string id = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), string name = null, System.Guid? tenantId = default(System.Guid?), string displayName = null, Azure.ResourceManager.ManagementGroups.Models.CreateManagementGroupDetails details = null, System.Collections.Generic.IEnumerable children = null) { throw null; } public static Azure.ResourceManager.ManagementGroups.ManagementGroupData ManagementGroupData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Guid? tenantId = default(System.Guid?), string displayName = null, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupInfo details = null, System.Collections.Generic.IEnumerable children = null) { throw null; } public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupInfo ManagementGroupInfo(int? version = default(int?), System.DateTimeOffset? updatedOn = default(System.DateTimeOffset?), string updatedBy = null, Azure.ResourceManager.ManagementGroups.Models.ParentManagementGroupInfo parent = null, System.Collections.Generic.IEnumerable path = null, System.Collections.Generic.IEnumerable managementGroupAncestors = null, System.Collections.Generic.IEnumerable managementGroupAncestorChain = null) { throw null; } public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupNameAvailabilityResult ManagementGroupNameAvailabilityResult(bool? nameAvailable = default(bool?), Azure.ResourceManager.ManagementGroups.Models.ManagementGroupNameUnavailableReason? reason = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupNameUnavailableReason?), string message = null) { throw null; } + public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupParentCreateOptions ManagementGroupParentCreateOptions(string id = null, string name = null, string displayName = null) { throw null; } public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupPathElement ManagementGroupPathElement(string name = null, string displayName = null) { throw null; } public static Azure.ResourceManager.Resources.ManagementLockData ManagementLockData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.Resources.Models.ManagementLockLevel level = default(Azure.ResourceManager.Resources.Models.ManagementLockLevel), string notes = null, System.Collections.Generic.IEnumerable owners = null) { throw null; } public static Azure.ResourceManager.Resources.Models.PairedRegion PairedRegion(string name = null, string id = null, string subscriptionId = null) { throw null; } @@ -512,12 +612,17 @@ public static partial class ResourceManagerModelFactory } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This type is obsolete and will be removed in a future release.", false)] - public partial class SystemAssignedServiceIdentity + public partial class SystemAssignedServiceIdentity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SystemAssignedServiceIdentity(Azure.ResourceManager.Models.SystemAssignedServiceIdentityType systemAssignedServiceIdentityType) { } public System.Guid? PrincipalId { get { throw null; } } public Azure.ResourceManager.Models.SystemAssignedServiceIdentityType SystemAssignedServiceIdentityType { get { throw null; } set { } } public System.Guid? TenantId { get { throw null; } } + Azure.ResourceManager.Models.SystemAssignedServiceIdentity 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.Models.SystemAssignedServiceIdentity 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.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This type is obsolete and will be removed in a future release.", false)] @@ -539,7 +644,7 @@ public SystemAssignedServiceIdentity(Azure.ResourceManager.Models.SystemAssigned public static bool operator !=(Azure.ResourceManager.Models.SystemAssignedServiceIdentityType left, Azure.ResourceManager.Models.SystemAssignedServiceIdentityType right) { throw null; } public override string ToString() { throw null; } } - public partial class SystemData + public partial class SystemData : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SystemData() { } public string CreatedBy { get { throw null; } } @@ -548,6 +653,11 @@ public SystemData() { } public string LastModifiedBy { get { throw null; } } public Azure.ResourceManager.Models.CreatedByType? LastModifiedByType { get { throw null; } } public System.DateTimeOffset? LastModifiedOn { get { throw null; } } + Azure.ResourceManager.Models.SystemData 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.Models.SystemData 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 abstract partial class TrackedResourceData : Azure.ResourceManager.Models.ResourceData { @@ -557,11 +667,16 @@ protected TrackedResourceData(Azure.Core.ResourceIdentifier id, string name, Azu public Azure.Core.AzureLocation Location { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } } - public partial class UserAssignedIdentity + public partial class UserAssignedIdentity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public UserAssignedIdentity() { } public System.Guid? ClientId { get { throw null; } } public System.Guid? PrincipalId { get { throw null; } } + Azure.ResourceManager.Models.UserAssignedIdentity 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.Models.UserAssignedIdentity 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; } } } namespace Azure.ResourceManager.Resources @@ -590,7 +705,7 @@ protected DataPolicyManifestCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class DataPolicyManifestData : Azure.ResourceManager.Models.ResourceData + public partial class DataPolicyManifestData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DataPolicyManifestData() { } public System.Collections.Generic.IReadOnlyList CustomDefinitions { get { throw null; } } @@ -601,6 +716,11 @@ internal DataPolicyManifestData() { } public string PolicyMode { get { throw null; } } public System.Collections.Generic.IReadOnlyList ResourceTypeAliases { get { throw null; } } public System.Collections.Generic.IReadOnlyList Standard { get { throw null; } } + Azure.ResourceManager.Resources.DataPolicyManifestData 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.Resources.DataPolicyManifestData 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 DataPolicyManifestResource : Azure.ResourceManager.ArmResource { @@ -627,10 +747,15 @@ protected FeatureCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class FeatureData : Azure.ResourceManager.Models.ResourceData + public partial class FeatureData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal FeatureData() { } public string FeatureState { get { throw null; } } + Azure.ResourceManager.Resources.FeatureData 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.Resources.FeatureData 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 FeatureResource : Azure.ResourceManager.ArmResource { @@ -674,7 +799,7 @@ protected GenericResourceCollection() { } public virtual Azure.Response Get(Azure.Core.ResourceIdentifier resourceId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(Azure.Core.ResourceIdentifier resourceId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class GenericResourceData : Azure.ResourceManager.Resources.Models.TrackedResourceExtendedData + public partial class GenericResourceData : Azure.ResourceManager.Resources.Models.TrackedResourceExtendedData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public GenericResourceData(Azure.Core.AzureLocation location) : base (default(Azure.Core.AzureLocation)) { } public System.DateTimeOffset? ChangedOn { get { throw null; } } @@ -686,6 +811,11 @@ public GenericResourceData(Azure.Core.AzureLocation location) : base (default(Az public System.BinaryData Properties { get { throw null; } set { } } public string ProvisioningState { get { throw null; } } public Azure.ResourceManager.Resources.Models.ResourcesSku Sku { get { throw null; } set { } } + Azure.ResourceManager.Resources.GenericResourceData 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.Resources.GenericResourceData 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 ManagementGroupPolicyDefinitionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { @@ -766,12 +896,17 @@ protected ManagementLockCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class ManagementLockData : Azure.ResourceManager.Models.ResourceData + public partial class ManagementLockData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagementLockData(Azure.ResourceManager.Resources.Models.ManagementLockLevel level) { } public Azure.ResourceManager.Resources.Models.ManagementLockLevel Level { get { throw null; } set { } } public string Notes { get { throw null; } set { } } public System.Collections.Generic.IList Owners { get { throw null; } } + Azure.ResourceManager.Resources.ManagementLockData 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.Resources.ManagementLockData 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 ManagementLockResource : Azure.ResourceManager.ArmResource { @@ -804,7 +939,7 @@ protected PolicyAssignmentCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class PolicyAssignmentData : Azure.ResourceManager.Models.ResourceData + public partial class PolicyAssignmentData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PolicyAssignmentData() { } public string Description { get { throw null; } set { } } @@ -823,6 +958,11 @@ public PolicyAssignmentData() { } public string PolicyDefinitionId { get { throw null; } set { } } public System.Collections.Generic.IList ResourceSelectors { get { throw null; } } public string Scope { get { throw null; } } + Azure.ResourceManager.Resources.PolicyAssignmentData 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.Resources.PolicyAssignmentData 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 PolicyAssignmentResource : Azure.ResourceManager.ArmResource { @@ -840,7 +980,7 @@ protected PolicyAssignmentResource() { } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.Resources.Models.PolicyAssignmentPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Resources.PolicyAssignmentData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class PolicyDefinitionData : Azure.ResourceManager.Models.ResourceData + public partial class PolicyDefinitionData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PolicyDefinitionData() { } public string Description { get { throw null; } set { } } @@ -850,8 +990,13 @@ public PolicyDefinitionData() { } public System.Collections.Generic.IDictionary Parameters { get { throw null; } } public System.BinaryData PolicyRule { get { throw null; } set { } } public Azure.ResourceManager.Resources.Models.PolicyType? PolicyType { get { throw null; } set { } } + Azure.ResourceManager.Resources.PolicyDefinitionData 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.Resources.PolicyDefinitionData 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 PolicySetDefinitionData : Azure.ResourceManager.Models.ResourceData + public partial class PolicySetDefinitionData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PolicySetDefinitionData() { } public string Description { get { throw null; } set { } } @@ -861,6 +1006,11 @@ public PolicySetDefinitionData() { } public System.Collections.Generic.IList PolicyDefinitionGroups { get { throw null; } } public System.Collections.Generic.IList PolicyDefinitions { get { throw null; } } public Azure.ResourceManager.Resources.Models.PolicyType? PolicyType { get { throw null; } set { } } + Azure.ResourceManager.Resources.PolicySetDefinitionData 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.Resources.PolicySetDefinitionData 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 ResourceGroupCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { @@ -879,11 +1029,16 @@ protected ResourceGroupCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class ResourceGroupData : Azure.ResourceManager.Models.TrackedResourceData + public partial class ResourceGroupData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResourceGroupData(Azure.Core.AzureLocation location) { } public string ManagedBy { get { throw null; } set { } } public string ResourceGroupProvisioningState { get { throw null; } } + Azure.ResourceManager.Resources.ResourceGroupData 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.Resources.ResourceGroupData 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 ResourceGroupResource : Azure.ResourceManager.ArmResource { @@ -934,7 +1089,7 @@ protected ResourceProviderCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class ResourceProviderData + public partial class ResourceProviderData : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResourceProviderData() { } public Azure.Core.ResourceIdentifier Id { get { throw null; } } @@ -943,6 +1098,11 @@ public ResourceProviderData() { } public string RegistrationPolicy { get { throw null; } } public string RegistrationState { get { throw null; } } public System.Collections.Generic.IReadOnlyList ResourceTypes { get { throw null; } } + Azure.ResourceManager.Resources.ResourceProviderData 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.Resources.ResourceProviderData 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 ResourceProviderResource : Azure.ResourceManager.ArmResource { @@ -980,7 +1140,7 @@ protected SubscriptionCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class SubscriptionData + public partial class SubscriptionData : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SubscriptionData() { } public string AuthorizationSource { get { throw null; } } @@ -992,6 +1152,11 @@ internal SubscriptionData() { } public Azure.ResourceManager.Resources.Models.SubscriptionPolicies SubscriptionPolicies { get { throw null; } } public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } public System.Guid? TenantId { get { throw null; } } + Azure.ResourceManager.Resources.SubscriptionData 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.Resources.SubscriptionData 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 SubscriptionPolicyDefinitionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { @@ -1116,10 +1281,15 @@ protected TagResource() { } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.Resources.Models.TagResourcePatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Resources.Models.TagResourcePatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class TagResourceData : Azure.ResourceManager.Models.ResourceData + public partial class TagResourceData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TagResourceData(Azure.ResourceManager.Resources.Models.Tag properties) { } public System.Collections.Generic.IDictionary TagValues { get { throw null; } } + Azure.ResourceManager.Resources.TagResourceData 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.Resources.TagResourceData 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 TenantCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { @@ -1130,7 +1300,7 @@ protected TenantCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class TenantData + public partial class TenantData : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal TenantData() { } public string Country { get { throw null; } } @@ -1143,6 +1313,11 @@ internal TenantData() { } public Azure.ResourceManager.Resources.Models.TenantCategory? TenantCategory { get { throw null; } } public System.Guid? TenantId { get { throw null; } } public string TenantType { get { throw null; } } + Azure.ResourceManager.Resources.TenantData 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.Resources.TenantData 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 TenantPolicyDefinitionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { @@ -1232,19 +1407,29 @@ protected TenantResource() { } } namespace Azure.ResourceManager.Resources.Models { - public partial class ApiProfile + public partial class ApiProfile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ApiProfile() { } public string ApiVersion { get { throw null; } } public string ProfileVersion { get { throw null; } } + Azure.ResourceManager.Resources.Models.ApiProfile 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.Resources.Models.ApiProfile 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 ArmPolicyParameter + public partial class ArmPolicyParameter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ArmPolicyParameter() { } public System.Collections.Generic.IList AllowedValues { get { throw null; } } public System.BinaryData DefaultValue { get { throw null; } set { } } public Azure.ResourceManager.Resources.Models.ParameterDefinitionsValueMetadata Metadata { get { throw null; } set { } } public Azure.ResourceManager.Resources.Models.ArmPolicyParameterType? ParameterType { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.ArmPolicyParameter 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.Resources.Models.ArmPolicyParameter 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 ArmPolicyParameterType : System.IEquatable @@ -1269,12 +1454,17 @@ public ArmPolicyParameter() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.ArmPolicyParameterType left, Azure.ResourceManager.Resources.Models.ArmPolicyParameterType right) { throw null; } public override string ToString() { throw null; } } - public partial class ArmPolicyParameterValue + public partial class ArmPolicyParameterValue : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ArmPolicyParameterValue() { } public System.BinaryData Value { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.ArmPolicyParameterValue 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.Resources.Models.ArmPolicyParameterValue 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 ArmRestApi + public partial class ArmRestApi : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ArmRestApi() { } public string Description { get { throw null; } } @@ -1283,14 +1473,24 @@ internal ArmRestApi() { } public string Origin { get { throw null; } } public string Provider { get { throw null; } } public string Resource { get { throw null; } } + Azure.ResourceManager.Resources.Models.ArmRestApi 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.Resources.Models.ArmRestApi 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 AvailabilityZoneMappings + public partial class AvailabilityZoneMappings : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AvailabilityZoneMappings() { } public string LogicalZone { get { throw null; } } public string PhysicalZone { get { throw null; } } + Azure.ResourceManager.Resources.Models.AvailabilityZoneMappings 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.Resources.Models.AvailabilityZoneMappings 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 AzureRoleDefinition + public partial class AzureRoleDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AzureRoleDefinition() { } public string Id { get { throw null; } } @@ -1298,20 +1498,35 @@ internal AzureRoleDefinition() { } public string Name { get { throw null; } } public System.Collections.Generic.IReadOnlyList Permissions { get { throw null; } } public System.Collections.Generic.IReadOnlyList Scopes { get { throw null; } } + Azure.ResourceManager.Resources.Models.AzureRoleDefinition 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.Resources.Models.AzureRoleDefinition 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 DataManifestCustomResourceFunctionDefinition + public partial class DataManifestCustomResourceFunctionDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DataManifestCustomResourceFunctionDefinition() { } public bool? AllowCustomProperties { get { throw null; } } public System.Collections.Generic.IReadOnlyList DefaultProperties { get { throw null; } } public Azure.Core.ResourceType? FullyQualifiedResourceType { get { throw null; } } public string Name { get { throw null; } } + Azure.ResourceManager.Resources.Models.DataManifestCustomResourceFunctionDefinition 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.Resources.Models.DataManifestCustomResourceFunctionDefinition 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 DataPolicyManifestEffect + public partial class DataPolicyManifestEffect : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DataPolicyManifestEffect() { } public System.BinaryData DetailsSchema { get { throw null; } } public string Name { get { throw null; } } + Azure.ResourceManager.Resources.Models.DataPolicyManifestEffect 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.Resources.Models.DataPolicyManifestEffect 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 EnforcementMode : System.IEquatable @@ -1333,17 +1548,27 @@ internal DataPolicyManifestEffect() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.EnforcementMode left, Azure.ResourceManager.Resources.Models.EnforcementMode right) { throw null; } public override string ToString() { throw null; } } - public partial class ExportTemplate + public partial class ExportTemplate : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ExportTemplate() { } public string Options { get { throw null; } set { } } public System.Collections.Generic.IList Resources { get { throw null; } } + Azure.ResourceManager.Resources.Models.ExportTemplate 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.Resources.Models.ExportTemplate 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 ExtendedLocation + public partial class ExtendedLocation : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ExtendedLocation() { } public Azure.ResourceManager.Resources.Models.ExtendedLocationType? ExtendedLocationType { get { throw null; } set { } } public string Name { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.ExtendedLocation 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.Resources.Models.ExtendedLocation 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 ExtendedLocationType : System.IEquatable @@ -1362,7 +1587,7 @@ public ExtendedLocation() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.ExtendedLocationType left, Azure.ResourceManager.Resources.Models.ExtendedLocationType right) { throw null; } public override string ToString() { throw null; } } - public partial class LocationExpanded + public partial class LocationExpanded : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal LocationExpanded() { } public System.Collections.Generic.IReadOnlyList AvailabilityZoneMappings { get { throw null; } } @@ -1374,8 +1599,13 @@ internal LocationExpanded() { } public string RegionalDisplayName { get { throw null; } } public string SubscriptionId { get { throw null; } } public static implicit operator Azure.Core.AzureLocation (Azure.ResourceManager.Resources.Models.LocationExpanded location) { throw null; } + Azure.ResourceManager.Resources.Models.LocationExpanded 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.Resources.Models.LocationExpanded 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 LocationMetadata + public partial class LocationMetadata : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal LocationMetadata() { } public string Geography { get { throw null; } } @@ -1387,16 +1617,26 @@ internal LocationMetadata() { } public string PhysicalLocation { get { throw null; } } public Azure.ResourceManager.Resources.Models.RegionCategory? RegionCategory { get { throw null; } } public Azure.ResourceManager.Resources.Models.RegionType? RegionType { get { throw null; } } + Azure.ResourceManager.Resources.Models.LocationMetadata 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.Resources.Models.LocationMetadata 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 enum LocationType { Region = 0, EdgeZone = 1, } - public partial class ManagedByTenant + public partial class ManagedByTenant : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ManagedByTenant() { } public System.Guid? TenantId { get { throw null; } } + Azure.ResourceManager.Resources.Models.ManagedByTenant 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.Resources.Models.ManagedByTenant 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 ManagementLockLevel : System.IEquatable @@ -1417,25 +1657,40 @@ internal ManagedByTenant() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.ManagementLockLevel left, Azure.ResourceManager.Resources.Models.ManagementLockLevel right) { throw null; } public override string ToString() { throw null; } } - public partial class ManagementLockOwner + public partial class ManagementLockOwner : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagementLockOwner() { } public string ApplicationId { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.ManagementLockOwner 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.Resources.Models.ManagementLockOwner 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 NonComplianceMessage + public partial class NonComplianceMessage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public NonComplianceMessage(string message) { } public string Message { get { throw null; } set { } } public string PolicyDefinitionReferenceId { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.NonComplianceMessage 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.Resources.Models.NonComplianceMessage 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 PairedRegion + public partial class PairedRegion : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal PairedRegion() { } public string Id { get { throw null; } } public string Name { get { throw null; } } public string SubscriptionId { get { throw null; } } + Azure.ResourceManager.Resources.Models.PairedRegion 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.Resources.Models.PairedRegion 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 ParameterDefinitionsValueMetadata + public partial class ParameterDefinitionsValueMetadata : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ParameterDefinitionsValueMetadata() { } public System.Collections.Generic.IDictionary AdditionalProperties { get { throw null; } } @@ -1443,24 +1698,39 @@ public ParameterDefinitionsValueMetadata() { } public string Description { get { throw null; } set { } } public string DisplayName { get { throw null; } set { } } public string StrongType { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.ParameterDefinitionsValueMetadata 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.Resources.Models.ParameterDefinitionsValueMetadata 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 Permission + public partial class Permission : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal Permission() { } public System.Collections.Generic.IReadOnlyList AllowedActions { get { throw null; } } public System.Collections.Generic.IReadOnlyList AllowedDataActions { get { throw null; } } public System.Collections.Generic.IReadOnlyList DeniedActions { get { throw null; } } public System.Collections.Generic.IReadOnlyList DeniedDataActions { get { throw null; } } + Azure.ResourceManager.Resources.Models.Permission 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.Resources.Models.Permission 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 PolicyAssignmentPatch + public partial class PolicyAssignmentPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PolicyAssignmentPatch() { } public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.Core.AzureLocation? Location { get { throw null; } set { } } public System.Collections.Generic.IList Overrides { get { throw null; } } public System.Collections.Generic.IList ResourceSelectors { get { throw null; } } + Azure.ResourceManager.Resources.Models.PolicyAssignmentPatch 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.Resources.Models.PolicyAssignmentPatch 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 PolicyDefinitionGroup + public partial class PolicyDefinitionGroup : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PolicyDefinitionGroup(string name) { } public string AdditionalMetadataId { get { throw null; } set { } } @@ -1468,21 +1738,36 @@ public PolicyDefinitionGroup(string name) { } public string Description { get { throw null; } set { } } public string DisplayName { get { throw null; } set { } } public string Name { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.PolicyDefinitionGroup 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.Resources.Models.PolicyDefinitionGroup 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 PolicyDefinitionReference + public partial class PolicyDefinitionReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PolicyDefinitionReference(string policyDefinitionId) { } public System.Collections.Generic.IList GroupNames { get { throw null; } } public System.Collections.Generic.IDictionary Parameters { get { throw null; } } public string PolicyDefinitionId { get { throw null; } set { } } public string PolicyDefinitionReferenceId { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.PolicyDefinitionReference 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.Resources.Models.PolicyDefinitionReference 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 PolicyOverride + public partial class PolicyOverride : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PolicyOverride() { } public Azure.ResourceManager.Resources.Models.PolicyOverrideKind? Kind { get { throw null; } set { } } public System.Collections.Generic.IList Selectors { get { throw null; } } public string Value { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.PolicyOverride 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.Resources.Models.PolicyOverride 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 PolicyOverrideKind : System.IEquatable @@ -1521,26 +1806,41 @@ public PolicyOverride() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.PolicyType left, Azure.ResourceManager.Resources.Models.PolicyType right) { throw null; } public override string ToString() { throw null; } } - public partial class PredefinedTag + public partial class PredefinedTag : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal PredefinedTag() { } public Azure.ResourceManager.Resources.Models.PredefinedTagCount Count { get { throw null; } } public string Id { get { throw null; } } public string TagName { get { throw null; } } public System.Collections.Generic.IReadOnlyList Values { get { throw null; } } + Azure.ResourceManager.Resources.Models.PredefinedTag 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.Resources.Models.PredefinedTag 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 PredefinedTagCount + public partial class PredefinedTagCount : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal PredefinedTagCount() { } public string PredefinedTagCountType { get { throw null; } } public int? Value { get { throw null; } } + Azure.ResourceManager.Resources.Models.PredefinedTagCount 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.Resources.Models.PredefinedTagCount 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 PredefinedTagValue + public partial class PredefinedTagValue : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal PredefinedTagValue() { } public Azure.ResourceManager.Resources.Models.PredefinedTagCount Count { get { throw null; } } public string Id { get { throw null; } } public string TagValue { get { throw null; } } + Azure.ResourceManager.Resources.Models.PredefinedTagValue 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.Resources.Models.PredefinedTagValue 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 ProviderAuthorizationConsentState : System.IEquatable @@ -1562,27 +1862,42 @@ internal PredefinedTagValue() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.ProviderAuthorizationConsentState left, Azure.ResourceManager.Resources.Models.ProviderAuthorizationConsentState right) { throw null; } public override string ToString() { throw null; } } - public partial class ProviderExtendedLocation + public partial class ProviderExtendedLocation : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ProviderExtendedLocation() { } public System.Collections.Generic.IReadOnlyList ExtendedLocations { get { throw null; } } public Azure.Core.AzureLocation? Location { get { throw null; } } public string ProviderExtendedLocationType { get { throw null; } } + Azure.ResourceManager.Resources.Models.ProviderExtendedLocation 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.Resources.Models.ProviderExtendedLocation 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 ProviderPermission + public partial class ProviderPermission : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ProviderPermission() { } public string ApplicationId { get { throw null; } } public Azure.ResourceManager.Resources.Models.AzureRoleDefinition ManagedByRoleDefinition { get { throw null; } } public Azure.ResourceManager.Resources.Models.ProviderAuthorizationConsentState? ProviderAuthorizationConsentState { get { throw null; } } public Azure.ResourceManager.Resources.Models.AzureRoleDefinition RoleDefinition { get { throw null; } } + Azure.ResourceManager.Resources.Models.ProviderPermission 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.Resources.Models.ProviderPermission 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 ProviderRegistrationContent + public partial class ProviderRegistrationContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ProviderRegistrationContent() { } public bool? ConsentToAuthorization { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.ProviderRegistrationContent 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.Resources.Models.ProviderRegistrationContent 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 ProviderResourceType + public partial class ProviderResourceType : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ProviderResourceType() { } public System.Collections.Generic.IReadOnlyList Aliases { get { throw null; } } @@ -1595,6 +1910,11 @@ internal ProviderResourceType() { } public System.Collections.Generic.IReadOnlyDictionary Properties { get { throw null; } } public string ResourceType { get { throw null; } } public System.Collections.Generic.IReadOnlyList ZoneMappings { get { throw null; } } + Azure.ResourceManager.Resources.Models.ProviderResourceType 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.Resources.Models.ProviderResourceType 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 RegionCategory : System.IEquatable @@ -1633,32 +1953,52 @@ internal ProviderResourceType() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.RegionType left, Azure.ResourceManager.Resources.Models.RegionType right) { throw null; } public override string ToString() { throw null; } } - public partial class ResourceGroupExportResult + public partial class ResourceGroupExportResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ResourceGroupExportResult() { } public Azure.ResponseError Error { get { throw null; } } public System.BinaryData Template { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceGroupExportResult 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.Resources.Models.ResourceGroupExportResult 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 ResourceGroupPatch + public partial class ResourceGroupPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResourceGroupPatch() { } public string ManagedBy { get { throw null; } set { } } public string Name { get { throw null; } set { } } public string ResourceGroupProvisioningState { get { throw null; } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceGroupPatch 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.Resources.Models.ResourceGroupPatch 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 ResourceSelector + public partial class ResourceSelector : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResourceSelector() { } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList Selectors { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceSelector 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.Resources.Models.ResourceSelector 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 ResourceSelectorExpression + public partial class ResourceSelectorExpression : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResourceSelectorExpression() { } public System.Collections.Generic.IList In { get { throw null; } } public Azure.ResourceManager.Resources.Models.ResourceSelectorKind? Kind { get { throw null; } set { } } public System.Collections.Generic.IList NotIn { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceSelectorExpression 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.Resources.Models.ResourceSelectorExpression 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 ResourceSelectorKind : System.IEquatable @@ -1680,15 +2020,20 @@ public ResourceSelectorExpression() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.ResourceSelectorKind left, Azure.ResourceManager.Resources.Models.ResourceSelectorKind right) { throw null; } public override string ToString() { throw null; } } - public partial class ResourcesMoveContent + public partial class ResourcesMoveContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResourcesMoveContent() { } public System.Collections.Generic.IList Resources { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public string TargetResourceGroup { get { throw null; } set { } } public Azure.Core.ResourceIdentifier TargetResourceGroupId { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.ResourcesMoveContent 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.Resources.Models.ResourcesMoveContent 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 ResourcesSku + public partial class ResourcesSku : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResourcesSku() { } public int? Capacity { get { throw null; } set { } } @@ -1697,8 +2042,13 @@ public ResourcesSku() { } public string Name { get { throw null; } set { } } public string Size { get { throw null; } set { } } public string Tier { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.ResourcesSku 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.Resources.Models.ResourcesSku 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 ResourceTypeAlias + public partial class ResourceTypeAlias : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ResourceTypeAlias() { } public Azure.ResourceManager.Resources.Models.ResourceTypeAliasType? AliasType { get { throw null; } } @@ -1707,20 +2057,35 @@ internal ResourceTypeAlias() { } public Azure.ResourceManager.Resources.Models.ResourceTypeAliasPattern DefaultPattern { get { throw null; } } public string Name { get { throw null; } } public System.Collections.Generic.IReadOnlyList Paths { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceTypeAlias 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.Resources.Models.ResourceTypeAlias 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 ResourceTypeAliases + public partial class ResourceTypeAliases : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ResourceTypeAliases() { } public System.Collections.Generic.IReadOnlyList Aliases { get { throw null; } } public string ResourceType { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceTypeAliases 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.Resources.Models.ResourceTypeAliases 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 ResourceTypeAliasPath + public partial class ResourceTypeAliasPath : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ResourceTypeAliasPath() { } public System.Collections.Generic.IReadOnlyList ApiVersions { get { throw null; } } public Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathMetadata Metadata { get { throw null; } } public string Path { get { throw null; } } public Azure.ResourceManager.Resources.Models.ResourceTypeAliasPattern Pattern { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceTypeAliasPath 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.Resources.Models.ResourceTypeAliasPath 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 ResourceTypeAliasPathAttributes : System.IEquatable @@ -1740,11 +2105,16 @@ internal ResourceTypeAliasPath() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathAttributes left, Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathAttributes right) { throw null; } public override string ToString() { throw null; } } - public partial class ResourceTypeAliasPathMetadata + public partial class ResourceTypeAliasPathMetadata : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ResourceTypeAliasPathMetadata() { } public Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathAttributes? Attributes { get { throw null; } } public Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathTokenType? TokenType { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathMetadata 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.Resources.Models.ResourceTypeAliasPathMetadata 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 ResourceTypeAliasPathTokenType : System.IEquatable @@ -1770,12 +2140,17 @@ internal ResourceTypeAliasPathMetadata() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathTokenType left, Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathTokenType right) { throw null; } public override string ToString() { throw null; } } - public partial class ResourceTypeAliasPattern + public partial class ResourceTypeAliasPattern : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ResourceTypeAliasPattern() { } public Azure.ResourceManager.Resources.Models.ResourceTypeAliasPatternType? PatternType { get { throw null; } } public string Phrase { get { throw null; } } public string Variable { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceTypeAliasPattern 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.Resources.Models.ResourceTypeAliasPattern 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 enum ResourceTypeAliasPatternType { @@ -1800,12 +2175,17 @@ public SubResource() { } protected internal SubResource(Azure.Core.ResourceIdentifier id) { } public virtual Azure.Core.ResourceIdentifier Id { get { throw null; } } } - public partial class SubscriptionPolicies + public partial class SubscriptionPolicies : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SubscriptionPolicies() { } public string LocationPlacementId { get { throw null; } } public string QuotaId { get { throw null; } } public Azure.ResourceManager.Resources.Models.SpendingLimit? SpendingLimit { get { throw null; } } + Azure.ResourceManager.Resources.Models.SubscriptionPolicies 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.Resources.Models.SubscriptionPolicies 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 enum SubscriptionState { @@ -1815,10 +2195,15 @@ public enum SubscriptionState Disabled = 3, Deleted = 4, } - public partial class Tag + public partial class Tag : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public Tag() { } public System.Collections.Generic.IDictionary TagValues { get { throw null; } } + Azure.ResourceManager.Resources.Models.Tag 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.Resources.Models.Tag 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 TagPatchMode : System.IEquatable @@ -1839,11 +2224,16 @@ public Tag() { } public static bool operator !=(Azure.ResourceManager.Resources.Models.TagPatchMode left, Azure.ResourceManager.Resources.Models.TagPatchMode right) { throw null; } public override string ToString() { throw null; } } - public partial class TagResourcePatch + public partial class TagResourcePatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TagResourcePatch() { } public Azure.ResourceManager.Resources.Models.TagPatchMode? PatchMode { get { throw null; } set { } } public System.Collections.Generic.IDictionary TagValues { get { throw null; } } + Azure.ResourceManager.Resources.Models.TagResourcePatch 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.Resources.Models.TagResourcePatch 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 enum TenantCategory { @@ -1851,16 +2241,26 @@ public enum TenantCategory ProjectedBy = 1, ManagedBy = 2, } - public partial class TenantResourceProvider + public partial class TenantResourceProvider : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal TenantResourceProvider() { } public string Namespace { get { throw null; } } public System.Collections.Generic.IReadOnlyList ResourceTypes { get { throw null; } } + Azure.ResourceManager.Resources.Models.TenantResourceProvider 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.Resources.Models.TenantResourceProvider 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 TrackedResourceExtendedData : Azure.ResourceManager.Models.TrackedResourceData + public partial class TrackedResourceExtendedData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrackedResourceExtendedData(Azure.Core.AzureLocation location) { } public Azure.ResourceManager.Resources.Models.ExtendedLocation ExtendedLocation { get { throw null; } set { } } + Azure.ResourceManager.Resources.Models.TrackedResourceExtendedData 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.Resources.Models.TrackedResourceExtendedData 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 WritableSubResource { @@ -1868,11 +2268,16 @@ public WritableSubResource() { } protected internal WritableSubResource(Azure.Core.ResourceIdentifier id) { } public Azure.Core.ResourceIdentifier Id { get { throw null; } set { } } } - public partial class ZoneMapping + public partial class ZoneMapping : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ZoneMapping() { } public Azure.Core.AzureLocation? Location { get { throw null; } } public System.Collections.Generic.IReadOnlyList Zones { get { throw null; } } + Azure.ResourceManager.Resources.Models.ZoneMapping 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.Resources.Models.ZoneMapping 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; } } } namespace Microsoft.Extensions.Azure diff --git a/sdk/resourcemanager/Azure.ResourceManager/assets.json b/sdk/resourcemanager/Azure.ResourceManager/assets.json index b43fdfb35bc78..45a68b7d0f678 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/assets.json +++ b/sdk/resourcemanager/Azure.ResourceManager/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/resourcemanager/Azure.ResourceManager", - "Tag": "net/resourcemanager/Azure.ResourceManager_a6ac32475b" + "Tag": "net/resourcemanager/Azure.ResourceManager_99b62451e1" } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentity.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentity.Serialization.cs index c3be68ca2376b..90d7d2372acd0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentity.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentity.Serialization.cs @@ -4,6 +4,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; @@ -13,12 +14,28 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(ManagedServiceIdentityConverter))] - public partial class ManagedServiceIdentity + public partial class ManagedServiceIdentity : IJsonModel { - internal void Write(Utf8JsonWriter writer, JsonSerializerOptions options = default) + internal void Write(Utf8JsonWriter writer, ModelReaderWriterOptions options, JsonSerializerOptions jOptions = default) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedServiceIdentity)} does not support '{format}' format."); + } + writer.WriteStartObject(); - JsonSerializer.Serialize(writer, ManagedServiceIdentityType, options); + JsonSerializer.Serialize(writer, ManagedServiceIdentityType, jOptions); + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId.Value); + } + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } if (Optional.IsCollectionDefined(UserAssignedIdentities)) { writer.WritePropertyName("userAssignedIdentities"u8); @@ -26,22 +43,38 @@ internal void Write(Utf8JsonWriter writer, JsonSerializerOptions options = defau foreach (var item in UserAssignedIdentities) { writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - } - else - { - writer.WriteObjectValue(item.Value); - } + JsonSerializer.Serialize(writer, item.Value); } writer.WriteEndObject(); } writer.WriteEndObject(); } - internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonElement element, JsonSerializerOptions options = default) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + Write(writer, options, null); + } + + ManagedServiceIdentity 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(ManagedServiceIdentity)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedServiceIdentity(document.RootElement, options); + } + + internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonElement element, ModelReaderWriterOptions options, JsonSerializerOptions jOptions) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } Optional principalId = default; Optional tenantId = default; ManagedServiceIdentityType type = default; @@ -52,7 +85,6 @@ internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonEle { if (property.Value.ValueKind == JsonValueKind.Null || property.Value.GetString().Length == 0) { - property.ThrowNonNullablePropertyIsNull(); continue; } principalId = property.Value.GetGuid(); @@ -62,7 +94,6 @@ internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonEle { if (property.Value.ValueKind == JsonValueKind.Null || property.Value.GetString().Length == 0) { - property.ThrowNonNullablePropertyIsNull(); continue; } tenantId = property.Value.GetGuid(); @@ -70,20 +101,19 @@ internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonEle } if (property.NameEquals("type"u8)) { - type = JsonSerializer.Deserialize($"{{{property}}}", options); + type = JsonSerializer.Deserialize($"{{{property}}}", jOptions); continue; } if (property.NameEquals("userAssignedIdentities"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { - dictionary.Add(new ResourceIdentifier(property0.Name), UserAssignedIdentity.DeserializeUserAssignedIdentity(property0.Value)); + dictionary.Add(new ResourceIdentifier(property0.Name), JsonSerializer.Deserialize(property0.Value.GetRawText())); } userAssignedIdentities = dictionary; continue; @@ -92,16 +122,52 @@ internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonEle return new ManagedServiceIdentity(Optional.ToNullable(principalId), Optional.ToNullable(tenantId), type, Optional.ToDictionary(userAssignedIdentities)); } + internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + return DeserializeManagedServiceIdentity(element, options, null); + } + + 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(ManagedServiceIdentity)} does not support '{options.Format}' format."); + } + } + + ManagedServiceIdentity 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 DeserializeManagedServiceIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedServiceIdentity)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class ManagedServiceIdentityConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, ManagedServiceIdentity model, JsonSerializerOptions options) { - model.Write(writer, options); + model.Write(writer, new ModelReaderWriterOptions("W"), options); } public override ManagedServiceIdentity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { using var document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedServiceIdentity(document.RootElement, options); + return DeserializeManagedServiceIdentity(document.RootElement, null, options); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentityType.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentityType.cs index 3035631a0300f..7954ef73df434 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentityType.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentityType.cs @@ -25,7 +25,10 @@ public override ManagedServiceIdentityType Read(ref Utf8JsonReader reader, Type using var document = JsonDocument.ParseValue(ref reader); foreach (var property in document.RootElement.EnumerateObject()) { - return new ManagedServiceIdentityType(property.Value.GetString()); + if (property.Value.ValueKind == JsonValueKind.Null) + return default; + else + return new ManagedServiceIdentityType(property.Value.GetString()); } return null; } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/ResourceManagerModelFactory.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/ResourceManagerModelFactory.cs new file mode 100644 index 0000000000000..e01c46178c061 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/ResourceManagerModelFactory.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Models +{ + /// Model factory for read-only models. + public static partial class ResourceManagerModelFactory + { + /// Initializes a new instance of LocationExpanded. + /// The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + /// The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. + /// A new instance for mocking. + public static ManagedServiceIdentity ManagedServiceIdentity(Guid? principalId, Guid? tenantId, ManagedServiceIdentityType managedServiceIdentityType, IDictionary userAssignedIdentities) + { + return new ManagedServiceIdentity(principalId, tenantId, managedServiceIdentityType, userAssignedIdentities); + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs index 8cb13d7f512ac..b38cf0587f5f5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -13,10 +14,18 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(ArmPlanConverter))] - public partial class ArmPlan : IUtf8JsonSerializable + public partial class ArmPlan : 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(ArmPlan)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); @@ -37,8 +46,22 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static ArmPlan DeserializeArmPlan(JsonElement element) + ArmPlan 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(ArmPlan)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeArmPlan(document.RootElement, options); + } + + internal static ArmPlan DeserializeArmPlan(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -79,6 +102,37 @@ internal static ArmPlan DeserializeArmPlan(JsonElement element) return new ArmPlan(name, publisher, product, promotionCode.Value, version.Value); } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ArmPlan)} does not support '{options.Format}' format."); + } + } + + ArmPlan 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 DeserializeArmPlan(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ArmPlan)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class ArmPlanConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, ArmPlan model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.cs index 734b25560cc13..3c484e589071e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.cs @@ -47,6 +47,11 @@ internal ArmPlan(string name, string publisher, string product, string promotion Version = version; } + /// Initializes a new instance of for deserialization. + internal ArmPlan() + { + } + /// A user defined name of the 3rd Party Artifact that is being procured. public string Name { get; set; } /// The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs index 1c3c78452ff76..06a9bbf327a92 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -13,10 +14,18 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(ArmSkuConverter))] - public partial class ArmSku : IUtf8JsonSerializable + public partial class ArmSku : 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(ArmSku)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); @@ -43,8 +52,22 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static ArmSku DeserializeArmSku(JsonElement element) + ArmSku 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(ArmSku)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeArmSku(document.RootElement, options); + } + + internal static ArmSku DeserializeArmSku(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -93,6 +116,37 @@ internal static ArmSku DeserializeArmSku(JsonElement element) return new ArmSku(name, Optional.ToNullable(tier), size.Value, family.Value, Optional.ToNullable(capacity)); } + 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(ArmSku)} does not support '{options.Format}' format."); + } + } + + ArmSku 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 DeserializeArmSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ArmSku)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class ArmSkuConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, ArmSku model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.cs index e9d807a11c931..1c1e36949262e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.cs @@ -41,6 +41,11 @@ internal ArmSku(string name, ArmSkuTier? tier, string size, string family, int? Capacity = capacity; } + /// Initializes a new instance of for deserialization. + internal ArmSku() + { + } + /// The name of the SKU. Ex - P3. It is typically a letter+number code. public string Name { get; set; } /// This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs index b80bbbcab093f..42445326af86d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -13,10 +14,18 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(EncryptionPropertiesConverter))] - public partial class EncryptionProperties : IUtf8JsonSerializable + public partial class EncryptionProperties : 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(EncryptionProperties)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Status)) { @@ -31,8 +40,22 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static EncryptionProperties DeserializeEncryptionProperties(JsonElement element) + EncryptionProperties 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(EncryptionProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEncryptionProperties(document.RootElement, options); + } + + internal static EncryptionProperties DeserializeEncryptionProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +86,37 @@ internal static EncryptionProperties DeserializeEncryptionProperties(JsonElement return new EncryptionProperties(Optional.ToNullable(status), keyVaultProperties.Value); } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EncryptionProperties)} does not support '{options.Format}' format."); + } + } + + EncryptionProperties 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 DeserializeEncryptionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EncryptionProperties)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class EncryptionPropertiesConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, EncryptionProperties model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs index 6345726d4365f..2dff5148e9b24 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -13,10 +14,18 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(KeyVaultPropertiesConverter))] - public partial class KeyVaultProperties : IUtf8JsonSerializable + public partial class KeyVaultProperties : 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(KeyVaultProperties)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(KeyIdentifier)) { @@ -31,8 +40,22 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement element) + KeyVaultProperties 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(KeyVaultProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyVaultProperties(document.RootElement, options); + } + + internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -55,6 +78,37 @@ internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement ele return new KeyVaultProperties(keyIdentifier.Value, identity.Value); } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(KeyVaultProperties)} does not support '{options.Format}' format."); + } + } + + KeyVaultProperties 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 DeserializeKeyVaultProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyVaultProperties)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class KeyVaultPropertiesConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, KeyVaultProperties model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs index 027b45d14e035..0f8543e6b580d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; @@ -15,16 +16,83 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(OperationStatusResultConverter))] - public partial class OperationStatusResult : IUtf8JsonSerializable + public partial class OperationStatusResult : 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(OperationStatusResult)} does not support '{format}' format."); + } + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (options.Format != "W" && Optional.IsDefined(PercentComplete)) + { + writer.WritePropertyName("percentComplete"u8); + writer.WriteNumberValue(PercentComplete.Value); + } + if (options.Format != "W" && Optional.IsDefined(StartOn)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(EndOn)) + { + writer.WritePropertyName("endTime"u8); + writer.WriteStringValue(EndOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Operations)) + { + writer.WritePropertyName("operations"u8); + writer.WriteStartArray(); + foreach (var item in Operations) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + JsonSerializer.Serialize(writer, Error); + } writer.WriteEndObject(); } - internal static OperationStatusResult DeserializeOperationStatusResult(JsonElement element) + OperationStatusResult 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(OperationStatusResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationStatusResult(document.RootElement, options); + } + + internal static OperationStatusResult DeserializeOperationStatusResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -112,6 +180,37 @@ internal static OperationStatusResult DeserializeOperationStatusResult(JsonEleme return new OperationStatusResult(id, name.Value, status, Optional.ToNullable(percentComplete), Optional.ToNullable(startTime), Optional.ToNullable(endTime), Optional.ToList(operations), error.Value); } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OperationStatusResult)} does not support '{options.Format}' format."); + } + } + + OperationStatusResult 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 DeserializeOperationStatusResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationStatusResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class OperationStatusResultConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, OperationStatusResult model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.cs index 5c7b4cec60fd8..c4c6d1f84d0f5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.cs @@ -50,6 +50,11 @@ protected OperationStatusResult(ResourceIdentifier id, string name, string statu Error = error; } + /// Initializes a new instance of for deserialization. + internal OperationStatusResult() + { + } + /// Fully qualified ID for the async operation. public ResourceIdentifier Id { get; } /// Name of the async operation. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs index 4b650d4e0fd55..2c1cce48ff110 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -13,18 +14,50 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(SystemAssignedServiceIdentityConverter))] - public partial class SystemAssignedServiceIdentity : IUtf8JsonSerializable + public partial class SystemAssignedServiceIdentity : 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(SystemAssignedServiceIdentity)} does not support '{format}' format."); + } + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId.Value); + } + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } writer.WritePropertyName("type"u8); writer.WriteStringValue(SystemAssignedServiceIdentityType.ToString()); writer.WriteEndObject(); } - internal static SystemAssignedServiceIdentity DeserializeSystemAssignedServiceIdentity(JsonElement element) + SystemAssignedServiceIdentity 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(SystemAssignedServiceIdentity)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSystemAssignedServiceIdentity(document.RootElement, options); + } + + internal static SystemAssignedServiceIdentity DeserializeSystemAssignedServiceIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -61,6 +94,37 @@ internal static SystemAssignedServiceIdentity DeserializeSystemAssignedServiceId return new SystemAssignedServiceIdentity(Optional.ToNullable(principalId), Optional.ToNullable(tenantId), type); } + 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(SystemAssignedServiceIdentity)} does not support '{options.Format}' format."); + } + } + + SystemAssignedServiceIdentity 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 DeserializeSystemAssignedServiceIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SystemAssignedServiceIdentity)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class SystemAssignedServiceIdentityConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, SystemAssignedServiceIdentity model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.cs index 0a504b64dd3a3..f7feea87c283b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.cs @@ -14,5 +14,9 @@ namespace Azure.ResourceManager.Models [PropertyReferenceType] public partial class SystemAssignedServiceIdentity { + /// Initializes a new instance of for deserialization. + internal SystemAssignedServiceIdentity() + { + } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs index 207c4ba287faf..636b0fc2e2df1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -13,16 +14,68 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(SystemDataConverter))] - public partial class SystemData : IUtf8JsonSerializable + public partial class SystemData : 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(SystemData)} does not support '{format}' format."); + } + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(CreatedByType)) + { + writer.WritePropertyName("createdByType"u8); + writer.WriteStringValue(CreatedByType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedByType)) + { + writer.WritePropertyName("lastModifiedByType"u8); + writer.WriteStringValue(LastModifiedByType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedOn)) + { + writer.WritePropertyName("lastModifiedAt"u8); + writer.WriteStringValue(LastModifiedOn.Value, "O"); + } writer.WriteEndObject(); } - internal static SystemData DeserializeSystemData(JsonElement element) + SystemData 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(SystemData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSystemData(document.RootElement, options); + } + + internal static SystemData DeserializeSystemData(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -85,6 +138,37 @@ internal static SystemData DeserializeSystemData(JsonElement element) return new SystemData(createdBy.Value, Optional.ToNullable(createdByType), Optional.ToNullable(createdAt), lastModifiedBy.Value, Optional.ToNullable(lastModifiedByType), Optional.ToNullable(lastModifiedAt)); } + 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(SystemData)} does not support '{options.Format}' format."); + } + } + + SystemData 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 DeserializeSystemData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SystemData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class SystemDataConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, SystemData model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs index af8133ca6cdeb..477d51f04d9f5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -13,16 +14,48 @@ namespace Azure.ResourceManager.Models { [JsonConverter(typeof(UserAssignedIdentityConverter))] - public partial class UserAssignedIdentity : IUtf8JsonSerializable + public partial class UserAssignedIdentity : 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(UserAssignedIdentity)} does not support '{format}' format."); + } + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId.Value); + } + if (options.Format != "W" && Optional.IsDefined(ClientId)) + { + writer.WritePropertyName("clientId"u8); + writer.WriteStringValue(ClientId.Value); + } writer.WriteEndObject(); } - internal static UserAssignedIdentity DeserializeUserAssignedIdentity(JsonElement element) + UserAssignedIdentity 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(UserAssignedIdentity)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserAssignedIdentity(document.RootElement, options); + } + + internal static UserAssignedIdentity DeserializeUserAssignedIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -53,6 +86,37 @@ internal static UserAssignedIdentity DeserializeUserAssignedIdentity(JsonElement return new UserAssignedIdentity(Optional.ToNullable(principalId), Optional.ToNullable(clientId)); } + 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(UserAssignedIdentity)} does not support '{options.Format}' format."); + } + } + + UserAssignedIdentity 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 DeserializeUserAssignedIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserAssignedIdentity)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class UserAssignedIdentityConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, UserAssignedIdentity model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.cs index 36ecb9a56328b..6309fcba0b5a8 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.cs @@ -19,6 +19,38 @@ namespace Azure.ResourceManager.ManagementGroups /// public partial class ManagementGroupData : 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 . internal ManagementGroupData() { @@ -34,12 +66,14 @@ internal ManagementGroupData() /// The friendly name of the management group. /// The details of a management group. /// The list of children. - internal ManagementGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, Guid? tenantId, string displayName, ManagementGroupInfo details, IReadOnlyList children) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, Guid? tenantId, string displayName, ManagementGroupInfo details, IReadOnlyList children, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { TenantId = tenantId; DisplayName = displayName; Details = details; Children = children; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupResource.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupResource.cs index 91345255668bc..a73c63db6d64b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupResource.cs @@ -392,7 +392,7 @@ public virtual AsyncPageable GetDescendantsAsync(string skiptoke { HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateGetDescendantsRequest(Id.Name, skiptoken, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateGetDescendantsNextPageRequest(nextLink, Id.Name, skiptoken, top); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, DescendantData.DeserializeDescendantData, _managementGroupClientDiagnostics, Pipeline, "ManagementGroupResource.GetDescendants", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DescendantData.DeserializeDescendantData(e), _managementGroupClientDiagnostics, Pipeline, "ManagementGroupResource.GetDescendants", "value", "nextLink", cancellationToken); } /// @@ -429,7 +429,7 @@ public virtual Pageable GetDescendants(string skiptoken = null, { HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateGetDescendantsRequest(Id.Name, skiptoken, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateGetDescendantsNextPageRequest(nextLink, Id.Name, skiptoken, top); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, DescendantData.DeserializeDescendantData, _managementGroupClientDiagnostics, Pipeline, "ManagementGroupResource.GetDescendants", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DescendantData.DeserializeDescendantData(e), _managementGroupClientDiagnostics, Pipeline, "ManagementGroupResource.GetDescendants", "value", "nextLink", cancellationToken); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.Serialization.cs index 7d15ff58959ec..715cc79e21477 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.Serialization.cs @@ -5,22 +5,163 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.ManagementGroups.Models { - public partial class CreateManagementGroupDetails : IUtf8JsonSerializable + public partial class CreateManagementGroupDetails : 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(CreateManagementGroupDetails)} does not support '{format}' format."); + } + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteNumberValue(Version.Value); + } + if (options.Format != "W" && Optional.IsDefined(UpdatedOn)) + { + writer.WritePropertyName("updatedTime"u8); + writer.WriteStringValue(UpdatedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(UpdatedBy)) + { + writer.WritePropertyName("updatedBy"u8); + writer.WriteStringValue(UpdatedBy); + } if (Optional.IsDefined(Parent)) { writer.WritePropertyName("parent"u8); writer.WriteObjectValue(Parent); } + 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(); } + + CreateManagementGroupDetails 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(CreateManagementGroupDetails)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateManagementGroupDetails(document.RootElement, options); + } + + internal static CreateManagementGroupDetails DeserializeCreateManagementGroupDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional version = default; + Optional updatedTime = default; + Optional updatedBy = default; + Optional parent = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("version"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + version = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("updatedTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updatedTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("updatedBy"u8)) + { + updatedBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("parent"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parent = ManagementGroupParentCreateOptions.DeserializeManagementGroupParentCreateOptions(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new CreateManagementGroupDetails(Optional.ToNullable(version), Optional.ToNullable(updatedTime), updatedBy.Value, parent.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(CreateManagementGroupDetails)} does not support '{options.Format}' format."); + } + } + + CreateManagementGroupDetails 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 DeserializeCreateManagementGroupDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateManagementGroupDetails)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.cs index 83b846770b5d4..44f9699c853c3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/CreateManagementGroupDetails.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.ResourceManager.ManagementGroups.Models { /// The details of a management group used during creation. public partial class CreateManagementGroupDetails { + /// + /// 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 CreateManagementGroupDetails() { @@ -22,12 +55,14 @@ public CreateManagementGroupDetails() /// The date and time when this object was last updated. /// The identity of the principal or process that updated the object. /// (Optional) The ID of the parent management group used during creation. - internal CreateManagementGroupDetails(int? version, DateTimeOffset? updatedOn, string updatedBy, ManagementGroupParentCreateOptions parent) + /// Keeps track of any properties unknown to the library. + internal CreateManagementGroupDetails(int? version, DateTimeOffset? updatedOn, string updatedBy, ManagementGroupParentCreateOptions parent, IDictionary serializedAdditionalRawData) { Version = version; UpdatedOn = updatedOn; UpdatedBy = updatedBy; Parent = parent; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The version number of the object. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs index 226be4a7e49c1..86a3f016f4a18 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs @@ -5,16 +5,109 @@ #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.ManagementGroups.Models { - public partial class DescendantData + public partial class DescendantData : IUtf8JsonSerializable, IJsonModel { - internal static DescendantData DeserializeDescendantData(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(DescendantData)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + if (DisplayName != null) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + else + { + writer.WriteNull("displayName"); + } + } + if (Optional.IsDefined(Parent)) + { + if (Parent != null) + { + writer.WritePropertyName("parent"u8); + writer.WriteObjectValue(Parent); + } + else + { + writer.WriteNull("parent"); + } + } + 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(); + } + + DescendantData 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(DescendantData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDescendantData(document.RootElement, options); + } + + internal static DescendantData DeserializeDescendantData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -25,6 +118,8 @@ internal static DescendantData DeserializeDescendantData(JsonElement element) Optional systemData = default; Optional displayName = default; Optional parent = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -83,8 +178,44 @@ internal static DescendantData DeserializeDescendantData(JsonElement element) } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DescendantData(id, name, type, systemData.Value, displayName.Value, parent.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(DescendantData)} does not support '{options.Format}' format."); + } + } + + DescendantData 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 DeserializeDescendantData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DescendantData)} does not support '{options.Format}' format."); } - return new DescendantData(id, name, type, systemData.Value, displayName.Value, parent.Value); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.cs index 8f63224c5f961..f6d0595185fe4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; @@ -13,6 +15,38 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// The descendant. public partial class DescendantData : 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 . internal DescendantData() { @@ -25,10 +59,12 @@ internal DescendantData() /// The systemData. /// The friendly name of the management group. /// The ID of the parent management group. - internal DescendantData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string displayName, DescendantParentGroupInfo parent) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal DescendantData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string displayName, DescendantParentGroupInfo parent, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { DisplayName = displayName; Parent = parent; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The friendly name of the management group. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs index f420e75bb2b5b..aeaaebd108ebe 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.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.ManagementGroups.Models { - internal partial class DescendantListResult + internal partial class DescendantListResult : IUtf8JsonSerializable, IJsonModel { - internal static DescendantListResult DeserializeDescendantListResult(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(DescendantListResult)} 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 (options.Format != "W" && 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(); + } + + DescendantListResult 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(DescendantListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDescendantListResult(document.RootElement, options); + } + + internal static DescendantListResult DeserializeDescendantListResult(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)) @@ -42,8 +104,44 @@ internal static DescendantListResult DeserializeDescendantListResult(JsonElement nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new DescendantListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DescendantListResult(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(DescendantListResult)} does not support '{options.Format}' format."); + } + } + + DescendantListResult 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 DeserializeDescendantListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DescendantListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.cs index 6633aff9d428f..62aff183d81cf 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// Describes the result of the request to view descendants. internal partial class DescendantListResult { + /// + /// 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 DescendantListResult() { @@ -22,10 +55,12 @@ internal DescendantListResult() /// Initializes a new instance of . /// The list of descendants. /// The URL to use for getting the next set of results. - internal DescendantListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal DescendantListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The list of descendants. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs index 1f0771c3f3583..5af71f4ed79ce 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs @@ -5,20 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.ManagementGroups.Models { - internal partial class DescendantParentGroupInfo + internal partial class DescendantParentGroupInfo : IUtf8JsonSerializable, IJsonModel { - internal static DescendantParentGroupInfo DeserializeDescendantParentGroupInfo(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(DescendantParentGroupInfo)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DescendantParentGroupInfo 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(DescendantParentGroupInfo)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDescendantParentGroupInfo(document.RootElement, options); + } + + internal static DescendantParentGroupInfo DeserializeDescendantParentGroupInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -30,8 +83,44 @@ internal static DescendantParentGroupInfo DeserializeDescendantParentGroupInfo(J id = new ResourceIdentifier(property.Value.GetString()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DescendantParentGroupInfo(id.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(DescendantParentGroupInfo)} does not support '{options.Format}' format."); } - return new DescendantParentGroupInfo(id.Value); } + + DescendantParentGroupInfo 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 DeserializeDescendantParentGroupInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DescendantParentGroupInfo)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.cs index 1f86a8e6b16b6..1f41e82898f9e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.ResourceManager.ManagementGroups.Models @@ -12,6 +14,38 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// The ID of the parent management group. internal partial class DescendantParentGroupInfo { + /// + /// 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 DescendantParentGroupInfo() { @@ -19,9 +53,11 @@ internal DescendantParentGroupInfo() /// Initializes a new instance of . /// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - internal DescendantParentGroupInfo(ResourceIdentifier id) + /// Keeps track of any properties unknown to the library. + internal DescendantParentGroupInfo(ResourceIdentifier id, IDictionary serializedAdditionalRawData) { Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs index 05b181f13d860..cc9e012d0ed19 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs @@ -5,16 +5,91 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.ManagementGroups.Models { - public partial class ManagementGroupChildInfo + public partial class ManagementGroupChildInfo : IUtf8JsonSerializable, IJsonModel { - internal static ManagementGroupChildInfo DeserializeManagementGroupChildInfo(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(ManagementGroupChildInfo)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ChildType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ChildType.Value.ToString()); + } + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsCollectionDefined(Children)) + { + writer.WritePropertyName("children"u8); + writer.WriteStartArray(); + foreach (var item in Children) + { + 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(); + } + + ManagementGroupChildInfo 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(ManagementGroupChildInfo)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupChildInfo(document.RootElement, options); + } + + internal static ManagementGroupChildInfo DeserializeManagementGroupChildInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -24,6 +99,8 @@ internal static ManagementGroupChildInfo DeserializeManagementGroupChildInfo(Jso Optional name = default; Optional displayName = default; Optional> children = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -64,8 +141,44 @@ internal static ManagementGroupChildInfo DeserializeManagementGroupChildInfo(Jso children = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupChildInfo(Optional.ToNullable(type), id.Value, name.Value, displayName.Value, Optional.ToList(children), 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(ManagementGroupChildInfo)} does not support '{options.Format}' format."); + } + } + + ManagementGroupChildInfo 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 DeserializeManagementGroupChildInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupChildInfo)} does not support '{options.Format}' format."); } - return new ManagementGroupChildInfo(Optional.ToNullable(type), id.Value, name.Value, displayName.Value, Optional.ToList(children)); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.cs index 48c0c60a48070..6c39dd6242a59 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// The child information of a management group. public partial class ManagementGroupChildInfo { + /// + /// 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 ManagementGroupChildInfo() { @@ -25,13 +58,15 @@ internal ManagementGroupChildInfo() /// The name of the child entity. /// The friendly name of the child resource. /// The list of children. - internal ManagementGroupChildInfo(ManagementGroupChildType? childType, string id, string name, string displayName, IReadOnlyList children) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupChildInfo(ManagementGroupChildType? childType, string id, string name, string displayName, IReadOnlyList children, IDictionary serializedAdditionalRawData) { ChildType = childType; Id = id; Name = name; DisplayName = displayName; Children = children; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups). diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.Serialization.cs new file mode 100644 index 0000000000000..996d9d52f1c5d --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + public partial class ManagementGroupChildOptions : IUtf8JsonSerializable, IJsonModel + { + 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(ManagementGroupChildOptions)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ChildType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ChildType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Children)) + { + writer.WritePropertyName("children"u8); + writer.WriteStartArray(); + foreach (var item in Children) + { + 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(); + } + + ManagementGroupChildOptions 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(ManagementGroupChildOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupChildOptions(document.RootElement, options); + } + + internal static ManagementGroupChildOptions DeserializeManagementGroupChildOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional type = default; + Optional id = default; + Optional name = default; + Optional displayName = default; + Optional> children = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new ManagementGroupChildType(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("children"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeserializeManagementGroupChildOptions(item)); + } + children = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupChildOptions(Optional.ToNullable(type), id.Value, name.Value, displayName.Value, Optional.ToList(children), 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(ManagementGroupChildOptions)} does not support '{options.Format}' format."); + } + } + + ManagementGroupChildOptions 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 DeserializeManagementGroupChildOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupChildOptions)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.cs index 2f7c80689cfd7..baabce119a3c6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildOptions.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// The child information of a management group used during creation. public partial class ManagementGroupChildOptions { + /// + /// 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 ManagementGroupChildOptions() { @@ -25,13 +58,15 @@ internal ManagementGroupChildOptions() /// The name of the child entity. /// The friendly name of the child resource. /// The list of children. - internal ManagementGroupChildOptions(ManagementGroupChildType? childType, string id, string name, string displayName, IReadOnlyList children) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupChildOptions(ManagementGroupChildType? childType, string id, string name, string displayName, IReadOnlyList children, IDictionary serializedAdditionalRawData) { ChildType = childType; Id = id; Name = name; DisplayName = displayName; Children = children; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups). diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.Serialization.cs index e5c9364579a87..3845938637721 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.Serialization.cs @@ -5,16 +5,37 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.ManagementGroups.Models { - public partial class ManagementGroupCreateOrUpdateContent : IUtf8JsonSerializable + public partial class ManagementGroupCreateOrUpdateContent : 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(ManagementGroupCreateOrUpdateContent)} does not support '{format}' format."); + } + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(ResourceType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType.Value); + } if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -22,6 +43,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } if (Optional.IsDefined(DisplayName)) { if (DisplayName != null) @@ -39,8 +65,185 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("details"u8); writer.WriteObjectValue(Details); } + if (options.Format != "W" && Optional.IsCollectionDefined(Children)) + { + if (Children != null) + { + writer.WritePropertyName("children"u8); + writer.WriteStartArray(); + foreach (var item in Children) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("children"); + } + } 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(); } + + ManagementGroupCreateOrUpdateContent 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(ManagementGroupCreateOrUpdateContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupCreateOrUpdateContent(document.RootElement, options); + } + + internal static ManagementGroupCreateOrUpdateContent DeserializeManagementGroupCreateOrUpdateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional id = default; + Optional type = default; + Optional name = default; + Optional tenantId = default; + Optional displayName = default; + Optional details = default; + Optional> children = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("tenantId"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tenantId = property0.Value.GetGuid(); + continue; + } + if (property0.NameEquals("displayName"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + displayName = null; + continue; + } + displayName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("details"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + details = CreateManagementGroupDetails.DeserializeCreateManagementGroupDetails(property0.Value); + continue; + } + if (property0.NameEquals("children"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + children = null; + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(ManagementGroupChildOptions.DeserializeManagementGroupChildOptions(item)); + } + children = array; + continue; + } + } + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupCreateOrUpdateContent(id.Value, Optional.ToNullable(type), name.Value, Optional.ToNullable(tenantId), displayName.Value, details.Value, Optional.ToList(children), 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(ManagementGroupCreateOrUpdateContent)} does not support '{options.Format}' format."); + } + } + + ManagementGroupCreateOrUpdateContent 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 DeserializeManagementGroupCreateOrUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupCreateOrUpdateContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.cs index 6501d1f87dfca..04b554b3c5071 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCreateOrUpdateContent.cs @@ -14,6 +14,38 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// Management group creation parameters. public partial class ManagementGroupCreateOrUpdateContent { + /// + /// 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 ManagementGroupCreateOrUpdateContent() { @@ -28,7 +60,8 @@ public ManagementGroupCreateOrUpdateContent() /// The friendly name of the management group. If no value is passed then this field will be set to the groupId. /// The details of a management group used during creation. /// The list of children. - internal ManagementGroupCreateOrUpdateContent(string id, ResourceType? resourceType, string name, Guid? tenantId, string displayName, CreateManagementGroupDetails details, IReadOnlyList children) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupCreateOrUpdateContent(string id, ResourceType? resourceType, string name, Guid? tenantId, string displayName, CreateManagementGroupDetails details, IReadOnlyList children, IDictionary serializedAdditionalRawData) { Id = id; ResourceType = resourceType; @@ -37,6 +70,7 @@ internal ManagementGroupCreateOrUpdateContent(string id, ResourceType? resourceT DisplayName = displayName; Details = details; Children = children; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupData.Serialization.cs index b8af08929f707..cffd745861c6c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupData.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,10 +15,108 @@ namespace Azure.ResourceManager.ManagementGroups { - public partial class ManagementGroupData + public partial class ManagementGroupData : IUtf8JsonSerializable, IJsonModel { - internal static ManagementGroupData DeserializeManagementGroupData(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(ManagementGroupData)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteObjectValue(Details); + } + if (Optional.IsCollectionDefined(Children)) + { + if (Children != null) + { + writer.WritePropertyName("children"u8); + writer.WriteStartArray(); + foreach (var item in Children) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("children"); + } + } + 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(); + } + + ManagementGroupData 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(ManagementGroupData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupData(document.RootElement, options); + } + + internal static ManagementGroupData DeserializeManagementGroupData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -30,6 +129,8 @@ internal static ManagementGroupData DeserializeManagementGroupData(JsonElement e Optional displayName = default; Optional details = default; Optional> children = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -106,8 +207,44 @@ internal static ManagementGroupData DeserializeManagementGroupData(JsonElement e } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ManagementGroupData(id, name, type, systemData.Value, Optional.ToNullable(tenantId), displayName.Value, details.Value, Optional.ToList(children)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupData(id, name, type, systemData.Value, Optional.ToNullable(tenantId), displayName.Value, details.Value, Optional.ToList(children), 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(ManagementGroupData)} does not support '{options.Format}' format."); + } + } + + ManagementGroupData 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 DeserializeManagementGroupData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs index efeffe3f735c4..9cae589d54c00 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs @@ -6,16 +6,131 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.ManagementGroups.Models { - public partial class ManagementGroupInfo + public partial class ManagementGroupInfo : IUtf8JsonSerializable, IJsonModel { - internal static ManagementGroupInfo DeserializeManagementGroupInfo(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(ManagementGroupInfo)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteNumberValue(Version.Value); + } + if (Optional.IsDefined(UpdatedOn)) + { + writer.WritePropertyName("updatedTime"u8); + writer.WriteStringValue(UpdatedOn.Value, "O"); + } + if (Optional.IsDefined(UpdatedBy)) + { + writer.WritePropertyName("updatedBy"u8); + writer.WriteStringValue(UpdatedBy); + } + if (Optional.IsDefined(Parent)) + { + writer.WritePropertyName("parent"u8); + writer.WriteObjectValue(Parent); + } + if (Optional.IsCollectionDefined(Path)) + { + if (Path != null) + { + writer.WritePropertyName("path"u8); + writer.WriteStartArray(); + foreach (var item in Path) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("path"); + } + } + if (Optional.IsCollectionDefined(ManagementGroupAncestors)) + { + if (ManagementGroupAncestors != null) + { + writer.WritePropertyName("managementGroupAncestors"u8); + writer.WriteStartArray(); + foreach (var item in ManagementGroupAncestors) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("managementGroupAncestors"); + } + } + if (Optional.IsCollectionDefined(ManagementGroupAncestorChain)) + { + if (ManagementGroupAncestorChain != null) + { + writer.WritePropertyName("managementGroupAncestorsChain"u8); + writer.WriteStartArray(); + foreach (var item in ManagementGroupAncestorChain) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("managementGroupAncestorsChain"); + } + } + 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(); + } + + ManagementGroupInfo 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(ManagementGroupInfo)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupInfo(document.RootElement, options); + } + + internal static ManagementGroupInfo DeserializeManagementGroupInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -27,6 +142,8 @@ internal static ManagementGroupInfo DeserializeManagementGroupInfo(JsonElement e Optional> path = default; Optional> managementGroupAncestors = default; Optional> managementGroupAncestorsChain = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("version"u8)) @@ -106,8 +223,44 @@ internal static ManagementGroupInfo DeserializeManagementGroupInfo(JsonElement e managementGroupAncestorsChain = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ManagementGroupInfo(Optional.ToNullable(version), Optional.ToNullable(updatedTime), updatedBy.Value, parent.Value, Optional.ToList(path), Optional.ToList(managementGroupAncestors), Optional.ToList(managementGroupAncestorsChain)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupInfo(Optional.ToNullable(version), Optional.ToNullable(updatedTime), updatedBy.Value, parent.Value, Optional.ToList(path), Optional.ToList(managementGroupAncestors), Optional.ToList(managementGroupAncestorsChain), 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(ManagementGroupInfo)} does not support '{options.Format}' format."); + } + } + + ManagementGroupInfo 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 DeserializeManagementGroupInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupInfo)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.cs index 70db602e75b7f..3bcdc40513ca6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.cs @@ -14,6 +14,38 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// The details of a management group. public partial class ManagementGroupInfo { + /// + /// 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 ManagementGroupInfo() { @@ -30,7 +62,8 @@ internal ManagementGroupInfo() /// The path from the root to the current group. /// The ancestors of the management group. /// The ancestors of the management group displayed in reversed order, from immediate parent to the root. - internal ManagementGroupInfo(int? version, DateTimeOffset? updatedOn, string updatedBy, ParentManagementGroupInfo parent, IReadOnlyList path, IReadOnlyList managementGroupAncestors, IReadOnlyList managementGroupAncestorChain) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupInfo(int? version, DateTimeOffset? updatedOn, string updatedBy, ParentManagementGroupInfo parent, IReadOnlyList path, IReadOnlyList managementGroupAncestors, IReadOnlyList managementGroupAncestorChain, IDictionary serializedAdditionalRawData) { Version = version; UpdatedOn = updatedOn; @@ -39,6 +72,7 @@ internal ManagementGroupInfo(int? version, DateTimeOffset? updatedOn, string upd Path = path; ManagementGroupAncestors = managementGroupAncestors; ManagementGroupAncestorChain = managementGroupAncestorChain; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The version number of the object. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs index ba2ebf4c8245d..9e19a9dd335b1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.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.ManagementGroups.Models { - internal partial class ManagementGroupListResult + internal partial class ManagementGroupListResult : IUtf8JsonSerializable, IJsonModel { - internal static ManagementGroupListResult DeserializeManagementGroupListResult(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(ManagementGroupListResult)} 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 (options.Format != "W" && 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(); + } + + ManagementGroupListResult 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(ManagementGroupListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupListResult(document.RootElement, options); + } + + internal static ManagementGroupListResult DeserializeManagementGroupListResult(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 ManagementGroupListResult DeserializeManagementGroupListResult(J nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ManagementGroupListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupListResult(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(ManagementGroupListResult)} does not support '{options.Format}' format."); + } + } + + ManagementGroupListResult 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 DeserializeManagementGroupListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.cs index c5fbb76d065dc..45e2d6ee1c4a2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.ManagementGroups; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// Describes the result of the request to list management groups. internal partial class ManagementGroupListResult { + /// + /// 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 ManagementGroupListResult() { @@ -23,10 +56,12 @@ internal ManagementGroupListResult() /// Initializes a new instance of . /// The list of management groups. /// The URL to use for getting the next set of results. - internal ManagementGroupListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The list of management groups. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityContent.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityContent.Serialization.cs index c67ddcbacb1e6..9cd88b03433cf 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityContent.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityContent.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.ManagementGroups.Models { - public partial class ManagementGroupNameAvailabilityContent : IUtf8JsonSerializable + public partial class ManagementGroupNameAvailabilityContent : 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(ManagementGroupNameAvailabilityContent)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Name)) { @@ -25,7 +36,102 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("type"u8); writer.WriteStringValue(ResourceType.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(); } + + ManagementGroupNameAvailabilityContent 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(ManagementGroupNameAvailabilityContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupNameAvailabilityContent(document.RootElement, options); + } + + internal static ManagementGroupNameAvailabilityContent DeserializeManagementGroupNameAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional name = default; + Optional type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new ResourceType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupNameAvailabilityContent(name.Value, Optional.ToNullable(type), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ManagementGroupNameAvailabilityContent)} does not support '{options.Format}' format."); + } + } + + ManagementGroupNameAvailabilityContent 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 DeserializeManagementGroupNameAvailabilityContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupNameAvailabilityContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityContent.cs index d36ef36e4a359..118498fa4b2b4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityContent.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityContent.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.ResourceManager.ManagementGroups.Models @@ -12,13 +14,47 @@ namespace Azure.ResourceManager.ManagementGroups.Models /// Management group name availability check parameters. public partial class ManagementGroupNameAvailabilityContent { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// the name to check for availability. /// fully qualified resource type which includes provider namespace. - internal ManagementGroupNameAvailabilityContent(string name, ResourceType? resourceType) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupNameAvailabilityContent(string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData) { Name = name; ResourceType = resourceType; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// the name to check for availability. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs index 9d70a2780f8d5..bc18bd2d913ea 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.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.ManagementGroups.Models { - public partial class ManagementGroupNameAvailabilityResult + public partial class ManagementGroupNameAvailabilityResult : IUtf8JsonSerializable, IJsonModel { - internal static ManagementGroupNameAvailabilityResult DeserializeManagementGroupNameAvailabilityResult(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(ManagementGroupNameAvailabilityResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(NameAvailable)) + { + writer.WritePropertyName("nameAvailable"u8); + writer.WriteBooleanValue(NameAvailable.Value); + } + if (options.Format != "W" && Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.Value.ToSerialString()); + } + if (options.Format != "W" && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagementGroupNameAvailabilityResult 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(ManagementGroupNameAvailabilityResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupNameAvailabilityResult(document.RootElement, options); + } + + internal static ManagementGroupNameAvailabilityResult DeserializeManagementGroupNameAvailabilityResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +82,8 @@ internal static ManagementGroupNameAvailabilityResult DeserializeManagementGroup Optional nameAvailable = default; Optional reason = default; Optional message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("nameAvailable"u8)) @@ -46,8 +109,44 @@ internal static ManagementGroupNameAvailabilityResult DeserializeManagementGroup message = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ManagementGroupNameAvailabilityResult(Optional.ToNullable(nameAvailable), Optional.ToNullable(reason), message.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupNameAvailabilityResult(Optional.ToNullable(nameAvailable), Optional.ToNullable(reason), 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(ManagementGroupNameAvailabilityResult)} does not support '{options.Format}' format."); + } + } + + ManagementGroupNameAvailabilityResult 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 DeserializeManagementGroupNameAvailabilityResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupNameAvailabilityResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.cs index 58b544a767663..7e8d065a3dc36 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.ManagementGroups.Models { /// Describes the result of the request to check management group name availability. public partial class ManagementGroupNameAvailabilityResult { + /// + /// 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 ManagementGroupNameAvailabilityResult() { @@ -19,11 +54,13 @@ internal ManagementGroupNameAvailabilityResult() /// Required. True indicates name is valid and available. False indicates the name is invalid, unavailable, or both. /// Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable. /// Required if nameAvailable == false. Localized. If reason == invalid, provide the user with the reason why the given name is invalid, and provide the resource naming requirements so that the user can select a valid name. If reason == AlreadyExists, explain that is already in use, and direct them to select a different name. - internal ManagementGroupNameAvailabilityResult(bool? nameAvailable, ManagementGroupNameUnavailableReason? reason, string message) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupNameAvailabilityResult(bool? nameAvailable, ManagementGroupNameUnavailableReason? reason, string message, IDictionary serializedAdditionalRawData) { NameAvailable = nameAvailable; Reason = reason; Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Required. True indicates name is valid and available. False indicates the name is invalid, unavailable, or both. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupParentCreateOptions.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupParentCreateOptions.Serialization.cs index 183acf77b2c44..c59cb8943ca27 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupParentCreateOptions.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupParentCreateOptions.Serialization.cs @@ -5,22 +5,140 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.ManagementGroups.Models { - public partial class ManagementGroupParentCreateOptions : IUtf8JsonSerializable + public partial class ManagementGroupParentCreateOptions : 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(ManagementGroupParentCreateOptions)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Id)) { writer.WritePropertyName("id"u8); writer.WriteStringValue(Id); } + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + 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(); } + + ManagementGroupParentCreateOptions 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(ManagementGroupParentCreateOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupParentCreateOptions(document.RootElement, options); + } + + internal static ManagementGroupParentCreateOptions DeserializeManagementGroupParentCreateOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional id = default; + Optional name = default; + Optional displayName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupParentCreateOptions(id.Value, name.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(ManagementGroupParentCreateOptions)} does not support '{options.Format}' format."); + } + } + + ManagementGroupParentCreateOptions 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 DeserializeManagementGroupParentCreateOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupParentCreateOptions)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupParentCreateOptions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupParentCreateOptions.cs index 05c451b4417b6..1669e7481452c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupParentCreateOptions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupParentCreateOptions.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.ManagementGroups.Models { /// (Optional) The ID of the parent management group used during creation. public partial class ManagementGroupParentCreateOptions { + /// + /// 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 ManagementGroupParentCreateOptions() { @@ -19,11 +54,13 @@ public ManagementGroupParentCreateOptions() /// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. /// The name of the parent management group. /// The friendly name of the parent management group. - internal ManagementGroupParentCreateOptions(string id, string name, string displayName) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupParentCreateOptions(string id, string name, string displayName, IDictionary serializedAdditionalRawData) { Id = id; Name = name; DisplayName = displayName; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPatch.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPatch.Serialization.cs index 04f90cb27abcd..55e8211f69e21 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPatch.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPatch.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.ManagementGroups.Models { - public partial class ManagementGroupPatch : IUtf8JsonSerializable + public partial class ManagementGroupPatch : 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(ManagementGroupPatch)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(DisplayName)) { @@ -39,7 +50,108 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("parentGroupId"); } } + 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(); } + + ManagementGroupPatch 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(ManagementGroupPatch)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupPatch(document.RootElement, options); + } + + internal static ManagementGroupPatch DeserializeManagementGroupPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional displayName = default; + Optional parentGroupId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayName"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + displayName = null; + continue; + } + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("parentGroupId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + parentGroupId = null; + continue; + } + parentGroupId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupPatch(displayName.Value, parentGroupId.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(ManagementGroupPatch)} does not support '{options.Format}' format."); + } + } + + ManagementGroupPatch 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 DeserializeManagementGroupPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupPatch)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPatch.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPatch.cs index 57420be129655..deb6e424a378e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPatch.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPatch.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.ManagementGroups.Models { /// Management group patch parameters. public partial class ManagementGroupPatch { + /// + /// 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 ManagementGroupPatch() { @@ -18,10 +53,12 @@ public ManagementGroupPatch() /// Initializes a new instance of . /// The friendly name of the management group. /// (Optional) The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - internal ManagementGroupPatch(string displayName, string parentGroupId) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupPatch(string displayName, string parentGroupId, IDictionary serializedAdditionalRawData) { DisplayName = displayName; ParentGroupId = parentGroupId; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The friendly name of the management group. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs index 2b80084cf7b6e..9b72f0b26a26e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.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.ManagementGroups.Models { - public partial class ManagementGroupPathElement + public partial class ManagementGroupPathElement : IUtf8JsonSerializable, IJsonModel { - internal static ManagementGroupPathElement DeserializeManagementGroupPathElement(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(ManagementGroupPathElement)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(DisplayName)) + { + 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(); + } + + ManagementGroupPathElement 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(ManagementGroupPathElement)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementGroupPathElement(document.RootElement, options); + } + + internal static ManagementGroupPathElement DeserializeManagementGroupPathElement(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional name = default; Optional displayName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -32,8 +90,44 @@ internal static ManagementGroupPathElement DeserializeManagementGroupPathElement displayName = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementGroupPathElement(name.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(ManagementGroupPathElement)} does not support '{options.Format}' format."); } - return new ManagementGroupPathElement(name.Value, displayName.Value); } + + ManagementGroupPathElement 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 DeserializeManagementGroupPathElement(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementGroupPathElement)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.cs index 56c23f30653e7..1f84c28f9bea3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.ManagementGroups.Models { /// A path element of a management group ancestors. public partial class ManagementGroupPathElement { + /// + /// 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 ManagementGroupPathElement() { @@ -18,10 +53,12 @@ internal ManagementGroupPathElement() /// Initializes a new instance of . /// The name of the group. /// The friendly name of the group. - internal ManagementGroupPathElement(string name, string displayName) + /// Keeps track of any properties unknown to the library. + internal ManagementGroupPathElement(string name, string displayName, IDictionary serializedAdditionalRawData) { Name = name; DisplayName = displayName; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The name of the group. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs index 350dfa55f8ea2..cf9b09d293d79 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.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.ManagementGroups.Models { - public partial class ParentManagementGroupInfo + public partial class ParentManagementGroupInfo : IUtf8JsonSerializable, IJsonModel { - internal static ParentManagementGroupInfo DeserializeParentManagementGroupInfo(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(ParentManagementGroupInfo)} 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); + } + if (Optional.IsDefined(DisplayName)) + { + 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(); + } + + ParentManagementGroupInfo 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(ParentManagementGroupInfo)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeParentManagementGroupInfo(document.RootElement, options); + } + + internal static ParentManagementGroupInfo DeserializeParentManagementGroupInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +82,8 @@ internal static ParentManagementGroupInfo DeserializeParentManagementGroupInfo(J Optional id = default; Optional name = default; Optional displayName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -38,8 +101,44 @@ internal static ParentManagementGroupInfo DeserializeParentManagementGroupInfo(J displayName = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ParentManagementGroupInfo(id.Value, name.Value, displayName.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ParentManagementGroupInfo(id.Value, name.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(ParentManagementGroupInfo)} does not support '{options.Format}' format."); + } + } + + ParentManagementGroupInfo 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 DeserializeParentManagementGroupInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ParentManagementGroupInfo)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.cs index 496e2fe929cc1..a6fd9b7ff9ef9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.ManagementGroups.Models { /// (Optional) The ID of the parent management group. public partial class ParentManagementGroupInfo { + /// + /// 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 ParentManagementGroupInfo() { @@ -19,11 +54,13 @@ internal ParentManagementGroupInfo() /// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. /// The name of the parent management group. /// The friendly name of the parent management group. - internal ParentManagementGroupInfo(string id, string name, string displayName) + /// Keeps track of any properties unknown to the library. + internal ParentManagementGroupInfo(string id, string name, string displayName, IDictionary serializedAdditionalRawData) { Id = id; Name = name; DisplayName = displayName; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ResourceManagerModelFactory.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ResourceManagerModelFactory.cs index 42e07f5a46dc3..86db45a1c9a14 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ResourceManagerModelFactory.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ResourceManagerModelFactory.cs @@ -31,7 +31,7 @@ public static ManagementGroupData ManagementGroupData(ResourceIdentifier id = nu { children ??= new List(); - return new ManagementGroupData(id, name, resourceType, systemData, tenantId, displayName, details, children?.ToList()); + return new ManagementGroupData(id, name, resourceType, systemData, tenantId, displayName, details, children?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -49,7 +49,7 @@ public static ManagementGroupInfo ManagementGroupInfo(int? version = null, DateT managementGroupAncestors ??= new List(); managementGroupAncestorChain ??= new List(); - return new ManagementGroupInfo(version, updatedOn, updatedBy, parent, path?.ToList(), managementGroupAncestors?.ToList(), managementGroupAncestorChain?.ToList()); + return new ManagementGroupInfo(version, updatedOn, updatedBy, parent, path?.ToList(), managementGroupAncestors?.ToList(), managementGroupAncestorChain?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -59,7 +59,7 @@ public static ManagementGroupInfo ManagementGroupInfo(int? version = null, DateT /// A new instance for mocking. public static ParentManagementGroupInfo ParentManagementGroupInfo(string id = null, string name = null, string displayName = null) { - return new ParentManagementGroupInfo(id, name, displayName); + return new ParentManagementGroupInfo(id, name, displayName, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -68,7 +68,7 @@ public static ParentManagementGroupInfo ParentManagementGroupInfo(string id = nu /// A new instance for mocking. public static ManagementGroupPathElement ManagementGroupPathElement(string name = null, string displayName = null) { - return new ManagementGroupPathElement(name, displayName); + return new ManagementGroupPathElement(name, displayName, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -82,7 +82,58 @@ public static ManagementGroupChildInfo ManagementGroupChildInfo(ManagementGroupC { children ??= new List(); - return new ManagementGroupChildInfo(childType, id, name, displayName, children?.ToList()); + return new ManagementGroupChildInfo(childType, id, name, displayName, children?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + /// The type of the resource. For example, Microsoft.Management/managementGroups. + /// The name of the management group. For example, 00000000-0000-0000-0000-000000000000. + /// The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000. + /// The friendly name of the management group. If no value is passed then this field will be set to the groupId. + /// The details of a management group used during creation. + /// The list of children. + /// A new instance for mocking. + public static ManagementGroupCreateOrUpdateContent ManagementGroupCreateOrUpdateContent(string id = null, ResourceType? resourceType = null, string name = null, Guid? tenantId = null, string displayName = null, CreateManagementGroupDetails details = null, IEnumerable children = null) + { + children ??= new List(); + + return new ManagementGroupCreateOrUpdateContent(id, resourceType, name, tenantId, displayName, details, children?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The version number of the object. + /// The date and time when this object was last updated. + /// The identity of the principal or process that updated the object. + /// (Optional) The ID of the parent management group used during creation. + /// A new instance for mocking. + public static CreateManagementGroupDetails CreateManagementGroupDetails(int? version = null, DateTimeOffset? updatedOn = null, string updatedBy = null, ManagementGroupParentCreateOptions parent = null) + { + return new CreateManagementGroupDetails(version, updatedOn, updatedBy, parent, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + /// The name of the parent management group. + /// The friendly name of the parent management group. + /// A new instance for mocking. + public static ManagementGroupParentCreateOptions ManagementGroupParentCreateOptions(string id = null, string name = null, string displayName = null) + { + return new ManagementGroupParentCreateOptions(id, name, displayName, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups). + /// The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + /// The name of the child entity. + /// The friendly name of the child resource. + /// The list of children. + /// A new instance for mocking. + public static ManagementGroupChildOptions ManagementGroupChildOptions(ManagementGroupChildType? childType = null, string id = null, string name = null, string displayName = null, IEnumerable children = null) + { + children ??= new List(); + + return new ManagementGroupChildOptions(childType, id, name, displayName, children?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -95,7 +146,7 @@ public static ManagementGroupChildInfo ManagementGroupChildInfo(ManagementGroupC /// A new instance for mocking. public static DescendantData DescendantData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string displayName = null, ResourceIdentifier parentId = null) { - return new DescendantData(id, name, resourceType, systemData, displayName, parentId != null ? new DescendantParentGroupInfo(parentId) : null); + return new DescendantData(id, name, resourceType, systemData, displayName, parentId != null ? new DescendantParentGroupInfo(parentId, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -105,7 +156,7 @@ public static DescendantData DescendantData(ResourceIdentifier id = null, string /// A new instance for mocking. public static ManagementGroupNameAvailabilityResult ManagementGroupNameAvailabilityResult(bool? nameAvailable = null, ManagementGroupNameUnavailableReason? reason = null, string message = null) { - return new ManagementGroupNameAvailabilityResult(nameAvailable, reason, message); + return new ManagementGroupNameAvailabilityResult(nameAvailable, reason, message, serializedAdditionalRawData: null); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApi.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApi.Serialization.cs index 9eafc0275aec9..d0abb99b69834 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApi.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApi.Serialization.cs @@ -1,19 +1,78 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// - #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ArmRestApi + public partial class ArmRestApi : IJsonModel { - internal static ArmRestApi DeserializeRestApi(JsonElement element) + 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(ArmRestApi)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (format != "W" && Optional.IsDefined(Origin)) + { + writer.WritePropertyName("origin"u8); + writer.WriteStringValue(Origin); + } + if (format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + writer.WritePropertyName("display"u8); + writer.WriteStartObject(); + if (format != "W" && Optional.IsDefined(Operation)) + { + writer.WritePropertyName("operation"u8); + writer.WriteStringValue(Operation); + } + if (format != "W" && Optional.IsDefined(Resource)) + { + writer.WritePropertyName("resource"u8); + writer.WriteStringValue(Resource); + } + if (format != "W" && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (format != "W" && Optional.IsDefined(Provider)) + { + writer.WritePropertyName("provider"u8); + writer.WriteStringValue(Provider); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + ArmRestApi 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(ArmRestApi)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeArmRestApi(document.RootElement, options); + } + + internal static ArmRestApi DeserializeArmRestApi(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + Optional origin = default; Optional name = default; Optional operation = default; @@ -36,7 +95,6 @@ internal static ArmRestApi DeserializeRestApi(JsonElement element) { if (property.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) @@ -67,5 +125,36 @@ internal static ArmRestApi DeserializeRestApi(JsonElement element) } return new ArmRestApi(origin.Value, name.Value, operation.Value, resource.Value, description.Value, provider.Value); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ArmRestApi)} does not support '{options.Format}' format."); + } + } + + ArmRestApi 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 DeserializeArmRestApi(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ArmRestApi)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApi.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApi.cs index 08da84c0097e8..164b744651d81 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApi.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApi.cs @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// - #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// Describes the properties of an Operation value. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApiListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApiListResult.Serialization.cs index 8e74f3e3a39af..fd4f6246a1510 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApiListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/Models/ArmRestApiListResult.Serialization.cs @@ -28,7 +28,7 @@ internal static ArmRestApiListResult DeserializeComputeOperationListResult(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ArmRestApi.DeserializeRestApi(item)); + array.Add(ArmRestApi.DeserializeArmRestApi(item)); } value = array; continue; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.cs index b9c02cef91d84..105ba8d7b299a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; @@ -18,6 +19,38 @@ namespace Azure.ResourceManager.Resources /// public partial class DataPolicyManifestData : 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 . internal DataPolicyManifestData() { @@ -42,7 +75,8 @@ internal DataPolicyManifestData() /// The non-alias field accessor values that can be used in the policy rule. /// The standard resource functions (subscription and/or resourceGroup). /// An array of data manifest custom resource definition. - internal DataPolicyManifestData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IReadOnlyList namespaces, string policyMode, bool? isBuiltInOnly, IReadOnlyList resourceTypeAliases, IReadOnlyList effects, IReadOnlyList fieldValues, IReadOnlyList standard, IReadOnlyList customDefinitions) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal DataPolicyManifestData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IReadOnlyList namespaces, string policyMode, bool? isBuiltInOnly, IReadOnlyList resourceTypeAliases, IReadOnlyList effects, IReadOnlyList fieldValues, IReadOnlyList standard, IReadOnlyList customDefinitions, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Namespaces = namespaces; PolicyMode = policyMode; @@ -52,6 +86,7 @@ internal DataPolicyManifestData(ResourceIdentifier id, string name, ResourceType FieldValues = fieldValues; Standard = standard; CustomDefinitions = customDefinitions; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The list of namespaces for the data policy manifest. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.cs index 6acfdf28e79b6..4c567c76dce4a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; using Azure.ResourceManager.Resources.Models; @@ -17,6 +19,38 @@ namespace Azure.ResourceManager.Resources /// public partial class FeatureData : 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 . internal FeatureData() { @@ -28,9 +62,11 @@ internal FeatureData() /// The resourceType. /// The systemData. /// Properties of the previewed feature. - internal FeatureData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, FeatureProperties properties) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal FeatureData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, FeatureProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Properties of the previewed feature. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.cs index 0bc08064e7ed1..2240cb4e277e7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.cs @@ -33,6 +33,7 @@ public GenericResourceData(AzureLocation location) : base(location) /// The tags. /// The location. /// Resource extended location. + /// Keeps track of any properties unknown to the library. /// The plan of the resource. /// The resource properties. /// The kind of the resource. @@ -42,7 +43,7 @@ public GenericResourceData(AzureLocation location) : base(location) /// The created time of the resource. This is only present if requested via the $expand query parameter. /// The changed time of the resource. This is only present if requested via the $expand query parameter. /// The provisioning state of the resource. This is only present if requested via the $expand query parameter. - internal GenericResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ExtendedLocation extendedLocation, ArmPlan plan, BinaryData properties, string kind, string managedBy, ResourcesSku sku, ManagedServiceIdentity identity, DateTimeOffset? createdOn, DateTimeOffset? changedOn, string provisioningState) : base(id, name, resourceType, systemData, tags, location, extendedLocation) + internal GenericResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData, ArmPlan plan, BinaryData properties, string kind, string managedBy, ResourcesSku sku, ManagedServiceIdentity identity, DateTimeOffset? createdOn, DateTimeOffset? changedOn, string provisioningState) : base(id, name, resourceType, systemData, tags, location, extendedLocation, serializedAdditionalRawData) { Plan = plan; Properties = properties; @@ -55,6 +56,11 @@ internal GenericResourceData(ResourceIdentifier id, string name, ResourceType re ProvisioningState = provisioningState; } + /// Initializes a new instance of for deserialization. + internal GenericResourceData() + { + } + /// The plan of the resource. public ArmPlan Plan { get; set; } /// diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.cs index 2734af806beff..6a7605310752e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; @@ -18,6 +19,38 @@ namespace Azure.ResourceManager.Resources /// public partial class ManagementLockData : 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 . /// The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. public ManagementLockData(ManagementLockLevel level) @@ -34,11 +67,18 @@ public ManagementLockData(ManagementLockLevel level) /// The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. /// Notes about the lock. Maximum of 512 characters. /// The owners of the lock. - internal ManagementLockData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ManagementLockLevel level, string notes, IList owners) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal ManagementLockData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ManagementLockLevel level, string notes, IList owners, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Level = level; Notes = notes; Owners = owners; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ManagementLockData() + { } /// The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs index ff16d53197eb8..e5eca2e121a03 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.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.Resources.Models { - public partial class ApiProfile + public partial class ApiProfile : IUtf8JsonSerializable, IJsonModel { - internal static ApiProfile DeserializeApiProfile(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(ApiProfile)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProfileVersion)) + { + writer.WritePropertyName("profileVersion"u8); + writer.WriteStringValue(ProfileVersion); + } + if (options.Format != "W" && Optional.IsDefined(ApiVersion)) + { + writer.WritePropertyName("apiVersion"u8); + writer.WriteStringValue(ApiVersion); + } + 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(); + } + + ApiProfile 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(ApiProfile)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApiProfile(document.RootElement, options); + } + + internal static ApiProfile DeserializeApiProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional profileVersion = default; Optional apiVersion = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("profileVersion"u8)) @@ -32,8 +90,44 @@ internal static ApiProfile DeserializeApiProfile(JsonElement element) apiVersion = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ApiProfile(profileVersion.Value, apiVersion.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(ApiProfile)} does not support '{options.Format}' format."); } - return new ApiProfile(profileVersion.Value, apiVersion.Value); } + + ApiProfile 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 DeserializeApiProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApiProfile)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.cs index 5c06c9953c594..d9643e8d4402e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// The ApiProfile. public partial class ApiProfile { + /// + /// 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 ApiProfile() { @@ -18,10 +53,12 @@ internal ApiProfile() /// Initializes a new instance of . /// The profile version. /// The API version. - internal ApiProfile(string profileVersion, string apiVersion) + /// Keeps track of any properties unknown to the library. + internal ApiProfile(string profileVersion, string apiVersion, IDictionary serializedAdditionalRawData) { ProfileVersion = profileVersion; ApiVersion = apiVersion; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The profile version. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs index 1617bfc1a5e07..bf0e5d144979a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.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.Resources.Models { - public partial class ArmPolicyParameter : IUtf8JsonSerializable + public partial class ArmPolicyParameter : 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(ArmPolicyParameter)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(ParameterType)) { @@ -61,11 +70,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("metadata"u8); writer.WriteObjectValue(Metadata); } + 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 ArmPolicyParameter DeserializeArmPolicyParameter(JsonElement element) + ArmPolicyParameter 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(ArmPolicyParameter)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeArmPolicyParameter(document.RootElement, options); + } + + internal static ArmPolicyParameter DeserializeArmPolicyParameter(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -74,6 +112,8 @@ internal static ArmPolicyParameter DeserializeArmPolicyParameter(JsonElement ele Optional> allowedValues = default; Optional defaultValue = default; Optional metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -124,8 +164,44 @@ internal static ArmPolicyParameter DeserializeArmPolicyParameter(JsonElement ele metadata = ParameterDefinitionsValueMetadata.DeserializeParameterDefinitionsValueMetadata(property.Value); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ArmPolicyParameter(Optional.ToNullable(type), Optional.ToList(allowedValues), defaultValue.Value, metadata.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(ArmPolicyParameter)} does not support '{options.Format}' format."); } - return new ArmPolicyParameter(Optional.ToNullable(type), Optional.ToList(allowedValues), defaultValue.Value, metadata.Value); } + + ArmPolicyParameter 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 DeserializeArmPolicyParameter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ArmPolicyParameter)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.cs index ccdc950e6707e..323f9dc66a994 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.cs @@ -14,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The definition of a parameter that can be provided to the policy. public partial class ArmPolicyParameter { + /// + /// 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 ArmPolicyParameter() { @@ -25,12 +57,14 @@ public ArmPolicyParameter() /// The allowed values for the parameter. /// The default value for the parameter if no value is provided. /// General metadata for the parameter. - internal ArmPolicyParameter(ArmPolicyParameterType? parameterType, IList allowedValues, BinaryData defaultValue, ParameterDefinitionsValueMetadata metadata) + /// Keeps track of any properties unknown to the library. + internal ArmPolicyParameter(ArmPolicyParameterType? parameterType, IList allowedValues, BinaryData defaultValue, ParameterDefinitionsValueMetadata metadata, IDictionary serializedAdditionalRawData) { ParameterType = parameterType; AllowedValues = allowedValues; DefaultValue = defaultValue; Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The data type of the parameter. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs index 35c4811473fbf..0cc140d82e037 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.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.Resources.Models { - public partial class ArmPolicyParameterValue : IUtf8JsonSerializable + public partial class ArmPolicyParameterValue : 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(ArmPolicyParameterValue)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Value)) { @@ -28,16 +38,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } #endif } + 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 ArmPolicyParameterValue DeserializeArmPolicyParameterValue(JsonElement element) + ArmPolicyParameterValue 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(ArmPolicyParameterValue)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeArmPolicyParameterValue(document.RootElement, options); + } + + internal static ArmPolicyParameterValue DeserializeArmPolicyParameterValue(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -49,8 +90,44 @@ internal static ArmPolicyParameterValue DeserializeArmPolicyParameterValue(JsonE value = BinaryData.FromString(property.Value.GetRawText()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ArmPolicyParameterValue(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(ArmPolicyParameterValue)} does not support '{options.Format}' format."); } - return new ArmPolicyParameterValue(value.Value); } + + ArmPolicyParameterValue 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 DeserializeArmPolicyParameterValue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ArmPolicyParameterValue)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.cs index 23adf56c62b47..984f9e858adac 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.ResourceManager.Resources.Models { /// The value of a parameter. public partial class ArmPolicyParameterValue { + /// + /// 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 ArmPolicyParameterValue() { @@ -19,9 +52,11 @@ public ArmPolicyParameterValue() /// Initializes a new instance of . /// The value of the parameter. - internal ArmPolicyParameterValue(BinaryData value) + /// Keeps track of any properties unknown to the library. + internal ArmPolicyParameterValue(BinaryData value, IDictionary serializedAdditionalRawData) { Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs index 95475f461e67c..6ce6545f95abc 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.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.Resources.Models { - public partial class AvailabilityZoneMappings + public partial class AvailabilityZoneMappings : IUtf8JsonSerializable, IJsonModel { - internal static AvailabilityZoneMappings DeserializeAvailabilityZoneMappings(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(AvailabilityZoneMappings)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(LogicalZone)) + { + writer.WritePropertyName("logicalZone"u8); + writer.WriteStringValue(LogicalZone); + } + if (options.Format != "W" && Optional.IsDefined(PhysicalZone)) + { + writer.WritePropertyName("physicalZone"u8); + writer.WriteStringValue(PhysicalZone); + } + 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(); + } + + AvailabilityZoneMappings 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(AvailabilityZoneMappings)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAvailabilityZoneMappings(document.RootElement, options); + } + + internal static AvailabilityZoneMappings DeserializeAvailabilityZoneMappings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional logicalZone = default; Optional physicalZone = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("logicalZone"u8)) @@ -32,8 +90,44 @@ internal static AvailabilityZoneMappings DeserializeAvailabilityZoneMappings(Jso physicalZone = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new AvailabilityZoneMappings(logicalZone.Value, physicalZone.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(AvailabilityZoneMappings)} does not support '{options.Format}' format."); } - return new AvailabilityZoneMappings(logicalZone.Value, physicalZone.Value); } + + AvailabilityZoneMappings 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 DeserializeAvailabilityZoneMappings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AvailabilityZoneMappings)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.cs index 409353951e5b7..57504373f2db4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// Availability zone mappings for the region. public partial class AvailabilityZoneMappings { + /// + /// 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 AvailabilityZoneMappings() { @@ -18,10 +53,12 @@ internal AvailabilityZoneMappings() /// Initializes a new instance of . /// The logical zone id for the availability zone. /// The fully qualified physical zone id of availability zone to which logical zone id is mapped to. - internal AvailabilityZoneMappings(string logicalZone, string physicalZone) + /// Keeps track of any properties unknown to the library. + internal AvailabilityZoneMappings(string logicalZone, string physicalZone, IDictionary serializedAdditionalRawData) { LogicalZone = logicalZone; PhysicalZone = physicalZone; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The logical zone id for the availability zone. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs index f7630be9bcbef..4e9dd88d63f05 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs @@ -5,16 +5,96 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class AzureRoleDefinition + public partial class AzureRoleDefinition : IUtf8JsonSerializable, IJsonModel { - internal static AzureRoleDefinition DeserializeAzureRoleDefinition(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(AzureRoleDefinition)} 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); + } + if (Optional.IsDefined(IsServiceRole)) + { + writer.WritePropertyName("isServiceRole"u8); + writer.WriteBooleanValue(IsServiceRole.Value); + } + if (Optional.IsCollectionDefined(Permissions)) + { + writer.WritePropertyName("permissions"u8); + writer.WriteStartArray(); + foreach (var item in Permissions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Scopes)) + { + writer.WritePropertyName("scopes"u8); + writer.WriteStartArray(); + foreach (var item in Scopes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AzureRoleDefinition 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(AzureRoleDefinition)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureRoleDefinition(document.RootElement, options); + } + + internal static AzureRoleDefinition DeserializeAzureRoleDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -24,6 +104,8 @@ internal static AzureRoleDefinition DeserializeAzureRoleDefinition(JsonElement e Optional isServiceRole = default; Optional> permissions = default; Optional> scopes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -73,8 +155,44 @@ internal static AzureRoleDefinition DeserializeAzureRoleDefinition(JsonElement e scopes = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new AzureRoleDefinition(id.Value, name.Value, Optional.ToNullable(isServiceRole), Optional.ToList(permissions), Optional.ToList(scopes)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new AzureRoleDefinition(id.Value, name.Value, Optional.ToNullable(isServiceRole), Optional.ToList(permissions), Optional.ToList(scopes), 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(AzureRoleDefinition)} does not support '{options.Format}' format."); + } + } + + AzureRoleDefinition 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 DeserializeAzureRoleDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureRoleDefinition)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.cs index 9df081800118a..6f9b794120f74 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Role definition properties. public partial class AzureRoleDefinition { + /// + /// 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 AzureRoleDefinition() { @@ -26,13 +59,15 @@ internal AzureRoleDefinition() /// If this is a service role. /// Role definition permissions. /// Role definition assignable scopes. - internal AzureRoleDefinition(string id, string name, bool? isServiceRole, IReadOnlyList permissions, IReadOnlyList scopes) + /// Keeps track of any properties unknown to the library. + internal AzureRoleDefinition(string id, string name, bool? isServiceRole, IReadOnlyList permissions, IReadOnlyList scopes, IDictionary serializedAdditionalRawData) { Id = id; Name = name; IsServiceRole = isServiceRole; Permissions = permissions; Scopes = scopes; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The role definition ID. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs index 8fbec8d6e92c2..77679cf4e0a31 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs @@ -5,16 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class DataManifestCustomResourceFunctionDefinition + public partial class DataManifestCustomResourceFunctionDefinition : IUtf8JsonSerializable, IJsonModel { - internal static DataManifestCustomResourceFunctionDefinition DeserializeDataManifestCustomResourceFunctionDefinition(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(DataManifestCustomResourceFunctionDefinition)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(FullyQualifiedResourceType)) + { + writer.WritePropertyName("fullyQualifiedResourceType"u8); + writer.WriteStringValue(FullyQualifiedResourceType.Value); + } + if (Optional.IsCollectionDefined(DefaultProperties)) + { + writer.WritePropertyName("defaultProperties"u8); + writer.WriteStartArray(); + foreach (var item in DefaultProperties) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(AllowCustomProperties)) + { + writer.WritePropertyName("allowCustomProperties"u8); + writer.WriteBooleanValue(AllowCustomProperties.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(); + } + + DataManifestCustomResourceFunctionDefinition 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(DataManifestCustomResourceFunctionDefinition)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataManifestCustomResourceFunctionDefinition(document.RootElement, options); + } + + internal static DataManifestCustomResourceFunctionDefinition DeserializeDataManifestCustomResourceFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +93,8 @@ internal static DataManifestCustomResourceFunctionDefinition DeserializeDataMani Optional fullyQualifiedResourceType = default; Optional> defaultProperties = default; Optional allowCustomProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -62,8 +134,44 @@ internal static DataManifestCustomResourceFunctionDefinition DeserializeDataMani allowCustomProperties = property.Value.GetBoolean(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new DataManifestCustomResourceFunctionDefinition(name.Value, Optional.ToNullable(fullyQualifiedResourceType), Optional.ToList(defaultProperties), Optional.ToNullable(allowCustomProperties)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DataManifestCustomResourceFunctionDefinition(name.Value, Optional.ToNullable(fullyQualifiedResourceType), Optional.ToList(defaultProperties), Optional.ToNullable(allowCustomProperties), 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(DataManifestCustomResourceFunctionDefinition)} does not support '{options.Format}' format."); + } + } + + DataManifestCustomResourceFunctionDefinition 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 DeserializeDataManifestCustomResourceFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataManifestCustomResourceFunctionDefinition)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.cs index 30144bd13115b..969333c719bd6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The custom resource function definition. public partial class DataManifestCustomResourceFunctionDefinition { + /// + /// 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 DataManifestCustomResourceFunctionDefinition() { @@ -24,12 +57,14 @@ internal DataManifestCustomResourceFunctionDefinition() /// The fully qualified control plane resource type that this function represents. eg - 'Microsoft.KeyVault/vaults'. /// The top-level properties that can be selected on the function's output. eg - [ "name", "location" ] if vault().name and vault().location are supported. /// A value indicating whether the custom properties within the property bag are allowed. Needs api-version to be specified in the policy rule eg - vault('2019-06-01'). - internal DataManifestCustomResourceFunctionDefinition(string name, ResourceType? fullyQualifiedResourceType, IReadOnlyList defaultProperties, bool? allowCustomProperties) + /// Keeps track of any properties unknown to the library. + internal DataManifestCustomResourceFunctionDefinition(string name, ResourceType? fullyQualifiedResourceType, IReadOnlyList defaultProperties, bool? allowCustomProperties, IDictionary serializedAdditionalRawData) { Name = name; FullyQualifiedResourceType = fullyQualifiedResourceType; DefaultProperties = defaultProperties; AllowCustomProperties = allowCustomProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The function name as it will appear in the policy rule. eg - 'vault'. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestData.Serialization.cs index ec1d5014f3ca0..986bed8139f27 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestData.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; @@ -13,10 +15,149 @@ namespace Azure.ResourceManager.Resources { - public partial class DataPolicyManifestData + public partial class DataPolicyManifestData : IUtf8JsonSerializable, IJsonModel { - internal static DataPolicyManifestData DeserializeDataPolicyManifestData(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(DataPolicyManifestData)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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.IsCollectionDefined(Namespaces)) + { + writer.WritePropertyName("namespaces"u8); + writer.WriteStartArray(); + foreach (var item in Namespaces) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PolicyMode)) + { + writer.WritePropertyName("policyMode"u8); + writer.WriteStringValue(PolicyMode); + } + if (Optional.IsDefined(IsBuiltInOnly)) + { + writer.WritePropertyName("isBuiltInOnly"u8); + writer.WriteBooleanValue(IsBuiltInOnly.Value); + } + if (Optional.IsCollectionDefined(ResourceTypeAliases)) + { + writer.WritePropertyName("resourceTypeAliases"u8); + writer.WriteStartArray(); + foreach (var item in ResourceTypeAliases) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Effects)) + { + writer.WritePropertyName("effects"u8); + writer.WriteStartArray(); + foreach (var item in Effects) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(FieldValues)) + { + writer.WritePropertyName("fieldValues"u8); + writer.WriteStartArray(); + foreach (var item in FieldValues) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("resourceFunctions"u8); + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Standard)) + { + writer.WritePropertyName("standard"u8); + writer.WriteStartArray(); + foreach (var item in Standard) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(CustomDefinitions)) + { + writer.WritePropertyName("custom"u8); + writer.WriteStartArray(); + foreach (var item in CustomDefinitions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + 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(); + } + + DataPolicyManifestData 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(DataPolicyManifestData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataPolicyManifestData(document.RootElement, options); + } + + internal static DataPolicyManifestData DeserializeDataPolicyManifestData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,6 +174,8 @@ internal static DataPolicyManifestData DeserializeDataPolicyManifestData(JsonEle Optional> fieldValues = default; Optional> standard = default; Optional> custom = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -181,8 +324,44 @@ internal static DataPolicyManifestData DeserializeDataPolicyManifestData(JsonEle } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DataPolicyManifestData(id, name, type, systemData.Value, Optional.ToList(namespaces), policyMode.Value, Optional.ToNullable(isBuiltInOnly), Optional.ToList(resourceTypeAliases), Optional.ToList(effects), Optional.ToList(fieldValues), Optional.ToList(standard), Optional.ToList(custom), 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(DataPolicyManifestData)} does not support '{options.Format}' format."); } - return new DataPolicyManifestData(id, name, type, systemData.Value, Optional.ToList(namespaces), policyMode.Value, Optional.ToNullable(isBuiltInOnly), Optional.ToList(resourceTypeAliases), Optional.ToList(effects), Optional.ToList(fieldValues), Optional.ToList(standard), Optional.ToList(custom)); } + + DataPolicyManifestData 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 DeserializeDataPolicyManifestData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataPolicyManifestData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs index d39b6988f2264..d07acb3b6cdc6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs @@ -6,21 +6,85 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class DataPolicyManifestEffect + public partial class DataPolicyManifestEffect : IUtf8JsonSerializable, IJsonModel { - internal static DataPolicyManifestEffect DeserializeDataPolicyManifestEffect(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(DataPolicyManifestEffect)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(DetailsSchema)) + { + writer.WritePropertyName("detailsSchema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(DetailsSchema); +#else + using (JsonDocument document = JsonDocument.Parse(DetailsSchema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + 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(); + } + + DataPolicyManifestEffect 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(DataPolicyManifestEffect)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataPolicyManifestEffect(document.RootElement, options); + } + + internal static DataPolicyManifestEffect DeserializeDataPolicyManifestEffect(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional name = default; Optional detailsSchema = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -37,8 +101,44 @@ internal static DataPolicyManifestEffect DeserializeDataPolicyManifestEffect(Jso detailsSchema = BinaryData.FromString(property.Value.GetRawText()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new DataPolicyManifestEffect(name.Value, detailsSchema.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DataPolicyManifestEffect(name.Value, detailsSchema.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(DataPolicyManifestEffect)} does not support '{options.Format}' format."); + } + } + + DataPolicyManifestEffect 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 DeserializeDataPolicyManifestEffect(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataPolicyManifestEffect)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.cs index 682744201d93b..dac41fd3b9aa3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.ResourceManager.Resources.Models { /// The data effect definition. public partial class DataPolicyManifestEffect { + /// + /// 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 DataPolicyManifestEffect() { @@ -20,10 +53,12 @@ internal DataPolicyManifestEffect() /// Initializes a new instance of . /// The data effect name. /// The data effect details schema. - internal DataPolicyManifestEffect(string name, BinaryData detailsSchema) + /// Keeps track of any properties unknown to the library. + internal DataPolicyManifestEffect(string name, BinaryData detailsSchema, IDictionary serializedAdditionalRawData) { Name = name; DetailsSchema = detailsSchema; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The data effect name. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs index 32a53028a6a52..588d59d141362 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.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.Resources.Models { - internal partial class DataPolicyManifestListResult + internal partial class DataPolicyManifestListResult : IUtf8JsonSerializable, IJsonModel { - internal static DataPolicyManifestListResult DeserializeDataPolicyManifestListResult(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(DataPolicyManifestListResult)} 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(); + } + + DataPolicyManifestListResult 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(DataPolicyManifestListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataPolicyManifestListResult(document.RootElement, options); + } + + internal static DataPolicyManifestListResult DeserializeDataPolicyManifestListResult(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 DataPolicyManifestListResult DeserializeDataPolicyManifestListRe nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new DataPolicyManifestListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DataPolicyManifestListResult(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(DataPolicyManifestListResult)} does not support '{options.Format}' format."); + } + } + + DataPolicyManifestListResult 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 DeserializeDataPolicyManifestListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataPolicyManifestListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.cs index b8480ca4d0329..40e5e5b2a4a8e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of data policy manifests. internal partial class DataPolicyManifestListResult { + /// + /// 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 DataPolicyManifestListResult() { @@ -23,10 +56,12 @@ internal DataPolicyManifestListResult() /// Initializes a new instance of . /// An array of data policy manifests. /// The URL to use for getting the next set of results. - internal DataPolicyManifestListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal DataPolicyManifestListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of data policy manifests. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExportTemplate.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExportTemplate.Serialization.cs index d6c765c90ed6b..5b7576e3df022 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExportTemplate.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExportTemplate.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.Resources.Models { - public partial class ExportTemplate : IUtf8JsonSerializable + public partial class ExportTemplate : 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(ExportTemplate)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsCollectionDefined(Resources)) { @@ -30,7 +41,107 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("options"u8); writer.WriteStringValue(Options); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } + + ExportTemplate 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(ExportTemplate)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExportTemplate(document.RootElement, options); + } + + internal static ExportTemplate DeserializeExportTemplate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> resources = default; + Optional options0 = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + resources = array; + continue; + } + if (property.NameEquals("options"u8)) + { + options0 = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ExportTemplate(Optional.ToList(resources), options0.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(ExportTemplate)} does not support '{options.Format}' format."); + } + } + + ExportTemplate 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 DeserializeExportTemplate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExportTemplate)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExportTemplate.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExportTemplate.cs index b575cf36a5a8d..884d990e17ea2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExportTemplate.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExportTemplate.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Export resource group template request parameters. public partial class ExportTemplate { + /// + /// 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 ExportTemplate() { @@ -22,10 +55,12 @@ public ExportTemplate() /// Initializes a new instance of . /// The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. /// The export template options. A CSV-formatted list containing zero or more of the following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - internal ExportTemplate(IList resources, string options) + /// Keeps track of any properties unknown to the library. + internal ExportTemplate(IList resources, string options, IDictionary serializedAdditionalRawData) { Resources = resources; Options = options; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs index 4efbe4af5ad8e..efbe0506d9747 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -13,10 +14,18 @@ namespace Azure.ResourceManager.Resources.Models { [JsonConverter(typeof(ExtendedLocationConverter))] - public partial class ExtendedLocation : IUtf8JsonSerializable + public partial class ExtendedLocation : 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(ExtendedLocation)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(ExtendedLocationType)) { @@ -31,8 +40,22 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static ExtendedLocation DeserializeExtendedLocation(JsonElement element) + ExtendedLocation 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(ExtendedLocation)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExtendedLocation(document.RootElement, options); + } + + internal static ExtendedLocation DeserializeExtendedLocation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -59,6 +82,37 @@ internal static ExtendedLocation DeserializeExtendedLocation(JsonElement element return new ExtendedLocation(Optional.ToNullable(type), name.Value); } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ExtendedLocation)} does not support '{options.Format}' format."); + } + } + + ExtendedLocation 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 DeserializeExtendedLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExtendedLocation)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + internal partial class ExtendedLocationConverter : JsonConverter { public override void Write(Utf8JsonWriter writer, ExtendedLocation model, JsonSerializerOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureData.Serialization.cs index 83e4e546b7fb0..0a721ee8147a4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureData.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.Models; @@ -12,10 +15,78 @@ namespace Azure.ResourceManager.Resources { - public partial class FeatureData + public partial class FeatureData : IUtf8JsonSerializable, IJsonModel { - internal static FeatureData DeserializeFeatureData(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(FeatureData)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties); + } + 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); + } + 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(); + } + + FeatureData 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(FeatureData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFeatureData(document.RootElement, options); + } + + internal static FeatureData DeserializeFeatureData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -25,6 +96,8 @@ internal static FeatureData DeserializeFeatureData(JsonElement element) string name = default; ResourceType type = default; Optional systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("properties"u8)) @@ -60,8 +133,44 @@ internal static FeatureData DeserializeFeatureData(JsonElement element) systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new FeatureData(id, name, type, systemData.Value, properties.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new FeatureData(id, name, type, systemData.Value, 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(FeatureData)} does not support '{options.Format}' format."); + } + } + + FeatureData 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 DeserializeFeatureData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FeatureData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs index f43ce6b4d596e..ead4aea016123 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.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.Resources.Models { - internal partial class FeatureOperationsListResult + internal partial class FeatureOperationsListResult : IUtf8JsonSerializable, IJsonModel { - internal static FeatureOperationsListResult DeserializeFeatureOperationsListResult(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(FeatureOperationsListResult)} 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(); + } + + FeatureOperationsListResult 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(FeatureOperationsListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFeatureOperationsListResult(document.RootElement, options); + } + + internal static FeatureOperationsListResult DeserializeFeatureOperationsListResult(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 FeatureOperationsListResult DeserializeFeatureOperationsListResu nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new FeatureOperationsListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new FeatureOperationsListResult(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(FeatureOperationsListResult)} does not support '{options.Format}' format."); + } + } + + FeatureOperationsListResult 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 DeserializeFeatureOperationsListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FeatureOperationsListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.cs index 124d76acf05a2..02d01d17d200a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of previewed features. internal partial class FeatureOperationsListResult { + /// + /// 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 FeatureOperationsListResult() { @@ -23,10 +56,12 @@ internal FeatureOperationsListResult() /// Initializes a new instance of . /// The array of features. /// The URL to use for getting the next set of results. - internal FeatureOperationsListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal FeatureOperationsListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The array of features. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs index 5188762404ca3..afb9bbca99901 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs @@ -5,20 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - internal partial class FeatureProperties + internal partial class FeatureProperties : IUtf8JsonSerializable, IJsonModel { - internal static FeatureProperties DeserializeFeatureProperties(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(FeatureProperties)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State); + } + 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(); + } + + FeatureProperties 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(FeatureProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFeatureProperties(document.RootElement, options); + } + + internal static FeatureProperties DeserializeFeatureProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("state"u8)) @@ -26,8 +79,44 @@ internal static FeatureProperties DeserializeFeatureProperties(JsonElement eleme state = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new FeatureProperties(state.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new FeatureProperties(state.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(FeatureProperties)} does not support '{options.Format}' format."); + } + } + + FeatureProperties 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 DeserializeFeatureProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FeatureProperties)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.cs index 5443cb7df83bd..db871db7c06f9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// Information about feature. internal partial class FeatureProperties { + /// + /// 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 FeatureProperties() { @@ -17,9 +52,11 @@ internal FeatureProperties() /// Initializes a new instance of . /// The registration state of the feature for the subscription. - internal FeatureProperties(string state) + /// Keeps track of any properties unknown to the library. + internal FeatureProperties(string state, IDictionary serializedAdditionalRawData) { State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The registration state of the feature for the subscription. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/GenericResourceData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/GenericResourceData.Serialization.cs index 4323d392c4349..1bb1345b63618 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/GenericResourceData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/GenericResourceData.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,10 +15,18 @@ namespace Azure.ResourceManager.Resources { - public partial class GenericResourceData : IUtf8JsonSerializable + public partial class GenericResourceData : 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(GenericResourceData)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Plan)) { @@ -56,6 +65,21 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("identity"u8); JsonSerializer.Serialize(writer, Identity); } + if (options.Format != "W" && Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdTime"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ChangedOn)) + { + writer.WritePropertyName("changedTime"u8); + writer.WriteStringValue(ChangedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } if (Optional.IsDefined(ExtendedLocation)) { writer.WritePropertyName("extendedLocation"u8); @@ -74,11 +98,60 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WritePropertyName("location"u8); writer.WriteStringValue(Location); + 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); + } + 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 GenericResourceData DeserializeGenericResourceData(JsonElement element) + GenericResourceData 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(GenericResourceData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGenericResourceData(document.RootElement, options); + } + + internal static GenericResourceData DeserializeGenericResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -99,6 +172,8 @@ internal static GenericResourceData DeserializeGenericResourceData(JsonElement e string name = default; ResourceType type = default; Optional systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("plan"u8)) @@ -222,8 +297,44 @@ internal static GenericResourceData DeserializeGenericResourceData(JsonElement e systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new GenericResourceData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, extendedLocation, serializedAdditionalRawData, plan, properties.Value, kind.Value, managedBy.Value, sku.Value, identity, Optional.ToNullable(createdTime), Optional.ToNullable(changedTime), provisioningState.Value); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GenericResourceData)} does not support '{options.Format}' format."); } - return new GenericResourceData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, extendedLocation, plan, properties.Value, kind.Value, managedBy.Value, sku.Value, identity, Optional.ToNullable(createdTime), Optional.ToNullable(changedTime), provisioningState.Value); } + + GenericResourceData 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 DeserializeGenericResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GenericResourceData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs index 41acf55b8b4f6..60a25141c3341 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs @@ -5,16 +5,106 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class LocationExpanded + public partial class LocationExpanded : IUtf8JsonSerializable, IJsonModel { - internal static LocationExpanded DeserializeLocationExpanded(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(LocationExpanded)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(LocationType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(LocationType.Value.ToSerialString()); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsDefined(RegionalDisplayName)) + { + writer.WritePropertyName("regionalDisplayName"u8); + writer.WriteStringValue(RegionalDisplayName); + } + if (Optional.IsDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteObjectValue(Metadata); + } + if (Optional.IsCollectionDefined(AvailabilityZoneMappings)) + { + writer.WritePropertyName("availabilityZoneMappings"u8); + writer.WriteStartArray(); + foreach (var item in AvailabilityZoneMappings) + { + 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(); + } + + LocationExpanded 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(LocationExpanded)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocationExpanded(document.RootElement, options); + } + + internal static LocationExpanded DeserializeLocationExpanded(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -27,6 +117,8 @@ internal static LocationExpanded DeserializeLocationExpanded(JsonElement element Optional regionalDisplayName = default; Optional metadata = default; Optional> availabilityZoneMappings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -86,8 +178,44 @@ internal static LocationExpanded DeserializeLocationExpanded(JsonElement element availabilityZoneMappings = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new LocationExpanded(id.Value, subscriptionId.Value, name.Value, Optional.ToNullable(type), displayName.Value, regionalDisplayName.Value, metadata.Value, Optional.ToList(availabilityZoneMappings)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new LocationExpanded(id.Value, subscriptionId.Value, name.Value, Optional.ToNullable(type), displayName.Value, regionalDisplayName.Value, metadata.Value, Optional.ToList(availabilityZoneMappings), 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(LocationExpanded)} does not support '{options.Format}' format."); + } + } + + LocationExpanded 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 DeserializeLocationExpanded(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocationExpanded)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.cs index ab35ad4c7bd29..fdd7572019c40 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,12 +14,67 @@ namespace Azure.ResourceManager.Resources.Models /// Location information. public partial class LocationExpanded { + /// + /// 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 LocationExpanded() { AvailabilityZoneMappings = new ChangeTrackingList(); } + /// Initializes a new instance of . + /// The fully qualified ID of the location. For example, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74/locations/westus. + /// The subscription ID. + /// The location name. + /// The location type. + /// The display name of the location. + /// The display name of the location and its region. + /// Metadata of the location, such as lat/long, paired region, and others. + /// The availability zone mappings for this region. + /// Keeps track of any properties unknown to the library. + internal LocationExpanded(string id, string subscriptionId, string name, LocationType? locationType, string displayName, string regionalDisplayName, LocationMetadata metadata, IReadOnlyList availabilityZoneMappings, IDictionary serializedAdditionalRawData) + { + Id = id; + SubscriptionId = subscriptionId; + Name = name; + LocationType = locationType; + DisplayName = displayName; + RegionalDisplayName = regionalDisplayName; + Metadata = metadata; + AvailabilityZoneMappings = availabilityZoneMappings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + /// The fully qualified ID of the location. For example, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74/locations/westus. public string Id { get; } /// The subscription ID. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs index a22c379b1d627..f2fbf972f676e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs @@ -5,21 +5,78 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - internal partial class LocationListResult + internal partial class LocationListResult : IUtf8JsonSerializable, IJsonModel { - internal static LocationListResult DeserializeLocationListResult(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(LocationListResult)} 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 (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(); + } + + LocationListResult 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(LocationListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocationListResult(document.RootElement, options); + } + + internal static LocationListResult DeserializeLocationListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional> value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -36,8 +93,44 @@ internal static LocationListResult DeserializeLocationListResult(JsonElement ele value = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new LocationListResult(Optional.ToList(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(LocationListResult)} does not support '{options.Format}' format."); + } + } + + LocationListResult 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 DeserializeLocationListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocationListResult)} does not support '{options.Format}' format."); } - return new LocationListResult(Optional.ToList(value)); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.cs index ba14136a955f2..9ffe3ce43ba34 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Location list operation response. internal partial class LocationListResult { + /// + /// 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 LocationListResult() { @@ -21,9 +54,11 @@ internal LocationListResult() /// Initializes a new instance of . /// An array of locations. - internal LocationListResult(IReadOnlyList value) + /// Keeps track of any properties unknown to the library. + internal LocationListResult(IReadOnlyList value, IDictionary serializedAdditionalRawData) { Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of locations. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs index 6f4342cc7435a..d846d4af28b58 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs @@ -5,16 +5,111 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class LocationMetadata + public partial class LocationMetadata : IUtf8JsonSerializable, IJsonModel { - internal static LocationMetadata DeserializeLocationMetadata(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(LocationMetadata)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(RegionType)) + { + writer.WritePropertyName("regionType"u8); + writer.WriteStringValue(RegionType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(RegionCategory)) + { + writer.WritePropertyName("regionCategory"u8); + writer.WriteStringValue(RegionCategory.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Geography)) + { + writer.WritePropertyName("geography"u8); + writer.WriteStringValue(Geography); + } + if (options.Format != "W" && Optional.IsDefined(GeographyGroup)) + { + writer.WritePropertyName("geographyGroup"u8); + writer.WriteStringValue(GeographyGroup); + } + if (options.Format != "W" && Optional.IsDefined(Longitude)) + { + writer.WritePropertyName("longitude"u8); + WriteLongitude(writer); + } + if (options.Format != "W" && Optional.IsDefined(Latitude)) + { + writer.WritePropertyName("latitude"u8); + WriteLatitude(writer); + } + if (options.Format != "W" && Optional.IsDefined(PhysicalLocation)) + { + writer.WritePropertyName("physicalLocation"u8); + writer.WriteStringValue(PhysicalLocation); + } + if (Optional.IsCollectionDefined(PairedRegions)) + { + writer.WritePropertyName("pairedRegion"u8); + writer.WriteStartArray(); + foreach (var item in PairedRegions) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(HomeLocation)) + { + writer.WritePropertyName("homeLocation"u8); + writer.WriteStringValue(HomeLocation); + } + 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(); + } + + LocationMetadata 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(LocationMetadata)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocationMetadata(document.RootElement, options); + } + + internal static LocationMetadata DeserializeLocationMetadata(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -28,6 +123,8 @@ internal static LocationMetadata DeserializeLocationMetadata(JsonElement element Optional physicalLocation = default; Optional> pairedRegion = default; Optional homeLocation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("regionType"u8)) @@ -92,8 +189,44 @@ internal static LocationMetadata DeserializeLocationMetadata(JsonElement element homeLocation = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new LocationMetadata(Optional.ToNullable(regionType), Optional.ToNullable(regionCategory), geography.Value, geographyGroup.Value, Optional.ToNullable(longitude), Optional.ToNullable(latitude), physicalLocation.Value, Optional.ToList(pairedRegion), homeLocation.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(LocationMetadata)} does not support '{options.Format}' format."); + } + } + + LocationMetadata 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 DeserializeLocationMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocationMetadata)} does not support '{options.Format}' format."); } - return new LocationMetadata(Optional.ToNullable(regionType), Optional.ToNullable(regionCategory), geography.Value, geographyGroup.Value, Optional.ToNullable(longitude), Optional.ToNullable(latitude), physicalLocation.Value, Optional.ToList(pairedRegion), homeLocation.Value); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.cs index a19a3bcac3a35..2c66175f6365e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Location metadata information. public partial class LocationMetadata { + /// + /// 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 LocationMetadata() { @@ -29,7 +62,8 @@ internal LocationMetadata() /// The physical location of the Azure location. /// The regions paired to this region. /// The home location of an edge zone. - internal LocationMetadata(RegionType? regionType, RegionCategory? regionCategory, string geography, string geographyGroup, double? longitude, double? latitude, string physicalLocation, IReadOnlyList pairedRegions, string homeLocation) + /// Keeps track of any properties unknown to the library. + internal LocationMetadata(RegionType? regionType, RegionCategory? regionCategory, string geography, string geographyGroup, double? longitude, double? latitude, string physicalLocation, IReadOnlyList pairedRegions, string homeLocation, IDictionary serializedAdditionalRawData) { RegionType = regionType; RegionCategory = regionCategory; @@ -40,6 +74,7 @@ internal LocationMetadata(RegionType? regionType, RegionCategory? regionCategory PhysicalLocation = physicalLocation; PairedRegions = pairedRegions; HomeLocation = homeLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The type of the region. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs index d69c63da61474..b1ffbe3ee5188 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs @@ -6,20 +6,72 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ManagedByTenant + public partial class ManagedByTenant : IUtf8JsonSerializable, IJsonModel { - internal static ManagedByTenant DeserializeManagedByTenant(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(ManagedByTenant)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.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(); + } + + ManagedByTenant 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(ManagedByTenant)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedByTenant(document.RootElement, options); + } + + internal static ManagedByTenant DeserializeManagedByTenant(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional tenantId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tenantId"u8)) @@ -31,8 +83,44 @@ internal static ManagedByTenant DeserializeManagedByTenant(JsonElement element) tenantId = property.Value.GetGuid(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagedByTenant(Optional.ToNullable(tenantId), 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(ManagedByTenant)} does not support '{options.Format}' format."); } - return new ManagedByTenant(Optional.ToNullable(tenantId)); } + + ManagedByTenant 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 DeserializeManagedByTenant(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedByTenant)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.cs index cae83f635509f..6883e58674a0f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.ResourceManager.Resources.Models { /// Information about a tenant managing the subscription. public partial class ManagedByTenant { + /// + /// 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 ManagedByTenant() { @@ -19,9 +52,11 @@ internal ManagedByTenant() /// Initializes a new instance of . /// The tenant ID of the managing tenant. This is a GUID. - internal ManagedByTenant(Guid? tenantId) + /// Keeps track of any properties unknown to the library. + internal ManagedByTenant(Guid? tenantId, IDictionary serializedAdditionalRawData) { TenantId = tenantId; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The tenant ID of the managing tenant. This is a GUID. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockData.Serialization.cs index b2fa6af614756..7c1b9d2dc9cea 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockData.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; @@ -13,11 +15,39 @@ namespace Azure.ResourceManager.Resources { - public partial class ManagementLockData : IUtf8JsonSerializable + public partial class ManagementLockData : 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(ManagementLockData)} does not support '{format}' format."); + } + writer.WriteStartObject(); + 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(); writer.WritePropertyName("level"u8); @@ -38,11 +68,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndArray(); } 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 ManagementLockData DeserializeManagementLockData(JsonElement element) + ManagementLockData 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(ManagementLockData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementLockData(document.RootElement, options); + } + + internal static ManagementLockData DeserializeManagementLockData(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -54,6 +113,8 @@ internal static ManagementLockData DeserializeManagementLockData(JsonElement ele ManagementLockLevel level = default; Optional notes = default; Optional> owners = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -116,8 +177,44 @@ internal static ManagementLockData DeserializeManagementLockData(JsonElement ele } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ManagementLockData(id, name, type, systemData.Value, level, notes.Value, Optional.ToList(owners)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementLockData(id, name, type, systemData.Value, level, notes.Value, Optional.ToList(owners), 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(ManagementLockData)} does not support '{options.Format}' format."); + } + } + + ManagementLockData 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 DeserializeManagementLockData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementLockData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs index 17660d41cee68..715da56d10fd3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.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.Resources.Models { - internal partial class ManagementLockListResult + internal partial class ManagementLockListResult : IUtf8JsonSerializable, IJsonModel { - internal static ManagementLockListResult DeserializeManagementLockListResult(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(ManagementLockListResult)} 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(); + } + + ManagementLockListResult 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(ManagementLockListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementLockListResult(document.RootElement, options); + } + + internal static ManagementLockListResult DeserializeManagementLockListResult(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 ManagementLockListResult DeserializeManagementLockListResult(Jso nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ManagementLockListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementLockListResult(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(ManagementLockListResult)} does not support '{options.Format}' format."); + } + } + + ManagementLockListResult 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 DeserializeManagementLockListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementLockListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.cs index 431b16a96d791..af691ff249647 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// The list of locks. internal partial class ManagementLockListResult { + /// + /// 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 ManagementLockListResult() { @@ -23,10 +56,12 @@ internal ManagementLockListResult() /// Initializes a new instance of . /// The list of locks. /// The URL to use for getting the next set of results. - internal ManagementLockListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal ManagementLockListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The list of locks. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs index eb654b67a84aa..14b60ad83041d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.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.Resources.Models { - public partial class ManagementLockOwner : IUtf8JsonSerializable + public partial class ManagementLockOwner : 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(ManagementLockOwner)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(ApplicationId)) { writer.WritePropertyName("applicationId"u8); writer.WriteStringValue(ApplicationId); } + 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 ManagementLockOwner DeserializeManagementLockOwner(JsonElement element) + ManagementLockOwner 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(ManagementLockOwner)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementLockOwner(document.RootElement, options); + } + + internal static ManagementLockOwner DeserializeManagementLockOwner(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional applicationId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("applicationId"u8)) @@ -37,8 +79,44 @@ internal static ManagementLockOwner DeserializeManagementLockOwner(JsonElement e applicationId = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ManagementLockOwner(applicationId.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(ManagementLockOwner)} does not support '{options.Format}' format."); } - return new ManagementLockOwner(applicationId.Value); } + + ManagementLockOwner 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 DeserializeManagementLockOwner(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementLockOwner)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.cs index 07a739bfe9f9e..9a31cf12f7b57 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// Lock owner properties. public partial class ManagementLockOwner { + /// + /// 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 ManagementLockOwner() { @@ -17,9 +52,11 @@ public ManagementLockOwner() /// Initializes a new instance of . /// The application ID of the lock owner. - internal ManagementLockOwner(string applicationId) + /// Keeps track of any properties unknown to the library. + internal ManagementLockOwner(string applicationId, IDictionary serializedAdditionalRawData) { ApplicationId = applicationId; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The application ID of the lock owner. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs index f49037a0f56d6..8cb631c30a3cd 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.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.Resources.Models { - public partial class NonComplianceMessage : IUtf8JsonSerializable + public partial class NonComplianceMessage : 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(NonComplianceMessage)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("message"u8); writer.WriteStringValue(Message); @@ -22,17 +33,48 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("policyDefinitionReferenceId"u8); writer.WriteStringValue(PolicyDefinitionReferenceId); } + 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 NonComplianceMessage DeserializeNonComplianceMessage(JsonElement element) + NonComplianceMessage 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(NonComplianceMessage)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNonComplianceMessage(document.RootElement, options); + } + + internal static NonComplianceMessage DeserializeNonComplianceMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } string message = default; Optional policyDefinitionReferenceId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("message"u8)) @@ -45,8 +87,44 @@ internal static NonComplianceMessage DeserializeNonComplianceMessage(JsonElement policyDefinitionReferenceId = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new NonComplianceMessage(message, policyDefinitionReferenceId.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(NonComplianceMessage)} does not support '{options.Format}' format."); } - return new NonComplianceMessage(message, policyDefinitionReferenceId.Value); } + + NonComplianceMessage 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 DeserializeNonComplianceMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NonComplianceMessage)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.cs index 0ed56fbf83ff1..335409e68050d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.ResourceManager.Resources.Models @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. public partial class NonComplianceMessage { + /// + /// 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 . /// A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. /// is null. @@ -26,10 +59,17 @@ public NonComplianceMessage(string message) /// Initializes a new instance of . /// A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. /// The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment. - internal NonComplianceMessage(string message, string policyDefinitionReferenceId) + /// Keeps track of any properties unknown to the library. + internal NonComplianceMessage(string message, string policyDefinitionReferenceId, IDictionary serializedAdditionalRawData) { Message = message; PolicyDefinitionReferenceId = policyDefinitionReferenceId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NonComplianceMessage() + { } /// A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs index 75d8f35ad7703..6018c0ea0a719 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.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.Resources.Models { - public partial class PairedRegion + public partial class PairedRegion : IUtf8JsonSerializable, IJsonModel { - internal static PairedRegion DeserializePairedRegion(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(PairedRegion)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + 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(); + } + + PairedRegion 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(PairedRegion)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePairedRegion(document.RootElement, options); + } + + internal static PairedRegion DeserializePairedRegion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +82,8 @@ internal static PairedRegion DeserializePairedRegion(JsonElement element) Optional name = default; Optional id = default; Optional subscriptionId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -38,8 +101,44 @@ internal static PairedRegion DeserializePairedRegion(JsonElement element) subscriptionId = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PairedRegion(name.Value, id.Value, subscriptionId.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PairedRegion(name.Value, id.Value, subscriptionId.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(PairedRegion)} does not support '{options.Format}' format."); + } + } + + PairedRegion 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 DeserializePairedRegion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PairedRegion)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.cs index b9f1e7efdc957..99a4d4e034a65 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// Information regarding paired region. public partial class PairedRegion { + /// + /// 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 PairedRegion() { @@ -19,11 +54,13 @@ internal PairedRegion() /// The name of the paired region. /// The fully qualified ID of the location. For example, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74/locations/westus. /// The subscription ID. - internal PairedRegion(string name, string id, string subscriptionId) + /// Keeps track of any properties unknown to the library. + internal PairedRegion(string name, string id, string subscriptionId, IDictionary serializedAdditionalRawData) { Name = name; Id = id; SubscriptionId = subscriptionId; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The name of the paired region. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs index 059d7a558ed40..22cd5ed0fc721 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.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.Resources.Models { - public partial class ParameterDefinitionsValueMetadata : IUtf8JsonSerializable + public partial class ParameterDefinitionsValueMetadata : 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(ParameterDefinitionsValueMetadata)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(DisplayName)) { @@ -52,8 +61,22 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static ParameterDefinitionsValueMetadata DeserializeParameterDefinitionsValueMetadata(JsonElement element) + ParameterDefinitionsValueMetadata 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(ParameterDefinitionsValueMetadata)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeParameterDefinitionsValueMetadata(document.RootElement, options); + } + + internal static ParameterDefinitionsValueMetadata DeserializeParameterDefinitionsValueMetadata(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -95,5 +118,36 @@ internal static ParameterDefinitionsValueMetadata DeserializeParameterDefinition additionalProperties = additionalPropertiesDictionary; return new ParameterDefinitionsValueMetadata(displayName.Value, description.Value, strongType.Value, Optional.ToNullable(assignPermissions), additionalProperties); } + + 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(ParameterDefinitionsValueMetadata)} does not support '{options.Format}' format."); + } + } + + ParameterDefinitionsValueMetadata 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 DeserializeParameterDefinitionsValueMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ParameterDefinitionsValueMetadata)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs index 9b68acc19a437..2a15618a7860c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs @@ -5,16 +5,101 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class Permission + public partial class Permission : IUtf8JsonSerializable, IJsonModel { - internal static Permission DeserializePermission(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(Permission)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(AllowedActions)) + { + writer.WritePropertyName("actions"u8); + writer.WriteStartArray(); + foreach (var item in AllowedActions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DeniedActions)) + { + writer.WritePropertyName("notActions"u8); + writer.WriteStartArray(); + foreach (var item in DeniedActions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AllowedDataActions)) + { + writer.WritePropertyName("dataActions"u8); + writer.WriteStartArray(); + foreach (var item in AllowedDataActions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DeniedDataActions)) + { + writer.WritePropertyName("notDataActions"u8); + writer.WriteStartArray(); + foreach (var item in DeniedDataActions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Permission 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(Permission)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePermission(document.RootElement, options); + } + + internal static Permission DeserializePermission(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +108,8 @@ internal static Permission DeserializePermission(JsonElement element) Optional> notActions = default; Optional> dataActions = default; Optional> notDataActions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("actions"u8)) @@ -81,8 +168,44 @@ internal static Permission DeserializePermission(JsonElement element) notDataActions = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new Permission(Optional.ToList(actions), Optional.ToList(notActions), Optional.ToList(dataActions), Optional.ToList(notDataActions), 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(Permission)} does not support '{options.Format}' format."); } - return new Permission(Optional.ToList(actions), Optional.ToList(notActions), Optional.ToList(dataActions), Optional.ToList(notDataActions)); } + + Permission 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 DeserializePermission(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Permission)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.cs index c64d3be8adc23..134dd3b95d28f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Role definition permissions. public partial class Permission { + /// + /// 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 Permission() { @@ -27,12 +60,14 @@ internal Permission() /// Denied actions. /// Allowed Data actions. /// Denied Data actions. - internal Permission(IReadOnlyList allowedActions, IReadOnlyList deniedActions, IReadOnlyList allowedDataActions, IReadOnlyList deniedDataActions) + /// Keeps track of any properties unknown to the library. + internal Permission(IReadOnlyList allowedActions, IReadOnlyList deniedActions, IReadOnlyList allowedDataActions, IReadOnlyList deniedDataActions, IDictionary serializedAdditionalRawData) { AllowedActions = allowedActions; DeniedActions = deniedActions; AllowedDataActions = allowedDataActions; DeniedDataActions = deniedDataActions; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Allowed actions. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentData.Serialization.cs index 379556b1a0d31..97449f736f70c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentData.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,10 +15,18 @@ namespace Azure.ResourceManager.Resources { - public partial class PolicyAssignmentData : IUtf8JsonSerializable + public partial class PolicyAssignmentData : 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(PolicyAssignmentData)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Location)) { @@ -29,6 +38,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("identity"u8); JsonSerializer.Serialize(writer, ManagedIdentity); } + 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)) @@ -41,6 +70,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("policyDefinitionId"u8); writer.WriteStringValue(PolicyDefinitionId); } + if (options.Format != "W" && Optional.IsDefined(Scope)) + { + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + } if (Optional.IsCollectionDefined(ExcludedScopes)) { writer.WritePropertyName("notScopes"u8); @@ -115,11 +149,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndArray(); } 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 PolicyAssignmentData DeserializePolicyAssignmentData(JsonElement element) + PolicyAssignmentData 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(PolicyAssignmentData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyAssignmentData(document.RootElement, options); + } + + internal static PolicyAssignmentData DeserializePolicyAssignmentData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -141,6 +204,8 @@ internal static PolicyAssignmentData DeserializePolicyAssignmentData(JsonElement Optional> nonComplianceMessages = default; Optional> resourceSelectors = default; Optional> overrides = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("location"u8)) @@ -305,8 +370,44 @@ internal static PolicyAssignmentData DeserializePolicyAssignmentData(JsonElement } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicyAssignmentData(id, name, type, systemData.Value, Optional.ToNullable(location), identity, displayName.Value, policyDefinitionId.Value, scope.Value, Optional.ToList(notScopes), Optional.ToDictionary(parameters), description.Value, metadata.Value, Optional.ToNullable(enforcementMode), Optional.ToList(nonComplianceMessages), Optional.ToList(resourceSelectors), Optional.ToList(overrides), 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(PolicyAssignmentData)} does not support '{options.Format}' format."); + } + } + + PolicyAssignmentData 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 DeserializePolicyAssignmentData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyAssignmentData)} does not support '{options.Format}' format."); } - return new PolicyAssignmentData(id, name, type, systemData.Value, Optional.ToNullable(location), identity, displayName.Value, policyDefinitionId.Value, scope.Value, Optional.ToList(notScopes), Optional.ToDictionary(parameters), description.Value, metadata.Value, Optional.ToNullable(enforcementMode), Optional.ToList(nonComplianceMessages), Optional.ToList(resourceSelectors), Optional.ToList(overrides)); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs index 778a6871f82ca..308808f0b72ac 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.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.Resources.Models { - internal partial class PolicyAssignmentListResult + internal partial class PolicyAssignmentListResult : IUtf8JsonSerializable, IJsonModel { - internal static PolicyAssignmentListResult DeserializePolicyAssignmentListResult(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(PolicyAssignmentListResult)} 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(); + } + + PolicyAssignmentListResult 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(PolicyAssignmentListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyAssignmentListResult(document.RootElement, options); + } + + internal static PolicyAssignmentListResult DeserializePolicyAssignmentListResult(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 PolicyAssignmentListResult DeserializePolicyAssignmentListResult nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PolicyAssignmentListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicyAssignmentListResult(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(PolicyAssignmentListResult)} does not support '{options.Format}' format."); + } + } + + PolicyAssignmentListResult 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 DeserializePolicyAssignmentListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyAssignmentListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.cs index bbf00ca4c96c7..0d7a3e1426246 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of policy assignments. internal partial class PolicyAssignmentListResult { + /// + /// 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 PolicyAssignmentListResult() { @@ -23,10 +56,12 @@ internal PolicyAssignmentListResult() /// Initializes a new instance of . /// An array of policy assignments. /// The URL to use for getting the next set of results. - internal PolicyAssignmentListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal PolicyAssignmentListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of policy assignments. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.Serialization.cs index b4b2a2392c2fb..df1f971e42db9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.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.Models; namespace Azure.ResourceManager.Resources.Models { - public partial class PolicyAssignmentPatch : IUtf8JsonSerializable + public partial class PolicyAssignmentPatch : 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(PolicyAssignmentPatch)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Location)) { @@ -48,7 +60,148 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndArray(); } 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(); } + + PolicyAssignmentPatch 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(PolicyAssignmentPatch)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyAssignmentPatch(document.RootElement, options); + } + + internal static PolicyAssignmentPatch DeserializePolicyAssignmentPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional location = default; + Optional identity = default; + Optional> resourceSelectors = default; + Optional> overrides = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("resourceSelectors"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(ResourceSelector.DeserializeResourceSelector(item)); + } + resourceSelectors = array; + continue; + } + if (property0.NameEquals("overrides"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(PolicyOverride.DeserializePolicyOverride(item)); + } + overrides = array; + continue; + } + } + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicyAssignmentPatch(Optional.ToNullable(location), identity, Optional.ToList(resourceSelectors), Optional.ToList(overrides), 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(PolicyAssignmentPatch)} does not support '{options.Format}' format."); + } + } + + PolicyAssignmentPatch 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 DeserializePolicyAssignmentPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyAssignmentPatch)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.cs index 93e78846f1dc6..b7bc4138a651d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentPatch.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// The policy assignment for Patch request. public partial class PolicyAssignmentPatch { + /// + /// 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 PolicyAssignmentPatch() { @@ -26,12 +59,14 @@ public PolicyAssignmentPatch() /// The managed identity associated with the policy assignment. Current supported identity types: None, SystemAssigned, UserAssigned. /// The resource selector list to filter policies by resource properties. /// The policy property value override. - internal PolicyAssignmentPatch(AzureLocation? location, ManagedServiceIdentity identity, IList resourceSelectors, IList overrides) + /// Keeps track of any properties unknown to the library. + internal PolicyAssignmentPatch(AzureLocation? location, ManagedServiceIdentity identity, IList resourceSelectors, IList overrides, IDictionary serializedAdditionalRawData) { Location = location; Identity = identity; ResourceSelectors = resourceSelectors; Overrides = overrides; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The location of the policy assignment. Only required when utilizing managed identity. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionData.Serialization.cs index 1870250150fc6..37770c5898b99 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionData.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,11 +15,39 @@ namespace Azure.ResourceManager.Resources { - public partial class PolicyDefinitionData : IUtf8JsonSerializable + public partial class PolicyDefinitionData : 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(PolicyDefinitionData)} does not support '{format}' format."); + } + writer.WriteStartObject(); + 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(PolicyType)) @@ -77,11 +106,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } 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 PolicyDefinitionData DeserializePolicyDefinitionData(JsonElement element) + PolicyDefinitionData 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(PolicyDefinitionData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyDefinitionData(document.RootElement, options); + } + + internal static PolicyDefinitionData DeserializePolicyDefinitionData(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -97,6 +155,8 @@ internal static PolicyDefinitionData DeserializePolicyDefinitionData(JsonElement Optional policyRule = default; Optional metadata = default; Optional> parameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -191,8 +251,44 @@ internal static PolicyDefinitionData DeserializePolicyDefinitionData(JsonElement } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PolicyDefinitionData(id, name, type, systemData.Value, Optional.ToNullable(policyType), mode.Value, displayName.Value, description.Value, policyRule.Value, metadata.Value, Optional.ToDictionary(parameters)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicyDefinitionData(id, name, type, systemData.Value, Optional.ToNullable(policyType), mode.Value, displayName.Value, description.Value, policyRule.Value, metadata.Value, Optional.ToDictionary(parameters), 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(PolicyDefinitionData)} does not support '{options.Format}' format."); + } + } + + PolicyDefinitionData 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 DeserializePolicyDefinitionData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyDefinitionData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs index 32f288d8bba44..2ef2ab4cda48c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.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.Resources.Models { - public partial class PolicyDefinitionGroup : IUtf8JsonSerializable + public partial class PolicyDefinitionGroup : 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(PolicyDefinitionGroup)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); @@ -37,11 +48,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("additionalMetadataId"u8); writer.WriteStringValue(AdditionalMetadataId); } + 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 PolicyDefinitionGroup DeserializePolicyDefinitionGroup(JsonElement element) + PolicyDefinitionGroup 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(PolicyDefinitionGroup)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyDefinitionGroup(document.RootElement, options); + } + + internal static PolicyDefinitionGroup DeserializePolicyDefinitionGroup(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -51,6 +91,8 @@ internal static PolicyDefinitionGroup DeserializePolicyDefinitionGroup(JsonEleme Optional category = default; Optional description = default; Optional additionalMetadataId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -78,8 +120,44 @@ internal static PolicyDefinitionGroup DeserializePolicyDefinitionGroup(JsonEleme additionalMetadataId = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicyDefinitionGroup(name, displayName.Value, category.Value, description.Value, additionalMetadataId.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(PolicyDefinitionGroup)} does not support '{options.Format}' format."); } - return new PolicyDefinitionGroup(name, displayName.Value, category.Value, description.Value, additionalMetadataId.Value); } + + PolicyDefinitionGroup 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 DeserializePolicyDefinitionGroup(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyDefinitionGroup)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.cs index 2e6d2dd6c1df2..63963cf8a5566 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.ResourceManager.Resources.Models @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The policy definition group. public partial class PolicyDefinitionGroup { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// The name of the group. /// is null. @@ -29,13 +62,20 @@ public PolicyDefinitionGroup(string name) /// The group's category. /// The group's description. /// A resource ID of a resource that contains additional metadata about the group. - internal PolicyDefinitionGroup(string name, string displayName, string category, string description, string additionalMetadataId) + /// Keeps track of any properties unknown to the library. + internal PolicyDefinitionGroup(string name, string displayName, string category, string description, string additionalMetadataId, IDictionary serializedAdditionalRawData) { Name = name; DisplayName = displayName; Category = category; Description = description; AdditionalMetadataId = additionalMetadataId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PolicyDefinitionGroup() + { } /// The name of the group. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs index bee6bf76be0b5..c908485735da7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.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.Resources.Models { - internal partial class PolicyDefinitionListResult + internal partial class PolicyDefinitionListResult : IUtf8JsonSerializable, IJsonModel { - internal static PolicyDefinitionListResult DeserializePolicyDefinitionListResult(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(PolicyDefinitionListResult)} 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(); + } + + PolicyDefinitionListResult 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(PolicyDefinitionListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyDefinitionListResult(document.RootElement, options); + } + + internal static PolicyDefinitionListResult DeserializePolicyDefinitionListResult(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 PolicyDefinitionListResult DeserializePolicyDefinitionListResult nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PolicyDefinitionListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicyDefinitionListResult(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(PolicyDefinitionListResult)} does not support '{options.Format}' format."); + } + } + + PolicyDefinitionListResult 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 DeserializePolicyDefinitionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyDefinitionListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.cs index 29c0d36cad427..a1e348a9b0a75 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of policy definitions. internal partial class PolicyDefinitionListResult { + /// + /// 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 PolicyDefinitionListResult() { @@ -23,10 +56,12 @@ internal PolicyDefinitionListResult() /// Initializes a new instance of . /// An array of policy definitions. /// The URL to use for getting the next set of results. - internal PolicyDefinitionListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal PolicyDefinitionListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of policy definitions. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs index 4b7b9ac256c33..f339303e9c723 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs @@ -5,16 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class PolicyDefinitionReference : IUtf8JsonSerializable + public partial class PolicyDefinitionReference : 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(PolicyDefinitionReference)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("policyDefinitionId"u8); writer.WriteStringValue(PolicyDefinitionId); @@ -44,11 +54,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 PolicyDefinitionReference DeserializePolicyDefinitionReference(JsonElement element) + PolicyDefinitionReference 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(PolicyDefinitionReference)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyDefinitionReference(document.RootElement, options); + } + + internal static PolicyDefinitionReference DeserializePolicyDefinitionReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -57,6 +96,8 @@ internal static PolicyDefinitionReference DeserializePolicyDefinitionReference(J Optional> parameters = default; Optional policyDefinitionReferenceId = default; Optional> groupNames = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("policyDefinitionId"u8)) @@ -97,8 +138,44 @@ internal static PolicyDefinitionReference DeserializePolicyDefinitionReference(J groupNames = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PolicyDefinitionReference(policyDefinitionId, Optional.ToDictionary(parameters), policyDefinitionReferenceId.Value, Optional.ToList(groupNames)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicyDefinitionReference(policyDefinitionId, Optional.ToDictionary(parameters), policyDefinitionReferenceId.Value, Optional.ToList(groupNames), 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(PolicyDefinitionReference)} does not support '{options.Format}' format."); + } + } + + PolicyDefinitionReference 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 DeserializePolicyDefinitionReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyDefinitionReference)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.cs index 9f0c6587d1bb5..9557f190e234e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.cs @@ -14,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The policy definition reference. public partial class PolicyDefinitionReference { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// The ID of the policy definition or policy set definition. /// is null. @@ -31,12 +63,19 @@ public PolicyDefinitionReference(string policyDefinitionId) /// The parameter values for the referenced policy rule. The keys are the parameter names. /// A unique id (within the policy set definition) for this policy definition reference. /// The name of the groups that this policy definition reference belongs to. - internal PolicyDefinitionReference(string policyDefinitionId, IDictionary parameters, string policyDefinitionReferenceId, IList groupNames) + /// Keeps track of any properties unknown to the library. + internal PolicyDefinitionReference(string policyDefinitionId, IDictionary parameters, string policyDefinitionReferenceId, IList groupNames, IDictionary serializedAdditionalRawData) { PolicyDefinitionId = policyDefinitionId; Parameters = parameters; PolicyDefinitionReferenceId = policyDefinitionReferenceId; GroupNames = groupNames; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PolicyDefinitionReference() + { } /// The ID of the policy definition or policy set definition. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs index 4a1e20c3025e7..fe94122a02ac7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs @@ -5,16 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class PolicyOverride : IUtf8JsonSerializable + public partial class PolicyOverride : 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(PolicyOverride)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Kind)) { @@ -36,11 +46,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 PolicyOverride DeserializePolicyOverride(JsonElement element) + PolicyOverride 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(PolicyOverride)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyOverride(document.RootElement, options); + } + + internal static PolicyOverride DeserializePolicyOverride(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -48,6 +87,8 @@ internal static PolicyOverride DeserializePolicyOverride(JsonElement element) Optional kind = default; Optional value = default; Optional> selectors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("kind"u8)) @@ -78,8 +119,44 @@ internal static PolicyOverride DeserializePolicyOverride(JsonElement element) selectors = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PolicyOverride(Optional.ToNullable(kind), value.Value, Optional.ToList(selectors)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicyOverride(Optional.ToNullable(kind), value.Value, Optional.ToList(selectors), 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(PolicyOverride)} does not support '{options.Format}' format."); + } + } + + PolicyOverride 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 DeserializePolicyOverride(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyOverride)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.cs index 90861af6cb862..24c17c6224b39 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The policy property value override. public partial class PolicyOverride { + /// + /// 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 PolicyOverride() { @@ -23,11 +56,13 @@ public PolicyOverride() /// The override kind. /// The value to override the policy property. /// The list of the selector expressions. - internal PolicyOverride(PolicyOverrideKind? kind, string value, IList selectors) + /// Keeps track of any properties unknown to the library. + internal PolicyOverride(PolicyOverrideKind? kind, string value, IList selectors, IDictionary serializedAdditionalRawData) { Kind = kind; Value = value; Selectors = selectors; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The override kind. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionData.Serialization.cs index 2a2524415f896..57d9c39d68d4f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionData.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,11 +15,39 @@ namespace Azure.ResourceManager.Resources { - public partial class PolicySetDefinitionData : IUtf8JsonSerializable + public partial class PolicySetDefinitionData : 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(PolicySetDefinitionData)} does not support '{format}' format."); + } + writer.WriteStartObject(); + 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(PolicyType)) @@ -80,11 +109,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndArray(); } 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 PolicySetDefinitionData DeserializePolicySetDefinitionData(JsonElement element) + PolicySetDefinitionData 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(PolicySetDefinitionData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicySetDefinitionData(document.RootElement, options); + } + + internal static PolicySetDefinitionData DeserializePolicySetDefinitionData(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -100,6 +158,8 @@ internal static PolicySetDefinitionData DeserializePolicySetDefinitionData(JsonE Optional> parameters = default; Optional> policyDefinitions = default; Optional> policyDefinitionGroups = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -208,8 +268,44 @@ internal static PolicySetDefinitionData DeserializePolicySetDefinitionData(JsonE } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PolicySetDefinitionData(id, name, type, systemData.Value, Optional.ToNullable(policyType), displayName.Value, description.Value, metadata.Value, Optional.ToDictionary(parameters), Optional.ToList(policyDefinitions), Optional.ToList(policyDefinitionGroups)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicySetDefinitionData(id, name, type, systemData.Value, Optional.ToNullable(policyType), displayName.Value, description.Value, metadata.Value, Optional.ToDictionary(parameters), Optional.ToList(policyDefinitions), Optional.ToList(policyDefinitionGroups), 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(PolicySetDefinitionData)} does not support '{options.Format}' format."); + } + } + + PolicySetDefinitionData 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 DeserializePolicySetDefinitionData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicySetDefinitionData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs index 9138a5a3b5bc9..8805aac19371f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.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.Resources.Models { - internal partial class PolicySetDefinitionListResult + internal partial class PolicySetDefinitionListResult : IUtf8JsonSerializable, IJsonModel { - internal static PolicySetDefinitionListResult DeserializePolicySetDefinitionListResult(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(PolicySetDefinitionListResult)} 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(); + } + + PolicySetDefinitionListResult 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(PolicySetDefinitionListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicySetDefinitionListResult(document.RootElement, options); + } + + internal static PolicySetDefinitionListResult DeserializePolicySetDefinitionListResult(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 PolicySetDefinitionListResult DeserializePolicySetDefinitionList nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PolicySetDefinitionListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PolicySetDefinitionListResult(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(PolicySetDefinitionListResult)} does not support '{options.Format}' format."); + } + } + + PolicySetDefinitionListResult 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 DeserializePolicySetDefinitionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicySetDefinitionListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.cs index 8102dcc9e967d..d121fa2660fbb 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of policy set definitions. internal partial class PolicySetDefinitionListResult { + /// + /// 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 PolicySetDefinitionListResult() { @@ -23,10 +56,12 @@ internal PolicySetDefinitionListResult() /// Initializes a new instance of . /// An array of policy set definitions. /// The URL to use for getting the next set of results. - internal PolicySetDefinitionListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal PolicySetDefinitionListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of policy set definitions. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs index 26275a10c94c7..854b3c9c1fd16 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs @@ -5,16 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class PredefinedTag + public partial class PredefinedTag : IUtf8JsonSerializable, IJsonModel { - internal static PredefinedTag DeserializePredefinedTag(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(PredefinedTag)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(TagName)) + { + writer.WritePropertyName("tagName"u8); + writer.WriteStringValue(TagName); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteObjectValue(Count); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (var item in Values) + { + 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(); + } + + PredefinedTag 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(PredefinedTag)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePredefinedTag(document.RootElement, options); + } + + internal static PredefinedTag DeserializePredefinedTag(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +93,8 @@ internal static PredefinedTag DeserializePredefinedTag(JsonElement element) Optional tagName = default; Optional count = default; Optional> values = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -58,8 +130,44 @@ internal static PredefinedTag DeserializePredefinedTag(JsonElement element) values = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PredefinedTag(id.Value, tagName.Value, count.Value, Optional.ToList(values)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PredefinedTag(id.Value, tagName.Value, count.Value, Optional.ToList(values), 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(PredefinedTag)} does not support '{options.Format}' format."); + } + } + + PredefinedTag 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 DeserializePredefinedTag(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PredefinedTag)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.cs index 6c06eb0f648e4..b26eb4c850dbf 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Tag details. public partial class PredefinedTag { + /// + /// 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 PredefinedTag() { @@ -24,12 +57,14 @@ internal PredefinedTag() /// The tag name. /// The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. /// The list of tag values. - internal PredefinedTag(string id, string tagName, PredefinedTagCount count, IReadOnlyList values) + /// Keeps track of any properties unknown to the library. + internal PredefinedTag(string id, string tagName, PredefinedTagCount count, IReadOnlyList values, IDictionary serializedAdditionalRawData) { Id = id; TagName = tagName; Count = count; Values = values; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The tag name ID. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs index d5b0075a19f7e..18d00e56f56c3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.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.Resources.Models { - public partial class PredefinedTagCount + public partial class PredefinedTagCount : IUtf8JsonSerializable, IJsonModel { - internal static PredefinedTagCount DeserializePredefinedTagCount(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(PredefinedTagCount)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(PredefinedTagCountType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(PredefinedTagCountType); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + PredefinedTagCount 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(PredefinedTagCount)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePredefinedTagCount(document.RootElement, options); + } + + internal static PredefinedTagCount DeserializePredefinedTagCount(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional type = default; Optional value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -36,8 +94,44 @@ internal static PredefinedTagCount DeserializePredefinedTagCount(JsonElement ele value = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PredefinedTagCount(type.Value, Optional.ToNullable(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(PredefinedTagCount)} does not support '{options.Format}' format."); + } + } + + PredefinedTagCount 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 DeserializePredefinedTagCount(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PredefinedTagCount)} does not support '{options.Format}' format."); } - return new PredefinedTagCount(type.Value, Optional.ToNullable(value)); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.cs index ddd1f187f3368..599f19011bd56 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// Tag count. public partial class PredefinedTagCount { + /// + /// 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 PredefinedTagCount() { @@ -18,10 +53,12 @@ internal PredefinedTagCount() /// Initializes a new instance of . /// Type of count. /// Value of count. - internal PredefinedTagCount(string predefinedTagCountType, int? value) + /// Keeps track of any properties unknown to the library. + internal PredefinedTagCount(string predefinedTagCountType, int? value, IDictionary serializedAdditionalRawData) { PredefinedTagCountType = predefinedTagCountType; Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Type of count. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs index 05226823074d9..64f7413d170a9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.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.Resources.Models { - public partial class PredefinedTagValue + public partial class PredefinedTagValue : IUtf8JsonSerializable, IJsonModel { - internal static PredefinedTagValue DeserializePredefinedTagValue(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(PredefinedTagValue)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(TagValue)) + { + writer.WritePropertyName("tagValue"u8); + writer.WriteStringValue(TagValue); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteObjectValue(Count); + } + 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(); + } + + PredefinedTagValue 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(PredefinedTagValue)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePredefinedTagValue(document.RootElement, options); + } + + internal static PredefinedTagValue DeserializePredefinedTagValue(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +82,8 @@ internal static PredefinedTagValue DeserializePredefinedTagValue(JsonElement ele Optional id = default; Optional tagValue = default; Optional count = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -42,8 +105,44 @@ internal static PredefinedTagValue DeserializePredefinedTagValue(JsonElement ele count = PredefinedTagCount.DeserializePredefinedTagCount(property.Value); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PredefinedTagValue(id.Value, tagValue.Value, count.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PredefinedTagValue(id.Value, tagValue.Value, count.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(PredefinedTagValue)} does not support '{options.Format}' format."); + } + } + + PredefinedTagValue 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 DeserializePredefinedTagValue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PredefinedTagValue)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.cs index 60fb62a552bab..0885ec56a0ea9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// Tag information. public partial class PredefinedTagValue { + /// + /// 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 PredefinedTagValue() { @@ -19,11 +54,13 @@ internal PredefinedTagValue() /// The tag value ID. /// The tag value. /// The tag value count. - internal PredefinedTagValue(string id, string tagValue, PredefinedTagCount count) + /// Keeps track of any properties unknown to the library. + internal PredefinedTagValue(string id, string tagValue, PredefinedTagCount count, IDictionary serializedAdditionalRawData) { Id = id; TagValue = tagValue; Count = count; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The tag value ID. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs index 2ff80243b58f1..ea3d06fe4bda7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.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.Resources.Models { - internal partial class PredefinedTagsListResult + internal partial class PredefinedTagsListResult : IUtf8JsonSerializable, IJsonModel { - internal static PredefinedTagsListResult DeserializePredefinedTagsListResult(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(PredefinedTagsListResult)} 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 (options.Format != "W" && 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(); + } + + PredefinedTagsListResult 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(PredefinedTagsListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePredefinedTagsListResult(document.RootElement, options); + } + + internal static PredefinedTagsListResult DeserializePredefinedTagsListResult(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)) @@ -42,8 +104,44 @@ internal static PredefinedTagsListResult DeserializePredefinedTagsListResult(Jso nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new PredefinedTagsListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new PredefinedTagsListResult(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(PredefinedTagsListResult)} does not support '{options.Format}' format."); + } + } + + PredefinedTagsListResult 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 DeserializePredefinedTagsListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PredefinedTagsListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.cs index c9d25697b8868..1fdf4e307d2e2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of subscription tags. internal partial class PredefinedTagsListResult { + /// + /// 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 PredefinedTagsListResult() { @@ -22,10 +55,12 @@ internal PredefinedTagsListResult() /// Initializes a new instance of . /// An array of tags. /// The URL to use for getting the next set of results. - internal PredefinedTagsListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal PredefinedTagsListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of tags. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderConsentDefinition.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderConsentDefinition.Serialization.cs index f9d51fd72bfce..8449b25cda780 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderConsentDefinition.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderConsentDefinition.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.Resources.Models { - internal partial class ProviderConsentDefinition : IUtf8JsonSerializable + internal partial class ProviderConsentDefinition : 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(ProviderConsentDefinition)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(ConsentToAuthorization)) { writer.WritePropertyName("consentToAuthorization"u8); writer.WriteBooleanValue(ConsentToAuthorization.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(); } + + ProviderConsentDefinition 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(ProviderConsentDefinition)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProviderConsentDefinition(document.RootElement, options); + } + + internal static ProviderConsentDefinition DeserializeProviderConsentDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional consentToAuthorization = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("consentToAuthorization"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + consentToAuthorization = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ProviderConsentDefinition(Optional.ToNullable(consentToAuthorization), 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(ProviderConsentDefinition)} does not support '{options.Format}' format."); + } + } + + ProviderConsentDefinition 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 DeserializeProviderConsentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProviderConsentDefinition)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderConsentDefinition.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderConsentDefinition.cs index b7bd06915ae62..2dcade584b19a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderConsentDefinition.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderConsentDefinition.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// The provider consent. internal partial class ProviderConsentDefinition { + /// + /// 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 ProviderConsentDefinition() { @@ -17,9 +52,11 @@ public ProviderConsentDefinition() /// Initializes a new instance of . /// A value indicating whether authorization is consented or not. - internal ProviderConsentDefinition(bool? consentToAuthorization) + /// Keeps track of any properties unknown to the library. + internal ProviderConsentDefinition(bool? consentToAuthorization, IDictionary serializedAdditionalRawData) { ConsentToAuthorization = consentToAuthorization; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// A value indicating whether authorization is consented or not. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs index 237884c597579..d0416e8460f7b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs @@ -5,16 +5,81 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ProviderExtendedLocation + public partial class ProviderExtendedLocation : IUtf8JsonSerializable, IJsonModel { - internal static ProviderExtendedLocation DeserializeProviderExtendedLocation(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(ProviderExtendedLocation)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.Value); + } + if (Optional.IsDefined(ProviderExtendedLocationType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ProviderExtendedLocationType); + } + if (Optional.IsCollectionDefined(ExtendedLocations)) + { + writer.WritePropertyName("extendedLocations"u8); + writer.WriteStartArray(); + foreach (var item in ExtendedLocations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ProviderExtendedLocation 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(ProviderExtendedLocation)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProviderExtendedLocation(document.RootElement, options); + } + + internal static ProviderExtendedLocation DeserializeProviderExtendedLocation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,6 +87,8 @@ internal static ProviderExtendedLocation DeserializeProviderExtendedLocation(Jso Optional location = default; Optional type = default; Optional> extendedLocations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("location"u8)) @@ -52,8 +119,44 @@ internal static ProviderExtendedLocation DeserializeProviderExtendedLocation(Jso extendedLocations = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ProviderExtendedLocation(Optional.ToNullable(location), type.Value, Optional.ToList(extendedLocations), 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(ProviderExtendedLocation)} does not support '{options.Format}' format."); } - return new ProviderExtendedLocation(Optional.ToNullable(location), type.Value, Optional.ToList(extendedLocations)); } + + ProviderExtendedLocation 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 DeserializeProviderExtendedLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProviderExtendedLocation)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.cs index e4995e15b351d..23484c899eb7d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The provider extended location. public partial class ProviderExtendedLocation { + /// + /// 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 ProviderExtendedLocation() { @@ -23,11 +56,13 @@ internal ProviderExtendedLocation() /// The azure location. /// The extended location type. /// The extended locations for the azure location. - internal ProviderExtendedLocation(AzureLocation? location, string providerExtendedLocationType, IReadOnlyList extendedLocations) + /// Keeps track of any properties unknown to the library. + internal ProviderExtendedLocation(AzureLocation? location, string providerExtendedLocationType, IReadOnlyList extendedLocations, IDictionary serializedAdditionalRawData) { Location = location; ProviderExtendedLocationType = providerExtendedLocationType; ExtendedLocations = extendedLocations; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The azure location. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs index 6ce29040a292b..7ee280fba2d33 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.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.Resources.Models { - public partial class ProviderPermission + public partial class ProviderPermission : IUtf8JsonSerializable, IJsonModel { - internal static ProviderPermission DeserializeProviderPermission(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(ProviderPermission)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ApplicationId)) + { + writer.WritePropertyName("applicationId"u8); + writer.WriteStringValue(ApplicationId); + } + if (Optional.IsDefined(RoleDefinition)) + { + writer.WritePropertyName("roleDefinition"u8); + writer.WriteObjectValue(RoleDefinition); + } + if (Optional.IsDefined(ManagedByRoleDefinition)) + { + writer.WritePropertyName("managedByRoleDefinition"u8); + writer.WriteObjectValue(ManagedByRoleDefinition); + } + if (Optional.IsDefined(ProviderAuthorizationConsentState)) + { + writer.WritePropertyName("providerAuthorizationConsentState"u8); + writer.WriteStringValue(ProviderAuthorizationConsentState.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(); + } + + ProviderPermission 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(ProviderPermission)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProviderPermission(document.RootElement, options); + } + + internal static ProviderPermission DeserializeProviderPermission(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,6 +88,8 @@ internal static ProviderPermission DeserializeProviderPermission(JsonElement ele Optional roleDefinition = default; Optional managedByRoleDefinition = default; Optional providerAuthorizationConsentState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("applicationId"u8)) @@ -56,8 +124,44 @@ internal static ProviderPermission DeserializeProviderPermission(JsonElement ele providerAuthorizationConsentState = new ProviderAuthorizationConsentState(property.Value.GetString()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ProviderPermission(applicationId.Value, roleDefinition.Value, managedByRoleDefinition.Value, Optional.ToNullable(providerAuthorizationConsentState), 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(ProviderPermission)} does not support '{options.Format}' format."); } - return new ProviderPermission(applicationId.Value, roleDefinition.Value, managedByRoleDefinition.Value, Optional.ToNullable(providerAuthorizationConsentState)); } + + ProviderPermission 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 DeserializeProviderPermission(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProviderPermission)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.cs index 61425dea8532b..eba5754f340f5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// The provider permission. public partial class ProviderPermission { + /// + /// 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 ProviderPermission() { @@ -20,12 +55,14 @@ internal ProviderPermission() /// Role definition properties. /// Role definition properties. /// The provider authorization consent state. - internal ProviderPermission(string applicationId, AzureRoleDefinition roleDefinition, AzureRoleDefinition managedByRoleDefinition, ProviderAuthorizationConsentState? providerAuthorizationConsentState) + /// Keeps track of any properties unknown to the library. + internal ProviderPermission(string applicationId, AzureRoleDefinition roleDefinition, AzureRoleDefinition managedByRoleDefinition, ProviderAuthorizationConsentState? providerAuthorizationConsentState, IDictionary serializedAdditionalRawData) { ApplicationId = applicationId; RoleDefinition = roleDefinition; ManagedByRoleDefinition = managedByRoleDefinition; ProviderAuthorizationConsentState = providerAuthorizationConsentState; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The application id. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs index 81b727f123f64..5ec6e30b14ef6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.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.Resources.Models { - internal partial class ProviderPermissionListResult + internal partial class ProviderPermissionListResult : IUtf8JsonSerializable, IJsonModel { - internal static ProviderPermissionListResult DeserializeProviderPermissionListResult(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(ProviderPermissionListResult)} 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 (options.Format != "W" && 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(); + } + + ProviderPermissionListResult 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(ProviderPermissionListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProviderPermissionListResult(document.RootElement, options); + } + + internal static ProviderPermissionListResult DeserializeProviderPermissionListResult(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)) @@ -42,8 +104,44 @@ internal static ProviderPermissionListResult DeserializeProviderPermissionListRe nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ProviderPermissionListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ProviderPermissionListResult(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(ProviderPermissionListResult)} does not support '{options.Format}' format."); + } + } + + ProviderPermissionListResult 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 DeserializeProviderPermissionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProviderPermissionListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.cs index c7a8c4eede638..31299162603c8 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of provider permissions. internal partial class ProviderPermissionListResult { + /// + /// 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 ProviderPermissionListResult() { @@ -22,10 +55,12 @@ internal ProviderPermissionListResult() /// Initializes a new instance of . /// An array of provider permissions. /// The URL to use for getting the next set of results. - internal ProviderPermissionListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal ProviderPermissionListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of provider permissions. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.Serialization.cs index 757c3f02c5f9b..52c26f0f03b71 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.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.Resources.Models { - public partial class ProviderRegistrationContent : IUtf8JsonSerializable + public partial class ProviderRegistrationContent : 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(ProviderRegistrationContent)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(ThirdPartyProviderConsent)) { writer.WritePropertyName("thirdPartyProviderConsent"u8); writer.WriteObjectValue(ThirdPartyProviderConsent); } + 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(); } + + ProviderRegistrationContent 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(ProviderRegistrationContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProviderRegistrationContent(document.RootElement, options); + } + + internal static ProviderRegistrationContent DeserializeProviderRegistrationContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional thirdPartyProviderConsent = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("thirdPartyProviderConsent"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + thirdPartyProviderConsent = ProviderConsentDefinition.DeserializeProviderConsentDefinition(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ProviderRegistrationContent(thirdPartyProviderConsent.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(ProviderRegistrationContent)} does not support '{options.Format}' format."); + } + } + + ProviderRegistrationContent 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 DeserializeProviderRegistrationContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProviderRegistrationContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.cs index 962c9eed3dfbe..77e84f6e41e3e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderRegistrationContent.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// The provider registration definition. public partial class ProviderRegistrationContent { + /// + /// 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 ProviderRegistrationContent() { @@ -17,9 +52,11 @@ public ProviderRegistrationContent() /// Initializes a new instance of . /// The provider consent. - internal ProviderRegistrationContent(ProviderConsentDefinition thirdPartyProviderConsent) + /// Keeps track of any properties unknown to the library. + internal ProviderRegistrationContent(ProviderConsentDefinition thirdPartyProviderConsent, IDictionary serializedAdditionalRawData) { ThirdPartyProviderConsent = thirdPartyProviderConsent; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The provider consent. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs index 5b8b3af3aacac..777b4b7e085f6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs @@ -5,16 +5,147 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ProviderResourceType + public partial class ProviderResourceType : IUtf8JsonSerializable, IJsonModel { - internal static ProviderResourceType DeserializeProviderResourceType(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(ProviderResourceType)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ResourceType)) + { + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + } + if (Optional.IsCollectionDefined(Locations)) + { + writer.WritePropertyName("locations"u8); + writer.WriteStartArray(); + foreach (var item in Locations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(LocationMappings)) + { + writer.WritePropertyName("locationMappings"u8); + writer.WriteStartArray(); + foreach (var item in LocationMappings) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Aliases)) + { + writer.WritePropertyName("aliases"u8); + writer.WriteStartArray(); + foreach (var item in Aliases) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ApiVersions)) + { + writer.WritePropertyName("apiVersions"u8); + writer.WriteStartArray(); + foreach (var item in ApiVersions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(DefaultApiVersion)) + { + writer.WritePropertyName("defaultApiVersion"u8); + writer.WriteStringValue(DefaultApiVersion); + } + if (Optional.IsCollectionDefined(ZoneMappings)) + { + writer.WritePropertyName("zoneMappings"u8); + writer.WriteStartArray(); + foreach (var item in ZoneMappings) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ApiProfiles)) + { + writer.WritePropertyName("apiProfiles"u8); + writer.WriteStartArray(); + foreach (var item in ApiProfiles) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Capabilities)) + { + writer.WritePropertyName("capabilities"u8); + writer.WriteStringValue(Capabilities); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ProviderResourceType 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(ProviderResourceType)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProviderResourceType(document.RootElement, options); + } + + internal static ProviderResourceType DeserializeProviderResourceType(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -29,6 +160,8 @@ internal static ProviderResourceType DeserializeProviderResourceType(JsonElement Optional> apiProfiles = default; Optional capabilities = default; Optional> properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("resourceType"u8)) @@ -144,8 +277,44 @@ internal static ProviderResourceType DeserializeProviderResourceType(JsonElement properties = dictionary; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ProviderResourceType(resourceType.Value, Optional.ToList(locations), Optional.ToList(locationMappings), Optional.ToList(aliases), Optional.ToList(apiVersions), defaultApiVersion.Value, Optional.ToList(zoneMappings), Optional.ToList(apiProfiles), capabilities.Value, Optional.ToDictionary(properties)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ProviderResourceType(resourceType.Value, Optional.ToList(locations), Optional.ToList(locationMappings), Optional.ToList(aliases), Optional.ToList(apiVersions), defaultApiVersion.Value, Optional.ToList(zoneMappings), Optional.ToList(apiProfiles), capabilities.Value, Optional.ToDictionary(properties), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ProviderResourceType)} does not support '{options.Format}' format."); + } + } + + ProviderResourceType 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 DeserializeProviderResourceType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProviderResourceType)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.cs index db5adb02748c6..97f3681188480 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Resource type managed by the resource provider. public partial class ProviderResourceType { + /// + /// 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 ProviderResourceType() { @@ -36,7 +69,8 @@ internal ProviderResourceType() /// The API profiles for the resource provider. /// The additional capabilities offered by this resource type. /// The properties. - internal ProviderResourceType(string resourceType, IReadOnlyList locations, IReadOnlyList locationMappings, IReadOnlyList aliases, IReadOnlyList apiVersions, string defaultApiVersion, IReadOnlyList zoneMappings, IReadOnlyList apiProfiles, string capabilities, IReadOnlyDictionary properties) + /// Keeps track of any properties unknown to the library. + internal ProviderResourceType(string resourceType, IReadOnlyList locations, IReadOnlyList locationMappings, IReadOnlyList aliases, IReadOnlyList apiVersions, string defaultApiVersion, IReadOnlyList zoneMappings, IReadOnlyList apiProfiles, string capabilities, IReadOnlyDictionary properties, IDictionary serializedAdditionalRawData) { ResourceType = resourceType; Locations = locations; @@ -48,6 +82,7 @@ internal ProviderResourceType(string resourceType, IReadOnlyList locatio ApiProfiles = apiProfiles; Capabilities = capabilities; Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The resource type. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs index 26fb7c85bbf5c..ee43a6a5f7a4d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.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.Resources.Models { - internal partial class ProviderResourceTypeListResult + internal partial class ProviderResourceTypeListResult : IUtf8JsonSerializable, IJsonModel { - internal static ProviderResourceTypeListResult DeserializeProviderResourceTypeListResult(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(ProviderResourceTypeListResult)} 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 (options.Format != "W" && 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(); + } + + ProviderResourceTypeListResult 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(ProviderResourceTypeListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProviderResourceTypeListResult(document.RootElement, options); + } + + internal static ProviderResourceTypeListResult DeserializeProviderResourceTypeListResult(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)) @@ -42,8 +104,44 @@ internal static ProviderResourceTypeListResult DeserializeProviderResourceTypeLi nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ProviderResourceTypeListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ProviderResourceTypeListResult(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(ProviderResourceTypeListResult)} does not support '{options.Format}' format."); + } + } + + ProviderResourceTypeListResult 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 DeserializeProviderResourceTypeListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProviderResourceTypeListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.cs index 2526edbd80144..b8785d0c8d914 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of resource types of a resource provider. internal partial class ProviderResourceTypeListResult { + /// + /// 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 ProviderResourceTypeListResult() { @@ -22,10 +55,12 @@ internal ProviderResourceTypeListResult() /// Initializes a new instance of . /// An array of resource types. /// The URL to use for getting the next set of results. - internal ProviderResourceTypeListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal ProviderResourceTypeListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of resource types. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupData.Serialization.cs index 722f0d775caa9..4780d95fa2f1f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupData.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; @@ -13,10 +15,18 @@ namespace Azure.ResourceManager.Resources { - public partial class ResourceGroupData : IUtf8JsonSerializable + public partial class ResourceGroupData : 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(ResourceGroupData)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Properties)) { @@ -41,11 +51,60 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WritePropertyName("location"u8); writer.WriteStringValue(Location); + 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); + } + 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 ResourceGroupData DeserializeResourceGroupData(JsonElement element) + ResourceGroupData 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(ResourceGroupData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceGroupData(document.RootElement, options); + } + + internal static ResourceGroupData DeserializeResourceGroupData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -58,6 +117,8 @@ internal static ResourceGroupData DeserializeResourceGroupData(JsonElement eleme string name = default; ResourceType type = default; Optional systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("properties"u8)) @@ -117,8 +178,44 @@ internal static ResourceGroupData DeserializeResourceGroupData(JsonElement eleme systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceGroupData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, properties.Value, managedBy.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceGroupData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, properties.Value, managedBy.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(ResourceGroupData)} does not support '{options.Format}' format."); + } + } + + ResourceGroupData 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 DeserializeResourceGroupData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceGroupData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs index c926112a5f1b2..c46e34eca3b88 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs @@ -6,22 +6,86 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ResourceGroupExportResult + public partial class ResourceGroupExportResult : IUtf8JsonSerializable, IJsonModel { - internal static ResourceGroupExportResult DeserializeResourceGroupExportResult(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(ResourceGroupExportResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Template)) + { + writer.WritePropertyName("template"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Template); +#else + using (JsonDocument document = JsonDocument.Parse(Template)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + JsonSerializer.Serialize(writer, Error); + } + 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(); + } + + ResourceGroupExportResult 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(ResourceGroupExportResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceGroupExportResult(document.RootElement, options); + } + + internal static ResourceGroupExportResult DeserializeResourceGroupExportResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional template = default; Optional error = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("template"u8)) @@ -42,8 +106,44 @@ internal static ResourceGroupExportResult DeserializeResourceGroupExportResult(J error = JsonSerializer.Deserialize(property.Value.GetRawText()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceGroupExportResult(template.Value, error.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceGroupExportResult(template.Value, error.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(ResourceGroupExportResult)} does not support '{options.Format}' format."); + } + } + + ResourceGroupExportResult 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 DeserializeResourceGroupExportResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceGroupExportResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.cs index 21976bcaadeed..2800a103b7f5b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure; namespace Azure.ResourceManager.Resources.Models @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Resource group export result. public partial class ResourceGroupExportResult { + /// + /// 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 ResourceGroupExportResult() { @@ -21,10 +54,12 @@ internal ResourceGroupExportResult() /// Initializes a new instance of . /// The template content. /// The template export error. - internal ResourceGroupExportResult(BinaryData template, ResponseError error) + /// Keeps track of any properties unknown to the library. + internal ResourceGroupExportResult(BinaryData template, ResponseError error, IDictionary serializedAdditionalRawData) { Template = template; Error = error; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs index ef3eb8bb0edf2..aa69b381e7ad0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.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.Resources.Models { - internal partial class ResourceGroupListResult + internal partial class ResourceGroupListResult : IUtf8JsonSerializable, IJsonModel { - internal static ResourceGroupListResult DeserializeResourceGroupListResult(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(ResourceGroupListResult)} 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 (options.Format != "W" && 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(); + } + + ResourceGroupListResult 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(ResourceGroupListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceGroupListResult(document.RootElement, options); + } + + internal static ResourceGroupListResult DeserializeResourceGroupListResult(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 ResourceGroupListResult DeserializeResourceGroupListResult(JsonE nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceGroupListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceGroupListResult(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(ResourceGroupListResult)} does not support '{options.Format}' format."); + } + } + + ResourceGroupListResult 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 DeserializeResourceGroupListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceGroupListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.cs index 240109a5e923f..eac4c6a2a6551 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of resource groups. internal partial class ResourceGroupListResult { + /// + /// 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 ResourceGroupListResult() { @@ -23,10 +56,12 @@ internal ResourceGroupListResult() /// Initializes a new instance of . /// An array of resource groups. /// The URL to use for getting the next set of results. - internal ResourceGroupListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal ResourceGroupListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of resource groups. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.Serialization.cs index de5c39dcfad51..66c23365d7c76 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.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.Resources.Models { - public partial class ResourceGroupPatch : IUtf8JsonSerializable + public partial class ResourceGroupPatch : 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(ResourceGroupPatch)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Name)) { @@ -41,7 +52,123 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } 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(); } + + ResourceGroupPatch 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(ResourceGroupPatch)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceGroupPatch(document.RootElement, options); + } + + internal static ResourceGroupPatch DeserializeResourceGroupPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional name = default; + Optional properties = default; + Optional managedBy = default; + Optional> tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ResourceGroupProperties.DeserializeResourceGroupProperties(property.Value); + continue; + } + if (property.NameEquals("managedBy"u8)) + { + managedBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceGroupPatch(name.Value, properties.Value, managedBy.Value, Optional.ToDictionary(tags), 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(ResourceGroupPatch)} does not support '{options.Format}' format."); + } + } + + ResourceGroupPatch 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 DeserializeResourceGroupPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceGroupPatch)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.cs index d0d1c83b0ef3e..478e418c6db8b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Resource group information. public partial class ResourceGroupPatch { + /// + /// 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 ResourceGroupPatch() { @@ -24,12 +57,14 @@ public ResourceGroupPatch() /// The resource group properties. /// The ID of the resource that manages this resource group. /// The tags attached to the resource group. - internal ResourceGroupPatch(string name, ResourceGroupProperties properties, string managedBy, IDictionary tags) + /// Keeps track of any properties unknown to the library. + internal ResourceGroupPatch(string name, ResourceGroupProperties properties, string managedBy, IDictionary tags, IDictionary serializedAdditionalRawData) { Name = name; Properties = properties; ManagedBy = managedBy; Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The name of the resource group. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs index bb1fe1451f8a1..ddb4fbc872d69 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs @@ -5,26 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - internal partial class ResourceGroupProperties : IUtf8JsonSerializable + internal partial class ResourceGroupProperties : 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(ResourceGroupProperties)} does not support '{format}' format."); + } + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + 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 ResourceGroupProperties DeserializeResourceGroupProperties(JsonElement element) + ResourceGroupProperties 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(ResourceGroupProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceGroupProperties(document.RootElement, options); + } + + internal static ResourceGroupProperties DeserializeResourceGroupProperties(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("provisioningState"u8)) @@ -32,8 +79,44 @@ internal static ResourceGroupProperties DeserializeResourceGroupProperties(JsonE provisioningState = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceGroupProperties(provisioningState.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(ResourceGroupProperties)} does not support '{options.Format}' format."); + } + } + + ResourceGroupProperties 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 DeserializeResourceGroupProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceGroupProperties)} does not support '{options.Format}' format."); } - return new ResourceGroupProperties(provisioningState.Value); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.cs index b748de4f58db6..4f5ff71de5dd3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// The resource group properties. internal partial class ResourceGroupProperties { + /// + /// 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 ResourceGroupProperties() { @@ -17,9 +52,11 @@ public ResourceGroupProperties() /// Initializes a new instance of . /// The provisioning state. - internal ResourceGroupProperties(string provisioningState) + /// Keeps track of any properties unknown to the library. + internal ResourceGroupProperties(string provisioningState, IDictionary serializedAdditionalRawData) { ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The provisioning state. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs index c146660318269..73664c68944aa 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.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.Resources.Models { - internal partial class ResourceListResult + internal partial class ResourceListResult : IUtf8JsonSerializable, IJsonModel { - internal static ResourceListResult DeserializeResourceListResult(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(ResourceListResult)} 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 (options.Format != "W" && 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(); + } + + ResourceListResult 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(ResourceListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceListResult(document.RootElement, options); + } + + internal static ResourceListResult DeserializeResourceListResult(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 ResourceListResult DeserializeResourceListResult(JsonElement ele nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceListResult(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(ResourceListResult)} does not support '{options.Format}' format."); + } + } + + ResourceListResult 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 DeserializeResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.cs index 70cd049aee11d..c911b9fbeab9b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of resource groups. internal partial class ResourceListResult { + /// + /// 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 ResourceListResult() { @@ -23,10 +56,12 @@ internal ResourceListResult() /// Initializes a new instance of . /// An array of resources. /// The URL to use for getting the next set of results. - internal ResourceListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal ResourceListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of resources. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderData.Serialization.cs index 153e026eca802..a210809c0a509 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderData.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,88 @@ namespace Azure.ResourceManager.Resources { - public partial class ResourceProviderData + public partial class ResourceProviderData : IUtf8JsonSerializable, IJsonModel { - internal static ResourceProviderData DeserializeResourceProviderData(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(ResourceProviderData)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Namespace)) + { + writer.WritePropertyName("namespace"u8); + writer.WriteStringValue(Namespace); + } + if (options.Format != "W" && Optional.IsDefined(RegistrationState)) + { + writer.WritePropertyName("registrationState"u8); + writer.WriteStringValue(RegistrationState); + } + if (options.Format != "W" && Optional.IsDefined(RegistrationPolicy)) + { + writer.WritePropertyName("registrationPolicy"u8); + writer.WriteStringValue(RegistrationPolicy); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ResourceTypes)) + { + writer.WritePropertyName("resourceTypes"u8); + writer.WriteStartArray(); + foreach (var item in ResourceTypes) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ProviderAuthorizationConsentState)) + { + writer.WritePropertyName("providerAuthorizationConsentState"u8); + writer.WriteStringValue(ProviderAuthorizationConsentState.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(); + } + + ResourceProviderData 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(ResourceProviderData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceProviderData(document.RootElement, options); + } + + internal static ResourceProviderData DeserializeResourceProviderData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -26,6 +106,8 @@ internal static ResourceProviderData DeserializeResourceProviderData(JsonElement Optional registrationPolicy = default; Optional> resourceTypes = default; Optional providerAuthorizationConsentState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -75,8 +157,44 @@ internal static ResourceProviderData DeserializeResourceProviderData(JsonElement providerAuthorizationConsentState = new ProviderAuthorizationConsentState(property.Value.GetString()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceProviderData(id.Value, @namespace.Value, registrationState.Value, registrationPolicy.Value, Optional.ToList(resourceTypes), Optional.ToNullable(providerAuthorizationConsentState)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceProviderData(id.Value, @namespace.Value, registrationState.Value, registrationPolicy.Value, Optional.ToList(resourceTypes), Optional.ToNullable(providerAuthorizationConsentState), 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(ResourceProviderData)} does not support '{options.Format}' format."); + } + } + + ResourceProviderData 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 DeserializeResourceProviderData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceProviderData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs index 9700f7cfd947a..5a2451fd7a79d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.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.Resources.Models { - internal partial class ResourceProviderListResult + internal partial class ResourceProviderListResult : IUtf8JsonSerializable, IJsonModel { - internal static ResourceProviderListResult DeserializeResourceProviderListResult(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(ResourceProviderListResult)} 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 (options.Format != "W" && 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(); + } + + ResourceProviderListResult 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(ResourceProviderListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceProviderListResult(document.RootElement, options); + } + + internal static ResourceProviderListResult DeserializeResourceProviderListResult(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 ResourceProviderListResult DeserializeResourceProviderListResult nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceProviderListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceProviderListResult(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(ResourceProviderListResult)} does not support '{options.Format}' format."); + } + } + + ResourceProviderListResult 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 DeserializeResourceProviderListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceProviderListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.cs index dedcb8607c816..ee55dc2ffd2f9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of resource providers. internal partial class ResourceProviderListResult { + /// + /// 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 ResourceProviderListResult() { @@ -23,10 +56,12 @@ internal ResourceProviderListResult() /// Initializes a new instance of . /// An array of resource providers. /// The URL to use for getting the next set of results. - internal ResourceProviderListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal ResourceProviderListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of resource providers. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs index a10a2b6fa0282..02d3cec72622e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs @@ -5,16 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ResourceSelector : IUtf8JsonSerializable + public partial class ResourceSelector : 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(ResourceSelector)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Name)) { @@ -31,17 +41,48 @@ 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 ResourceSelector DeserializeResourceSelector(JsonElement element) + ResourceSelector 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(ResourceSelector)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceSelector(document.RootElement, options); + } + + internal static ResourceSelector DeserializeResourceSelector(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional name = default; Optional> selectors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -63,8 +104,44 @@ internal static ResourceSelector DeserializeResourceSelector(JsonElement element selectors = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceSelector(name.Value, Optional.ToList(selectors)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceSelector(name.Value, Optional.ToList(selectors), 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(ResourceSelector)} does not support '{options.Format}' format."); + } + } + + ResourceSelector 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 DeserializeResourceSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceSelector)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.cs index 6592035344de2..a74df83487297 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The resource selector to filter policies by resource properties. public partial class ResourceSelector { + /// + /// 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 ResourceSelector() { @@ -22,10 +55,12 @@ public ResourceSelector() /// Initializes a new instance of . /// The name of the resource selector. /// The list of the selector expressions. - internal ResourceSelector(string name, IList selectors) + /// Keeps track of any properties unknown to the library. + internal ResourceSelector(string name, IList selectors, IDictionary serializedAdditionalRawData) { Name = name; Selectors = selectors; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The name of the resource selector. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs index 209773684d8d0..4aea322f016d5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs @@ -5,16 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ResourceSelectorExpression : IUtf8JsonSerializable + public partial class ResourceSelectorExpression : 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(ResourceSelectorExpression)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Kind)) { @@ -41,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 ResourceSelectorExpression DeserializeResourceSelectorExpression(JsonElement element) + ResourceSelectorExpression 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(ResourceSelectorExpression)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceSelectorExpression(document.RootElement, options); + } + + internal static ResourceSelectorExpression DeserializeResourceSelectorExpression(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -53,6 +92,8 @@ internal static ResourceSelectorExpression DeserializeResourceSelectorExpression Optional kind = default; Optional> @in = default; Optional> notIn = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("kind"u8)) @@ -92,8 +133,44 @@ internal static ResourceSelectorExpression DeserializeResourceSelectorExpression notIn = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceSelectorExpression(Optional.ToNullable(kind), Optional.ToList(@in), Optional.ToList(notIn)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceSelectorExpression(Optional.ToNullable(kind), Optional.ToList(@in), Optional.ToList(notIn), 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(ResourceSelectorExpression)} does not support '{options.Format}' format."); + } + } + + ResourceSelectorExpression 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 DeserializeResourceSelectorExpression(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceSelectorExpression)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.cs index 9be7f6914b4a9..4951da8a14ab0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The selector expression. public partial class ResourceSelectorExpression { + /// + /// 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 ResourceSelectorExpression() { @@ -24,11 +57,13 @@ public ResourceSelectorExpression() /// The selector kind. /// The list of values to filter in. /// The list of values to filter out. - internal ResourceSelectorExpression(ResourceSelectorKind? kind, IList @in, IList notIn) + /// Keeps track of any properties unknown to the library. + internal ResourceSelectorExpression(ResourceSelectorKind? kind, IList @in, IList notIn, IDictionary serializedAdditionalRawData) { Kind = kind; In = @in; NotIn = notIn; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The selector kind. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs index e8525b1aaf2e0..9993f75bdb8c3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs @@ -5,16 +5,96 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ResourceTypeAlias + public partial class ResourceTypeAlias : IUtf8JsonSerializable, IJsonModel { - internal static ResourceTypeAlias DeserializeResourceTypeAlias(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(ResourceTypeAlias)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsCollectionDefined(Paths)) + { + writer.WritePropertyName("paths"u8); + writer.WriteStartArray(); + foreach (var item in Paths) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(AliasType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(AliasType.Value.ToSerialString()); + } + if (Optional.IsDefined(DefaultPath)) + { + writer.WritePropertyName("defaultPath"u8); + writer.WriteStringValue(DefaultPath); + } + if (Optional.IsDefined(DefaultPattern)) + { + writer.WritePropertyName("defaultPattern"u8); + writer.WriteObjectValue(DefaultPattern); + } + if (options.Format != "W" && Optional.IsDefined(DefaultMetadata)) + { + writer.WritePropertyName("defaultMetadata"u8); + writer.WriteObjectValue(DefaultMetadata); + } + 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(); + } + + ResourceTypeAlias 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(ResourceTypeAlias)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceTypeAlias(document.RootElement, options); + } + + internal static ResourceTypeAlias DeserializeResourceTypeAlias(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -25,6 +105,8 @@ internal static ResourceTypeAlias DeserializeResourceTypeAlias(JsonElement eleme Optional defaultPath = default; Optional defaultPattern = default; Optional defaultMetadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -78,8 +160,44 @@ internal static ResourceTypeAlias DeserializeResourceTypeAlias(JsonElement eleme defaultMetadata = ResourceTypeAliasPathMetadata.DeserializeResourceTypeAliasPathMetadata(property.Value); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceTypeAlias(name.Value, Optional.ToList(paths), Optional.ToNullable(type), defaultPath.Value, defaultPattern.Value, defaultMetadata.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceTypeAlias(name.Value, Optional.ToList(paths), Optional.ToNullable(type), defaultPath.Value, defaultPattern.Value, defaultMetadata.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(ResourceTypeAlias)} does not support '{options.Format}' format."); + } + } + + ResourceTypeAlias 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 DeserializeResourceTypeAlias(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceTypeAlias)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.cs index ba258660b7cda..20281d1430f50 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The alias type. public partial class ResourceTypeAlias { + /// + /// 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 ResourceTypeAlias() { @@ -26,7 +59,8 @@ internal ResourceTypeAlias() /// The default path for an alias. /// The default pattern for an alias. /// The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. - internal ResourceTypeAlias(string name, IReadOnlyList paths, ResourceTypeAliasType? aliasType, string defaultPath, ResourceTypeAliasPattern defaultPattern, ResourceTypeAliasPathMetadata defaultMetadata) + /// Keeps track of any properties unknown to the library. + internal ResourceTypeAlias(string name, IReadOnlyList paths, ResourceTypeAliasType? aliasType, string defaultPath, ResourceTypeAliasPattern defaultPattern, ResourceTypeAliasPathMetadata defaultMetadata, IDictionary serializedAdditionalRawData) { Name = name; Paths = paths; @@ -34,6 +68,7 @@ internal ResourceTypeAlias(string name, IReadOnlyList pat DefaultPath = defaultPath; DefaultPattern = defaultPattern; DefaultMetadata = defaultMetadata; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The alias name. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs index 5b6c8759a486f..ea9a4c66a95d9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs @@ -5,16 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class ResourceTypeAliasPath + public partial class ResourceTypeAliasPath : IUtf8JsonSerializable, IJsonModel { - internal static ResourceTypeAliasPath DeserializeResourceTypeAliasPath(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(ResourceTypeAliasPath)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Path)) + { + writer.WritePropertyName("path"u8); + writer.WriteStringValue(Path); + } + if (Optional.IsCollectionDefined(ApiVersions)) + { + writer.WritePropertyName("apiVersions"u8); + writer.WriteStartArray(); + foreach (var item in ApiVersions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Pattern)) + { + writer.WritePropertyName("pattern"u8); + writer.WriteObjectValue(Pattern); + } + if (options.Format != "W" && Optional.IsDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteObjectValue(Metadata); + } + 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(); + } + + ResourceTypeAliasPath 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(ResourceTypeAliasPath)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceTypeAliasPath(document.RootElement, options); + } + + internal static ResourceTypeAliasPath DeserializeResourceTypeAliasPath(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +93,8 @@ internal static ResourceTypeAliasPath DeserializeResourceTypeAliasPath(JsonEleme Optional> apiVersions = default; Optional pattern = default; Optional metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("path"u8)) @@ -62,8 +134,44 @@ internal static ResourceTypeAliasPath DeserializeResourceTypeAliasPath(JsonEleme metadata = ResourceTypeAliasPathMetadata.DeserializeResourceTypeAliasPathMetadata(property.Value); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceTypeAliasPath(path.Value, Optional.ToList(apiVersions), pattern.Value, metadata.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceTypeAliasPath(path.Value, Optional.ToList(apiVersions), pattern.Value, metadata.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(ResourceTypeAliasPath)} does not support '{options.Format}' format."); + } + } + + ResourceTypeAliasPath 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 DeserializeResourceTypeAliasPath(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceTypeAliasPath)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.cs index 14d258acded29..d3bb36c3709f6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The type of the paths for alias. public partial class ResourceTypeAliasPath { + /// + /// 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 ResourceTypeAliasPath() { @@ -24,12 +57,14 @@ internal ResourceTypeAliasPath() /// The API versions. /// The pattern for an alias path. /// The metadata of the alias path. If missing, fall back to the default metadata of the alias. - internal ResourceTypeAliasPath(string path, IReadOnlyList apiVersions, ResourceTypeAliasPattern pattern, ResourceTypeAliasPathMetadata metadata) + /// Keeps track of any properties unknown to the library. + internal ResourceTypeAliasPath(string path, IReadOnlyList apiVersions, ResourceTypeAliasPattern pattern, ResourceTypeAliasPathMetadata metadata, IDictionary serializedAdditionalRawData) { Path = path; ApiVersions = apiVersions; Pattern = pattern; Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The path of an alias. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs index 8e131cb4ca7ff..acc2a258c2758 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.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.Resources.Models { - public partial class ResourceTypeAliasPathMetadata + public partial class ResourceTypeAliasPathMetadata : IUtf8JsonSerializable, IJsonModel { - internal static ResourceTypeAliasPathMetadata DeserializeResourceTypeAliasPathMetadata(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(ResourceTypeAliasPathMetadata)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(TokenType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(TokenType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteStringValue(Attributes.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(); + } + + ResourceTypeAliasPathMetadata 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(ResourceTypeAliasPathMetadata)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceTypeAliasPathMetadata(document.RootElement, options); + } + + internal static ResourceTypeAliasPathMetadata DeserializeResourceTypeAliasPathMetadata(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional type = default; Optional attributes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -40,8 +98,44 @@ internal static ResourceTypeAliasPathMetadata DeserializeResourceTypeAliasPathMe attributes = new ResourceTypeAliasPathAttributes(property.Value.GetString()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceTypeAliasPathMetadata(Optional.ToNullable(type), Optional.ToNullable(attributes), 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(ResourceTypeAliasPathMetadata)} does not support '{options.Format}' format."); + } + } + + ResourceTypeAliasPathMetadata 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 DeserializeResourceTypeAliasPathMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceTypeAliasPathMetadata)} does not support '{options.Format}' format."); } - return new ResourceTypeAliasPathMetadata(Optional.ToNullable(type), Optional.ToNullable(attributes)); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.cs index 62c06035b27ed..befa6e27d336c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// The ResourceTypeAliasPathMetadata. public partial class ResourceTypeAliasPathMetadata { + /// + /// 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 ResourceTypeAliasPathMetadata() { @@ -18,10 +53,12 @@ internal ResourceTypeAliasPathMetadata() /// Initializes a new instance of . /// The type of the token that the alias path is referring to. /// The attributes of the token that the alias path is referring to. - internal ResourceTypeAliasPathMetadata(ResourceTypeAliasPathTokenType? tokenType, ResourceTypeAliasPathAttributes? attributes) + /// Keeps track of any properties unknown to the library. + internal ResourceTypeAliasPathMetadata(ResourceTypeAliasPathTokenType? tokenType, ResourceTypeAliasPathAttributes? attributes, IDictionary serializedAdditionalRawData) { TokenType = tokenType; Attributes = attributes; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The type of the token that the alias path is referring to. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs index 544baf503463b..e00ed6427761b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.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.Resources.Models { - public partial class ResourceTypeAliasPattern + public partial class ResourceTypeAliasPattern : IUtf8JsonSerializable, IJsonModel { - internal static ResourceTypeAliasPattern DeserializeResourceTypeAliasPattern(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(ResourceTypeAliasPattern)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Phrase)) + { + writer.WritePropertyName("phrase"u8); + writer.WriteStringValue(Phrase); + } + if (Optional.IsDefined(Variable)) + { + writer.WritePropertyName("variable"u8); + writer.WriteStringValue(Variable); + } + if (Optional.IsDefined(PatternType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(PatternType.Value.ToSerialString()); + } + 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(); + } + + ResourceTypeAliasPattern 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(ResourceTypeAliasPattern)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceTypeAliasPattern(document.RootElement, options); + } + + internal static ResourceTypeAliasPattern DeserializeResourceTypeAliasPattern(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +82,8 @@ internal static ResourceTypeAliasPattern DeserializeResourceTypeAliasPattern(Jso Optional phrase = default; Optional variable = default; Optional type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("phrase"u8)) @@ -42,8 +105,44 @@ internal static ResourceTypeAliasPattern DeserializeResourceTypeAliasPattern(Jso type = property.Value.GetString().ToResourceTypeAliasPatternType(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceTypeAliasPattern(phrase.Value, variable.Value, Optional.ToNullable(type)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceTypeAliasPattern(phrase.Value, variable.Value, Optional.ToNullable(type), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ResourceTypeAliasPattern)} does not support '{options.Format}' format."); + } + } + + ResourceTypeAliasPattern 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 DeserializeResourceTypeAliasPattern(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceTypeAliasPattern)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.cs index 3a74e0356b8d8..64b8153d9ebc9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// The type of the pattern for an alias path. public partial class ResourceTypeAliasPattern { + /// + /// 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 ResourceTypeAliasPattern() { @@ -19,11 +54,13 @@ internal ResourceTypeAliasPattern() /// The alias pattern phrase. /// The alias pattern variable. /// The type of alias pattern. - internal ResourceTypeAliasPattern(string phrase, string variable, ResourceTypeAliasPatternType? patternType) + /// Keeps track of any properties unknown to the library. + internal ResourceTypeAliasPattern(string phrase, string variable, ResourceTypeAliasPatternType? patternType, IDictionary serializedAdditionalRawData) { Phrase = phrase; Variable = variable; PatternType = patternType; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The alias pattern phrase. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs index 6086d03f80539..722d104387fb9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.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.Resources.Models { - public partial class ResourceTypeAliases + public partial class ResourceTypeAliases : IUtf8JsonSerializable, IJsonModel { - internal static ResourceTypeAliases DeserializeResourceTypeAliases(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(ResourceTypeAliases)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ResourceType)) + { + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + } + if (Optional.IsCollectionDefined(Aliases)) + { + writer.WritePropertyName("aliases"u8); + writer.WriteStartArray(); + foreach (var item in Aliases) + { + 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(); + } + + ResourceTypeAliases 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(ResourceTypeAliases)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceTypeAliases(document.RootElement, options); + } + + internal static ResourceTypeAliases DeserializeResourceTypeAliases(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional resourceType = default; Optional> aliases = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("resourceType"u8)) @@ -42,8 +104,44 @@ internal static ResourceTypeAliases DeserializeResourceTypeAliases(JsonElement e aliases = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourceTypeAliases(resourceType.Value, Optional.ToList(aliases)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceTypeAliases(resourceType.Value, Optional.ToList(aliases), 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(ResourceTypeAliases)} does not support '{options.Format}' format."); + } + } + + ResourceTypeAliases 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 DeserializeResourceTypeAliases(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceTypeAliases)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.cs index b7c582b79a3a8..4b543d3b72421 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The resource type aliases definition. public partial class ResourceTypeAliases { + /// + /// 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 ResourceTypeAliases() { @@ -22,10 +55,12 @@ internal ResourceTypeAliases() /// Initializes a new instance of . /// The resource type name. /// The aliases for property names. - internal ResourceTypeAliases(string resourceType, IReadOnlyList aliases) + /// Keeps track of any properties unknown to the library. + internal ResourceTypeAliases(string resourceType, IReadOnlyList aliases, IDictionary serializedAdditionalRawData) { ResourceType = resourceType; Aliases = aliases; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The resource type name. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesMoveContent.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesMoveContent.Serialization.cs index 7fbec4b13fc80..840e8af9f73d3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesMoveContent.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesMoveContent.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.Resources.Models { - public partial class ResourcesMoveContent : IUtf8JsonSerializable + public partial class ResourcesMoveContent : 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(ResourcesMoveContent)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsCollectionDefined(Resources)) { @@ -30,7 +41,111 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("targetResourceGroup"u8); writer.WriteStringValue(TargetResourceGroupId); } + 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(); } + + ResourcesMoveContent 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(ResourcesMoveContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourcesMoveContent(document.RootElement, options); + } + + internal static ResourcesMoveContent DeserializeResourcesMoveContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> resources = default; + Optional targetResourceGroup = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + resources = array; + continue; + } + if (property.NameEquals("targetResourceGroup"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceGroup = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourcesMoveContent(Optional.ToList(resources), targetResourceGroup.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(ResourcesMoveContent)} does not support '{options.Format}' format."); + } + } + + ResourcesMoveContent 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 DeserializeResourcesMoveContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourcesMoveContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesMoveContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesMoveContent.cs index 635a99dd91f38..9e0bd896f0699 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesMoveContent.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesMoveContent.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Parameters of move resources. public partial class ResourcesMoveContent { + /// + /// 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 ResourcesMoveContent() { @@ -22,10 +55,12 @@ public ResourcesMoveContent() /// Initializes a new instance of . /// The IDs of the resources. /// The target resource group. - internal ResourcesMoveContent(IList resources, ResourceIdentifier targetResourceGroupId) + /// Keeps track of any properties unknown to the library. + internal ResourcesMoveContent(IList resources, ResourceIdentifier targetResourceGroupId, IDictionary serializedAdditionalRawData) { Resources = resources; TargetResourceGroupId = targetResourceGroupId; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The IDs of the resources. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs index a37689c917ce0..d1c83c48ef1d5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.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.Resources.Models { - public partial class ResourcesSku : IUtf8JsonSerializable + public partial class ResourcesSku : 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(ResourcesSku)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Name)) { @@ -45,11 +56,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("capacity"u8); writer.WriteNumberValue(Capacity.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 ResourcesSku DeserializeResourcesSku(JsonElement element) + ResourcesSku 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(ResourcesSku)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourcesSku(document.RootElement, options); + } + + internal static ResourcesSku DeserializeResourcesSku(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -60,6 +100,8 @@ internal static ResourcesSku DeserializeResourcesSku(JsonElement element) Optional family = default; Optional model = default; Optional capacity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -96,8 +138,44 @@ internal static ResourcesSku DeserializeResourcesSku(JsonElement element) capacity = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ResourcesSku(name.Value, tier.Value, size.Value, family.Value, model.Value, Optional.ToNullable(capacity)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourcesSku(name.Value, tier.Value, size.Value, family.Value, model.Value, Optional.ToNullable(capacity), 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(ResourcesSku)} does not support '{options.Format}' format."); + } + } + + ResourcesSku 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 DeserializeResourcesSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourcesSku)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.cs index 30323ba9d5feb..6370467fbd7bf 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// SKU for the resource. public partial class ResourcesSku { + /// + /// 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 ResourcesSku() { @@ -22,7 +57,8 @@ public ResourcesSku() /// The SKU family. /// The SKU model. /// The SKU capacity. - internal ResourcesSku(string name, string tier, string size, string family, string model, int? capacity) + /// Keeps track of any properties unknown to the library. + internal ResourcesSku(string name, string tier, string size, string family, string model, int? capacity, IDictionary serializedAdditionalRawData) { Name = name; Tier = tier; @@ -30,6 +66,7 @@ internal ResourcesSku(string name, string tier, string size, string family, stri Family = family; Model = model; Capacity = capacity; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The SKU name. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubResource.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubResource.cs index 37887530fc958..b5bc3d1195066 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubResource.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.ResourceManager.Resources.Models @@ -12,5 +14,45 @@ namespace Azure.ResourceManager.Resources.Models /// Sub-resource. public partial class SubResource { + /// + /// 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 . + /// Resource ID. + /// Keeps track of any properties unknown to the library. + internal SubResource(ResourceIdentifier id, IDictionary serializedAdditionalRawData) + { + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionData.Serialization.cs index 0274848240fa1..325efe9ba1713 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionData.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; @@ -13,10 +14,109 @@ namespace Azure.ResourceManager.Resources { - public partial class SubscriptionData + public partial class SubscriptionData : IUtf8JsonSerializable, IJsonModel { - internal static SubscriptionData DeserializeSubscriptionData(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(SubscriptionData)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } + if (options.Format != "W" && Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.ToSerialString()); + } + if (Optional.IsDefined(SubscriptionPolicies)) + { + writer.WritePropertyName("subscriptionPolicies"u8); + writer.WriteObjectValue(SubscriptionPolicies); + } + if (Optional.IsDefined(AuthorizationSource)) + { + writer.WritePropertyName("authorizationSource"u8); + writer.WriteStringValue(AuthorizationSource); + } + if (Optional.IsCollectionDefined(ManagedByTenants)) + { + writer.WritePropertyName("managedByTenants"u8); + writer.WriteStartArray(); + foreach (var item in ManagedByTenants) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SubscriptionData 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(SubscriptionData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubscriptionData(document.RootElement, options); + } + + internal static SubscriptionData DeserializeSubscriptionData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -30,6 +130,8 @@ internal static SubscriptionData DeserializeSubscriptionData(JsonElement element Optional authorizationSource = default; Optional> managedByTenants = default; Optional> tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -111,8 +213,44 @@ internal static SubscriptionData DeserializeSubscriptionData(JsonElement element tags = dictionary; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SubscriptionData(id.Value, subscriptionId.Value, displayName.Value, Optional.ToNullable(tenantId), Optional.ToNullable(state), subscriptionPolicies.Value, authorizationSource.Value, Optional.ToList(managedByTenants), Optional.ToDictionary(tags)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SubscriptionData(id.Value, subscriptionId.Value, displayName.Value, Optional.ToNullable(tenantId), Optional.ToNullable(state), subscriptionPolicies.Value, authorizationSource.Value, Optional.ToList(managedByTenants), Optional.ToDictionary(tags), 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(SubscriptionData)} does not support '{options.Format}' format."); + } + } + + SubscriptionData 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 DeserializeSubscriptionData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubscriptionData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs index cb8cc86ac5deb..5f75eb23cef93 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.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,73 @@ namespace Azure.ResourceManager.Resources.Models { - internal partial class SubscriptionListResult + internal partial class SubscriptionListResult : IUtf8JsonSerializable, IJsonModel { - internal static SubscriptionListResult DeserializeSubscriptionListResult(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(SubscriptionListResult)} 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(); + } + 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(); + } + + SubscriptionListResult 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(SubscriptionListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubscriptionListResult(document.RootElement, options); + } + + internal static SubscriptionListResult DeserializeSubscriptionListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional> value = default; string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -43,8 +102,44 @@ internal static SubscriptionListResult DeserializeSubscriptionListResult(JsonEle nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SubscriptionListResult(Optional.ToList(value), nextLink, 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(SubscriptionListResult)} does not support '{options.Format}' format."); + } + } + + SubscriptionListResult 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 DeserializeSubscriptionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubscriptionListResult)} does not support '{options.Format}' format."); } - return new SubscriptionListResult(Optional.ToList(value), nextLink); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.cs index b4e2c682bbff2..8ca810079115e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.cs @@ -15,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// Subscription list operation response. internal partial class SubscriptionListResult { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// The URL to get the next set of results. /// is null. @@ -29,10 +61,17 @@ internal SubscriptionListResult(string nextLink) /// Initializes a new instance of . /// An array of subscriptions. /// The URL to get the next set of results. - internal SubscriptionListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal SubscriptionListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SubscriptionListResult() + { } /// An array of subscriptions. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs index a72fae0fdac03..b0b497a0261d1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.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.Resources.Models { - public partial class SubscriptionPolicies + public partial class SubscriptionPolicies : IUtf8JsonSerializable, IJsonModel { - internal static SubscriptionPolicies DeserializeSubscriptionPolicies(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(SubscriptionPolicies)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(LocationPlacementId)) + { + writer.WritePropertyName("locationPlacementId"u8); + writer.WriteStringValue(LocationPlacementId); + } + if (options.Format != "W" && Optional.IsDefined(QuotaId)) + { + writer.WritePropertyName("quotaId"u8); + writer.WriteStringValue(QuotaId); + } + if (options.Format != "W" && Optional.IsDefined(SpendingLimit)) + { + writer.WritePropertyName("spendingLimit"u8); + writer.WriteStringValue(SpendingLimit.Value.ToSerialString()); + } + 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(); + } + + SubscriptionPolicies 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(SubscriptionPolicies)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubscriptionPolicies(document.RootElement, options); + } + + internal static SubscriptionPolicies DeserializeSubscriptionPolicies(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +82,8 @@ internal static SubscriptionPolicies DeserializeSubscriptionPolicies(JsonElement Optional locationPlacementId = default; Optional quotaId = default; Optional spendingLimit = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("locationPlacementId"u8)) @@ -42,8 +105,44 @@ internal static SubscriptionPolicies DeserializeSubscriptionPolicies(JsonElement spendingLimit = property.Value.GetString().ToSpendingLimit(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SubscriptionPolicies(locationPlacementId.Value, quotaId.Value, Optional.ToNullable(spendingLimit)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SubscriptionPolicies(locationPlacementId.Value, quotaId.Value, Optional.ToNullable(spendingLimit), 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(SubscriptionPolicies)} does not support '{options.Format}' format."); + } + } + + SubscriptionPolicies 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 DeserializeSubscriptionPolicies(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubscriptionPolicies)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.cs index 358cc412e7278..c83c5e055fe9f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.Resources.Models { /// Subscription policies. public partial class SubscriptionPolicies { + /// + /// 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 SubscriptionPolicies() { @@ -19,11 +54,13 @@ internal SubscriptionPolicies() /// The subscription location placement ID. The ID indicates which regions are visible for a subscription. For example, a subscription with a location placement Id of Public_2014-09-01 has access to Azure public regions. /// The subscription quota ID. /// The subscription spending limit. - internal SubscriptionPolicies(string locationPlacementId, string quotaId, SpendingLimit? spendingLimit) + /// Keeps track of any properties unknown to the library. + internal SubscriptionPolicies(string locationPlacementId, string quotaId, SpendingLimit? spendingLimit, IDictionary serializedAdditionalRawData) { LocationPlacementId = locationPlacementId; QuotaId = quotaId; SpendingLimit = spendingLimit; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The subscription location placement ID. The ID indicates which regions are visible for a subscription. For example, a subscription with a location placement Id of Public_2014-09-01 has access to Azure public regions. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs index 61c890433d2d8..f9f21d00ce243 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs @@ -5,16 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.Resources.Models { - public partial class Tag : IUtf8JsonSerializable + public partial class Tag : 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(Tag)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsCollectionDefined(TagValues)) { @@ -27,16 +37,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } 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 Tag DeserializeTag(JsonElement element) + Tag 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(Tag)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTag(document.RootElement, options); + } + + internal static Tag DeserializeTag(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional> tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tags"u8)) @@ -53,8 +94,44 @@ internal static Tag DeserializeTag(JsonElement element) tags = dictionary; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new Tag(Optional.ToDictionary(tags)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new Tag(Optional.ToDictionary(tags), 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(Tag)} does not support '{options.Format}' format."); + } + } + + Tag 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 DeserializeTag(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Tag)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.cs index 5fa661337e2ef..18f30b9f867cc 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// A dictionary of name and value pairs. public partial class Tag { + /// + /// 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 Tag() { @@ -21,9 +54,11 @@ public Tag() /// Initializes a new instance of . /// Dictionary of <string>. - internal Tag(IDictionary tagValues) + /// Keeps track of any properties unknown to the library. + internal Tag(IDictionary tagValues, IDictionary serializedAdditionalRawData) { TagValues = tagValues; + _serializedAdditionalRawData = serializedAdditionalRawData; } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourceData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourceData.Serialization.cs index 400badf750369..08b94f97ef524 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourceData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourceData.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.Models; @@ -12,18 +15,75 @@ namespace Azure.ResourceManager.Resources { - public partial class TagResourceData : IUtf8JsonSerializable + public partial class TagResourceData : 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(TagResourceData)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties); + 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); + } + 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 TagResourceData DeserializeTagResourceData(JsonElement element) + TagResourceData 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(TagResourceData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTagResourceData(document.RootElement, options); + } + + internal static TagResourceData DeserializeTagResourceData(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,6 +93,8 @@ internal static TagResourceData DeserializeTagResourceData(JsonElement element) string name = default; ResourceType type = default; Optional systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("properties"u8)) @@ -64,8 +126,44 @@ internal static TagResourceData DeserializeTagResourceData(JsonElement element) systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new TagResourceData(id, name, type, systemData.Value, properties); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new TagResourceData(id, name, type, systemData.Value, properties, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TagResourceData)} does not support '{options.Format}' format."); + } + } + + TagResourceData 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 DeserializeTagResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TagResourceData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.Serialization.cs index 12c6eb346f8d3..4a437d5fb7f08 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.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.Resources.Models { - public partial class TagResourcePatch : IUtf8JsonSerializable + public partial class TagResourcePatch : 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(TagResourcePatch)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(PatchMode)) { @@ -25,7 +36,106 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) 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(); } + + TagResourcePatch 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(TagResourcePatch)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTagResourcePatch(document.RootElement, options); + } + + internal static TagResourcePatch DeserializeTagResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional operation = default; + Optional properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + operation = new TagPatchMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = Tag.DeserializeTag(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new TagResourcePatch(Optional.ToNullable(operation), 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(TagResourcePatch)} does not support '{options.Format}' format."); + } + } + + TagResourcePatch 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 DeserializeTagResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TagResourcePatch)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.cs index 056880dc1478c..1fbe9be30f463 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TagResourcePatch.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.ResourceManager.Resources.Models @@ -12,6 +13,38 @@ namespace Azure.ResourceManager.Resources.Models /// Wrapper resource for tags patch API request only. public partial class TagResourcePatch { + /// + /// 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 TagResourcePatch() { @@ -20,10 +53,12 @@ public TagResourcePatch() /// Initializes a new instance of . /// The operation type for the patch API. /// The set of tags. - internal TagResourcePatch(TagPatchMode? patchMode, Tag properties) + /// Keeps track of any properties unknown to the library. + internal TagResourcePatch(TagPatchMode? patchMode, Tag properties, IDictionary serializedAdditionalRawData) { PatchMode = patchMode; Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The operation type for the patch API. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantData.Serialization.cs index 50ee2c1cac743..7c03264a7ec85 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantData.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; @@ -13,10 +14,108 @@ namespace Azure.ResourceManager.Resources { - public partial class TenantData + public partial class TenantData : IUtf8JsonSerializable, IJsonModel { - internal static TenantData DeserializeTenantData(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(TenantData)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } + if (options.Format != "W" && Optional.IsDefined(TenantCategory)) + { + writer.WritePropertyName("tenantCategory"u8); + writer.WriteStringValue(TenantCategory.Value.ToSerialString()); + } + if (options.Format != "W" && Optional.IsDefined(Country)) + { + writer.WritePropertyName("country"u8); + writer.WriteStringValue(Country); + } + if (options.Format != "W" && Optional.IsDefined(CountryCode)) + { + writer.WritePropertyName("countryCode"u8); + writer.WriteStringValue(CountryCode); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Domains)) + { + writer.WritePropertyName("domains"u8); + writer.WriteStartArray(); + foreach (var item in Domains) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(DefaultDomain)) + { + writer.WritePropertyName("defaultDomain"u8); + writer.WriteStringValue(DefaultDomain); + } + if (options.Format != "W" && Optional.IsDefined(TenantType)) + { + writer.WritePropertyName("tenantType"u8); + writer.WriteStringValue(TenantType); + } + if (options.Format != "W" && Optional.IsDefined(TenantBrandingLogoUri)) + { + writer.WritePropertyName("tenantBrandingLogoUrl"u8); + writer.WriteStringValue(TenantBrandingLogoUri.AbsoluteUri); + } + 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(); + } + + TenantData 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(TenantData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTenantData(document.RootElement, options); + } + + internal static TenantData DeserializeTenantData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -31,6 +130,8 @@ internal static TenantData DeserializeTenantData(JsonElement element) Optional defaultDomain = default; Optional tenantType = default; Optional tenantBrandingLogoUrl = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -104,8 +205,44 @@ internal static TenantData DeserializeTenantData(JsonElement element) tenantBrandingLogoUrl = new Uri(property.Value.GetString()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new TenantData(id.Value, Optional.ToNullable(tenantId), Optional.ToNullable(tenantCategory), country.Value, countryCode.Value, displayName.Value, Optional.ToList(domains), defaultDomain.Value, tenantType.Value, tenantBrandingLogoUrl.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new TenantData(id.Value, Optional.ToNullable(tenantId), Optional.ToNullable(tenantCategory), country.Value, countryCode.Value, displayName.Value, Optional.ToList(domains), defaultDomain.Value, tenantType.Value, tenantBrandingLogoUrl.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(TenantData)} does not support '{options.Format}' format."); + } + } + + TenantData 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 DeserializeTenantData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TenantData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs index 1b85e263c8d58..b408cce63ebe9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.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,73 @@ namespace Azure.ResourceManager.Resources.Models { - internal partial class TenantListResult + internal partial class TenantListResult : IUtf8JsonSerializable, IJsonModel { - internal static TenantListResult DeserializeTenantListResult(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(TenantListResult)} 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(); + } + 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(); + } + + TenantListResult 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(TenantListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTenantListResult(document.RootElement, options); + } + + internal static TenantListResult DeserializeTenantListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional> value = default; string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -43,8 +102,44 @@ internal static TenantListResult DeserializeTenantListResult(JsonElement element nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new TenantListResult(Optional.ToList(value), nextLink, 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(TenantListResult)} does not support '{options.Format}' format."); + } + } + + TenantListResult 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 DeserializeTenantListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TenantListResult)} does not support '{options.Format}' format."); } - return new TenantListResult(Optional.ToList(value), nextLink); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.cs index 5d93ef926e038..9f60bbb5d5fca 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.cs @@ -15,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// Tenant Ids information. internal partial class TenantListResult { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// The URL to use for getting the next set of results. /// is null. @@ -29,10 +61,17 @@ internal TenantListResult(string nextLink) /// Initializes a new instance of . /// An array of tenants. /// The URL to use for getting the next set of results. - internal TenantListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal TenantListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TenantListResult() + { } /// An array of tenants. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs index ee7da8e289eff..dd5925bc55fe9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.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.Resources.Models { - public partial class TenantResourceProvider + public partial class TenantResourceProvider : IUtf8JsonSerializable, IJsonModel { - internal static TenantResourceProvider DeserializeTenantResourceProvider(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(TenantResourceProvider)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Namespace)) + { + writer.WritePropertyName("namespace"u8); + writer.WriteStringValue(Namespace); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ResourceTypes)) + { + writer.WritePropertyName("resourceTypes"u8); + writer.WriteStartArray(); + foreach (var item in ResourceTypes) + { + 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(); + } + + TenantResourceProvider 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(TenantResourceProvider)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTenantResourceProvider(document.RootElement, options); + } + + internal static TenantResourceProvider DeserializeTenantResourceProvider(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional @namespace = default; Optional> resourceTypes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("namespace"u8)) @@ -42,8 +104,44 @@ internal static TenantResourceProvider DeserializeTenantResourceProvider(JsonEle resourceTypes = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new TenantResourceProvider(@namespace.Value, Optional.ToList(resourceTypes)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new TenantResourceProvider(@namespace.Value, Optional.ToList(resourceTypes), 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(TenantResourceProvider)} does not support '{options.Format}' format."); + } + } + + TenantResourceProvider 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 DeserializeTenantResourceProvider(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TenantResourceProvider)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.cs index 442c622e556e2..507de583f806f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// Resource provider information. public partial class TenantResourceProvider { + /// + /// 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 TenantResourceProvider() { @@ -22,10 +55,12 @@ internal TenantResourceProvider() /// Initializes a new instance of . /// The namespace of the resource provider. /// The collection of provider resource types. - internal TenantResourceProvider(string @namespace, IReadOnlyList resourceTypes) + /// Keeps track of any properties unknown to the library. + internal TenantResourceProvider(string @namespace, IReadOnlyList resourceTypes, IDictionary serializedAdditionalRawData) { Namespace = @namespace; ResourceTypes = resourceTypes; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The namespace of the resource provider. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs index cfa772a62cff9..07f977d4cff2e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.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.Resources.Models { - internal partial class TenantResourceProviderListResult + internal partial class TenantResourceProviderListResult : IUtf8JsonSerializable, IJsonModel { - internal static TenantResourceProviderListResult DeserializeTenantResourceProviderListResult(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(TenantResourceProviderListResult)} 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 (options.Format != "W" && 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(); + } + + TenantResourceProviderListResult 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(TenantResourceProviderListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTenantResourceProviderListResult(document.RootElement, options); + } + + internal static TenantResourceProviderListResult DeserializeTenantResourceProviderListResult(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)) @@ -42,8 +104,44 @@ internal static TenantResourceProviderListResult DeserializeTenantResourceProvid nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new TenantResourceProviderListResult(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new TenantResourceProviderListResult(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(TenantResourceProviderListResult)} does not support '{options.Format}' format."); + } + } + + TenantResourceProviderListResult 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 DeserializeTenantResourceProviderListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TenantResourceProviderListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.cs index 04a32c38499c9..2d9c3dcd0a778 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// List of resource providers. internal partial class TenantResourceProviderListResult { + /// + /// 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 TenantResourceProviderListResult() { @@ -22,10 +55,12 @@ internal TenantResourceProviderListResult() /// Initializes a new instance of . /// An array of resource providers. /// The URL to use for getting the next set of results. - internal TenantResourceProviderListResult(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal TenantResourceProviderListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// An array of resource providers. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs index 503f1a848fb15..4890d3e43c430 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.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,18 @@ namespace Azure.ResourceManager.Resources.Models { - public partial class TrackedResourceExtendedData : IUtf8JsonSerializable + public partial class TrackedResourceExtendedData : 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(TrackedResourceExtendedData)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(ExtendedLocation)) { @@ -35,11 +45,60 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WritePropertyName("location"u8); writer.WriteStringValue(Location); + 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); + } + 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 TrackedResourceExtendedData DeserializeTrackedResourceExtendedData(JsonElement element) + TrackedResourceExtendedData 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(TrackedResourceExtendedData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrackedResourceExtendedData(document.RootElement, options); + } + + internal static TrackedResourceExtendedData DeserializeTrackedResourceExtendedData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -51,6 +110,8 @@ internal static TrackedResourceExtendedData DeserializeTrackedResourceExtendedDa string name = default; ResourceType type = default; Optional systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("extendedLocation"u8)) @@ -105,8 +166,44 @@ internal static TrackedResourceExtendedData DeserializeTrackedResourceExtendedDa systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new TrackedResourceExtendedData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, extendedLocation); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new TrackedResourceExtendedData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, extendedLocation, 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(TrackedResourceExtendedData)} does not support '{options.Format}' format."); + } + } + + TrackedResourceExtendedData 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 DeserializeTrackedResourceExtendedData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrackedResourceExtendedData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.cs index 3036401bf8a42..842e949e26efa 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.Resources.Models /// Specified resource. public partial class TrackedResourceExtendedData : TrackedResourceData { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// The location. public TrackedResourceExtendedData(AzureLocation location) : base(location) @@ -28,9 +61,16 @@ public TrackedResourceExtendedData(AzureLocation location) : base(location) /// The tags. /// The location. /// Resource extended location. - internal TrackedResourceExtendedData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ExtendedLocation extendedLocation) : base(id, name, resourceType, systemData, tags, location) + /// Keeps track of any properties unknown to the library. + internal TrackedResourceExtendedData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) { ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TrackedResourceExtendedData() + { } /// Resource extended location. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs index 00c02336fe1b7..7484ae1249548 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.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.Resources.Models { - public partial class ZoneMapping + public partial class ZoneMapping : IUtf8JsonSerializable, IJsonModel { - internal static ZoneMapping DeserializeZoneMapping(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(ZoneMapping)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.Value); + } + if (Optional.IsCollectionDefined(Zones)) + { + writer.WritePropertyName("zones"u8); + writer.WriteStartArray(); + foreach (var item in Zones) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ZoneMapping 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(ZoneMapping)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeZoneMapping(document.RootElement, options); + } + + internal static ZoneMapping DeserializeZoneMapping(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional location = default; Optional> zones = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("location"u8)) @@ -46,8 +108,44 @@ internal static ZoneMapping DeserializeZoneMapping(JsonElement element) zones = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ZoneMapping(Optional.ToNullable(location), Optional.ToList(zones)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ZoneMapping(Optional.ToNullable(location), Optional.ToList(zones), 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(ZoneMapping)} does not support '{options.Format}' format."); + } + } + + ZoneMapping 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 DeserializeZoneMapping(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ZoneMapping)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.cs index 2e47bcdbe4a06..8faf11bf30e07 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.Resources.Models /// The ZoneMapping. public partial class ZoneMapping { + /// + /// 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 ZoneMapping() { @@ -22,10 +55,12 @@ internal ZoneMapping() /// Initializes a new instance of . /// The location of the zone mapping. /// - internal ZoneMapping(AzureLocation? location, IReadOnlyList zones) + /// Keeps track of any properties unknown to the library. + internal ZoneMapping(AzureLocation? location, IReadOnlyList zones, IDictionary serializedAdditionalRawData) { Location = location; Zones = zones; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The location of the zone mapping. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.cs index d20b5335ede06..85ef3d303fa57 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.cs @@ -19,6 +19,38 @@ namespace Azure.ResourceManager.Resources /// public partial class PolicyAssignmentData : 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 . public PolicyAssignmentData() { @@ -47,7 +79,8 @@ public PolicyAssignmentData() /// The messages that describe why a resource is non-compliant with the policy. /// The resource selector list to filter policies by resource properties. /// The policy property value override. - internal PolicyAssignmentData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AzureLocation? location, ManagedServiceIdentity managedIdentity, string displayName, string policyDefinitionId, string scope, IList excludedScopes, IDictionary parameters, string description, BinaryData metadata, EnforcementMode? enforcementMode, IList nonComplianceMessages, IList resourceSelectors, IList overrides) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal PolicyAssignmentData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AzureLocation? location, ManagedServiceIdentity managedIdentity, string displayName, string policyDefinitionId, string scope, IList excludedScopes, IDictionary parameters, string description, BinaryData metadata, EnforcementMode? enforcementMode, IList nonComplianceMessages, IList resourceSelectors, IList overrides, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Location = location; ManagedIdentity = managedIdentity; @@ -62,6 +95,7 @@ internal PolicyAssignmentData(ResourceIdentifier id, string name, ResourceType r NonComplianceMessages = nonComplianceMessages; ResourceSelectors = resourceSelectors; Overrides = overrides; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The location of the policy assignment. Only required when utilizing managed identity. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.cs index 65105bc854333..e04bfe0a0a1e5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.cs @@ -19,6 +19,38 @@ namespace Azure.ResourceManager.Resources /// public partial class PolicyDefinitionData : 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 . public PolicyDefinitionData() { @@ -37,7 +69,8 @@ public PolicyDefinitionData() /// The policy rule. /// The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. /// The parameter definitions for parameters used in the policy rule. The keys are the parameter names. - internal PolicyDefinitionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, PolicyType? policyType, string mode, string displayName, string description, BinaryData policyRule, BinaryData metadata, IDictionary parameters) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal PolicyDefinitionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, PolicyType? policyType, string mode, string displayName, string description, BinaryData policyRule, BinaryData metadata, IDictionary parameters, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { PolicyType = policyType; Mode = mode; @@ -46,6 +79,7 @@ internal PolicyDefinitionData(ResourceIdentifier id, string name, ResourceType r PolicyRule = policyRule; Metadata = metadata; Parameters = parameters; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.cs index bacc0553b4d35..6ef0042b403c6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.cs @@ -19,6 +19,38 @@ namespace Azure.ResourceManager.Resources /// public partial class PolicySetDefinitionData : 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 . public PolicySetDefinitionData() { @@ -39,7 +71,8 @@ public PolicySetDefinitionData() /// The policy set definition parameters that can be used in policy definition references. /// An array of policy definition references. /// The metadata describing groups of policy definition references within the policy set definition. - internal PolicySetDefinitionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, PolicyType? policyType, string displayName, string description, BinaryData metadata, IDictionary parameters, IList policyDefinitions, IList policyDefinitionGroups) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal PolicySetDefinitionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, PolicyType? policyType, string displayName, string description, BinaryData metadata, IDictionary parameters, IList policyDefinitions, IList policyDefinitionGroups, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { PolicyType = policyType; DisplayName = displayName; @@ -48,6 +81,7 @@ internal PolicySetDefinitionData(ResourceIdentifier id, string name, ResourceTyp Parameters = parameters; PolicyDefinitions = policyDefinitions; PolicyDefinitionGroups = policyDefinitionGroups; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.cs index a7007c499ae9f..6459ab2281aa2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; @@ -18,6 +19,38 @@ namespace Azure.ResourceManager.Resources /// public partial class ResourceGroupData : TrackedResourceData { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// The location. public ResourceGroupData(AzureLocation location) : base(location) @@ -33,10 +66,17 @@ public ResourceGroupData(AzureLocation location) : base(location) /// The location. /// The resource group properties. /// The ID of the resource that manages this resource group. - internal ResourceGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ResourceGroupProperties properties, string managedBy) : base(id, name, resourceType, systemData, tags, location) + /// Keeps track of any properties unknown to the library. + internal ResourceGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ResourceGroupProperties properties, string managedBy, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) { Properties = properties; ManagedBy = managedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResourceGroupData() + { } /// The resource group properties. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceManagerModelFactory.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceManagerModelFactory.cs index f006fc3ef6179..676cc6d0732fb 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceManagerModelFactory.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceManagerModelFactory.cs @@ -45,7 +45,7 @@ public static PolicyAssignmentData PolicyAssignmentData(ResourceIdentifier id = resourceSelectors ??= new List(); overrides ??= new List(); - return new PolicyAssignmentData(id, name, resourceType, systemData, location, managedIdentity, displayName, policyDefinitionId, scope, excludedScopes?.ToList(), parameters, description, metadata, enforcementMode, nonComplianceMessages?.ToList(), resourceSelectors?.ToList(), overrides?.ToList()); + return new PolicyAssignmentData(id, name, resourceType, systemData, location, managedIdentity, displayName, policyDefinitionId, scope, excludedScopes?.ToList(), parameters, description, metadata, enforcementMode, nonComplianceMessages?.ToList(), resourceSelectors?.ToList(), overrides?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -65,7 +65,7 @@ public static PolicyDefinitionData PolicyDefinitionData(ResourceIdentifier id = { parameters ??= new Dictionary(); - return new PolicyDefinitionData(id, name, resourceType, systemData, policyType, mode, displayName, description, policyRule, metadata, parameters); + return new PolicyDefinitionData(id, name, resourceType, systemData, policyType, mode, displayName, description, policyRule, metadata, parameters, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -87,7 +87,7 @@ public static PolicySetDefinitionData PolicySetDefinitionData(ResourceIdentifier policyDefinitions ??= new List(); policyDefinitionGroups ??= new List(); - return new PolicySetDefinitionData(id, name, resourceType, systemData, policyType, displayName, description, metadata, parameters, policyDefinitions?.ToList(), policyDefinitionGroups?.ToList()); + return new PolicySetDefinitionData(id, name, resourceType, systemData, policyType, displayName, description, metadata, parameters, policyDefinitions?.ToList(), policyDefinitionGroups?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -113,7 +113,7 @@ public static DataPolicyManifestData DataPolicyManifestData(ResourceIdentifier i standard ??= new List(); customDefinitions ??= new List(); - return new DataPolicyManifestData(id, name, resourceType, systemData, namespaces?.ToList(), policyMode, isBuiltInOnly, resourceTypeAliases?.ToList(), effects?.ToList(), fieldValues?.ToList(), standard?.ToList(), customDefinitions?.ToList()); + return new DataPolicyManifestData(id, name, resourceType, systemData, namespaces?.ToList(), policyMode, isBuiltInOnly, resourceTypeAliases?.ToList(), effects?.ToList(), fieldValues?.ToList(), standard?.ToList(), customDefinitions?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -124,7 +124,7 @@ public static ResourceTypeAliases ResourceTypeAliases(string resourceType = null { aliases ??= new List(); - return new ResourceTypeAliases(resourceType, aliases?.ToList()); + return new ResourceTypeAliases(resourceType, aliases?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -139,7 +139,7 @@ public static ResourceTypeAlias ResourceTypeAlias(string name = null, IEnumerabl { paths ??= new List(); - return new ResourceTypeAlias(name, paths?.ToList(), aliasType, defaultPath, defaultPattern, defaultMetadata); + return new ResourceTypeAlias(name, paths?.ToList(), aliasType, defaultPath, defaultPattern, defaultMetadata, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -152,7 +152,7 @@ public static ResourceTypeAliasPath ResourceTypeAliasPath(string path = null, IE { apiVersions ??= new List(); - return new ResourceTypeAliasPath(path, apiVersions?.ToList(), pattern, metadata); + return new ResourceTypeAliasPath(path, apiVersions?.ToList(), pattern, metadata, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -162,7 +162,7 @@ public static ResourceTypeAliasPath ResourceTypeAliasPath(string path = null, IE /// A new instance for mocking. public static ResourceTypeAliasPattern ResourceTypeAliasPattern(string phrase = null, string variable = null, ResourceTypeAliasPatternType? patternType = null) { - return new ResourceTypeAliasPattern(phrase, variable, patternType); + return new ResourceTypeAliasPattern(phrase, variable, patternType, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -171,7 +171,7 @@ public static ResourceTypeAliasPattern ResourceTypeAliasPattern(string phrase = /// A new instance for mocking. public static ResourceTypeAliasPathMetadata ResourceTypeAliasPathMetadata(ResourceTypeAliasPathTokenType? tokenType = null, ResourceTypeAliasPathAttributes? attributes = null) { - return new ResourceTypeAliasPathMetadata(tokenType, attributes); + return new ResourceTypeAliasPathMetadata(tokenType, attributes, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -180,7 +180,7 @@ public static ResourceTypeAliasPathMetadata ResourceTypeAliasPathMetadata(Resour /// A new instance for mocking. public static DataPolicyManifestEffect DataPolicyManifestEffect(string name = null, BinaryData detailsSchema = null) { - return new DataPolicyManifestEffect(name, detailsSchema); + return new DataPolicyManifestEffect(name, detailsSchema, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -193,7 +193,7 @@ public static DataManifestCustomResourceFunctionDefinition DataManifestCustomRes { defaultProperties ??= new List(); - return new DataManifestCustomResourceFunctionDefinition(name, fullyQualifiedResourceType, defaultProperties?.ToList(), allowCustomProperties); + return new DataManifestCustomResourceFunctionDefinition(name, fullyQualifiedResourceType, defaultProperties?.ToList(), allowCustomProperties, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -209,7 +209,7 @@ public static ManagementLockData ManagementLockData(ResourceIdentifier id = null { owners ??= new List(); - return new ManagementLockData(id, name, resourceType, systemData, level, notes, owners?.ToList()); + return new ManagementLockData(id, name, resourceType, systemData, level, notes, owners?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -224,7 +224,7 @@ public static ResourceProviderData ResourceProviderData(ResourceIdentifier id = { resourceTypes ??= new List(); - return new ResourceProviderData(id, @namespace, registrationState, registrationPolicy, resourceTypes?.ToList(), providerAuthorizationConsentState); + return new ResourceProviderData(id, @namespace, registrationState, registrationPolicy, resourceTypes?.ToList(), providerAuthorizationConsentState, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -249,7 +249,7 @@ public static ProviderResourceType ProviderResourceType(string resourceType = nu apiProfiles ??= new List(); properties ??= new Dictionary(); - return new ProviderResourceType(resourceType, locations?.ToList(), locationMappings?.ToList(), aliases?.ToList(), apiVersions?.ToList(), defaultApiVersion, zoneMappings?.ToList(), apiProfiles?.ToList(), capabilities, properties); + return new ProviderResourceType(resourceType, locations?.ToList(), locationMappings?.ToList(), aliases?.ToList(), apiVersions?.ToList(), defaultApiVersion, zoneMappings?.ToList(), apiProfiles?.ToList(), capabilities, properties, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -261,7 +261,7 @@ public static ProviderExtendedLocation ProviderExtendedLocation(AzureLocation? l { extendedLocations ??= new List(); - return new ProviderExtendedLocation(location, providerExtendedLocationType, extendedLocations?.ToList()); + return new ProviderExtendedLocation(location, providerExtendedLocationType, extendedLocations?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -272,7 +272,7 @@ public static ZoneMapping ZoneMapping(AzureLocation? location = null, IEnumerabl { zones ??= new List(); - return new ZoneMapping(location, zones?.ToList()); + return new ZoneMapping(location, zones?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -281,7 +281,7 @@ public static ZoneMapping ZoneMapping(AzureLocation? location = null, IEnumerabl /// A new instance for mocking. public static ApiProfile ApiProfile(string profileVersion = null, string apiVersion = null) { - return new ApiProfile(profileVersion, apiVersion); + return new ApiProfile(profileVersion, apiVersion, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -292,7 +292,7 @@ public static ApiProfile ApiProfile(string profileVersion = null, string apiVers /// A new instance for mocking. public static ProviderPermission ProviderPermission(string applicationId = null, AzureRoleDefinition roleDefinition = null, AzureRoleDefinition managedByRoleDefinition = null, ProviderAuthorizationConsentState? providerAuthorizationConsentState = null) { - return new ProviderPermission(applicationId, roleDefinition, managedByRoleDefinition, providerAuthorizationConsentState); + return new ProviderPermission(applicationId, roleDefinition, managedByRoleDefinition, providerAuthorizationConsentState, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -307,7 +307,7 @@ public static AzureRoleDefinition AzureRoleDefinition(string id = null, string n permissions ??= new List(); scopes ??= new List(); - return new AzureRoleDefinition(id, name, isServiceRole, permissions?.ToList(), scopes?.ToList()); + return new AzureRoleDefinition(id, name, isServiceRole, permissions?.ToList(), scopes?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -323,7 +323,7 @@ public static Permission Permission(IEnumerable allowedActions = null, I allowedDataActions ??= new List(); deniedDataActions ??= new List(); - return new Permission(allowedActions?.ToList(), deniedActions?.ToList(), allowedDataActions?.ToList(), deniedDataActions?.ToList()); + return new Permission(allowedActions?.ToList(), deniedActions?.ToList(), allowedDataActions?.ToList(), deniedDataActions?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -334,7 +334,7 @@ public static TenantResourceProvider TenantResourceProvider(string @namespace = { resourceTypes ??= new List(); - return new TenantResourceProvider(@namespace, resourceTypes?.ToList()); + return new TenantResourceProvider(@namespace, resourceTypes?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -359,7 +359,7 @@ public static GenericResourceData GenericResourceData(ResourceIdentifier id = nu { tags ??= new Dictionary(); - return new GenericResourceData(id, name, resourceType, systemData, tags, location, extendedLocation, plan, properties, kind, managedBy, sku, identity, createdOn, changedOn, provisioningState); + return new GenericResourceData(id, name, resourceType, systemData, tags, location, extendedLocation, serializedAdditionalRawData: null, plan, properties, kind, managedBy, sku, identity, createdOn, changedOn, provisioningState); } /// Initializes a new instance of . @@ -375,7 +375,7 @@ public static TrackedResourceExtendedData TrackedResourceExtendedData(ResourceId { tags ??= new Dictionary(); - return new TrackedResourceExtendedData(id, name, resourceType, systemData, tags, location, extendedLocation); + return new TrackedResourceExtendedData(id, name, resourceType, systemData, tags, location, extendedLocation, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -392,7 +392,7 @@ public static ResourceGroupData ResourceGroupData(ResourceIdentifier id = null, { tags ??= new Dictionary(); - return new ResourceGroupData(id, name, resourceType, systemData, tags, location, resourceGroupProvisioningState != null ? new ResourceGroupProperties(resourceGroupProvisioningState) : null, managedBy); + return new ResourceGroupData(id, name, resourceType, systemData, tags, location, resourceGroupProvisioningState != null ? new ResourceGroupProperties(resourceGroupProvisioningState, serializedAdditionalRawData: null) : null, managedBy, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -401,7 +401,7 @@ public static ResourceGroupData ResourceGroupData(ResourceIdentifier id = null, /// A new instance for mocking. public static ResourceGroupExportResult ResourceGroupExportResult(BinaryData template = null, ResponseError error = null) { - return new ResourceGroupExportResult(template, error); + return new ResourceGroupExportResult(template, error, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -411,7 +411,7 @@ public static ResourceGroupExportResult ResourceGroupExportResult(BinaryData tem /// A new instance for mocking. public static PredefinedTagValue PredefinedTagValue(string id = null, string tagValue = null, PredefinedTagCount count = null) { - return new PredefinedTagValue(id, tagValue, count); + return new PredefinedTagValue(id, tagValue, count, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -420,7 +420,7 @@ public static PredefinedTagValue PredefinedTagValue(string id = null, string tag /// A new instance for mocking. public static PredefinedTagCount PredefinedTagCount(string predefinedTagCountType = null, int? value = null) { - return new PredefinedTagCount(predefinedTagCountType, value); + return new PredefinedTagCount(predefinedTagCountType, value, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -433,7 +433,7 @@ public static PredefinedTag PredefinedTag(string id = null, string tagName = nul { values ??= new List(); - return new PredefinedTag(id, tagName, count, values?.ToList()); + return new PredefinedTag(id, tagName, count, values?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -447,7 +447,7 @@ public static TagResourceData TagResourceData(ResourceIdentifier id = null, stri { tagValues ??= new Dictionary(); - return new TagResourceData(id, name, resourceType, systemData, tagValues != null ? new Tag(tagValues) : null); + return new TagResourceData(id, name, resourceType, systemData, tagValues != null ? new Tag(tagValues, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -464,7 +464,7 @@ public static LocationExpanded LocationExpanded(string id = null, string subscri { availabilityZoneMappings ??= new List(); - return new LocationExpanded(id, subscriptionId, name, locationType, displayName, regionalDisplayName, metadata, availabilityZoneMappings?.ToList()); + return new LocationExpanded(id, subscriptionId, name, locationType, displayName, regionalDisplayName, metadata, availabilityZoneMappings?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -482,7 +482,7 @@ public static LocationMetadata LocationMetadata(RegionType? regionType = null, R { pairedRegions ??= new List(); - return new LocationMetadata(regionType, regionCategory, geography, geographyGroup, longitude, latitude, physicalLocation, pairedRegions?.ToList(), homeLocation); + return new LocationMetadata(regionType, regionCategory, geography, geographyGroup, longitude, latitude, physicalLocation, pairedRegions?.ToList(), homeLocation, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -492,7 +492,7 @@ public static LocationMetadata LocationMetadata(RegionType? regionType = null, R /// A new instance for mocking. public static PairedRegion PairedRegion(string name = null, string id = null, string subscriptionId = null) { - return new PairedRegion(name, id, subscriptionId); + return new PairedRegion(name, id, subscriptionId, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -501,7 +501,7 @@ public static PairedRegion PairedRegion(string name = null, string id = null, st /// A new instance for mocking. public static AvailabilityZoneMappings AvailabilityZoneMappings(string logicalZone = null, string physicalZone = null) { - return new AvailabilityZoneMappings(logicalZone, physicalZone); + return new AvailabilityZoneMappings(logicalZone, physicalZone, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -520,7 +520,7 @@ public static SubscriptionData SubscriptionData(ResourceIdentifier id = null, st managedByTenants ??= new List(); tags ??= new Dictionary(); - return new SubscriptionData(id, subscriptionId, displayName, tenantId, state, subscriptionPolicies, authorizationSource, managedByTenants?.ToList(), tags); + return new SubscriptionData(id, subscriptionId, displayName, tenantId, state, subscriptionPolicies, authorizationSource, managedByTenants?.ToList(), tags, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -530,7 +530,7 @@ public static SubscriptionData SubscriptionData(ResourceIdentifier id = null, st /// A new instance for mocking. public static SubscriptionPolicies SubscriptionPolicies(string locationPlacementId = null, string quotaId = null, SpendingLimit? spendingLimit = null) { - return new SubscriptionPolicies(locationPlacementId, quotaId, spendingLimit); + return new SubscriptionPolicies(locationPlacementId, quotaId, spendingLimit, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -538,7 +538,7 @@ public static SubscriptionPolicies SubscriptionPolicies(string locationPlacement /// A new instance for mocking. public static ManagedByTenant ManagedByTenant(Guid? tenantId = null) { - return new ManagedByTenant(tenantId); + return new ManagedByTenant(tenantId, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -557,7 +557,7 @@ public static TenantData TenantData(string id = null, Guid? tenantId = null, Ten { domains ??= new List(); - return new TenantData(id, tenantId, tenantCategory, country, countryCode, displayName, domains?.ToList(), defaultDomain, tenantType, tenantBrandingLogoUri); + return new TenantData(id, tenantId, tenantCategory, country, countryCode, displayName, domains?.ToList(), defaultDomain, tenantType, tenantBrandingLogoUri, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -569,7 +569,7 @@ public static TenantData TenantData(string id = null, Guid? tenantId = null, Ten /// A new instance for mocking. public static FeatureData FeatureData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string featureState = null) { - return new FeatureData(id, name, resourceType, systemData, featureState != null ? new FeatureProperties(featureState) : null); + return new FeatureData(id, name, resourceType, systemData, featureState != null ? new FeatureProperties(featureState, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.cs index 1a6194f24b03c..f55aac05fec99 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -17,6 +18,56 @@ namespace Azure.ResourceManager.Resources /// public partial class ResourceProviderData { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The provider ID. + /// The namespace of the resource provider. + /// The registration state of the resource provider. + /// The registration policy of the resource provider. + /// The collection of provider resource types. + /// The provider authorization consent state. + /// Keeps track of any properties unknown to the library. + internal ResourceProviderData(ResourceIdentifier id, string @namespace, string registrationState, string registrationPolicy, IReadOnlyList resourceTypes, ProviderAuthorizationConsentState? providerAuthorizationConsentState, IDictionary serializedAdditionalRawData) + { + Id = id; + Namespace = @namespace; + RegistrationState = registrationState; + RegistrationPolicy = registrationPolicy; + ResourceTypes = resourceTypes; + ProviderAuthorizationConsentState = providerAuthorizationConsentState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } /// The namespace of the resource provider. public string Namespace { get; } /// The registration state of the resource provider. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderResource.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderResource.cs index 107b4038ace09..e2e317c6dc5d9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderResource.cs @@ -347,7 +347,7 @@ public virtual Response Unregister(CancellationToken c public virtual AsyncPageable ProviderPermissionsAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => _resourceProviderProvidersRestClient.CreateProviderPermissionsRequest(Id.SubscriptionId, Id.Provider); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, ProviderPermission.DeserializeProviderPermission, _resourceProviderProvidersClientDiagnostics, Pipeline, "ResourceProviderResource.ProviderPermissions", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => ProviderPermission.DeserializeProviderPermission(e), _resourceProviderProvidersClientDiagnostics, Pipeline, "ResourceProviderResource.ProviderPermissions", "value", null, cancellationToken); } /// @@ -376,7 +376,7 @@ public virtual AsyncPageable ProviderPermissionsAsync(Cancel public virtual Pageable ProviderPermissions(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => _resourceProviderProvidersRestClient.CreateProviderPermissionsRequest(Id.SubscriptionId, Id.Provider); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, ProviderPermission.DeserializeProviderPermission, _resourceProviderProvidersClientDiagnostics, Pipeline, "ResourceProviderResource.ProviderPermissions", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => ProviderPermission.DeserializeProviderPermission(e), _resourceProviderProvidersClientDiagnostics, Pipeline, "ResourceProviderResource.ProviderPermissions", "value", null, cancellationToken); } /// @@ -480,7 +480,7 @@ public virtual Response Register(ProviderRegistrationC public virtual AsyncPageable GetProviderResourceTypesAsync(string expand = null, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => _providerResourceTypesRestClient.CreateListRequest(Id.SubscriptionId, Id.Provider, expand); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, ProviderResourceType.DeserializeProviderResourceType, _providerResourceTypesClientDiagnostics, Pipeline, "ResourceProviderResource.GetProviderResourceTypes", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => ProviderResourceType.DeserializeProviderResourceType(e), _providerResourceTypesClientDiagnostics, Pipeline, "ResourceProviderResource.GetProviderResourceTypes", "value", null, cancellationToken); } /// @@ -506,7 +506,7 @@ public virtual AsyncPageable GetProviderResourceTypesAsync public virtual Pageable GetProviderResourceTypes(string expand = null, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => _providerResourceTypesRestClient.CreateListRequest(Id.SubscriptionId, Id.Provider, expand); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, ProviderResourceType.DeserializeProviderResourceType, _providerResourceTypesClientDiagnostics, Pipeline, "ResourceProviderResource.GetProviderResourceTypes", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => ProviderResourceType.DeserializeProviderResourceType(e), _providerResourceTypesClientDiagnostics, Pipeline, "ResourceProviderResource.GetProviderResourceTypes", "value", null, cancellationToken); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.cs index 3a4652fbc3b02..bd4f09422e15a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.cs @@ -18,6 +18,38 @@ namespace Azure.ResourceManager.Resources /// public partial class SubscriptionData { + /// + /// 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 SubscriptionData() { @@ -35,7 +67,8 @@ internal SubscriptionData() /// The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. /// An array containing the tenants managing the subscription. /// The tags attached to the subscription. - internal SubscriptionData(ResourceIdentifier id, string subscriptionId, string displayName, Guid? tenantId, SubscriptionState? state, SubscriptionPolicies subscriptionPolicies, string authorizationSource, IReadOnlyList managedByTenants, IReadOnlyDictionary tags) + /// Keeps track of any properties unknown to the library. + internal SubscriptionData(ResourceIdentifier id, string subscriptionId, string displayName, Guid? tenantId, SubscriptionState? state, SubscriptionPolicies subscriptionPolicies, string authorizationSource, IReadOnlyList managedByTenants, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) { Id = id; SubscriptionId = subscriptionId; @@ -46,6 +79,7 @@ internal SubscriptionData(ResourceIdentifier id, string subscriptionId, string d AuthorizationSource = authorizationSource; ManagedByTenants = managedByTenants; Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The subscription ID. public string SubscriptionId { get; } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionResource.cs index 466f3ab4e5639..c7185609c60d5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionResource.cs @@ -809,7 +809,7 @@ public virtual AsyncPageable GetAllPredefinedTagsAsync(Cancellati { HttpMessage FirstPageRequest(int? pageSizeHint) => _subscriptionTagsRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _subscriptionTagsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, PredefinedTag.DeserializePredefinedTag, _subscriptionTagsClientDiagnostics, Pipeline, "SubscriptionResource.GetAllPredefinedTags", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => PredefinedTag.DeserializePredefinedTag(e), _subscriptionTagsClientDiagnostics, Pipeline, "SubscriptionResource.GetAllPredefinedTags", "value", "nextLink", cancellationToken); } /// @@ -839,7 +839,7 @@ public virtual Pageable GetAllPredefinedTags(CancellationToken ca { HttpMessage FirstPageRequest(int? pageSizeHint) => _subscriptionTagsRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _subscriptionTagsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, PredefinedTag.DeserializePredefinedTag, _subscriptionTagsClientDiagnostics, Pipeline, "SubscriptionResource.GetAllPredefinedTags", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => PredefinedTag.DeserializePredefinedTag(e), _subscriptionTagsClientDiagnostics, Pipeline, "SubscriptionResource.GetAllPredefinedTags", "value", "nextLink", cancellationToken); } /// @@ -869,7 +869,7 @@ public virtual Pageable GetAllPredefinedTags(CancellationToken ca public virtual AsyncPageable GetLocationsAsync(bool? includeExtendedLocations = null, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => _subscriptionRestClient.CreateListLocationsRequest(Id.SubscriptionId, includeExtendedLocations); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, LocationExpanded.DeserializeLocationExpanded, _subscriptionClientDiagnostics, Pipeline, "SubscriptionResource.GetLocations", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => LocationExpanded.DeserializeLocationExpanded(e), _subscriptionClientDiagnostics, Pipeline, "SubscriptionResource.GetLocations", "value", null, cancellationToken); } /// @@ -899,7 +899,7 @@ public virtual AsyncPageable GetLocationsAsync(bool? includeEx public virtual Pageable GetLocations(bool? includeExtendedLocations = null, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => _subscriptionRestClient.CreateListLocationsRequest(Id.SubscriptionId, includeExtendedLocations); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, LocationExpanded.DeserializeLocationExpanded, _subscriptionClientDiagnostics, Pipeline, "SubscriptionResource.GetLocations", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => LocationExpanded.DeserializeLocationExpanded(e), _subscriptionClientDiagnostics, Pipeline, "SubscriptionResource.GetLocations", "value", null, cancellationToken); } /// diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.cs index bfb4571b162e2..38ff04f76eb77 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.cs @@ -19,6 +19,38 @@ namespace Azure.ResourceManager.Resources /// public partial class TagResourceData : 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 . /// The set of tags. /// is null. @@ -35,9 +67,16 @@ public TagResourceData(Tag properties) /// The resourceType. /// The systemData. /// The set of tags. - internal TagResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, Tag properties) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal TagResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, Tag properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TagResourceData() + { } /// The set of tags. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.cs index c581e8ee9db0c..9a5100a772488 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.cs @@ -18,6 +18,38 @@ namespace Azure.ResourceManager.Resources /// public partial class TenantData { + /// + /// 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 TenantData() { @@ -35,7 +67,8 @@ internal TenantData() /// The default domain for the tenant. /// The tenant type. Only available for 'Home' tenant category. /// The tenant's branding logo URL. Only available for 'Home' tenant category. - internal TenantData(string id, Guid? tenantId, TenantCategory? tenantCategory, string country, string countryCode, string displayName, IReadOnlyList domains, string defaultDomain, string tenantType, Uri tenantBrandingLogoUri) + /// Keeps track of any properties unknown to the library. + internal TenantData(string id, Guid? tenantId, TenantCategory? tenantCategory, string country, string countryCode, string displayName, IReadOnlyList domains, string defaultDomain, string tenantType, Uri tenantBrandingLogoUri, IDictionary serializedAdditionalRawData) { Id = id; TenantId = tenantId; @@ -47,6 +80,7 @@ internal TenantData(string id, Guid? tenantId, TenantCategory? tenantCategory, s DefaultDomain = defaultDomain; TenantType = tenantType; TenantBrandingLogoUri = tenantBrandingLogoUri; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The fully qualified ID of the tenant. For example, /tenants/8d65815f-a5b6-402f-9298-045155da7d74. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantResource.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantResource.cs index f4507b05f7c37..ea430d98e8d3d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantResource.cs @@ -391,7 +391,7 @@ public virtual AsyncPageable GetTenantResourceProvidersA { HttpMessage FirstPageRequest(int? pageSizeHint) => _resourceProviderProvidersRestClient.CreateListAtTenantScopeRequest(expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceProviderProvidersRestClient.CreateListAtTenantScopeNextPageRequest(nextLink, expand); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, TenantResourceProvider.DeserializeTenantResourceProvider, _resourceProviderProvidersClientDiagnostics, Pipeline, "TenantResource.GetTenantResourceProviders", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TenantResourceProvider.DeserializeTenantResourceProvider(e), _resourceProviderProvidersClientDiagnostics, Pipeline, "TenantResource.GetTenantResourceProviders", "value", "nextLink", cancellationToken); } /// @@ -422,7 +422,7 @@ public virtual Pageable GetTenantResourceProviders(strin { HttpMessage FirstPageRequest(int? pageSizeHint) => _resourceProviderProvidersRestClient.CreateListAtTenantScopeRequest(expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceProviderProvidersRestClient.CreateListAtTenantScopeNextPageRequest(nextLink, expand); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, TenantResourceProvider.DeserializeTenantResourceProvider, _resourceProviderProvidersClientDiagnostics, Pipeline, "TenantResource.GetTenantResourceProviders", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TenantResourceProvider.DeserializeTenantResourceProvider(e), _resourceProviderProvidersClientDiagnostics, Pipeline, "TenantResource.GetTenantResourceProviders", "value", "nextLink", cancellationToken); } /// diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md b/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md index 21a6fd3c8378a..4a51affd763b5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md +++ b/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md @@ -12,6 +12,7 @@ public-clients: false head-as-boolean: false modelerfour: lenient-model-deduplication: true +use-model-reader-writer: true deserialize-null-collection-as-null-value: true # mgmt-debug: @@ -279,9 +280,6 @@ acronym-mapping: SSO: Sso URI: Uri -# mgmt-debug: -# show-serialized-names: true - rename-mapping: PolicyAssignment.identity: ManagedIdentity Override: PolicyOverride diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Azure.ResourceManager.Tests.csproj b/sdk/resourcemanager/Azure.ResourceManager/tests/Azure.ResourceManager.Tests.csproj index 0fe82886dacfd..a71119a0c486e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Azure.ResourceManager.Tests.csproj +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Azure.ResourceManager.Tests.csproj @@ -31,7 +31,7 @@ - + diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/ModelReaderWriterImplementationValidation.Exceptions.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/ModelReaderWriterImplementationValidation.Exceptions.cs new file mode 100644 index 0000000000000..fb0321809ae5f --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/ModelReaderWriterImplementationValidation.Exceptions.cs @@ -0,0 +1,20 @@ +// 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.Resources.Models.SubResource", + "Azure.ResourceManager.Resources.Models.WritableSubResource", + "Azure.ResourceManager.Models.ManagedServiceIdentity", // TODO -- we should remove this when we support it + "Azure.ResourceManager.Models.ResourceData", + "Azure.ResourceManager.Models.TrackedResourceData" + }; + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/LocationExpandedTests.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/LocationExpandedTests.cs index e6eb15bff1e4b..7f9e81ff40bd6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/LocationExpandedTests.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/LocationExpandedTests.cs @@ -20,7 +20,6 @@ public async Task VerifyMetadata() await foreach (LocationExpanded loc in listLocs) { Assert.IsNotNull(loc.Metadata); - Assert.IsNotNull(loc.SubscriptionId); Assert.IsNotNull(loc.RegionalDisplayName); AzureLocation locStruct = loc; diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/SubscriptionOperationsTests.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/SubscriptionOperationsTests.cs index 419c70facedbd..39033f37d8e57 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/SubscriptionOperationsTests.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/SubscriptionOperationsTests.cs @@ -140,7 +140,6 @@ public async Task TestListLocations() var location = locations.First(); Assert.IsNotNull(location.Metadata, "Metadata was null"); Assert.IsNotNull(location.Id, "Id was null"); - Assert.AreEqual(subOps.Id.SubscriptionId, location.SubscriptionId); } [RecordedTest] diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/GenericResourceDataTests.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/GenericResourceDataTests.cs index 7bc2996598de8..6db53c708a048 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/GenericResourceDataTests.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/GenericResourceDataTests.cs @@ -22,8 +22,8 @@ public void SerializationTestType1() string expected = File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "Unit", "TestAssets", "GenericResourceData", "SerializationTestType1.json")); ResourceIdentifier id = new ResourceIdentifier(Id); ArmPlan plan = new ArmPlan("NameForPlan", "PublisherForPlan", "ProductForPlan", "PromotionCodeForPlan", "VersionForPlan"); - ResourcesSku sku = new ResourcesSku("NameForSku", ArmSkuTier.Basic.ToString(), "SizeForSku", "FamilyForSku", "ModelForSku", 15464547); - GenericResourceData data = new GenericResourceData(id, id.Name, id.ResourceType, null, new Dictionary(), AzureLocation.EastUS, null, plan, null, "KindForResource", "ManagedByForResource", sku, null, null, null, null); + ResourcesSku sku = new ResourcesSku("NameForSku", ArmSkuTier.Basic.ToString(), "SizeForSku", "FamilyForSku", "ModelForSku", 15464547, null); + GenericResourceData data = new GenericResourceData(id, id.Name, id.ResourceType, null, new Dictionary(), AzureLocation.EastUS, null, null, plan, null, "KindForResource", "ManagedByForResource", sku, null, null, null, null); var json = JsonHelper.SerializePropertiesToString(data, indented: true) + Environment.NewLine; Assert.AreEqual(expected, json); @@ -37,8 +37,8 @@ public void SerializationTestType2() var plan = new ArmPlan("NameForPlan", "PublisherForPlan", "ProductForPlan", "PromotionCodeForPlan", "VersionForPlan"); var kind = "KindForResource"; var managedBy = "ManagedByForResource"; - var sku = new ResourcesSku("NameForSku", ArmSkuTier.Basic.ToString(), "SizeForSku", "FamilyForSku", "ModelForSku", 15464547); - GenericResourceData genericResource = new GenericResourceData(id, id.Name, id.ResourceType, null, new Dictionary(), AzureLocation.EastUS, null, plan, null, kind, managedBy, sku, null, null, null, null); + var sku = new ResourcesSku("NameForSku", ArmSkuTier.Basic.ToString(), "SizeForSku", "FamilyForSku", "ModelForSku", 15464547, null); + GenericResourceData genericResource = new GenericResourceData(id, id.Name, id.ResourceType, null, new Dictionary(), AzureLocation.EastUS, null, null, plan, null, kind, managedBy, sku, null, null, null, null); genericResource.Tags.Add("key1", "value1"); genericResource.Tags.Add("key2", "value2"); @@ -51,7 +51,7 @@ public void InvalidSerializationTest() { string expected = "{\"properties\":{\"tags\":{},\"location\":\"eastus\"}}"; ResourceIdentifier id = new ResourceIdentifier(Id); - GenericResourceData data = new GenericResourceData(id, id.Name, id.ResourceType, null, new Dictionary(), AzureLocation.EastUS, null, null, null, null, null, null, null, null, null, null); + GenericResourceData data = new GenericResourceData(id, id.Name, id.ResourceType, null, new Dictionary(), AzureLocation.EastUS, null, null, null, null, null, null, null, null, null, null, null); var json = JsonHelper.SerializePropertiesToString(data); Assert.AreEqual(expected, json); diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/ManagedServiceIdentityTest.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/ManagedServiceIdentityTest.cs index a3540759d8761..6e9b9de4917f7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/ManagedServiceIdentityTest.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/ManagedServiceIdentityTest.cs @@ -34,7 +34,7 @@ public void TestDeserializerInvalidDefaultJson() public void TestDeserializerInvalidNullType() { var identityJsonProperty = DeserializerHelper("InvalidTypeIsNull.json"); - Assert.Throws(delegate { ManagedServiceIdentity.DeserializeManagedServiceIdentity(identityJsonProperty.Value); }); + Assert.AreEqual(default(ManagedServiceIdentityType), ManagedServiceIdentity.DeserializeManagedServiceIdentity(identityJsonProperty.Value).ManagedServiceIdentityType); } [TestCase] @@ -52,12 +52,9 @@ public void TestDeserializerInvalidType() public void TestDeserializerNoneWithEmptyStringIds() { var identityJsonProperty = DeserializerHelper("NoneEmptyStringIds.json"); -#if DEBUG - Assert.Throws(delegate { ManagedServiceIdentity.DeserializeManagedServiceIdentity(identityJsonProperty.Value); }); -#else - ManagedServiceIdentity back = ManagedServiceIdentity.DeserializeManagedServiceIdentity(identityJsonProperty.Value); - Assert.AreEqual(ManagedServiceIdentityType.None, back.ManagedServiceIdentityType); -#endif + var msi = ManagedServiceIdentity.DeserializeManagedServiceIdentity(identityJsonProperty.Value); + Assert.IsNull(msi.PrincipalId); + Assert.IsNull(msi.TenantId); } [TestCase] diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/ResourceListOperationsTest.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/ResourceListOperationsTest.cs index 8dbc2e0981583..ecf1aa333016d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/ResourceListOperationsTest.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/ResourceListOperationsTest.cs @@ -18,7 +18,7 @@ private static ArmPlan GetPlan() private static ResourcesSku GetSku() { - return new ResourcesSku("name", ArmSkuTier.Basic.ToString(), "size", "family", "model", 10); + return new ResourcesSku("name", ArmSkuTier.Basic.ToString(), "size", "family", "model", 10, null); } private static GenericResourceData GetGenericResource() @@ -41,7 +41,7 @@ private static GenericResourceData GetGenericResource( string location) { ResourceIdentifier id = new ResourceIdentifier($"/subscriptions/{Guid.NewGuid()}/resourceGroups/myResourceGroup/providers/Microsoft.Widgets/widgets/myWidget"); - return new GenericResourceData(id, id.Name, id.ResourceType, null, tags, location, null, plan, null, kind, managedBy, sku, null, null, null, null); + return new GenericResourceData(id, id.Name, id.ResourceType, null, tags, location, null, null, plan, null, kind, managedBy, sku, null, null, null, null); } } }