| | 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.Storage.Models |
| | 14 | | { |
| | 15 | | public partial class ObjectReplicationPolicy : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 8 | 19 | | writer.WriteStartObject(); |
| 8 | 20 | | if (Id != null) |
| | 21 | | { |
| 0 | 22 | | writer.WritePropertyName("id"); |
| 0 | 23 | | writer.WriteStringValue(Id); |
| | 24 | | } |
| 8 | 25 | | if (Name != null) |
| | 26 | | { |
| 0 | 27 | | writer.WritePropertyName("name"); |
| 0 | 28 | | writer.WriteStringValue(Name); |
| | 29 | | } |
| 8 | 30 | | if (Type != null) |
| | 31 | | { |
| 0 | 32 | | writer.WritePropertyName("type"); |
| 0 | 33 | | writer.WriteStringValue(Type); |
| | 34 | | } |
| 8 | 35 | | writer.WritePropertyName("properties"); |
| 8 | 36 | | writer.WriteStartObject(); |
| 8 | 37 | | if (PolicyId != null) |
| | 38 | | { |
| 4 | 39 | | writer.WritePropertyName("policyId"); |
| 4 | 40 | | writer.WriteStringValue(PolicyId); |
| | 41 | | } |
| 8 | 42 | | if (EnabledTime != null) |
| | 43 | | { |
| 0 | 44 | | writer.WritePropertyName("enabledTime"); |
| 0 | 45 | | writer.WriteStringValue(EnabledTime.Value, "O"); |
| | 46 | | } |
| 8 | 47 | | if (SourceAccount != null) |
| | 48 | | { |
| 8 | 49 | | writer.WritePropertyName("sourceAccount"); |
| 8 | 50 | | writer.WriteStringValue(SourceAccount); |
| | 51 | | } |
| 8 | 52 | | if (DestinationAccount != null) |
| | 53 | | { |
| 8 | 54 | | writer.WritePropertyName("destinationAccount"); |
| 8 | 55 | | writer.WriteStringValue(DestinationAccount); |
| | 56 | | } |
| 8 | 57 | | if (Rules != null) |
| | 58 | | { |
| 8 | 59 | | writer.WritePropertyName("rules"); |
| 8 | 60 | | writer.WriteStartArray(); |
| 48 | 61 | | foreach (var item in Rules) |
| | 62 | | { |
| 16 | 63 | | writer.WriteObjectValue(item); |
| | 64 | | } |
| 8 | 65 | | writer.WriteEndArray(); |
| | 66 | | } |
| 8 | 67 | | writer.WriteEndObject(); |
| 8 | 68 | | writer.WriteEndObject(); |
| 8 | 69 | | } |
| | 70 | |
|
| | 71 | | internal static ObjectReplicationPolicy DeserializeObjectReplicationPolicy(JsonElement element) |
| | 72 | | { |
| 24 | 73 | | string id = default; |
| 24 | 74 | | string name = default; |
| 24 | 75 | | string type = default; |
| 24 | 76 | | string policyId = default; |
| 24 | 77 | | DateTimeOffset? enabledTime = default; |
| 24 | 78 | | string sourceAccount = default; |
| 24 | 79 | | string destinationAccount = default; |
| 24 | 80 | | IList<ObjectReplicationPolicyRule> rules = default; |
| 192 | 81 | | foreach (var property in element.EnumerateObject()) |
| | 82 | | { |
| 72 | 83 | | if (property.NameEquals("id")) |
| | 84 | | { |
| 16 | 85 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 86 | | { |
| | 87 | | continue; |
| | 88 | | } |
| 16 | 89 | | id = property.Value.GetString(); |
| 16 | 90 | | continue; |
| | 91 | | } |
| 56 | 92 | | if (property.NameEquals("name")) |
| | 93 | | { |
| 16 | 94 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 95 | | { |
| | 96 | | continue; |
| | 97 | | } |
| 16 | 98 | | name = property.Value.GetString(); |
| 16 | 99 | | continue; |
| | 100 | | } |
| 40 | 101 | | if (property.NameEquals("type")) |
| | 102 | | { |
| 16 | 103 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 104 | | { |
| | 105 | | continue; |
| | 106 | | } |
| 16 | 107 | | type = property.Value.GetString(); |
| 16 | 108 | | continue; |
| | 109 | | } |
| 24 | 110 | | if (property.NameEquals("properties")) |
| | 111 | | { |
| 248 | 112 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 113 | | { |
| 100 | 114 | | if (property0.NameEquals("policyId")) |
| | 115 | | { |
| 24 | 116 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 117 | | { |
| | 118 | | continue; |
| | 119 | | } |
| 24 | 120 | | policyId = property0.Value.GetString(); |
| 24 | 121 | | continue; |
| | 122 | | } |
| 76 | 123 | | if (property0.NameEquals("enabledTime")) |
| | 124 | | { |
| 4 | 125 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 126 | | { |
| | 127 | | continue; |
| | 128 | | } |
| 4 | 129 | | enabledTime = property0.Value.GetDateTimeOffset("O"); |
| 4 | 130 | | continue; |
| | 131 | | } |
| 72 | 132 | | if (property0.NameEquals("sourceAccount")) |
| | 133 | | { |
| 24 | 134 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 135 | | { |
| | 136 | | continue; |
| | 137 | | } |
| 24 | 138 | | sourceAccount = property0.Value.GetString(); |
| 24 | 139 | | continue; |
| | 140 | | } |
| 48 | 141 | | if (property0.NameEquals("destinationAccount")) |
| | 142 | | { |
| 24 | 143 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 144 | | { |
| | 145 | | continue; |
| | 146 | | } |
| 24 | 147 | | destinationAccount = property0.Value.GetString(); |
| 24 | 148 | | continue; |
| | 149 | | } |
| 24 | 150 | | if (property0.NameEquals("rules")) |
| | 151 | | { |
| 24 | 152 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 153 | | { |
| | 154 | | continue; |
| | 155 | | } |
| 24 | 156 | | List<ObjectReplicationPolicyRule> array = new List<ObjectReplicationPolicyRule>(); |
| 144 | 157 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 158 | | { |
| 48 | 159 | | if (item.ValueKind == JsonValueKind.Null) |
| | 160 | | { |
| 0 | 161 | | array.Add(null); |
| | 162 | | } |
| | 163 | | else |
| | 164 | | { |
| 48 | 165 | | array.Add(ObjectReplicationPolicyRule.DeserializeObjectReplicationPolicyRule(item)); |
| | 166 | | } |
| | 167 | | } |
| 24 | 168 | | rules = array; |
| | 169 | | continue; |
| | 170 | | } |
| | 171 | | } |
| | 172 | | continue; |
| | 173 | | } |
| | 174 | | } |
| 24 | 175 | | return new ObjectReplicationPolicy(id, name, type, policyId, enabledTime, sourceAccount, destinationAccount, |
| | 176 | | } |
| | 177 | | } |
| | 178 | | } |