| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Text.Json; |
| | 6 | |
|
| | 7 | | namespace Azure.Security.KeyVault.Certificates |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// A deleted <see cref="KeyVaultCertificateWithPolicy"/>. |
| | 11 | | /// </summary> |
| | 12 | | public class DeletedCertificate : KeyVaultCertificateWithPolicy |
| | 13 | | { |
| | 14 | | private const string RecoveryIdPropertyName = "recoveryId"; |
| | 15 | | private const string ScheduledPurgeDatePropertyName = "scheduledPurgeDate"; |
| | 16 | | private const string DeletedOnPropertyName = "deletedDate"; |
| | 17 | |
|
| | 18 | | private string _recoveryId; |
| | 19 | |
|
| 8 | 20 | | internal DeletedCertificate(CertificateProperties properties = null) : base(properties) |
| | 21 | | { |
| 8 | 22 | | } |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Gets the identifier of the deleted certificate. |
| | 26 | | /// </summary> |
| | 27 | | public Uri RecoveryId |
| | 28 | | { |
| 16 | 29 | | get => _recoveryId is null ? null : new Uri(_recoveryId); |
| 0 | 30 | | internal set => _recoveryId = value?.ToString(); |
| | 31 | | } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Gets a <see cref="DateTimeOffset"/> indicating when the certificate was deleted. |
| | 35 | | /// </summary> |
| 0 | 36 | | public DateTimeOffset? DeletedOn { get; internal set; } |
| | 37 | |
|
| | 38 | | /// <summary> |
| | 39 | | /// Gets a <see cref="DateTimeOffset"/> for when the deleted certificate will be purged. |
| | 40 | | /// </summary> |
| 0 | 41 | | public DateTimeOffset? ScheduledPurgeDate { get; internal set; } |
| | 42 | |
|
| | 43 | | internal override void ReadProperty(JsonProperty prop) |
| | 44 | | { |
| 88 | 45 | | switch (prop.Name) |
| | 46 | | { |
| | 47 | | case RecoveryIdPropertyName: |
| 8 | 48 | | _recoveryId = prop.Value.GetString(); |
| 8 | 49 | | break; |
| | 50 | |
|
| | 51 | | case DeletedOnPropertyName: |
| 8 | 52 | | DeletedOn = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); |
| 8 | 53 | | break; |
| | 54 | |
|
| | 55 | | case ScheduledPurgeDatePropertyName: |
| 8 | 56 | | ScheduledPurgeDate = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); |
| 8 | 57 | | break; |
| | 58 | |
|
| | 59 | | default: |
| 64 | 60 | | base.ReadProperty(prop); |
| | 61 | | break; |
| | 62 | | } |
| 64 | 63 | | } |
| | 64 | | } |
| | 65 | | } |