| | | 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 PolicyDefinition : IUtf8JsonSerializable |
| | | 15 | | { |
| | | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | | 17 | | { |
| | 68 | 18 | | writer.WriteStartObject(); |
| | 68 | 19 | | if (Id != null) |
| | | 20 | | { |
| | 0 | 21 | | writer.WritePropertyName("id"); |
| | 0 | 22 | | writer.WriteStringValue(Id); |
| | | 23 | | } |
| | 68 | 24 | | if (Name != null) |
| | | 25 | | { |
| | 0 | 26 | | writer.WritePropertyName("name"); |
| | 0 | 27 | | writer.WriteStringValue(Name); |
| | | 28 | | } |
| | 68 | 29 | | if (Type != null) |
| | | 30 | | { |
| | 0 | 31 | | writer.WritePropertyName("type"); |
| | 0 | 32 | | writer.WriteStringValue(Type); |
| | | 33 | | } |
| | 68 | 34 | | writer.WritePropertyName("properties"); |
| | 68 | 35 | | writer.WriteStartObject(); |
| | 68 | 36 | | if (PolicyType != null) |
| | | 37 | | { |
| | 0 | 38 | | writer.WritePropertyName("policyType"); |
| | 0 | 39 | | writer.WriteStringValue(PolicyType.Value.ToString()); |
| | | 40 | | } |
| | 68 | 41 | | if (Mode != null) |
| | | 42 | | { |
| | 16 | 43 | | writer.WritePropertyName("mode"); |
| | 16 | 44 | | writer.WriteStringValue(Mode); |
| | | 45 | | } |
| | 68 | 46 | | if (DisplayName != null) |
| | | 47 | | { |
| | 68 | 48 | | writer.WritePropertyName("displayName"); |
| | 68 | 49 | | writer.WriteStringValue(DisplayName); |
| | | 50 | | } |
| | 68 | 51 | | if (Description != null) |
| | | 52 | | { |
| | 4 | 53 | | writer.WritePropertyName("description"); |
| | 4 | 54 | | writer.WriteStringValue(Description); |
| | | 55 | | } |
| | 68 | 56 | | if (PolicyRule != null) |
| | | 57 | | { |
| | 64 | 58 | | writer.WritePropertyName("policyRule"); |
| | 64 | 59 | | writer.WriteObjectValue(PolicyRule); |
| | | 60 | | } |
| | 68 | 61 | | if (Metadata != null) |
| | | 62 | | { |
| | 4 | 63 | | writer.WritePropertyName("metadata"); |
| | 4 | 64 | | writer.WriteObjectValue(Metadata); |
| | | 65 | | } |
| | 68 | 66 | | if (Parameters != null) |
| | | 67 | | { |
| | 12 | 68 | | writer.WritePropertyName("parameters"); |
| | 12 | 69 | | writer.WriteStartObject(); |
| | 48 | 70 | | foreach (var item in Parameters) |
| | | 71 | | { |
| | 12 | 72 | | writer.WritePropertyName(item.Key); |
| | 12 | 73 | | writer.WriteObjectValue(item.Value); |
| | | 74 | | } |
| | 12 | 75 | | writer.WriteEndObject(); |
| | | 76 | | } |
| | 68 | 77 | | writer.WriteEndObject(); |
| | 68 | 78 | | writer.WriteEndObject(); |
| | 68 | 79 | | } |
| | | 80 | | |
| | | 81 | | internal static PolicyDefinition DeserializePolicyDefinition(JsonElement element) |
| | | 82 | | { |
| | 81532 | 83 | | string id = default; |
| | 81532 | 84 | | string name = default; |
| | 81532 | 85 | | string type = default; |
| | 81532 | 86 | | PolicyType? policyType = default; |
| | 81532 | 87 | | string mode = default; |
| | 81532 | 88 | | string displayName = default; |
| | 81532 | 89 | | string description = default; |
| | 81532 | 90 | | object policyRule = default; |
| | 81532 | 91 | | object metadata = default; |
| | 81532 | 92 | | IDictionary<string, ParameterDefinitionsValue> parameters = default; |
| | 815320 | 93 | | foreach (var property in element.EnumerateObject()) |
| | | 94 | | { |
| | 326128 | 95 | | if (property.NameEquals("id")) |
| | | 96 | | { |
| | 81532 | 97 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 98 | | { |
| | | 99 | | continue; |
| | | 100 | | } |
| | 81532 | 101 | | id = property.Value.GetString(); |
| | 81532 | 102 | | continue; |
| | | 103 | | } |
| | 244596 | 104 | | if (property.NameEquals("name")) |
| | | 105 | | { |
| | 81532 | 106 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 107 | | { |
| | | 108 | | continue; |
| | | 109 | | } |
| | 81532 | 110 | | name = property.Value.GetString(); |
| | 81532 | 111 | | continue; |
| | | 112 | | } |
| | 163064 | 113 | | if (property.NameEquals("type")) |
| | | 114 | | { |
| | 81532 | 115 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 116 | | { |
| | | 117 | | continue; |
| | | 118 | | } |
| | 81532 | 119 | | type = property.Value.GetString(); |
| | 81532 | 120 | | continue; |
| | | 121 | | } |
| | 81532 | 122 | | if (property.NameEquals("properties")) |
| | | 123 | | { |
| | 1198120 | 124 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | | 125 | | { |
| | 517528 | 126 | | if (property0.NameEquals("policyType")) |
| | | 127 | | { |
| | 81532 | 128 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 129 | | { |
| | | 130 | | continue; |
| | | 131 | | } |
| | 81532 | 132 | | policyType = new PolicyType(property0.Value.GetString()); |
| | 81532 | 133 | | continue; |
| | | 134 | | } |
| | 435996 | 135 | | if (property0.NameEquals("mode")) |
| | | 136 | | { |
| | 81532 | 137 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 138 | | { |
| | | 139 | | continue; |
| | | 140 | | } |
| | 81532 | 141 | | mode = property0.Value.GetString(); |
| | 81532 | 142 | | continue; |
| | | 143 | | } |
| | 354464 | 144 | | if (property0.NameEquals("displayName")) |
| | | 145 | | { |
| | 81444 | 146 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 147 | | { |
| | | 148 | | continue; |
| | | 149 | | } |
| | 81444 | 150 | | displayName = property0.Value.GetString(); |
| | 81444 | 151 | | continue; |
| | | 152 | | } |
| | 273020 | 153 | | if (property0.NameEquals("description")) |
| | | 154 | | { |
| | 81368 | 155 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 156 | | { |
| | | 157 | | continue; |
| | | 158 | | } |
| | 81368 | 159 | | description = property0.Value.GetString(); |
| | 81368 | 160 | | continue; |
| | | 161 | | } |
| | 191652 | 162 | | if (property0.NameEquals("policyRule")) |
| | | 163 | | { |
| | 81532 | 164 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 165 | | { |
| | | 166 | | continue; |
| | | 167 | | } |
| | 81532 | 168 | | policyRule = property0.Value.GetObject(); |
| | 81532 | 169 | | continue; |
| | | 170 | | } |
| | 110120 | 171 | | if (property0.NameEquals("metadata")) |
| | | 172 | | { |
| | 81532 | 173 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 174 | | { |
| | | 175 | | continue; |
| | | 176 | | } |
| | 81532 | 177 | | metadata = property0.Value.GetObject(); |
| | 81532 | 178 | | continue; |
| | | 179 | | } |
| | 28588 | 180 | | if (property0.NameEquals("parameters")) |
| | | 181 | | { |
| | 28588 | 182 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 183 | | { |
| | | 184 | | continue; |
| | | 185 | | } |
| | 28588 | 186 | | Dictionary<string, ParameterDefinitionsValue> dictionary = new Dictionary<string, ParameterD |
| | 149392 | 187 | | foreach (var property1 in property0.Value.EnumerateObject()) |
| | | 188 | | { |
| | 46108 | 189 | | if (property1.Value.ValueKind == JsonValueKind.Null) |
| | | 190 | | { |
| | 0 | 191 | | dictionary.Add(property1.Name, null); |
| | | 192 | | } |
| | | 193 | | else |
| | | 194 | | { |
| | 46108 | 195 | | dictionary.Add(property1.Name, ParameterDefinitionsValue.DeserializeParameterDefinit |
| | | 196 | | } |
| | | 197 | | } |
| | 28588 | 198 | | parameters = dictionary; |
| | | 199 | | continue; |
| | | 200 | | } |
| | | 201 | | } |
| | | 202 | | continue; |
| | | 203 | | } |
| | | 204 | | } |
| | 81532 | 205 | | return new PolicyDefinition(id, name, type, policyType, mode, displayName, description, policyRule, metadata |
| | | 206 | | } |
| | | 207 | | } |
| | | 208 | | } |