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