| | 1 | | using Microsoft.Azure.KeyVault.Models; |
| | 2 | | using Microsoft.Rest.TransientFaultHandling; |
| | 3 | | using System; |
| | 4 | | using System.Net; |
| | 5 | |
|
| | 6 | | namespace KeyVault.TestFramework |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// A retry strategy that will wait until keys/secrets have been deleted or purged entirely. |
| | 10 | | /// Since this is a long running operation that is not guaranteed to complete immediately. |
| | 11 | | /// </summary> |
| | 12 | | public class SoftDeleteErrorDetectionStrategy : ITransientErrorDetectionStrategy |
| | 13 | | { |
| | 14 | | public bool IsTransient(Exception ex) |
| | 15 | | { |
| 154 | 16 | | if (ex != null) |
| | 17 | | { |
| | 18 | | // Key vault will use this error type for all exceptions. |
| | 19 | | KeyVaultErrorException kvException; |
| 154 | 20 | | if((kvException = ex as KeyVaultErrorException) != null) |
| | 21 | | { |
| | 22 | | // Retry on not found and conflict while object is in transitioning state. |
| 154 | 23 | | if (kvException.Response.StatusCode == HttpStatusCode.NotFound || |
| 154 | 24 | | kvException.Response.StatusCode == HttpStatusCode.Conflict) |
| | 25 | | { |
| 154 | 26 | | return true; |
| | 27 | | } |
| | 28 | | } |
| | 29 | | } |
| 0 | 30 | | return false; |
| | 31 | |
|
| | 32 | | } |
| | 33 | | } |
| | 34 | | } |