| | 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 PolicySetDefinition : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 32 | 18 | | writer.WriteStartObject(); |
| 32 | 19 | | if (Id != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("id"); |
| 0 | 22 | | writer.WriteStringValue(Id); |
| | 23 | | } |
| 32 | 24 | | if (Name != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("name"); |
| 0 | 27 | | writer.WriteStringValue(Name); |
| | 28 | | } |
| 32 | 29 | | if (Type != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("type"); |
| 0 | 32 | | writer.WriteStringValue(Type); |
| | 33 | | } |
| 32 | 34 | | writer.WritePropertyName("properties"); |
| 32 | 35 | | writer.WriteStartObject(); |
| 32 | 36 | | if (PolicyType != null) |
| | 37 | | { |
| 0 | 38 | | writer.WritePropertyName("policyType"); |
| 0 | 39 | | writer.WriteStringValue(PolicyType.Value.ToString()); |
| | 40 | | } |
| 32 | 41 | | if (DisplayName != null) |
| | 42 | | { |
| 32 | 43 | | writer.WritePropertyName("displayName"); |
| 32 | 44 | | writer.WriteStringValue(DisplayName); |
| | 45 | | } |
| 32 | 46 | | if (Description != null) |
| | 47 | | { |
| 8 | 48 | | writer.WritePropertyName("description"); |
| 8 | 49 | | writer.WriteStringValue(Description); |
| | 50 | | } |
| 32 | 51 | | if (Metadata != null) |
| | 52 | | { |
| 8 | 53 | | writer.WritePropertyName("metadata"); |
| 8 | 54 | | writer.WriteObjectValue(Metadata); |
| | 55 | | } |
| 32 | 56 | | if (Parameters != null) |
| | 57 | | { |
| 8 | 58 | | writer.WritePropertyName("parameters"); |
| 8 | 59 | | writer.WriteStartObject(); |
| 32 | 60 | | foreach (var item in Parameters) |
| | 61 | | { |
| 8 | 62 | | writer.WritePropertyName(item.Key); |
| 8 | 63 | | writer.WriteObjectValue(item.Value); |
| | 64 | | } |
| 8 | 65 | | writer.WriteEndObject(); |
| | 66 | | } |
| 32 | 67 | | if (PolicyDefinitions != null) |
| | 68 | | { |
| 28 | 69 | | writer.WritePropertyName("policyDefinitions"); |
| 28 | 70 | | writer.WriteStartArray(); |
| 128 | 71 | | foreach (var item in PolicyDefinitions) |
| | 72 | | { |
| 36 | 73 | | writer.WriteObjectValue(item); |
| | 74 | | } |
| 28 | 75 | | writer.WriteEndArray(); |
| | 76 | | } |
| 32 | 77 | | if (PolicyDefinitionGroups != null) |
| | 78 | | { |
| 4 | 79 | | writer.WritePropertyName("policyDefinitionGroups"); |
| 4 | 80 | | writer.WriteStartArray(); |
| 24 | 81 | | foreach (var item in PolicyDefinitionGroups) |
| | 82 | | { |
| 8 | 83 | | writer.WriteObjectValue(item); |
| | 84 | | } |
| 4 | 85 | | writer.WriteEndArray(); |
| | 86 | | } |
| 32 | 87 | | writer.WriteEndObject(); |
| 32 | 88 | | writer.WriteEndObject(); |
| 32 | 89 | | } |
| | 90 | |
|
| | 91 | | internal static PolicySetDefinition DeserializePolicySetDefinition(JsonElement element) |
| | 92 | | { |
| 1444 | 93 | | string id = default; |
| 1444 | 94 | | string name = default; |
| 1444 | 95 | | string type = default; |
| 1444 | 96 | | PolicyType? policyType = default; |
| 1444 | 97 | | string displayName = default; |
| 1444 | 98 | | string description = default; |
| 1444 | 99 | | object metadata = default; |
| 1444 | 100 | | IDictionary<string, ParameterDefinitionsValue> parameters = default; |
| 1444 | 101 | | IList<PolicyDefinitionReference> policyDefinitions = default; |
| 1444 | 102 | | IList<PolicyDefinitionGroup> policyDefinitionGroups = default; |
| 14440 | 103 | | foreach (var property in element.EnumerateObject()) |
| | 104 | | { |
| 5776 | 105 | | if (property.NameEquals("id")) |
| | 106 | | { |
| 1444 | 107 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 108 | | { |
| | 109 | | continue; |
| | 110 | | } |
| 1444 | 111 | | id = property.Value.GetString(); |
| 1444 | 112 | | continue; |
| | 113 | | } |
| 4332 | 114 | | if (property.NameEquals("name")) |
| | 115 | | { |
| 1444 | 116 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 117 | | { |
| | 118 | | continue; |
| | 119 | | } |
| 1444 | 120 | | name = property.Value.GetString(); |
| 1444 | 121 | | continue; |
| | 122 | | } |
| 2888 | 123 | | if (property.NameEquals("type")) |
| | 124 | | { |
| 1444 | 125 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 126 | | { |
| | 127 | | continue; |
| | 128 | | } |
| 1444 | 129 | | type = property.Value.GetString(); |
| 1444 | 130 | | continue; |
| | 131 | | } |
| 1444 | 132 | | if (property.NameEquals("properties")) |
| | 133 | | { |
| 20136 | 134 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 135 | | { |
| 8624 | 136 | | if (property0.NameEquals("policyType")) |
| | 137 | | { |
| 1444 | 138 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 139 | | { |
| | 140 | | continue; |
| | 141 | | } |
| 1444 | 142 | | policyType = new PolicyType(property0.Value.GetString()); |
| 1444 | 143 | | continue; |
| | 144 | | } |
| 7180 | 145 | | if (property0.NameEquals("displayName")) |
| | 146 | | { |
| 1444 | 147 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 148 | | { |
| | 149 | | continue; |
| | 150 | | } |
| 1444 | 151 | | displayName = property0.Value.GetString(); |
| 1444 | 152 | | continue; |
| | 153 | | } |
| 5736 | 154 | | if (property0.NameEquals("description")) |
| | 155 | | { |
| 1424 | 156 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 157 | | { |
| | 158 | | continue; |
| | 159 | | } |
| 1424 | 160 | | description = property0.Value.GetString(); |
| 1424 | 161 | | continue; |
| | 162 | | } |
| 4312 | 163 | | if (property0.NameEquals("metadata")) |
| | 164 | | { |
| 1444 | 165 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 166 | | { |
| | 167 | | continue; |
| | 168 | | } |
| 1444 | 169 | | metadata = property0.Value.GetObject(); |
| 1444 | 170 | | continue; |
| | 171 | | } |
| 2868 | 172 | | if (property0.NameEquals("parameters")) |
| | 173 | | { |
| 1320 | 174 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 175 | | { |
| | 176 | | continue; |
| | 177 | | } |
| 1320 | 178 | | Dictionary<string, ParameterDefinitionsValue> dictionary = new Dictionary<string, ParameterD |
| 38496 | 179 | | foreach (var property1 in property0.Value.EnumerateObject()) |
| | 180 | | { |
| 17928 | 181 | | if (property1.Value.ValueKind == JsonValueKind.Null) |
| | 182 | | { |
| 0 | 183 | | dictionary.Add(property1.Name, null); |
| | 184 | | } |
| | 185 | | else |
| | 186 | | { |
| 17928 | 187 | | dictionary.Add(property1.Name, ParameterDefinitionsValue.DeserializeParameterDefinit |
| | 188 | | } |
| | 189 | | } |
| 1320 | 190 | | parameters = dictionary; |
| 1320 | 191 | | continue; |
| | 192 | | } |
| 1548 | 193 | | if (property0.NameEquals("policyDefinitions")) |
| | 194 | | { |
| 1444 | 195 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 196 | | { |
| | 197 | | continue; |
| | 198 | | } |
| 1444 | 199 | | List<PolicyDefinitionReference> array = new List<PolicyDefinitionReference>(); |
| 136432 | 200 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 201 | | { |
| 66772 | 202 | | if (item.ValueKind == JsonValueKind.Null) |
| | 203 | | { |
| 0 | 204 | | array.Add(null); |
| | 205 | | } |
| | 206 | | else |
| | 207 | | { |
| 66772 | 208 | | array.Add(PolicyDefinitionReference.DeserializePolicyDefinitionReference(item)); |
| | 209 | | } |
| | 210 | | } |
| 1444 | 211 | | policyDefinitions = array; |
| 1444 | 212 | | continue; |
| | 213 | | } |
| 104 | 214 | | if (property0.NameEquals("policyDefinitionGroups")) |
| | 215 | | { |
| 104 | 216 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 217 | | { |
| | 218 | | continue; |
| | 219 | | } |
| 104 | 220 | | List<PolicyDefinitionGroup> array = new List<PolicyDefinitionGroup>(); |
| 34992 | 221 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 222 | | { |
| 17392 | 223 | | if (item.ValueKind == JsonValueKind.Null) |
| | 224 | | { |
| 0 | 225 | | array.Add(null); |
| | 226 | | } |
| | 227 | | else |
| | 228 | | { |
| 17392 | 229 | | array.Add(PolicyDefinitionGroup.DeserializePolicyDefinitionGroup(item)); |
| | 230 | | } |
| | 231 | | } |
| 104 | 232 | | policyDefinitionGroups = array; |
| | 233 | | continue; |
| | 234 | | } |
| | 235 | | } |
| | 236 | | continue; |
| | 237 | | } |
| | 238 | | } |
| 1444 | 239 | | return new PolicySetDefinition(id, name, type, policyType, displayName, description, metadata, parameters, p |
| | 240 | | } |
| | 241 | | } |
| | 242 | | } |