| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Collections.Generic; |
| | 5 | | using System.Text.Json; |
| | 6 | |
|
| | 7 | | namespace Azure.Security.KeyVault.Certificates |
| | 8 | | { |
| | 9 | | internal class CertificateUpdateParameters : IJsonSerializable |
| | 10 | | { |
| | 11 | | private const string AttributesPropertyName = "attributes"; |
| | 12 | | private const string EnabledPropertyName = "enabled"; |
| | 13 | | private const string TagsPropertyName = "tags"; |
| | 14 | |
|
| 2 | 15 | | private static readonly JsonEncodedText s_attributesPropertyNameBytes = JsonEncodedText.Encode(AttributesPropert |
| 2 | 16 | | private static readonly JsonEncodedText s_enabledPropertyNameBytes = JsonEncodedText.Encode(EnabledPropertyName) |
| 2 | 17 | | private static readonly JsonEncodedText s_tagsPropertyNameBytes = JsonEncodedText.Encode(TagsPropertyName); |
| | 18 | |
|
| 8 | 19 | | public CertificateUpdateParameters(CertificateProperties properties) |
| | 20 | | { |
| 8 | 21 | | Properties = properties; |
| 8 | 22 | | } |
| | 23 | |
|
| 36 | 24 | | public CertificateProperties Properties { get; } |
| | 25 | |
|
| | 26 | | void IJsonSerializable.WriteProperties(Utf8JsonWriter json) |
| | 27 | | { |
| 8 | 28 | | if (Properties.Enabled.HasValue) |
| | 29 | | { |
| 8 | 30 | | json.WriteStartObject(s_attributesPropertyNameBytes); |
| | 31 | |
|
| 8 | 32 | | json.WriteBoolean(s_enabledPropertyNameBytes, Properties.Enabled.Value); |
| | 33 | |
|
| 8 | 34 | | json.WriteEndObject(); |
| | 35 | | } |
| | 36 | |
|
| 8 | 37 | | if (Properties.HasTags && Properties.Tags.Count > 0) |
| | 38 | | { |
| 4 | 39 | | json.WriteStartObject(s_tagsPropertyNameBytes); |
| | 40 | |
|
| 16 | 41 | | foreach (KeyValuePair<string, string> kvp in Properties.Tags) |
| | 42 | | { |
| 4 | 43 | | json.WriteString(kvp.Key, kvp.Value); |
| | 44 | | } |
| | 45 | |
|
| 4 | 46 | | json.WriteEndObject(); |
| | 47 | | } |
| 8 | 48 | | } |
| | 49 | | } |
| | 50 | | } |