| | 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.AppConfiguration.Models |
| | 13 | | { |
| | 14 | | public partial class ResourceIdentity : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Type != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("type"); |
| 0 | 22 | | writer.WriteStringValue(Type.Value.ToString()); |
| | 23 | | } |
| 0 | 24 | | if (UserAssignedIdentities != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("userAssignedIdentities"); |
| 0 | 27 | | writer.WriteStartObject(); |
| 0 | 28 | | foreach (var item in UserAssignedIdentities) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName(item.Key); |
| 0 | 31 | | writer.WriteObjectValue(item.Value); |
| | 32 | | } |
| 0 | 33 | | writer.WriteEndObject(); |
| | 34 | | } |
| 0 | 35 | | if (PrincipalId != null) |
| | 36 | | { |
| 0 | 37 | | writer.WritePropertyName("principalId"); |
| 0 | 38 | | writer.WriteStringValue(PrincipalId); |
| | 39 | | } |
| 0 | 40 | | if (TenantId != null) |
| | 41 | | { |
| 0 | 42 | | writer.WritePropertyName("tenantId"); |
| 0 | 43 | | writer.WriteStringValue(TenantId); |
| | 44 | | } |
| 0 | 45 | | writer.WriteEndObject(); |
| 0 | 46 | | } |
| | 47 | |
|
| | 48 | | internal static ResourceIdentity DeserializeResourceIdentity(JsonElement element) |
| | 49 | | { |
| 0 | 50 | | IdentityType? type = default; |
| 0 | 51 | | IDictionary<string, UserIdentity> userAssignedIdentities = default; |
| 0 | 52 | | string principalId = default; |
| 0 | 53 | | string tenantId = default; |
| 0 | 54 | | foreach (var property in element.EnumerateObject()) |
| | 55 | | { |
| 0 | 56 | | if (property.NameEquals("type")) |
| | 57 | | { |
| 0 | 58 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 59 | | { |
| | 60 | | continue; |
| | 61 | | } |
| 0 | 62 | | type = new IdentityType(property.Value.GetString()); |
| 0 | 63 | | continue; |
| | 64 | | } |
| 0 | 65 | | if (property.NameEquals("userAssignedIdentities")) |
| | 66 | | { |
| 0 | 67 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 68 | | { |
| | 69 | | continue; |
| | 70 | | } |
| 0 | 71 | | Dictionary<string, UserIdentity> dictionary = new Dictionary<string, UserIdentity>(); |
| 0 | 72 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 73 | | { |
| 0 | 74 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 75 | | { |
| 0 | 76 | | dictionary.Add(property0.Name, null); |
| | 77 | | } |
| | 78 | | else |
| | 79 | | { |
| 0 | 80 | | dictionary.Add(property0.Name, UserIdentity.DeserializeUserIdentity(property0.Value)); |
| | 81 | | } |
| | 82 | | } |
| 0 | 83 | | userAssignedIdentities = dictionary; |
| 0 | 84 | | continue; |
| | 85 | | } |
| 0 | 86 | | if (property.NameEquals("principalId")) |
| | 87 | | { |
| 0 | 88 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 89 | | { |
| | 90 | | continue; |
| | 91 | | } |
| 0 | 92 | | principalId = property.Value.GetString(); |
| 0 | 93 | | continue; |
| | 94 | | } |
| 0 | 95 | | if (property.NameEquals("tenantId")) |
| | 96 | | { |
| 0 | 97 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 98 | | { |
| | 99 | | continue; |
| | 100 | | } |
| 0 | 101 | | tenantId = property.Value.GetString(); |
| | 102 | | continue; |
| | 103 | | } |
| | 104 | | } |
| 0 | 105 | | return new ResourceIdentity(type, userAssignedIdentities, principalId, tenantId); |
| | 106 | | } |
| | 107 | | } |
| | 108 | | } |