| | 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; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using Azure.Core; |
| | 12 | |
|
| | 13 | | namespace Azure.ResourceManager.Resources.Models |
| | 14 | | { |
| | 15 | | public partial class ScriptConfigurationBase : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 0 | 19 | | writer.WriteStartObject(); |
| 0 | 20 | | if (PrimaryScriptUri != null) |
| | 21 | | { |
| 0 | 22 | | writer.WritePropertyName("primaryScriptUri"); |
| 0 | 23 | | writer.WriteStringValue(PrimaryScriptUri); |
| | 24 | | } |
| 0 | 25 | | if (SupportingScriptUris != null) |
| | 26 | | { |
| 0 | 27 | | writer.WritePropertyName("supportingScriptUris"); |
| 0 | 28 | | writer.WriteStartArray(); |
| 0 | 29 | | foreach (var item in SupportingScriptUris) |
| | 30 | | { |
| 0 | 31 | | writer.WriteStringValue(item); |
| | 32 | | } |
| 0 | 33 | | writer.WriteEndArray(); |
| | 34 | | } |
| 0 | 35 | | if (ScriptContent != null) |
| | 36 | | { |
| 0 | 37 | | writer.WritePropertyName("scriptContent"); |
| 0 | 38 | | writer.WriteStringValue(ScriptContent); |
| | 39 | | } |
| 0 | 40 | | if (Arguments != null) |
| | 41 | | { |
| 0 | 42 | | writer.WritePropertyName("arguments"); |
| 0 | 43 | | writer.WriteStringValue(Arguments); |
| | 44 | | } |
| 0 | 45 | | if (EnvironmentVariables != null) |
| | 46 | | { |
| 0 | 47 | | writer.WritePropertyName("environmentVariables"); |
| 0 | 48 | | writer.WriteStartArray(); |
| 0 | 49 | | foreach (var item in EnvironmentVariables) |
| | 50 | | { |
| 0 | 51 | | writer.WriteObjectValue(item); |
| | 52 | | } |
| 0 | 53 | | writer.WriteEndArray(); |
| | 54 | | } |
| 0 | 55 | | if (ForceUpdateTag != null) |
| | 56 | | { |
| 0 | 57 | | writer.WritePropertyName("forceUpdateTag"); |
| 0 | 58 | | writer.WriteStringValue(ForceUpdateTag); |
| | 59 | | } |
| 0 | 60 | | writer.WritePropertyName("retentionInterval"); |
| 0 | 61 | | writer.WriteStringValue(RetentionInterval, "P"); |
| 0 | 62 | | if (Timeout != null) |
| | 63 | | { |
| 0 | 64 | | writer.WritePropertyName("timeout"); |
| 0 | 65 | | writer.WriteStringValue(Timeout.Value, "P"); |
| | 66 | | } |
| 0 | 67 | | writer.WriteEndObject(); |
| 0 | 68 | | } |
| | 69 | |
|
| | 70 | | internal static ScriptConfigurationBase DeserializeScriptConfigurationBase(JsonElement element) |
| | 71 | | { |
| 0 | 72 | | string primaryScriptUri = default; |
| 0 | 73 | | IList<string> supportingScriptUris = default; |
| 0 | 74 | | string scriptContent = default; |
| 0 | 75 | | string arguments = default; |
| 0 | 76 | | IList<EnvironmentVariable> environmentVariables = default; |
| 0 | 77 | | string forceUpdateTag = default; |
| 0 | 78 | | TimeSpan retentionInterval = default; |
| 0 | 79 | | TimeSpan? timeout = default; |
| 0 | 80 | | foreach (var property in element.EnumerateObject()) |
| | 81 | | { |
| 0 | 82 | | if (property.NameEquals("primaryScriptUri")) |
| | 83 | | { |
| 0 | 84 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 85 | | { |
| | 86 | | continue; |
| | 87 | | } |
| 0 | 88 | | primaryScriptUri = property.Value.GetString(); |
| 0 | 89 | | continue; |
| | 90 | | } |
| 0 | 91 | | if (property.NameEquals("supportingScriptUris")) |
| | 92 | | { |
| 0 | 93 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 94 | | { |
| | 95 | | continue; |
| | 96 | | } |
| 0 | 97 | | List<string> array = new List<string>(); |
| 0 | 98 | | foreach (var item in property.Value.EnumerateArray()) |
| | 99 | | { |
| 0 | 100 | | if (item.ValueKind == JsonValueKind.Null) |
| | 101 | | { |
| 0 | 102 | | array.Add(null); |
| | 103 | | } |
| | 104 | | else |
| | 105 | | { |
| 0 | 106 | | array.Add(item.GetString()); |
| | 107 | | } |
| | 108 | | } |
| 0 | 109 | | supportingScriptUris = array; |
| 0 | 110 | | continue; |
| | 111 | | } |
| 0 | 112 | | if (property.NameEquals("scriptContent")) |
| | 113 | | { |
| 0 | 114 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 115 | | { |
| | 116 | | continue; |
| | 117 | | } |
| 0 | 118 | | scriptContent = property.Value.GetString(); |
| 0 | 119 | | continue; |
| | 120 | | } |
| 0 | 121 | | if (property.NameEquals("arguments")) |
| | 122 | | { |
| 0 | 123 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 124 | | { |
| | 125 | | continue; |
| | 126 | | } |
| 0 | 127 | | arguments = property.Value.GetString(); |
| 0 | 128 | | continue; |
| | 129 | | } |
| 0 | 130 | | if (property.NameEquals("environmentVariables")) |
| | 131 | | { |
| 0 | 132 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 133 | | { |
| | 134 | | continue; |
| | 135 | | } |
| 0 | 136 | | List<EnvironmentVariable> array = new List<EnvironmentVariable>(); |
| 0 | 137 | | foreach (var item in property.Value.EnumerateArray()) |
| | 138 | | { |
| 0 | 139 | | if (item.ValueKind == JsonValueKind.Null) |
| | 140 | | { |
| 0 | 141 | | array.Add(null); |
| | 142 | | } |
| | 143 | | else |
| | 144 | | { |
| 0 | 145 | | array.Add(EnvironmentVariable.DeserializeEnvironmentVariable(item)); |
| | 146 | | } |
| | 147 | | } |
| 0 | 148 | | environmentVariables = array; |
| 0 | 149 | | continue; |
| | 150 | | } |
| 0 | 151 | | if (property.NameEquals("forceUpdateTag")) |
| | 152 | | { |
| 0 | 153 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 154 | | { |
| | 155 | | continue; |
| | 156 | | } |
| 0 | 157 | | forceUpdateTag = property.Value.GetString(); |
| 0 | 158 | | continue; |
| | 159 | | } |
| 0 | 160 | | if (property.NameEquals("retentionInterval")) |
| | 161 | | { |
| 0 | 162 | | retentionInterval = property.Value.GetTimeSpan("P"); |
| 0 | 163 | | continue; |
| | 164 | | } |
| 0 | 165 | | if (property.NameEquals("timeout")) |
| | 166 | | { |
| 0 | 167 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 168 | | { |
| | 169 | | continue; |
| | 170 | | } |
| 0 | 171 | | timeout = property.Value.GetTimeSpan("P"); |
| | 172 | | continue; |
| | 173 | | } |
| | 174 | | } |
| 0 | 175 | | return new ScriptConfigurationBase(primaryScriptUri, supportingScriptUris, scriptContent, arguments, environ |
| | 176 | | } |
| | 177 | | } |
| | 178 | | } |