| | 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.KeyVault.Models |
| | 13 | | { |
| | 14 | | public partial class Permissions : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 104 | 18 | | writer.WriteStartObject(); |
| 104 | 19 | | if (Optional.IsCollectionDefined(Keys)) |
| | 20 | | { |
| 96 | 21 | | writer.WritePropertyName("keys"); |
| 96 | 22 | | writer.WriteStartArray(); |
| 384 | 23 | | foreach (var item in Keys) |
| | 24 | | { |
| 96 | 25 | | writer.WriteStringValue(item.ToString()); |
| | 26 | | } |
| 96 | 27 | | writer.WriteEndArray(); |
| | 28 | | } |
| 104 | 29 | | if (Optional.IsCollectionDefined(Secrets)) |
| | 30 | | { |
| 104 | 31 | | writer.WritePropertyName("secrets"); |
| 104 | 32 | | writer.WriteStartArray(); |
| 432 | 33 | | foreach (var item in Secrets) |
| | 34 | | { |
| 112 | 35 | | writer.WriteStringValue(item.ToString()); |
| | 36 | | } |
| 104 | 37 | | writer.WriteEndArray(); |
| | 38 | | } |
| 104 | 39 | | if (Optional.IsCollectionDefined(Certificates)) |
| | 40 | | { |
| 104 | 41 | | writer.WritePropertyName("certificates"); |
| 104 | 42 | | writer.WriteStartArray(); |
| 416 | 43 | | foreach (var item in Certificates) |
| | 44 | | { |
| 104 | 45 | | writer.WriteStringValue(item.ToString()); |
| | 46 | | } |
| 104 | 47 | | writer.WriteEndArray(); |
| | 48 | | } |
| 104 | 49 | | if (Optional.IsCollectionDefined(Storage)) |
| | 50 | | { |
| 104 | 51 | | writer.WritePropertyName("storage"); |
| 104 | 52 | | writer.WriteStartArray(); |
| 432 | 53 | | foreach (var item in Storage) |
| | 54 | | { |
| 112 | 55 | | writer.WriteStringValue(item.ToString()); |
| | 56 | | } |
| 104 | 57 | | writer.WriteEndArray(); |
| | 58 | | } |
| 104 | 59 | | writer.WriteEndObject(); |
| 104 | 60 | | } |
| | 61 | |
|
| | 62 | | internal static Permissions DeserializePermissions(JsonElement element) |
| | 63 | | { |
| 76 | 64 | | Optional<IList<KeyPermissions>> keys = default; |
| 76 | 65 | | Optional<IList<SecretPermissions>> secrets = default; |
| 76 | 66 | | Optional<IList<CertificatePermissions>> certificates = default; |
| 76 | 67 | | Optional<IList<StoragePermissions>> storage = default; |
| 744 | 68 | | foreach (var property in element.EnumerateObject()) |
| | 69 | | { |
| 296 | 70 | | if (property.NameEquals("keys")) |
| | 71 | | { |
| 68 | 72 | | List<KeyPermissions> array = new List<KeyPermissions>(); |
| 272 | 73 | | foreach (var item in property.Value.EnumerateArray()) |
| | 74 | | { |
| 68 | 75 | | array.Add(new KeyPermissions(item.GetString())); |
| | 76 | | } |
| 68 | 77 | | keys = array; |
| 68 | 78 | | continue; |
| | 79 | | } |
| 228 | 80 | | if (property.NameEquals("secrets")) |
| | 81 | | { |
| 76 | 82 | | List<SecretPermissions> array = new List<SecretPermissions>(); |
| 320 | 83 | | foreach (var item in property.Value.EnumerateArray()) |
| | 84 | | { |
| 84 | 85 | | array.Add(new SecretPermissions(item.GetString())); |
| | 86 | | } |
| 76 | 87 | | secrets = array; |
| 76 | 88 | | continue; |
| | 89 | | } |
| 152 | 90 | | if (property.NameEquals("certificates")) |
| | 91 | | { |
| 76 | 92 | | List<CertificatePermissions> array = new List<CertificatePermissions>(); |
| 304 | 93 | | foreach (var item in property.Value.EnumerateArray()) |
| | 94 | | { |
| 76 | 95 | | array.Add(new CertificatePermissions(item.GetString())); |
| | 96 | | } |
| 76 | 97 | | certificates = array; |
| 76 | 98 | | continue; |
| | 99 | | } |
| 76 | 100 | | if (property.NameEquals("storage")) |
| | 101 | | { |
| 76 | 102 | | List<StoragePermissions> array = new List<StoragePermissions>(); |
| 320 | 103 | | foreach (var item in property.Value.EnumerateArray()) |
| | 104 | | { |
| 84 | 105 | | array.Add(new StoragePermissions(item.GetString())); |
| | 106 | | } |
| 76 | 107 | | storage = array; |
| | 108 | | continue; |
| | 109 | | } |
| | 110 | | } |
| 76 | 111 | | return new Permissions(Optional.ToList(keys), Optional.ToList(secrets), Optional.ToList(certificates), Optio |
| | 112 | | } |
| | 113 | | } |
| | 114 | | } |