| | 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.EventHubs.Models |
| | 13 | | { |
| | 14 | | public partial class AuthorizationRule : 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 (Rights != null) |
| | 37 | | { |
| 32 | 38 | | writer.WritePropertyName("rights"); |
| 32 | 39 | | writer.WriteStartArray(); |
| 168 | 40 | | foreach (var item in Rights) |
| | 41 | | { |
| 52 | 42 | | writer.WriteStringValue(item.ToString()); |
| | 43 | | } |
| 32 | 44 | | writer.WriteEndArray(); |
| | 45 | | } |
| 32 | 46 | | writer.WriteEndObject(); |
| 32 | 47 | | writer.WriteEndObject(); |
| 32 | 48 | | } |
| | 49 | |
|
| | 50 | | internal static AuthorizationRule DeserializeAuthorizationRule(JsonElement element) |
| | 51 | | { |
| 92 | 52 | | string id = default; |
| 92 | 53 | | string name = default; |
| 92 | 54 | | string type = default; |
| 92 | 55 | | IList<AccessRights> rights = default; |
| 1104 | 56 | | foreach (var property in element.EnumerateObject()) |
| | 57 | | { |
| 460 | 58 | | if (property.NameEquals("id")) |
| | 59 | | { |
| 92 | 60 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 61 | | { |
| | 62 | | continue; |
| | 63 | | } |
| 92 | 64 | | id = property.Value.GetString(); |
| 92 | 65 | | continue; |
| | 66 | | } |
| 368 | 67 | | if (property.NameEquals("name")) |
| | 68 | | { |
| 92 | 69 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 70 | | { |
| | 71 | | continue; |
| | 72 | | } |
| 92 | 73 | | name = property.Value.GetString(); |
| 92 | 74 | | continue; |
| | 75 | | } |
| 276 | 76 | | if (property.NameEquals("type")) |
| | 77 | | { |
| 92 | 78 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 79 | | { |
| | 80 | | continue; |
| | 81 | | } |
| 92 | 82 | | type = property.Value.GetString(); |
| 92 | 83 | | continue; |
| | 84 | | } |
| 184 | 85 | | if (property.NameEquals("properties")) |
| | 86 | | { |
| 368 | 87 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 88 | | { |
| 92 | 89 | | if (property0.NameEquals("rights")) |
| | 90 | | { |
| 92 | 91 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 92 | | { |
| | 93 | | continue; |
| | 94 | | } |
| 92 | 95 | | List<AccessRights> array = new List<AccessRights>(); |
| 520 | 96 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 97 | | { |
| 168 | 98 | | array.Add(new AccessRights(item.GetString())); |
| | 99 | | } |
| 92 | 100 | | rights = array; |
| | 101 | | continue; |
| | 102 | | } |
| | 103 | | } |
| | 104 | | continue; |
| | 105 | | } |
| | 106 | | } |
| 92 | 107 | | return new AuthorizationRule(id, name, type, rights); |
| | 108 | | } |
| | 109 | | } |
| | 110 | | } |