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