| | 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.Network.Models |
| | 13 | | { |
| | 14 | | public partial class Delegation : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Name != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("name"); |
| 0 | 22 | | writer.WriteStringValue(Name); |
| | 23 | | } |
| 0 | 24 | | if (Etag != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("etag"); |
| 0 | 27 | | writer.WriteStringValue(Etag); |
| | 28 | | } |
| 0 | 29 | | if (Id != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("id"); |
| 0 | 32 | | writer.WriteStringValue(Id); |
| | 33 | | } |
| 0 | 34 | | writer.WritePropertyName("properties"); |
| 0 | 35 | | writer.WriteStartObject(); |
| 0 | 36 | | if (ServiceName != null) |
| | 37 | | { |
| 0 | 38 | | writer.WritePropertyName("serviceName"); |
| 0 | 39 | | writer.WriteStringValue(ServiceName); |
| | 40 | | } |
| 0 | 41 | | if (Actions != null) |
| | 42 | | { |
| 0 | 43 | | writer.WritePropertyName("actions"); |
| 0 | 44 | | writer.WriteStartArray(); |
| 0 | 45 | | foreach (var item in Actions) |
| | 46 | | { |
| 0 | 47 | | writer.WriteStringValue(item); |
| | 48 | | } |
| 0 | 49 | | writer.WriteEndArray(); |
| | 50 | | } |
| 0 | 51 | | if (ProvisioningState != null) |
| | 52 | | { |
| 0 | 53 | | writer.WritePropertyName("provisioningState"); |
| 0 | 54 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 55 | | } |
| 0 | 56 | | writer.WriteEndObject(); |
| 0 | 57 | | writer.WriteEndObject(); |
| 0 | 58 | | } |
| | 59 | |
|
| | 60 | | internal static Delegation DeserializeDelegation(JsonElement element) |
| | 61 | | { |
| 0 | 62 | | string name = default; |
| 0 | 63 | | string etag = default; |
| 0 | 64 | | string id = default; |
| 0 | 65 | | string serviceName = default; |
| 0 | 66 | | IList<string> actions = default; |
| 0 | 67 | | ProvisioningState? provisioningState = default; |
| 0 | 68 | | foreach (var property in element.EnumerateObject()) |
| | 69 | | { |
| 0 | 70 | | if (property.NameEquals("name")) |
| | 71 | | { |
| 0 | 72 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 73 | | { |
| | 74 | | continue; |
| | 75 | | } |
| 0 | 76 | | name = property.Value.GetString(); |
| 0 | 77 | | continue; |
| | 78 | | } |
| 0 | 79 | | if (property.NameEquals("etag")) |
| | 80 | | { |
| 0 | 81 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 82 | | { |
| | 83 | | continue; |
| | 84 | | } |
| 0 | 85 | | etag = property.Value.GetString(); |
| 0 | 86 | | continue; |
| | 87 | | } |
| 0 | 88 | | if (property.NameEquals("id")) |
| | 89 | | { |
| 0 | 90 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 91 | | { |
| | 92 | | continue; |
| | 93 | | } |
| 0 | 94 | | id = property.Value.GetString(); |
| 0 | 95 | | continue; |
| | 96 | | } |
| 0 | 97 | | if (property.NameEquals("properties")) |
| | 98 | | { |
| 0 | 99 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 100 | | { |
| 0 | 101 | | if (property0.NameEquals("serviceName")) |
| | 102 | | { |
| 0 | 103 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 104 | | { |
| | 105 | | continue; |
| | 106 | | } |
| 0 | 107 | | serviceName = property0.Value.GetString(); |
| 0 | 108 | | continue; |
| | 109 | | } |
| 0 | 110 | | if (property0.NameEquals("actions")) |
| | 111 | | { |
| 0 | 112 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 113 | | { |
| | 114 | | continue; |
| | 115 | | } |
| 0 | 116 | | List<string> array = new List<string>(); |
| 0 | 117 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 118 | | { |
| 0 | 119 | | if (item.ValueKind == JsonValueKind.Null) |
| | 120 | | { |
| 0 | 121 | | array.Add(null); |
| | 122 | | } |
| | 123 | | else |
| | 124 | | { |
| 0 | 125 | | array.Add(item.GetString()); |
| | 126 | | } |
| | 127 | | } |
| 0 | 128 | | actions = array; |
| 0 | 129 | | continue; |
| | 130 | | } |
| 0 | 131 | | if (property0.NameEquals("provisioningState")) |
| | 132 | | { |
| 0 | 133 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 134 | | { |
| | 135 | | continue; |
| | 136 | | } |
| 0 | 137 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| | 138 | | continue; |
| | 139 | | } |
| | 140 | | } |
| | 141 | | continue; |
| | 142 | | } |
| | 143 | | } |
| 0 | 144 | | return new Delegation(id, name, etag, serviceName, actions, provisioningState); |
| | 145 | | } |
| | 146 | | } |
| | 147 | | } |