| | 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 PolicyAssignment : 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 (Type != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("type"); |
| 0 | 27 | | writer.WriteStringValue(Type); |
| | 28 | | } |
| 32 | 29 | | if (Name != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("name"); |
| 0 | 32 | | writer.WriteStringValue(Name); |
| | 33 | | } |
| 32 | 34 | | if (Sku != null) |
| | 35 | | { |
| 32 | 36 | | writer.WritePropertyName("sku"); |
| 32 | 37 | | writer.WriteObjectValue(Sku); |
| | 38 | | } |
| 32 | 39 | | if (Location != null) |
| | 40 | | { |
| 8 | 41 | | writer.WritePropertyName("location"); |
| 8 | 42 | | writer.WriteStringValue(Location); |
| | 43 | | } |
| 32 | 44 | | if (Identity != null) |
| | 45 | | { |
| 8 | 46 | | writer.WritePropertyName("identity"); |
| 8 | 47 | | writer.WriteObjectValue(Identity); |
| | 48 | | } |
| 32 | 49 | | writer.WritePropertyName("properties"); |
| 32 | 50 | | writer.WriteStartObject(); |
| 32 | 51 | | if (DisplayName != null) |
| | 52 | | { |
| 32 | 53 | | writer.WritePropertyName("displayName"); |
| 32 | 54 | | writer.WriteStringValue(DisplayName); |
| | 55 | | } |
| 32 | 56 | | if (PolicyDefinitionId != null) |
| | 57 | | { |
| 28 | 58 | | writer.WritePropertyName("policyDefinitionId"); |
| 28 | 59 | | writer.WriteStringValue(PolicyDefinitionId); |
| | 60 | | } |
| 32 | 61 | | if (Scope != null) |
| | 62 | | { |
| 8 | 63 | | writer.WritePropertyName("scope"); |
| 8 | 64 | | writer.WriteStringValue(Scope); |
| | 65 | | } |
| 32 | 66 | | if (NotScopes != null) |
| | 67 | | { |
| 0 | 68 | | writer.WritePropertyName("notScopes"); |
| 0 | 69 | | writer.WriteStartArray(); |
| 0 | 70 | | foreach (var item in NotScopes) |
| | 71 | | { |
| 0 | 72 | | writer.WriteStringValue(item); |
| | 73 | | } |
| 0 | 74 | | writer.WriteEndArray(); |
| | 75 | | } |
| 32 | 76 | | if (Parameters != null) |
| | 77 | | { |
| 0 | 78 | | writer.WritePropertyName("parameters"); |
| 0 | 79 | | writer.WriteStartObject(); |
| 0 | 80 | | foreach (var item in Parameters) |
| | 81 | | { |
| 0 | 82 | | writer.WritePropertyName(item.Key); |
| 0 | 83 | | writer.WriteObjectValue(item.Value); |
| | 84 | | } |
| 0 | 85 | | writer.WriteEndObject(); |
| | 86 | | } |
| 32 | 87 | | if (Description != null) |
| | 88 | | { |
| 8 | 89 | | writer.WritePropertyName("description"); |
| 8 | 90 | | writer.WriteStringValue(Description); |
| | 91 | | } |
| 32 | 92 | | if (Metadata != null) |
| | 93 | | { |
| 8 | 94 | | writer.WritePropertyName("metadata"); |
| 8 | 95 | | writer.WriteObjectValue(Metadata); |
| | 96 | | } |
| 32 | 97 | | if (EnforcementMode != null) |
| | 98 | | { |
| 8 | 99 | | writer.WritePropertyName("enforcementMode"); |
| 8 | 100 | | writer.WriteStringValue(EnforcementMode.Value.ToString()); |
| | 101 | | } |
| 32 | 102 | | writer.WriteEndObject(); |
| 32 | 103 | | writer.WriteEndObject(); |
| 32 | 104 | | } |
| | 105 | |
|
| | 106 | | internal static PolicyAssignment DeserializePolicyAssignment(JsonElement element) |
| | 107 | | { |
| 88 | 108 | | string id = default; |
| 88 | 109 | | string type = default; |
| 88 | 110 | | string name = default; |
| 88 | 111 | | PolicySku sku = default; |
| 88 | 112 | | string location = default; |
| 88 | 113 | | IdentityAutoGenerated identity = default; |
| 88 | 114 | | string displayName = default; |
| 88 | 115 | | string policyDefinitionId = default; |
| 88 | 116 | | string scope = default; |
| 88 | 117 | | IList<string> notScopes = default; |
| 88 | 118 | | IDictionary<string, ParameterValuesValue> parameters = default; |
| 88 | 119 | | string description = default; |
| 88 | 120 | | object metadata = default; |
| 88 | 121 | | EnforcementMode? enforcementMode = default; |
| 1152 | 122 | | foreach (var property in element.EnumerateObject()) |
| | 123 | | { |
| 488 | 124 | | if (property.NameEquals("id")) |
| | 125 | | { |
| 88 | 126 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 127 | | { |
| | 128 | | continue; |
| | 129 | | } |
| 88 | 130 | | id = property.Value.GetString(); |
| 88 | 131 | | continue; |
| | 132 | | } |
| 400 | 133 | | if (property.NameEquals("type")) |
| | 134 | | { |
| 88 | 135 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 136 | | { |
| | 137 | | continue; |
| | 138 | | } |
| 88 | 139 | | type = property.Value.GetString(); |
| 88 | 140 | | continue; |
| | 141 | | } |
| 312 | 142 | | if (property.NameEquals("name")) |
| | 143 | | { |
| 88 | 144 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 145 | | { |
| | 146 | | continue; |
| | 147 | | } |
| 88 | 148 | | name = property.Value.GetString(); |
| 88 | 149 | | continue; |
| | 150 | | } |
| 224 | 151 | | if (property.NameEquals("sku")) |
| | 152 | | { |
| 88 | 153 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 154 | | { |
| | 155 | | continue; |
| | 156 | | } |
| 88 | 157 | | sku = PolicySku.DeserializePolicySku(property.Value); |
| 88 | 158 | | continue; |
| | 159 | | } |
| 136 | 160 | | if (property.NameEquals("location")) |
| | 161 | | { |
| 24 | 162 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 163 | | { |
| | 164 | | continue; |
| | 165 | | } |
| 24 | 166 | | location = property.Value.GetString(); |
| 24 | 167 | | continue; |
| | 168 | | } |
| 112 | 169 | | if (property.NameEquals("identity")) |
| | 170 | | { |
| 24 | 171 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 172 | | { |
| | 173 | | continue; |
| | 174 | | } |
| 24 | 175 | | identity = IdentityAutoGenerated.DeserializeIdentityAutoGenerated(property.Value); |
| 24 | 176 | | continue; |
| | 177 | | } |
| 88 | 178 | | if (property.NameEquals("properties")) |
| | 179 | | { |
| 1064 | 180 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 181 | | { |
| 444 | 182 | | if (property0.NameEquals("displayName")) |
| | 183 | | { |
| 68 | 184 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 185 | | { |
| | 186 | | continue; |
| | 187 | | } |
| 68 | 188 | | displayName = property0.Value.GetString(); |
| 68 | 189 | | continue; |
| | 190 | | } |
| 376 | 191 | | if (property0.NameEquals("policyDefinitionId")) |
| | 192 | | { |
| 88 | 193 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 194 | | { |
| | 195 | | continue; |
| | 196 | | } |
| 88 | 197 | | policyDefinitionId = property0.Value.GetString(); |
| 88 | 198 | | continue; |
| | 199 | | } |
| 288 | 200 | | if (property0.NameEquals("scope")) |
| | 201 | | { |
| 88 | 202 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 203 | | { |
| | 204 | | continue; |
| | 205 | | } |
| 88 | 206 | | scope = property0.Value.GetString(); |
| 88 | 207 | | continue; |
| | 208 | | } |
| 200 | 209 | | if (property0.NameEquals("notScopes")) |
| | 210 | | { |
| 0 | 211 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 212 | | { |
| | 213 | | continue; |
| | 214 | | } |
| 0 | 215 | | List<string> array = new List<string>(); |
| 0 | 216 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 217 | | { |
| 0 | 218 | | if (item.ValueKind == JsonValueKind.Null) |
| | 219 | | { |
| 0 | 220 | | array.Add(null); |
| | 221 | | } |
| | 222 | | else |
| | 223 | | { |
| 0 | 224 | | array.Add(item.GetString()); |
| | 225 | | } |
| | 226 | | } |
| 0 | 227 | | notScopes = array; |
| 0 | 228 | | continue; |
| | 229 | | } |
| 200 | 230 | | if (property0.NameEquals("parameters")) |
| | 231 | | { |
| 0 | 232 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 233 | | { |
| | 234 | | continue; |
| | 235 | | } |
| 0 | 236 | | Dictionary<string, ParameterValuesValue> dictionary = new Dictionary<string, ParameterValues |
| 0 | 237 | | foreach (var property1 in property0.Value.EnumerateObject()) |
| | 238 | | { |
| 0 | 239 | | if (property1.Value.ValueKind == JsonValueKind.Null) |
| | 240 | | { |
| 0 | 241 | | dictionary.Add(property1.Name, null); |
| | 242 | | } |
| | 243 | | else |
| | 244 | | { |
| 0 | 245 | | dictionary.Add(property1.Name, ParameterValuesValue.DeserializeParameterValuesValue( |
| | 246 | | } |
| | 247 | | } |
| 0 | 248 | | parameters = dictionary; |
| 0 | 249 | | continue; |
| | 250 | | } |
| 200 | 251 | | if (property0.NameEquals("description")) |
| | 252 | | { |
| 24 | 253 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 254 | | { |
| | 255 | | continue; |
| | 256 | | } |
| 24 | 257 | | description = property0.Value.GetString(); |
| 24 | 258 | | continue; |
| | 259 | | } |
| 176 | 260 | | if (property0.NameEquals("metadata")) |
| | 261 | | { |
| 88 | 262 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 263 | | { |
| | 264 | | continue; |
| | 265 | | } |
| 88 | 266 | | metadata = property0.Value.GetObject(); |
| 88 | 267 | | continue; |
| | 268 | | } |
| 88 | 269 | | if (property0.NameEquals("enforcementMode")) |
| | 270 | | { |
| 88 | 271 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 272 | | { |
| | 273 | | continue; |
| | 274 | | } |
| 88 | 275 | | enforcementMode = new EnforcementMode(property0.Value.GetString()); |
| | 276 | | continue; |
| | 277 | | } |
| | 278 | | } |
| | 279 | | continue; |
| | 280 | | } |
| | 281 | | } |
| 88 | 282 | | return new PolicyAssignment(id, type, name, sku, location, identity, displayName, policyDefinitionId, scope, |
| | 283 | | } |
| | 284 | | } |
| | 285 | | } |