| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Resources.Models |
| | 13 | | { |
| | 14 | | public partial class PolicyDefinitionReference : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 36 | 18 | | writer.WriteStartObject(); |
| 36 | 19 | | writer.WritePropertyName("policyDefinitionId"); |
| 36 | 20 | | writer.WriteStringValue(PolicyDefinitionId); |
| 36 | 21 | | if (Parameters != null) |
| | 22 | | { |
| 8 | 23 | | writer.WritePropertyName("parameters"); |
| 8 | 24 | | writer.WriteStartObject(); |
| 32 | 25 | | foreach (var item in Parameters) |
| | 26 | | { |
| 8 | 27 | | writer.WritePropertyName(item.Key); |
| 8 | 28 | | writer.WriteObjectValue(item.Value); |
| | 29 | | } |
| 8 | 30 | | writer.WriteEndObject(); |
| | 31 | | } |
| 36 | 32 | | if (PolicyDefinitionReferenceId != null) |
| | 33 | | { |
| 8 | 34 | | writer.WritePropertyName("policyDefinitionReferenceId"); |
| 8 | 35 | | writer.WriteStringValue(PolicyDefinitionReferenceId); |
| | 36 | | } |
| 36 | 37 | | if (GroupNames != null) |
| | 38 | | { |
| 8 | 39 | | writer.WritePropertyName("groupNames"); |
| 8 | 40 | | writer.WriteStartArray(); |
| 40 | 41 | | foreach (var item in GroupNames) |
| | 42 | | { |
| 12 | 43 | | writer.WriteStringValue(item); |
| | 44 | | } |
| 8 | 45 | | writer.WriteEndArray(); |
| | 46 | | } |
| 36 | 47 | | writer.WriteEndObject(); |
| 36 | 48 | | } |
| | 49 | |
|
| | 50 | | internal static PolicyDefinitionReference DeserializePolicyDefinitionReference(JsonElement element) |
| | 51 | | { |
| 66772 | 52 | | string policyDefinitionId = default; |
| 66772 | 53 | | IDictionary<string, ParameterValuesValue> parameters = default; |
| 66772 | 54 | | string policyDefinitionReferenceId = default; |
| 66772 | 55 | | IList<string> groupNames = default; |
| 595752 | 56 | | foreach (var property in element.EnumerateObject()) |
| | 57 | | { |
| 231104 | 58 | | if (property.NameEquals("policyDefinitionId")) |
| | 59 | | { |
| 66772 | 60 | | policyDefinitionId = property.Value.GetString(); |
| 66772 | 61 | | continue; |
| | 62 | | } |
| 164332 | 63 | | if (property.NameEquals("parameters")) |
| | 64 | | { |
| 64104 | 65 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 66 | | { |
| | 67 | | continue; |
| | 68 | | } |
| 64104 | 69 | | Dictionary<string, ParameterValuesValue> dictionary = new Dictionary<string, ParameterValuesValue>() |
| 164640 | 70 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 71 | | { |
| 18216 | 72 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 73 | | { |
| 0 | 74 | | dictionary.Add(property0.Name, null); |
| | 75 | | } |
| | 76 | | else |
| | 77 | | { |
| 18216 | 78 | | dictionary.Add(property0.Name, ParameterValuesValue.DeserializeParameterValuesValue(property |
| | 79 | | } |
| | 80 | | } |
| 64104 | 81 | | parameters = dictionary; |
| 64104 | 82 | | continue; |
| | 83 | | } |
| 100228 | 84 | | if (property.NameEquals("policyDefinitionReferenceId")) |
| | 85 | | { |
| 66772 | 86 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 87 | | { |
| | 88 | | continue; |
| | 89 | | } |
| 66772 | 90 | | policyDefinitionReferenceId = property.Value.GetString(); |
| 66772 | 91 | | continue; |
| | 92 | | } |
| 33456 | 93 | | if (property.NameEquals("groupNames")) |
| | 94 | | { |
| 33456 | 95 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 96 | | { |
| | 97 | | continue; |
| | 98 | | } |
| 33456 | 99 | | List<string> array = new List<string>(); |
| 139216 | 100 | | foreach (var item in property.Value.EnumerateArray()) |
| | 101 | | { |
| 36152 | 102 | | if (item.ValueKind == JsonValueKind.Null) |
| | 103 | | { |
| 0 | 104 | | array.Add(null); |
| | 105 | | } |
| | 106 | | else |
| | 107 | | { |
| 36152 | 108 | | array.Add(item.GetString()); |
| | 109 | | } |
| | 110 | | } |
| 33456 | 111 | | groupNames = array; |
| | 112 | | continue; |
| | 113 | | } |
| | 114 | | } |
| 66772 | 115 | | return new PolicyDefinitionReference(policyDefinitionId, parameters, policyDefinitionReferenceId, groupNames |
| | 116 | | } |
| | 117 | | } |
| | 118 | | } |