| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Globalization; |
| | 7 | | using System.Threading; |
| | 8 | | using System.Threading.Tasks; |
| | 9 | | using Azure.Core; |
| | 10 | | using Azure.Core.Pipeline; |
| | 11 | |
|
| | 12 | | namespace Azure.Security.KeyVault.Certificates |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// The CertificateClient provides synchronous and asynchronous methods to manage <see cref="KeyVaultCertificate"/>s |
| | 16 | | /// supports creating, retrieving, updating, deleting, purging, backing up, restoring, and listing the <see cref="Ke |
| | 17 | | /// certificate <see cref="CertificateIssuer"/>s and <see cref="CertificateContact"/>s. The client also supports lis |
| | 18 | | /// enabled key vault. |
| | 19 | | /// </summary> |
| | 20 | | public class CertificateClient |
| | 21 | | { |
| | 22 | | internal const string CertificatesPath = "/certificates/"; |
| | 23 | | internal const string DeletedCertificatesPath = "/deletedcertificates/"; |
| | 24 | | private const string IssuersPath = "/certificates/issuers/"; |
| | 25 | | private const string ContactsPath = "/certificates/contacts/"; |
| | 26 | |
|
| | 27 | | private readonly KeyVaultPipeline _pipeline; |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Initializes a new instance of the <see cref="CertificateClient"/> class for mocking. |
| | 31 | | /// </summary> |
| 172 | 32 | | protected CertificateClient() |
| | 33 | | { |
| 172 | 34 | | } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Initializes a new instance of the <see cref="CertificateClient"/> class for the specified vault. |
| | 38 | | /// </summary> |
| | 39 | | /// <param name="vaultUri">A <see cref="Uri"/> to the vault on which the client operates. Appears as "DNS Name" |
| | 40 | | /// <param name="credential">A <see cref="TokenCredential"/> used to authenticate requests to the vault, such as |
| | 41 | | /// <exception cref="ArgumentNullException"><paramref name="vaultUri"/> or <paramref name="credential"/> is null |
| | 42 | | public CertificateClient(Uri vaultUri, TokenCredential credential) |
| 0 | 43 | | : this(vaultUri, credential, null) |
| | 44 | | { |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Initializes a new instance of the <see cref="CertificateClient"/> class for the specified vault. |
| | 49 | | /// </summary> |
| | 50 | | /// <param name="vaultUri">A <see cref="Uri"/> to the vault on which the client operates. Appears as "DNS Name" |
| | 51 | | /// <param name="credential">A <see cref="TokenCredential"/> used to authenticate requests to the vault, such as |
| | 52 | | /// <param name="options"><see cref="CertificateClientOptions"/> that allow to configure the management of the r |
| | 53 | | /// <exception cref="ArgumentNullException"><paramref name="vaultUri"/> or <paramref name="credential"/> is null |
| 172 | 54 | | public CertificateClient(Uri vaultUri, TokenCredential credential, CertificateClientOptions options) |
| | 55 | | { |
| 172 | 56 | | Argument.AssertNotNull(vaultUri, nameof(vaultUri)); |
| 172 | 57 | | Argument.AssertNotNull(credential, nameof(credential)); |
| | 58 | |
|
| 172 | 59 | | options ??= new CertificateClientOptions(); |
| | 60 | |
|
| 172 | 61 | | HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new ChallengeBasedAuthenticationPolicy(credential |
| | 62 | |
|
| 172 | 63 | | _pipeline = new KeyVaultPipeline(vaultUri, options.GetVersionString(), pipeline, new ClientDiagnostics(optio |
| 172 | 64 | | } |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Gets the <see cref="Uri"/> of the vault used to create this instance of the <see cref="CertificateClient"/>. |
| | 68 | | /// </summary> |
| 4 | 69 | | public virtual Uri VaultUri => _pipeline.VaultUri; |
| | 70 | |
|
| | 71 | | /// <summary> |
| | 72 | | /// Starts a long running operation to create a <see cref="KeyVaultCertificate"/> in the vault with the specifie |
| | 73 | | /// </summary> |
| | 74 | | /// <remarks> |
| | 75 | | /// If no certificate with the specified name exists it will be created; otherwise, a new version of the existin |
| | 76 | | /// This operation requires the certificates/create permission. |
| | 77 | | /// </remarks> |
| | 78 | | /// <param name="certificateName">The name of the certificate to create.</param> |
| | 79 | | /// <param name="policy">The <see cref="CertificatePolicy"/> which governs the properties and lifecycle of the c |
| | 80 | | /// <param name="enabled">Specifies whether the certificate should be created in an enabled state. If null, the |
| | 81 | | /// <param name="tags">Tags to be applied to the created certificate.</param> |
| | 82 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 83 | | /// <returns>A <see cref="CertificateOperation"/> which contains details on the create operation, and can be use |
| | 84 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 85 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> or <paramref name="policy"/> is n |
| | 86 | | public virtual CertificateOperation StartCreateCertificate(string certificateName, CertificatePolicy policy, boo |
| | 87 | | { |
| 30 | 88 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| 30 | 89 | | Argument.AssertNotNull(policy, nameof(policy)); |
| | 90 | |
|
| 30 | 91 | | var parameters = new CertificateCreateParameters(policy, enabled, tags); |
| | 92 | |
|
| 30 | 93 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(StartCreateCertifi |
| 30 | 94 | | scope.AddAttribute("certificate", certificateName); |
| 30 | 95 | | scope.Start(); |
| | 96 | |
|
| | 97 | | try |
| | 98 | | { |
| 58 | 99 | | Response<CertificateOperationProperties> response = _pipeline.SendRequest(RequestMethod.Post, parameters |
| | 100 | |
|
| 28 | 101 | | return new CertificateOperation(response, this); |
| | 102 | | } |
| 2 | 103 | | catch (Exception e) |
| | 104 | | { |
| 2 | 105 | | scope.Failed(e); |
| 2 | 106 | | throw; |
| | 107 | | } |
| 28 | 108 | | } |
| | 109 | |
|
| | 110 | | /// <summary> |
| | 111 | | /// Starts a long running operation to create a <see cref="KeyVaultCertificate"/> in the vault with the specifie |
| | 112 | | /// </summary> |
| | 113 | | /// <remarks> |
| | 114 | | /// If no certificate with the specified name exists it will be created; otherwise, a new version of the existin |
| | 115 | | /// This operation requires the certificates/create permission. |
| | 116 | | /// </remarks> |
| | 117 | | /// <param name="certificateName">The name of the certificate to create.</param> |
| | 118 | | /// <param name="policy">The <see cref="CertificatePolicy"/> which governs the properties and lifecycle of the c |
| | 119 | | /// <param name="enabled">Specifies whether the certificate should be created in an enabled state. If null, the |
| | 120 | | /// <param name="tags">Tags to be applied to the created certificate.</param> |
| | 121 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 122 | | /// <returns>A <see cref="CertificateOperation"/> which contains details on the create operation, and can be use |
| | 123 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 124 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> or <paramref name="policy"/> is n |
| | 125 | | public virtual async Task<CertificateOperation> StartCreateCertificateAsync(string certificateName, CertificateP |
| | 126 | | { |
| 30 | 127 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| 30 | 128 | | Argument.AssertNotNull(policy, nameof(policy)); |
| | 129 | |
|
| 30 | 130 | | var parameters = new CertificateCreateParameters(policy, enabled, tags); |
| | 131 | |
|
| 30 | 132 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(StartCreateCertifi |
| 30 | 133 | | scope.AddAttribute("certificate", certificateName); |
| 30 | 134 | | scope.Start(); |
| | 135 | |
|
| | 136 | | try |
| | 137 | | { |
| 58 | 138 | | Response<CertificateOperationProperties> response = await _pipeline.SendRequestAsync(RequestMethod.Post, |
| | 139 | |
|
| 28 | 140 | | return new CertificateOperation(response, this); |
| | 141 | | } |
| 2 | 142 | | catch (Exception e) |
| | 143 | | { |
| 2 | 144 | | scope.Failed(e); |
| 2 | 145 | | throw; |
| | 146 | | } |
| 28 | 147 | | } |
| | 148 | |
|
| | 149 | | /// <summary> |
| | 150 | | /// Returns the latest version of the <see cref="KeyVaultCertificate"/> along with its <see cref="CertificatePol |
| | 151 | | /// </summary> |
| | 152 | | /// <param name="certificateName">The name of the <see cref="KeyVaultCertificate"/> to retrieve.</param> |
| | 153 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 154 | | /// <returns>A response containing the certificate and policy as a <see cref="KeyVaultCertificateWithPolicy"/> i |
| | 155 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 156 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 157 | | public virtual Response<KeyVaultCertificateWithPolicy> GetCertificate(string certificateName, CancellationToken |
| | 158 | | { |
| 20 | 159 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 160 | |
|
| 20 | 161 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetCertificate)}") |
| 20 | 162 | | scope.AddAttribute("certificate", certificateName); |
| 20 | 163 | | scope.Start(); |
| | 164 | |
|
| | 165 | | try |
| | 166 | | { |
| 38 | 167 | | return _pipeline.SendRequest(RequestMethod.Get, () => new KeyVaultCertificateWithPolicy(), cancellationT |
| | 168 | | } |
| 2 | 169 | | catch (Exception e) |
| | 170 | | { |
| 2 | 171 | | scope.Failed(e); |
| 2 | 172 | | throw; |
| | 173 | | } |
| 18 | 174 | | } |
| | 175 | |
|
| | 176 | | /// <summary> |
| | 177 | | /// Returns the latest version of the <see cref="KeyVaultCertificate"/> along with its <see cref="CertificatePol |
| | 178 | | /// </summary> |
| | 179 | | /// <param name="certificateName">The name of the <see cref="KeyVaultCertificate"/> to retrieve.</param> |
| | 180 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 181 | | /// <returns>A response containing the certificate and policy as a <see cref="KeyVaultCertificateWithPolicy"/> i |
| | 182 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 183 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 184 | | public virtual async Task<Response<KeyVaultCertificateWithPolicy>> GetCertificateAsync(string certificateName, C |
| | 185 | | { |
| 20 | 186 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 187 | |
|
| 20 | 188 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetCertificate)}") |
| 20 | 189 | | scope.AddAttribute("certificate", certificateName); |
| 20 | 190 | | scope.Start(); |
| | 191 | |
|
| | 192 | | try |
| | 193 | | { |
| 38 | 194 | | return await _pipeline.SendRequestAsync(RequestMethod.Get, () => new KeyVaultCertificateWithPolicy(), ca |
| | 195 | | } |
| 2 | 196 | | catch (Exception e) |
| | 197 | | { |
| 2 | 198 | | scope.Failed(e); |
| 2 | 199 | | throw; |
| | 200 | | } |
| 18 | 201 | | } |
| | 202 | |
|
| | 203 | | /// <summary> |
| | 204 | | /// Gets a specific version of the <see cref="KeyVaultCertificate"/>. This operation requires the certificates/g |
| | 205 | | /// </summary> |
| | 206 | | /// <param name="certificateName">The name of the <see cref="KeyVaultCertificate"/> to retrieve.</param> |
| | 207 | | /// <param name="version">The version of the <see cref="KeyVaultCertificate"/> to retrieve.</param> |
| | 208 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 209 | | /// <returns>The requested <see cref="KeyVaultCertificate"/>.</returns> |
| | 210 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 211 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 212 | | public virtual Response<KeyVaultCertificate> GetCertificateVersion(string certificateName, string version, Cance |
| | 213 | | { |
| 4 | 214 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 215 | |
|
| 4 | 216 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetCertificateVers |
| 4 | 217 | | scope.AddAttribute("certificate", certificateName); |
| 4 | 218 | | scope.Start(); |
| | 219 | |
|
| | 220 | | try |
| | 221 | | { |
| 8 | 222 | | return _pipeline.SendRequest(RequestMethod.Get, () => new KeyVaultCertificate(), cancellationToken, Cert |
| | 223 | | } |
| 0 | 224 | | catch (Exception e) |
| | 225 | | { |
| 0 | 226 | | scope.Failed(e); |
| 0 | 227 | | throw; |
| | 228 | | } |
| 4 | 229 | | } |
| | 230 | |
|
| | 231 | | /// <summary> |
| | 232 | | /// Gets a specific version of the <see cref="KeyVaultCertificate"/>. This operation requires the certificates/g |
| | 233 | | /// </summary> |
| | 234 | | /// <param name="certificateName">The name of the <see cref="KeyVaultCertificate"/> to retrieve.</param> |
| | 235 | | /// <param name="version">The version of the <see cref="KeyVaultCertificate"/> to retrieve.</param> |
| | 236 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 237 | | /// <returns>The requested <see cref="KeyVaultCertificate"/>.</returns> |
| | 238 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 239 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 240 | | public virtual async Task<Response<KeyVaultCertificate>> GetCertificateVersionAsync(string certificateName, stri |
| | 241 | | { |
| 4 | 242 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| 4 | 243 | | Argument.AssertNotNullOrEmpty(version, nameof(version)); |
| | 244 | |
|
| 4 | 245 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetCertificateVers |
| 4 | 246 | | scope.AddAttribute("certificate", certificateName); |
| 4 | 247 | | scope.Start(); |
| | 248 | |
|
| | 249 | | try |
| | 250 | | { |
| 8 | 251 | | return await _pipeline.SendRequestAsync(RequestMethod.Get, () => new KeyVaultCertificate(), cancellation |
| | 252 | | } |
| 0 | 253 | | catch (Exception e) |
| | 254 | | { |
| 0 | 255 | | scope.Failed(e); |
| 0 | 256 | | throw; |
| | 257 | | } |
| 4 | 258 | | } |
| | 259 | |
|
| | 260 | | /// <summary> |
| | 261 | | /// Updates the specified <see cref="KeyVaultCertificate"/> with the specified values for its mutable properties |
| | 262 | | /// </summary> |
| | 263 | | /// <param name="properties">The <see cref="CertificateProperties"/> object with updated properties.</param> |
| | 264 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 265 | | /// <returns>The updated <see cref="KeyVaultCertificate"/>.</returns> |
| | 266 | | /// <exception cref="ArgumentNullException"><paramref name="properties"/> is null.</exception> |
| | 267 | | public virtual Response<KeyVaultCertificate> UpdateCertificateProperties(CertificateProperties properties, Cance |
| | 268 | | { |
| 4 | 269 | | Argument.AssertNotNull(properties, nameof(properties)); |
| | 270 | |
|
| 4 | 271 | | var parameters = new CertificateUpdateParameters(properties); |
| | 272 | |
|
| 4 | 273 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(UpdateCertificateP |
| 4 | 274 | | scope.AddAttribute("certificate", properties.Name); |
| 4 | 275 | | scope.Start(); |
| | 276 | |
|
| | 277 | | try |
| | 278 | | { |
| 8 | 279 | | return _pipeline.SendRequest(RequestMethod.Patch, parameters, () => new KeyVaultCertificate(), cancellat |
| | 280 | | } |
| 0 | 281 | | catch (Exception e) |
| | 282 | | { |
| 0 | 283 | | scope.Failed(e); |
| 0 | 284 | | throw; |
| | 285 | | } |
| 4 | 286 | | } |
| | 287 | |
|
| | 288 | | /// <summary> |
| | 289 | | /// Updates the specified <see cref="KeyVaultCertificate"/> with the specified values for its mutable properties |
| | 290 | | /// </summary> |
| | 291 | | /// <param name="properties">The <see cref="CertificateProperties"/> object with updated properties.</param> |
| | 292 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 293 | | /// <returns>The updated <see cref="KeyVaultCertificate"/>.</returns> |
| | 294 | | /// <exception cref="ArgumentNullException"><paramref name="properties"/> is null.</exception> |
| | 295 | | public virtual async Task<Response<KeyVaultCertificate>> UpdateCertificatePropertiesAsync(CertificateProperties |
| | 296 | | { |
| 4 | 297 | | Argument.AssertNotNull(properties, nameof(properties)); |
| | 298 | |
|
| 4 | 299 | | var parameters = new CertificateUpdateParameters(properties); |
| | 300 | |
|
| 4 | 301 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(UpdateCertificateP |
| 4 | 302 | | scope.AddAttribute("certificate", properties.Name); |
| 4 | 303 | | scope.Start(); |
| | 304 | |
|
| | 305 | | try |
| | 306 | | { |
| 8 | 307 | | return await _pipeline.SendRequestAsync(RequestMethod.Patch, parameters, () => new KeyVaultCertificate() |
| | 308 | | } |
| 0 | 309 | | catch (Exception e) |
| | 310 | | { |
| 0 | 311 | | scope.Failed(e); |
| 0 | 312 | | throw; |
| | 313 | | } |
| 4 | 314 | | } |
| | 315 | |
|
| | 316 | | /// <summary> |
| | 317 | | /// Deletes all versions of the specified <see cref="KeyVaultCertificate"/>. If the vault is soft delete-enabled |
| | 318 | | /// and can be recovered with <see cref="StartRecoverDeletedCertificate"/>, or purged with <see cref="PurgeDelet |
| | 319 | | /// </summary> |
| | 320 | | /// <param name="certificateName">The name of the <see cref="KeyVaultCertificate"/> to delete.</param> |
| | 321 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 322 | | /// <returns> |
| | 323 | | /// A <see cref="Certificates.DeleteCertificateOperation"/> to wait on this long-running operation. |
| | 324 | | /// If the Key Vault is soft delete-enabled, you only need to wait for the operation to complete if you need to |
| | 325 | | /// otherwise, the certificate is deleted automatically on the <see cref="DeletedCertificate.ScheduledPurgeDate" |
| | 326 | | /// </returns> |
| | 327 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 328 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 329 | | public virtual DeleteCertificateOperation StartDeleteCertificate(string certificateName, CancellationToken cance |
| | 330 | | { |
| 4 | 331 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 332 | |
|
| 4 | 333 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(StartDeleteCertifi |
| 4 | 334 | | scope.AddAttribute("certificate", certificateName); |
| 4 | 335 | | scope.Start(); |
| | 336 | |
|
| | 337 | | try |
| | 338 | | { |
| 8 | 339 | | Response<DeletedCertificate> response = _pipeline.SendRequest(RequestMethod.Delete, () => new DeletedCer |
| 4 | 340 | | return new DeleteCertificateOperation(_pipeline, response); |
| | 341 | | } |
| 0 | 342 | | catch (Exception e) |
| | 343 | | { |
| 0 | 344 | | scope.Failed(e); |
| 0 | 345 | | throw; |
| | 346 | | } |
| 4 | 347 | | } |
| | 348 | |
|
| | 349 | | /// <summary> |
| | 350 | | /// Deletes all versions of the specified <see cref="KeyVaultCertificate"/>. If the vault is soft delete-enabled |
| | 351 | | /// and can be recovered with <see cref="StartRecoverDeletedCertificate"/>, or purged with <see cref="PurgeDelet |
| | 352 | | /// </summary> |
| | 353 | | /// <param name="certificateName">The name of the <see cref="KeyVaultCertificate"/> to delete.</param> |
| | 354 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 355 | | /// <returns> |
| | 356 | | /// A <see cref="Certificates.DeleteCertificateOperation"/> to wait on this long-running operation. |
| | 357 | | /// If the Key Vault is soft delete-enabled, you only need to wait for the operation to complete if you need to |
| | 358 | | /// otherwise, the certificate is deleted automatically on the <see cref="DeletedCertificate.ScheduledPurgeDate" |
| | 359 | | /// </returns> |
| | 360 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 361 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 362 | | public virtual async Task<DeleteCertificateOperation> StartDeleteCertificateAsync(string certificateName, Cancel |
| | 363 | | { |
| 4 | 364 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 365 | |
|
| 4 | 366 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(StartDeleteCertifi |
| 4 | 367 | | scope.AddAttribute("certificate", certificateName); |
| 4 | 368 | | scope.Start(); |
| | 369 | |
|
| | 370 | | try |
| | 371 | | { |
| 8 | 372 | | Response<DeletedCertificate> response = await _pipeline.SendRequestAsync(RequestMethod.Delete, () => new |
| 4 | 373 | | return new DeleteCertificateOperation(_pipeline, response); |
| | 374 | | } |
| 0 | 375 | | catch (Exception e) |
| | 376 | | { |
| 0 | 377 | | scope.Failed(e); |
| 0 | 378 | | throw; |
| | 379 | | } |
| 4 | 380 | | } |
| | 381 | |
|
| | 382 | | /// <summary> |
| | 383 | | /// Retrieves information about the specified deleted <see cref="KeyVaultCertificate"/>. This operation is only |
| | 384 | | /// requires the certificates/get permission. |
| | 385 | | /// </summary> |
| | 386 | | /// <param name="certificateName">The name of the <see cref="DeletedCertificate"/>.</param> |
| | 387 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 388 | | /// <returns>The details of the <see cref="DeletedCertificate"/>.</returns> |
| | 389 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 390 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 391 | | public virtual Response<DeletedCertificate> GetDeletedCertificate(string certificateName, CancellationToken canc |
| | 392 | | { |
| 0 | 393 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 394 | |
|
| 0 | 395 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetDeletedCertific |
| 0 | 396 | | scope.AddAttribute("certificate", certificateName); |
| 0 | 397 | | scope.Start(); |
| | 398 | |
|
| | 399 | | try |
| | 400 | | { |
| 0 | 401 | | return _pipeline.SendRequest(RequestMethod.Get, () => new DeletedCertificate(), cancellationToken, Delet |
| | 402 | | } |
| 0 | 403 | | catch (Exception e) |
| | 404 | | { |
| 0 | 405 | | scope.Failed(e); |
| 0 | 406 | | throw; |
| | 407 | | } |
| 0 | 408 | | } |
| | 409 | |
|
| | 410 | | /// <summary> |
| | 411 | | /// Retrieves information about the specified deleted <see cref="KeyVaultCertificate"/>. This operation is only |
| | 412 | | /// requires the certificates/get permission. |
| | 413 | | /// </summary> |
| | 414 | | /// <param name="certificateName">The name of the <see cref="DeletedCertificate"/>.</param> |
| | 415 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 416 | | /// <returns>The details of the <see cref="DeletedCertificate"/>.</returns> |
| | 417 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 418 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 419 | | public virtual async Task<Response<DeletedCertificate>> GetDeletedCertificateAsync(string certificateName, Cance |
| | 420 | | { |
| 0 | 421 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 422 | |
|
| 0 | 423 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetDeletedCertific |
| 0 | 424 | | scope.AddAttribute("certificate", certificateName); |
| 0 | 425 | | scope.Start(); |
| | 426 | |
|
| | 427 | | try |
| | 428 | | { |
| 0 | 429 | | return await _pipeline.SendRequestAsync(RequestMethod.Get, () => new DeletedCertificate(), cancellationT |
| | 430 | | } |
| 0 | 431 | | catch (Exception e) |
| | 432 | | { |
| 0 | 433 | | scope.Failed(e); |
| 0 | 434 | | throw; |
| | 435 | | } |
| 0 | 436 | | } |
| | 437 | |
|
| | 438 | | /// <summary> |
| | 439 | | /// Recovers the <see cref="DeletedCertificate"/> to its pre-deleted state. This operation is only applicable in |
| | 440 | | /// requires the certificates/recover permission. |
| | 441 | | /// </summary> |
| | 442 | | /// <param name="certificateName">The name of the <see cref="DeletedCertificate"/>.</param> |
| | 443 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 444 | | /// <returns>A <see cref="RecoverDeletedCertificateOperation"/> to wait on this long-running operation.</returns |
| | 445 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 446 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 447 | | public virtual RecoverDeletedCertificateOperation StartRecoverDeletedCertificate(string certificateName, Cancell |
| | 448 | | { |
| 2 | 449 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 450 | |
|
| 2 | 451 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(StartRecoverDelete |
| 2 | 452 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 453 | | scope.Start(); |
| | 454 | |
|
| | 455 | | try |
| | 456 | | { |
| 4 | 457 | | Response<KeyVaultCertificateWithPolicy> response = _pipeline.SendRequest(RequestMethod.Post, () => new K |
| 2 | 458 | | return new RecoverDeletedCertificateOperation(_pipeline, response); |
| | 459 | | } |
| 0 | 460 | | catch (Exception e) |
| | 461 | | { |
| 0 | 462 | | scope.Failed(e); |
| 0 | 463 | | throw; |
| | 464 | | } |
| 2 | 465 | | } |
| | 466 | |
|
| | 467 | | /// <summary> |
| | 468 | | /// Recovers the <see cref="DeletedCertificate"/> to its pre-deleted state. This operation is only applicable in |
| | 469 | | /// requires the certificates/recover permission. |
| | 470 | | /// </summary> |
| | 471 | | /// <param name="certificateName">The name of the <see cref="DeletedCertificate"/>.</param> |
| | 472 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 473 | | /// <returns>A <see cref="RecoverDeletedCertificateOperation"/> to wait on this long-running operation.</returns |
| | 474 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 475 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 476 | | public virtual async Task<RecoverDeletedCertificateOperation> StartRecoverDeletedCertificateAsync(string certifi |
| | 477 | | { |
| 2 | 478 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 479 | |
|
| 2 | 480 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(StartRecoverDelete |
| 2 | 481 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 482 | | scope.Start(); |
| | 483 | |
|
| | 484 | | try |
| | 485 | | { |
| 4 | 486 | | Response<KeyVaultCertificateWithPolicy> response = await _pipeline.SendRequestAsync(RequestMethod.Post, |
| 2 | 487 | | return new RecoverDeletedCertificateOperation(_pipeline, response); |
| | 488 | | } |
| 0 | 489 | | catch (Exception e) |
| | 490 | | { |
| 0 | 491 | | scope.Failed(e); |
| 0 | 492 | | throw; |
| | 493 | | } |
| 2 | 494 | | } |
| | 495 | |
|
| | 496 | | /// <summary> |
| | 497 | | /// Permanently and irreversibly deletes the specified deleted certificate, without the possibility of recovery. |
| | 498 | | /// requires the certificates/purge permission. The operation is not available if the DeletedCertificate.Recover |
| | 499 | | /// </summary> |
| | 500 | | /// <param name="certificateName">The name of the <see cref="DeletedCertificate"/> to permanently delete.</param |
| | 501 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 502 | | /// <returns>The HTTP response from the service.</returns> |
| | 503 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 504 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 505 | | public virtual Response PurgeDeletedCertificate(string certificateName, CancellationToken cancellationToken = de |
| | 506 | | { |
| 2 | 507 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 508 | |
|
| 2 | 509 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(PurgeDeletedCertif |
| 2 | 510 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 511 | | scope.Start(); |
| | 512 | |
|
| | 513 | | try |
| | 514 | | { |
| 2 | 515 | | return _pipeline.SendRequest(RequestMethod.Delete, cancellationToken, DeletedCertificatesPath, certifica |
| | 516 | | } |
| 0 | 517 | | catch (Exception e) |
| | 518 | | { |
| 0 | 519 | | scope.Failed(e); |
| 0 | 520 | | throw; |
| | 521 | | } |
| 2 | 522 | | } |
| | 523 | |
|
| | 524 | | /// <summary> |
| | 525 | | /// Permanently and irreversibly deletes the specified deleted certificate, without the possibility of recovery. |
| | 526 | | /// requires the certificates/purge permission. The operation is not available if the DeletedCertificate.Recover |
| | 527 | | /// </summary> |
| | 528 | | /// <param name="certificateName">The name of the <see cref="DeletedCertificate"/> to permanently delete.</param |
| | 529 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 530 | | /// <returns>The HTTP response from the service.</returns> |
| | 531 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 532 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 533 | | public virtual async Task<Response> PurgeDeletedCertificateAsync(string certificateName, CancellationToken cance |
| | 534 | | { |
| 2 | 535 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 536 | |
|
| 2 | 537 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(PurgeDeletedCertif |
| 2 | 538 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 539 | | scope.Start(); |
| | 540 | |
|
| | 541 | | try |
| | 542 | | { |
| 2 | 543 | | return await _pipeline.SendRequestAsync(RequestMethod.Delete, cancellationToken, DeletedCertificatesPath |
| | 544 | | } |
| 0 | 545 | | catch (Exception e) |
| | 546 | | { |
| 0 | 547 | | scope.Failed(e); |
| 0 | 548 | | throw; |
| | 549 | | } |
| 2 | 550 | | } |
| | 551 | |
|
| | 552 | | /// <summary> |
| | 553 | | /// Creates a backup of the certificate, including all versions, which can be used to restore the certificate to |
| | 554 | | /// restore the certificate to a different vault in the same region as the original value. This operation requir |
| | 555 | | /// </summary> |
| | 556 | | /// <param name="certificateName">The name of the <see cref="KeyVaultCertificate"/> to backup.</param> |
| | 557 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 558 | | /// <returns>The certificate backup.</returns> |
| | 559 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 560 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 561 | | public virtual Response<byte[]> BackupCertificate(string certificateName, CancellationToken cancellationToken = |
| | 562 | | { |
| 0 | 563 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 564 | |
|
| 0 | 565 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(BackupCertificate) |
| 0 | 566 | | scope.AddAttribute("certificate", certificateName); |
| 0 | 567 | | scope.Start(); |
| | 568 | |
|
| | 569 | | try |
| | 570 | | { |
| 0 | 571 | | Response<CertificateBackup> backup = _pipeline.SendRequest(RequestMethod.Post, () => new CertificateBack |
| | 572 | |
|
| 0 | 573 | | return Response.FromValue(backup.Value.Value, backup.GetRawResponse()); |
| | 574 | | } |
| 0 | 575 | | catch (Exception e) |
| | 576 | | { |
| 0 | 577 | | scope.Failed(e); |
| 0 | 578 | | throw; |
| | 579 | | } |
| 0 | 580 | | } |
| | 581 | |
|
| | 582 | | /// <summary> |
| | 583 | | /// Creates a backup of the certificate, including all versions, which can be used to restore the certificate to |
| | 584 | | /// restore the certificate to a different vault in the same region as the original value. This operation requir |
| | 585 | | /// </summary> |
| | 586 | | /// <param name="certificateName">The name of the <see cref="KeyVaultCertificate"/> to backup.</param> |
| | 587 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 588 | | /// <returns>The certificate backup.</returns> |
| | 589 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 590 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 591 | | public virtual async Task<Response<byte[]>> BackupCertificateAsync(string certificateName, CancellationToken can |
| | 592 | | { |
| 0 | 593 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 594 | |
|
| 0 | 595 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(BackupCertificate) |
| 0 | 596 | | scope.AddAttribute("certificate", certificateName); |
| 0 | 597 | | scope.Start(); |
| | 598 | |
|
| | 599 | | try |
| | 600 | | { |
| 0 | 601 | | Response<CertificateBackup> backup = await _pipeline.SendRequestAsync(RequestMethod.Post, () => new Cert |
| | 602 | |
|
| 0 | 603 | | return Response.FromValue(backup.Value.Value, backup.GetRawResponse()); |
| | 604 | | } |
| 0 | 605 | | catch (Exception e) |
| | 606 | | { |
| 0 | 607 | | scope.Failed(e); |
| 0 | 608 | | throw; |
| | 609 | | } |
| 0 | 610 | | } |
| | 611 | |
|
| | 612 | | /// <summary> |
| | 613 | | /// Restores a <see cref="KeyVaultCertificate"/>, including all versions, from a backup created from the <see cr |
| | 614 | | /// to a vault in the same region as its original vault. This operation requires the certificate/restore permiss |
| | 615 | | /// </summary> |
| | 616 | | /// <param name="backup">The backup of the <see cref="KeyVaultCertificate"/> to restore.</param> |
| | 617 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 618 | | /// <returns>The restored certificate and policy.</returns> |
| | 619 | | /// <exception cref="ArgumentNullException"><paramref name="backup"/> is null.</exception> |
| | 620 | | public virtual Response<KeyVaultCertificateWithPolicy> RestoreCertificateBackup(byte[] backup, CancellationToken |
| | 621 | | { |
| 0 | 622 | | Argument.AssertNotNull(backup, nameof(backup)); |
| | 623 | |
|
| 0 | 624 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(RestoreCertificate |
| 0 | 625 | | scope.Start(); |
| | 626 | |
|
| | 627 | | try |
| | 628 | | { |
| 0 | 629 | | return _pipeline.SendRequest(RequestMethod.Post, new CertificateBackup { Value = backup }, () => new Key |
| | 630 | | } |
| 0 | 631 | | catch (Exception e) |
| | 632 | | { |
| 0 | 633 | | scope.Failed(e); |
| 0 | 634 | | throw; |
| | 635 | | } |
| 0 | 636 | | } |
| | 637 | |
|
| | 638 | | /// <summary> |
| | 639 | | /// Restores a <see cref="KeyVaultCertificate"/>, including all versions, from a backup created from the <see cr |
| | 640 | | /// to a vault in the same region as its original vault. This operation requires the certificate/restore permiss |
| | 641 | | /// </summary> |
| | 642 | | /// <param name="backup">The backup of the <see cref="KeyVaultCertificate"/> to restore.</param> |
| | 643 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 644 | | /// <returns>The restored certificate and policy.</returns> |
| | 645 | | /// <exception cref="ArgumentNullException"><paramref name="backup"/> is null.</exception> |
| | 646 | | public virtual async Task<Response<KeyVaultCertificateWithPolicy>> RestoreCertificateBackupAsync(byte[] backup, |
| | 647 | | { |
| 0 | 648 | | Argument.AssertNotNull(backup, nameof(backup)); |
| | 649 | |
|
| 0 | 650 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(RestoreCertificate |
| 0 | 651 | | scope.Start(); |
| | 652 | |
|
| | 653 | | try |
| | 654 | | { |
| 0 | 655 | | return await _pipeline.SendRequestAsync(RequestMethod.Post, new CertificateBackup { Value = backup }, () |
| | 656 | | } |
| 0 | 657 | | catch (Exception e) |
| | 658 | | { |
| 0 | 659 | | scope.Failed(e); |
| 0 | 660 | | throw; |
| | 661 | | } |
| 0 | 662 | | } |
| | 663 | |
|
| | 664 | | /// <summary> |
| | 665 | | /// Imports a pre-existing certificate to the key vault. The specified certificate must be in PFX or ASCII PEM f |
| | 666 | | /// certificates/import permission. |
| | 667 | | /// </summary> |
| | 668 | | /// <param name="importCertificateOptions">The details of the certificate to import to the key vault.</param> |
| | 669 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 670 | | /// <returns>The imported certificate and policy.</returns> |
| | 671 | | /// <exception cref="ArgumentException"><see cref="ImportCertificateOptions.Name"/> of <paramref name="importCer |
| | 672 | | /// <exception cref="ArgumentNullException"><paramref name="importCertificateOptions"/> or <see cref="ImportCert |
| | 673 | | public virtual Response<KeyVaultCertificateWithPolicy> ImportCertificate(ImportCertificateOptions importCertific |
| | 674 | | { |
| 4 | 675 | | Argument.AssertNotNull(importCertificateOptions, nameof(importCertificateOptions)); |
| 4 | 676 | | Argument.AssertNotNullOrEmpty(importCertificateOptions.Name, nameof(importCertificateOptions.Name)); |
| | 677 | |
|
| 4 | 678 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(ImportCertificate) |
| 4 | 679 | | scope.AddAttribute("certificate", importCertificateOptions.Name); |
| 4 | 680 | | scope.Start(); |
| | 681 | |
|
| | 682 | | try |
| | 683 | | { |
| 8 | 684 | | return _pipeline.SendRequest(RequestMethod.Post, importCertificateOptions, () => new KeyVaultCertificate |
| | 685 | | } |
| 0 | 686 | | catch (Exception e) |
| | 687 | | { |
| 0 | 688 | | scope.Failed(e); |
| 0 | 689 | | throw; |
| | 690 | | } |
| 4 | 691 | | } |
| | 692 | |
|
| | 693 | | /// <summary> |
| | 694 | | /// Imports a pre-existing certificate to the key vault. The specified certificate must be in PFX or ASCII PEM f |
| | 695 | | /// certificates/import permission. |
| | 696 | | /// </summary> |
| | 697 | | /// <param name="importCertificateOptions">The details of the certificate to import to the key vault.</param> |
| | 698 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 699 | | /// <returns>The imported certificate and policy.</returns> |
| | 700 | | /// <exception cref="ArgumentException"><see cref="ImportCertificateOptions.Name"/> of <paramref name="importCer |
| | 701 | | /// <exception cref="ArgumentNullException"><paramref name="importCertificateOptions"/> or <see cref="ImportCert |
| | 702 | | public virtual async Task<Response<KeyVaultCertificateWithPolicy>> ImportCertificateAsync(ImportCertificateOptio |
| | 703 | | { |
| 4 | 704 | | Argument.AssertNotNull(importCertificateOptions, nameof(importCertificateOptions)); |
| 4 | 705 | | Argument.AssertNotNullOrEmpty(importCertificateOptions.Name, nameof(importCertificateOptions.Name)); |
| | 706 | |
|
| 4 | 707 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(ImportCertificate) |
| 4 | 708 | | scope.AddAttribute("certificate", importCertificateOptions.Name); |
| 4 | 709 | | scope.Start(); |
| | 710 | |
|
| | 711 | | try |
| | 712 | | { |
| 8 | 713 | | return await _pipeline.SendRequestAsync(RequestMethod.Post, importCertificateOptions, () => new KeyVault |
| | 714 | | } |
| 0 | 715 | | catch (Exception e) |
| | 716 | | { |
| 0 | 717 | | scope.Failed(e); |
| 0 | 718 | | throw; |
| | 719 | | } |
| 4 | 720 | | } |
| | 721 | |
|
| | 722 | | /// <summary> |
| | 723 | | /// Lists the properties of all certificates in the specified vault. You can use the returned <see cref="Certifi |
| | 724 | | /// This operation requires the certificates/list permission. |
| | 725 | | /// </summary> |
| | 726 | | /// <param name="includePending">Specifies whether to include certificates in a pending state as well.</param> |
| | 727 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 728 | | /// <returns>An enumerable collection of certificate metadata.</returns> |
| | 729 | | public virtual Pageable<CertificateProperties> GetPropertiesOfCertificates(bool includePending = default, Cancel |
| | 730 | | { |
| 0 | 731 | | Uri firstPageUri = _pipeline.CreateFirstPageUri(CertificatesPath, ("includePending", includePending.ToString |
| | 732 | |
|
| 0 | 733 | | return PageResponseEnumerator.CreateEnumerable(nextLink => _pipeline.GetPage(firstPageUri, nextLink, () => n |
| | 734 | | } |
| | 735 | |
|
| | 736 | | /// <summary> |
| | 737 | | /// Lists the properties of all certificates in the specified vault. You can use the returned <see cref="Certifi |
| | 738 | | /// This operation requires the certificates/list permission. |
| | 739 | | /// </summary> |
| | 740 | | /// <param name="includePending">Specifies whether to include certificates in a pending state as well.</param> |
| | 741 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 742 | | /// <returns>An enumerable collection of certificate metadata.</returns> |
| | 743 | | public virtual AsyncPageable<CertificateProperties> GetPropertiesOfCertificatesAsync(bool includePending = defau |
| | 744 | | { |
| 0 | 745 | | Uri firstPageUri = _pipeline.CreateFirstPageUri(CertificatesPath, ("includePending", includePending.ToString |
| | 746 | |
|
| 0 | 747 | | return PageResponseEnumerator.CreateAsyncEnumerable(nextLink => _pipeline.GetPageAsync(firstPageUri, nextLin |
| | 748 | | } |
| | 749 | |
|
| | 750 | | /// <summary> |
| | 751 | | /// Lists the properties of all versions of the specified certificate in the specified vault. You can use the re |
| | 752 | | /// This operation requires the certificates/list permission. |
| | 753 | | /// </summary> |
| | 754 | | /// <param name="certificateName">The name of the certificate whose versions should be retrieved.</param> |
| | 755 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 756 | | /// <returns>An enumerable collection of the certificate's versions.</returns> |
| | 757 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 758 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 759 | | public virtual Pageable<CertificateProperties> GetPropertiesOfCertificateVersions(string certificateName, Cancel |
| | 760 | | { |
| 0 | 761 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 762 | |
|
| 0 | 763 | | Uri firstPageUri = _pipeline.CreateFirstPageUri($"{CertificatesPath}{certificateName}/versions"); |
| | 764 | |
|
| 0 | 765 | | return PageResponseEnumerator.CreateEnumerable(nextLink => _pipeline.GetPage(firstPageUri, nextLink, () => n |
| | 766 | | } |
| | 767 | |
|
| | 768 | | /// <summary> |
| | 769 | | /// Lists the properties of all versions of the specified certificate in the specified vault. You can use the re |
| | 770 | | /// This operation requires the certificates/list permission. |
| | 771 | | /// </summary> |
| | 772 | | /// <param name="certificateName">The name of the certificate whose versions should be retrieved.</param> |
| | 773 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 774 | | /// <returns>An enumerable collection of the certificate's versions.</returns> |
| | 775 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 776 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 777 | | public virtual AsyncPageable<CertificateProperties> GetPropertiesOfCertificateVersionsAsync(string certificateNa |
| | 778 | | { |
| 0 | 779 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 780 | |
|
| 0 | 781 | | Uri firstPageUri = _pipeline.CreateFirstPageUri($"{CertificatesPath}{certificateName}/versions"); |
| | 782 | |
|
| 0 | 783 | | return PageResponseEnumerator.CreateAsyncEnumerable(nextLink => _pipeline.GetPageAsync(firstPageUri, nextLin |
| | 784 | | } |
| | 785 | |
|
| | 786 | | /// <summary> |
| | 787 | | /// Enumerates the deleted certificates in the vault. This operation is only available on soft delete-enabled va |
| | 788 | | /// </summary> |
| | 789 | | /// <param name="includePending">Specifies whether to include certificates in a delete pending state as well.</p |
| | 790 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 791 | | /// <returns>An enumerable collection of deleted certificates.</returns> |
| | 792 | | public virtual Pageable<DeletedCertificate> GetDeletedCertificates(bool includePending = default, CancellationTo |
| | 793 | | { |
| 0 | 794 | | Uri firstPageUri = _pipeline.CreateFirstPageUri(DeletedCertificatesPath, ("includePending", includePending.T |
| | 795 | |
|
| 0 | 796 | | return PageResponseEnumerator.CreateEnumerable(nextLink => _pipeline.GetPage(firstPageUri, nextLink, () => n |
| | 797 | | } |
| | 798 | |
|
| | 799 | | /// <summary> |
| | 800 | | /// Enumerates the deleted certificates in the vault. This operation is only available on soft delete-enabled va |
| | 801 | | /// </summary> |
| | 802 | | /// <param name="includePending">Specifies whether to include certificates in a delete pending state as well.</p |
| | 803 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 804 | | /// <returns>An enumerable collection of deleted certificates.</returns> |
| | 805 | | public virtual AsyncPageable<DeletedCertificate> GetDeletedCertificatesAsync(bool includePending = default, Canc |
| | 806 | | { |
| 0 | 807 | | Uri firstPageUri = _pipeline.CreateFirstPageUri(DeletedCertificatesPath, ("includePending", includePending.T |
| | 808 | |
|
| 0 | 809 | | return PageResponseEnumerator.CreateAsyncEnumerable(nextLink => _pipeline.GetPageAsync(firstPageUri, nextLin |
| | 810 | | } |
| | 811 | |
|
| | 812 | | /// <summary> |
| | 813 | | /// Retrieves the <see cref="CertificatePolicy"/> of the specified certificate. This operation requires the cert |
| | 814 | | /// </summary> |
| | 815 | | /// <param name="certificateName">The name of the certificate whose policy should be retrieved.</param> |
| | 816 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 817 | | /// <returns>The <see cref="CertificatePolicy"/> of the specified certificate.</returns> |
| | 818 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 819 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 820 | | public virtual Response<CertificatePolicy> GetCertificatePolicy(string certificateName, CancellationToken cancel |
| | 821 | | { |
| 6 | 822 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 823 | |
|
| 2 | 824 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetCertificatePoli |
| 2 | 825 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 826 | | scope.Start(); |
| | 827 | |
|
| | 828 | | try |
| | 829 | | { |
| 4 | 830 | | return _pipeline.SendRequest(RequestMethod.Get, () => new CertificatePolicy(), cancellationToken, Certif |
| | 831 | | } |
| 0 | 832 | | catch (Exception e) |
| | 833 | | { |
| 0 | 834 | | scope.Failed(e); |
| 0 | 835 | | throw; |
| | 836 | | } |
| 2 | 837 | | } |
| | 838 | |
|
| | 839 | | /// <summary> |
| | 840 | | /// Retrieves the <see cref="CertificatePolicy"/> of the specified certificate. This operation requires the cert |
| | 841 | | /// </summary> |
| | 842 | | /// <param name="certificateName">The name of the certificate whose policy should be retrieved.</param> |
| | 843 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 844 | | /// <returns>The <see cref="CertificatePolicy"/> of the specified certificate.</returns> |
| | 845 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 846 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 847 | | public virtual async Task<Response<CertificatePolicy>> GetCertificatePolicyAsync(string certificateName, Cancell |
| | 848 | | { |
| 6 | 849 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 850 | |
|
| 2 | 851 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetCertificatePoli |
| 2 | 852 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 853 | | scope.Start(); |
| | 854 | |
|
| | 855 | | try |
| | 856 | | { |
| 4 | 857 | | return await _pipeline.SendRequestAsync(RequestMethod.Get, () => new CertificatePolicy(), cancellationTo |
| | 858 | | } |
| 0 | 859 | | catch (Exception e) |
| | 860 | | { |
| 0 | 861 | | scope.Failed(e); |
| 0 | 862 | | throw; |
| | 863 | | } |
| 2 | 864 | | } |
| | 865 | |
|
| | 866 | | /// <summary> |
| | 867 | | /// Updates the <see cref="CertificatePolicy"/> of the specified certificate. This operation requires the certif |
| | 868 | | /// </summary> |
| | 869 | | /// <param name="certificateName">The name of the certificate whose policy should be updated.</param> |
| | 870 | | /// <param name="policy">The updated policy for the specified certificate.</param> |
| | 871 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 872 | | /// <returns>The updated certificate policy.</returns> |
| | 873 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 874 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 875 | | public virtual Response<CertificatePolicy> UpdateCertificatePolicy(string certificateName, CertificatePolicy pol |
| | 876 | | { |
| 6 | 877 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 878 | |
|
| 2 | 879 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(UpdateCertificateP |
| 2 | 880 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 881 | | scope.Start(); |
| | 882 | |
|
| | 883 | | try |
| | 884 | | { |
| 4 | 885 | | return _pipeline.SendRequest(RequestMethod.Patch, policy, () => new CertificatePolicy(), cancellationTok |
| | 886 | | } |
| 0 | 887 | | catch (Exception e) |
| | 888 | | { |
| 0 | 889 | | scope.Failed(e); |
| 0 | 890 | | throw; |
| | 891 | | } |
| 2 | 892 | | } |
| | 893 | |
|
| | 894 | | /// <summary> |
| | 895 | | /// Updates the <see cref="CertificatePolicy"/> of the specified certificate. This operation requires the certif |
| | 896 | | /// </summary> |
| | 897 | | /// <param name="certificateName">The name of the certificate whose policy should be updated.</param> |
| | 898 | | /// <param name="policy">The updated policy for the specified certificate.</param> |
| | 899 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 900 | | /// <returns>The updated certificate policy.</returns> |
| | 901 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 902 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 903 | | public virtual async Task<Response<CertificatePolicy>> UpdateCertificatePolicyAsync(string certificateName, Cert |
| | 904 | | { |
| 6 | 905 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 906 | |
|
| 2 | 907 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(UpdateCertificateP |
| 2 | 908 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 909 | | scope.Start(); |
| | 910 | |
|
| | 911 | | try |
| | 912 | | { |
| 4 | 913 | | return await _pipeline.SendRequestAsync(RequestMethod.Patch, policy, () => new CertificatePolicy(), canc |
| | 914 | | } |
| 0 | 915 | | catch (Exception e) |
| | 916 | | { |
| 0 | 917 | | scope.Failed(e); |
| 0 | 918 | | throw; |
| | 919 | | } |
| 2 | 920 | | } |
| | 921 | |
|
| | 922 | | /// <summary> |
| | 923 | | /// Creates or replaces a certificate <see cref="CertificateIssuer"/> in the key vault. This operation requires |
| | 924 | | /// </summary> |
| | 925 | | /// <param name="issuer">The <see cref="CertificateIssuer"/> to add or replace in the vault.</param> |
| | 926 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 927 | | /// <returns>The created certificate issuer.</returns> |
| | 928 | | /// <exception cref="ArgumentException"><see cref="CertificateIssuer.Name"/> of <paramref name="issuer"/> is emp |
| | 929 | | /// <exception cref="ArgumentNullException"><paramref name="issuer"/> or <see cref="CertificateIssuer.Name"/> of |
| | 930 | | public virtual Response<CertificateIssuer> CreateIssuer(CertificateIssuer issuer, CancellationToken cancellation |
| | 931 | | { |
| 16 | 932 | | Argument.AssertNotNull(issuer, nameof(issuer)); |
| | 933 | |
|
| 14 | 934 | | if (string.IsNullOrEmpty(issuer.Name)) |
| | 935 | | { |
| 2 | 936 | | throw new ArgumentException($"{nameof(issuer)}.{nameof(issuer.Name)} cannot be null or an empty string." |
| | 937 | | } |
| | 938 | |
|
| 12 | 939 | | if (string.IsNullOrEmpty(issuer.Provider)) |
| | 940 | | { |
| 2 | 941 | | throw new ArgumentException($"{nameof(issuer)}.{nameof(issuer.Provider)} cannot be null or an empty stri |
| | 942 | | } |
| | 943 | |
|
| 10 | 944 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(CreateIssuer)}"); |
| 10 | 945 | | scope.AddAttribute("issuer", issuer.Name); |
| 10 | 946 | | scope.Start(); |
| | 947 | |
|
| | 948 | | try |
| | 949 | | { |
| 20 | 950 | | return _pipeline.SendRequest(RequestMethod.Put, issuer, () => new CertificateIssuer(), cancellationToken |
| | 951 | | } |
| 0 | 952 | | catch (Exception e) |
| | 953 | | { |
| 0 | 954 | | scope.Failed(e); |
| 0 | 955 | | throw; |
| | 956 | | } |
| 10 | 957 | | } |
| | 958 | |
|
| | 959 | | /// <summary> |
| | 960 | | /// Creates or replaces a certificate <see cref="CertificateIssuer"/> in the key vault. This operation requires |
| | 961 | | /// </summary> |
| | 962 | | /// <param name="issuer">The <see cref="CertificateIssuer"/> to add or replace in the vault.</param> |
| | 963 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 964 | | /// <returns>The created certificate issuer.</returns> |
| | 965 | | /// <exception cref="ArgumentException"><see cref="CertificateIssuer.Name"/> of <paramref name="issuer"/> is emp |
| | 966 | | /// <exception cref="ArgumentNullException"><paramref name="issuer"/> or <see cref="CertificateIssuer.Name"/> of |
| | 967 | | public virtual async Task<Response<CertificateIssuer>> CreateIssuerAsync(CertificateIssuer issuer, CancellationT |
| | 968 | | { |
| 16 | 969 | | Argument.AssertNotNull(issuer, nameof(issuer)); |
| | 970 | |
|
| 14 | 971 | | if (string.IsNullOrEmpty(issuer.Name)) |
| | 972 | | { |
| 2 | 973 | | throw new ArgumentException($"{nameof(issuer)}.{nameof(issuer.Name)} cannot be null or an empty string." |
| | 974 | | } |
| | 975 | |
|
| 12 | 976 | | if (string.IsNullOrEmpty(issuer.Provider)) |
| | 977 | | { |
| 2 | 978 | | throw new ArgumentException($"{nameof(issuer)}.{nameof(issuer.Provider)} cannot be null or an empty stri |
| | 979 | | } |
| | 980 | |
|
| 10 | 981 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(CreateIssuer)}"); |
| 10 | 982 | | scope.AddAttribute("issuer", issuer.Name); |
| 10 | 983 | | scope.Start(); |
| | 984 | |
|
| | 985 | | try |
| | 986 | | { |
| 20 | 987 | | return await _pipeline.SendRequestAsync(RequestMethod.Put, issuer, () => new CertificateIssuer(), cancel |
| | 988 | | } |
| 0 | 989 | | catch (Exception e) |
| | 990 | | { |
| 0 | 991 | | scope.Failed(e); |
| 0 | 992 | | throw; |
| | 993 | | } |
| 10 | 994 | | } |
| | 995 | |
|
| | 996 | | /// <summary> |
| | 997 | | /// Retrieves the specified certificate <see cref="CertificateIssuer"/> from the vault. This operation requires |
| | 998 | | /// </summary> |
| | 999 | | /// <param name="issuerName">The name of the <see cref="CertificateIssuer"/> to retrieve.</param> |
| | 1000 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1001 | | /// <returns>The retrieved certificate issuer.</returns> |
| | 1002 | | /// <exception cref="ArgumentException"><paramref name="issuerName"/> is empty.</exception> |
| | 1003 | | /// <exception cref="ArgumentNullException"><paramref name="issuerName"/> is null.</exception> |
| | 1004 | | public virtual Response<CertificateIssuer> GetIssuer(string issuerName, CancellationToken cancellationToken = de |
| | 1005 | | { |
| 6 | 1006 | | Argument.AssertNotNullOrEmpty(issuerName, nameof(issuerName)); |
| | 1007 | |
|
| 2 | 1008 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetIssuer)}"); |
| 2 | 1009 | | scope.AddAttribute("issuer", issuerName); |
| 2 | 1010 | | scope.Start(); |
| | 1011 | |
|
| | 1012 | | try |
| | 1013 | | { |
| 4 | 1014 | | return _pipeline.SendRequest(RequestMethod.Get, () => new CertificateIssuer(), cancellationToken, Issuer |
| | 1015 | | } |
| 0 | 1016 | | catch (Exception e) |
| | 1017 | | { |
| 0 | 1018 | | scope.Failed(e); |
| 0 | 1019 | | throw; |
| | 1020 | | } |
| 2 | 1021 | | } |
| | 1022 | |
|
| | 1023 | | /// <summary> |
| | 1024 | | /// Retrieves the specified certificate <see cref="CertificateIssuer"/> from the vault. This operation requires |
| | 1025 | | /// </summary> |
| | 1026 | | /// <param name="issuerName">The name of the <see cref="CertificateIssuer"/> to retrieve.</param> |
| | 1027 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1028 | | /// <returns>The retrieved certificate issuer.</returns> |
| | 1029 | | /// <exception cref="ArgumentException"><paramref name="issuerName"/> is empty.</exception> |
| | 1030 | | /// <exception cref="ArgumentNullException"><paramref name="issuerName"/> is null.</exception> |
| | 1031 | | public virtual async Task<Response<CertificateIssuer>> GetIssuerAsync(string issuerName, CancellationToken cance |
| | 1032 | | { |
| 6 | 1033 | | Argument.AssertNotNullOrEmpty(issuerName, nameof(issuerName)); |
| | 1034 | |
|
| 2 | 1035 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetIssuer)}"); |
| 2 | 1036 | | scope.AddAttribute("issuer", issuerName); |
| 2 | 1037 | | scope.Start(); |
| | 1038 | |
|
| | 1039 | | try |
| | 1040 | | { |
| 4 | 1041 | | return await _pipeline.SendRequestAsync(RequestMethod.Get, () => new CertificateIssuer(), cancellationTo |
| | 1042 | | } |
| 0 | 1043 | | catch (Exception e) |
| | 1044 | | { |
| 0 | 1045 | | scope.Failed(e); |
| 0 | 1046 | | throw; |
| | 1047 | | } |
| 2 | 1048 | | } |
| | 1049 | |
|
| | 1050 | | /// <summary> |
| | 1051 | | /// Updates the specified certificate <see cref="CertificateIssuer"/> in the vault, only updating the specified |
| | 1052 | | /// </summary> |
| | 1053 | | /// <param name="issuer">The <see cref="CertificateIssuer"/> to update in the vault.</param> |
| | 1054 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1055 | | /// <returns>The updated certificate issuer.</returns> |
| | 1056 | | /// <exception cref="ArgumentException"><see cref="CertificateIssuer.Name"/> of <paramref name="issuer"/> is emp |
| | 1057 | | /// <exception cref="ArgumentNullException"><paramref name="issuer"/> or <see cref="CertificateIssuer.Name"/> of |
| | 1058 | | public virtual Response<CertificateIssuer> UpdateIssuer(CertificateIssuer issuer, CancellationToken cancellation |
| | 1059 | | { |
| 6 | 1060 | | Argument.AssertNotNull(issuer, nameof(issuer)); |
| | 1061 | |
|
| 4 | 1062 | | if (string.IsNullOrEmpty(issuer.Name)) |
| | 1063 | | { |
| 2 | 1064 | | throw new ArgumentException($"{nameof(issuer)}.{nameof(issuer.Name)} cannot be null or an empty string." |
| | 1065 | | } |
| | 1066 | |
|
| 2 | 1067 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(UpdateIssuer)}"); |
| 2 | 1068 | | scope.AddAttribute("issuer", issuer.Name); |
| 2 | 1069 | | scope.Start(); |
| | 1070 | |
|
| | 1071 | | try |
| | 1072 | | { |
| 4 | 1073 | | return _pipeline.SendRequest(RequestMethod.Patch, issuer, () => new CertificateIssuer(), cancellationTok |
| | 1074 | | } |
| 0 | 1075 | | catch (Exception e) |
| | 1076 | | { |
| 0 | 1077 | | scope.Failed(e); |
| 0 | 1078 | | throw; |
| | 1079 | | } |
| 2 | 1080 | | } |
| | 1081 | |
|
| | 1082 | | /// <summary> |
| | 1083 | | /// Updates the specified certificate <see cref="CertificateIssuer"/> in the vault, only updating the specified |
| | 1084 | | /// </summary> |
| | 1085 | | /// <param name="issuer">The <see cref="CertificateIssuer"/> to update in the vault.</param> |
| | 1086 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1087 | | /// <returns>The updated certificate issuer.</returns> |
| | 1088 | | /// <exception cref="ArgumentException"><see cref="CertificateIssuer.Name"/> of <paramref name="issuer"/> is emp |
| | 1089 | | /// <exception cref="ArgumentNullException"><paramref name="issuer"/> or <see cref="CertificateIssuer.Name"/> of |
| | 1090 | | public virtual async Task<Response<CertificateIssuer>> UpdateIssuerAsync(CertificateIssuer issuer, CancellationT |
| | 1091 | | { |
| 6 | 1092 | | Argument.AssertNotNull(issuer, nameof(issuer)); |
| | 1093 | |
|
| 4 | 1094 | | if (string.IsNullOrEmpty(issuer.Name)) |
| | 1095 | | { |
| 2 | 1096 | | throw new ArgumentException($"{nameof(issuer)}.{nameof(issuer.Name)} cannot be null or an empty string." |
| | 1097 | | } |
| | 1098 | |
|
| 2 | 1099 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(UpdateIssuer)}"); |
| 2 | 1100 | | scope.AddAttribute("issuer", issuer.Name); |
| 2 | 1101 | | scope.Start(); |
| | 1102 | |
|
| | 1103 | | try |
| | 1104 | | { |
| 4 | 1105 | | return await _pipeline.SendRequestAsync(RequestMethod.Patch, issuer, () => new CertificateIssuer(), canc |
| | 1106 | | } |
| 0 | 1107 | | catch (Exception e) |
| | 1108 | | { |
| 0 | 1109 | | scope.Failed(e); |
| 0 | 1110 | | throw; |
| | 1111 | | } |
| 2 | 1112 | | } |
| | 1113 | |
|
| | 1114 | | /// <summary> |
| | 1115 | | /// Deletes the specified certificate <see cref="CertificateIssuer"/> from the vault. This operation requires th |
| | 1116 | | /// </summary> |
| | 1117 | | /// <param name="issuerName">The name of the <see cref="CertificateIssuer"/> to delete.</param> |
| | 1118 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1119 | | /// <returns>The deleted certificate issuer.</returns> |
| | 1120 | | /// <exception cref="ArgumentException"><paramref name="issuerName"/> is empty.</exception> |
| | 1121 | | /// <exception cref="ArgumentNullException"><paramref name="issuerName"/> is null.</exception> |
| | 1122 | | public virtual Response<CertificateIssuer> DeleteIssuer(string issuerName, CancellationToken cancellationToken = |
| | 1123 | | { |
| 6 | 1124 | | Argument.AssertNotNullOrEmpty(issuerName, nameof(issuerName)); |
| | 1125 | |
|
| 2 | 1126 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(DeleteIssuer)}"); |
| 2 | 1127 | | scope.AddAttribute("issuer", issuerName); |
| 2 | 1128 | | scope.Start(); |
| | 1129 | |
|
| | 1130 | | try |
| | 1131 | | { |
| 4 | 1132 | | return _pipeline.SendRequest(RequestMethod.Delete, () => new CertificateIssuer(), cancellationToken, Iss |
| | 1133 | | } |
| 0 | 1134 | | catch (Exception e) |
| | 1135 | | { |
| 0 | 1136 | | scope.Failed(e); |
| 0 | 1137 | | throw; |
| | 1138 | | } |
| 2 | 1139 | | } |
| | 1140 | |
|
| | 1141 | | /// <summary> |
| | 1142 | | /// Deletes the specified certificate <see cref="CertificateIssuer"/> from the vault. This operation requires th |
| | 1143 | | /// </summary> |
| | 1144 | | /// <param name="issuerName">The name of the <see cref="CertificateIssuer"/> to delete.</param> |
| | 1145 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1146 | | /// <returns>The deleted certificate issuer.</returns> |
| | 1147 | | /// <exception cref="ArgumentException"><paramref name="issuerName"/> is empty.</exception> |
| | 1148 | | /// <exception cref="ArgumentNullException"><paramref name="issuerName"/> is null.</exception> |
| | 1149 | | public virtual async Task<Response<CertificateIssuer>> DeleteIssuerAsync(string issuerName, CancellationToken ca |
| | 1150 | | { |
| 6 | 1151 | | Argument.AssertNotNullOrEmpty(issuerName, nameof(issuerName)); |
| | 1152 | |
|
| 2 | 1153 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(DeleteIssuer)}"); |
| 2 | 1154 | | scope.AddAttribute("issuer", issuerName); |
| 2 | 1155 | | scope.Start(); |
| | 1156 | |
|
| | 1157 | | try |
| | 1158 | | { |
| 4 | 1159 | | return await _pipeline.SendRequestAsync(RequestMethod.Delete, () => new CertificateIssuer(), cancellatio |
| | 1160 | | } |
| 0 | 1161 | | catch (Exception e) |
| | 1162 | | { |
| 0 | 1163 | | scope.Failed(e); |
| 0 | 1164 | | throw; |
| | 1165 | | } |
| 2 | 1166 | | } |
| | 1167 | |
|
| | 1168 | | /// <summary> |
| | 1169 | | /// Lists the properties of all issuers in the specified vault. You can use the returned <see cref="CertificateP |
| | 1170 | | /// This operation requires the certificates/getissuers permission. |
| | 1171 | | /// </summary> |
| | 1172 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1173 | | /// <returns>An enumerable collection of certificate issuers' metadata.</returns> |
| | 1174 | | public virtual Pageable<IssuerProperties> GetPropertiesOfIssuers(CancellationToken cancellationToken = default) |
| | 1175 | | { |
| 2 | 1176 | | Uri firstPageUri = _pipeline.CreateFirstPageUri(IssuersPath); |
| | 1177 | |
|
| 16 | 1178 | | return PageResponseEnumerator.CreateEnumerable(nextLink => _pipeline.GetPage(firstPageUri, nextLink, () => n |
| | 1179 | | } |
| | 1180 | |
|
| | 1181 | | /// <summary> |
| | 1182 | | /// Lists the properties of all issuers in the specified vault. You can use the returned <see cref="CertificateP |
| | 1183 | | /// This operation requires the certificates/getissuers permission. |
| | 1184 | | /// </summary> |
| | 1185 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1186 | | /// <returns>An enumerable collection of certificate issuers' metadata.</returns> |
| | 1187 | | public virtual AsyncPageable<IssuerProperties> GetPropertiesOfIssuersAsync(CancellationToken cancellationToken = |
| | 1188 | | { |
| 2 | 1189 | | Uri firstPageUri = _pipeline.CreateFirstPageUri(IssuersPath); |
| | 1190 | |
|
| 16 | 1191 | | return PageResponseEnumerator.CreateAsyncEnumerable(nextLink => _pipeline.GetPageAsync(firstPageUri, nextLin |
| | 1192 | | } |
| | 1193 | |
|
| | 1194 | | /// <summary> |
| | 1195 | | /// Gets a pending <see cref="CertificateOperation"/> from the key vault. This operation requires the certificat |
| | 1196 | | /// </summary> |
| | 1197 | | /// <param name="certificateName">The name of the certificate for which an operation is pending.</param> |
| | 1198 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1199 | | /// <returns>The given certificate's current pending operation.</returns> |
| | 1200 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 1201 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 1202 | | public virtual CertificateOperation GetCertificateOperation(string certificateName, CancellationToken cancellati |
| | 1203 | | { |
| 2 | 1204 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 1205 | |
|
| 2 | 1206 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetCertificateOper |
| 2 | 1207 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 1208 | | scope.Start(); |
| | 1209 | |
|
| | 1210 | | try |
| | 1211 | | { |
| 4 | 1212 | | Response<CertificateOperationProperties> response = _pipeline.SendRequest(RequestMethod.Get, () => new C |
| | 1213 | |
|
| 2 | 1214 | | return new CertificateOperation(response, this); |
| | 1215 | | } |
| 0 | 1216 | | catch (Exception e) |
| | 1217 | | { |
| 0 | 1218 | | scope.Failed(e); |
| 0 | 1219 | | throw; |
| | 1220 | | } |
| 2 | 1221 | | } |
| | 1222 | |
|
| | 1223 | | /// <summary> |
| | 1224 | | /// Gets a pending <see cref="CertificateOperation"/> from the key vault. This operation requires the certificat |
| | 1225 | | /// </summary> |
| | 1226 | | /// <param name="certificateName">The name of the certificate for which an operation is pending.</param> |
| | 1227 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1228 | | /// <returns>The given certificate's current pending operation.</returns> |
| | 1229 | | /// <exception cref="ArgumentException"><paramref name="certificateName"/> is empty.</exception> |
| | 1230 | | /// <exception cref="ArgumentNullException"><paramref name="certificateName"/> is null.</exception> |
| | 1231 | | public virtual async Task<CertificateOperation> GetCertificateOperationAsync(string certificateName, Cancellatio |
| | 1232 | | { |
| 2 | 1233 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 1234 | |
|
| 2 | 1235 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetCertificateOper |
| 2 | 1236 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 1237 | | scope.Start(); |
| | 1238 | |
|
| | 1239 | | try |
| | 1240 | | { |
| 4 | 1241 | | Response<CertificateOperationProperties> response = await _pipeline.SendRequestAsync(RequestMethod.Get, |
| | 1242 | |
|
| 2 | 1243 | | return new CertificateOperation(response, this); |
| | 1244 | | } |
| 0 | 1245 | | catch (Exception e) |
| | 1246 | | { |
| 0 | 1247 | | scope.Failed(e); |
| 0 | 1248 | | throw; |
| | 1249 | | } |
| 2 | 1250 | | } |
| | 1251 | |
|
| | 1252 | | /// <summary> |
| | 1253 | | /// Sets the certificate <see cref="CertificateContact"/>s for the key vault, replacing any existing contacts. T |
| | 1254 | | /// </summary> |
| | 1255 | | /// <param name="contacts">The certificate contacts for the vault.</param> |
| | 1256 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1257 | | /// <returns>The updated certificate contacts of the vault.</returns> |
| | 1258 | | /// <exception cref="ArgumentNullException"><paramref name="contacts"/> is null.</exception> |
| | 1259 | | public virtual Response<IList<CertificateContact>> SetContacts(IEnumerable<CertificateContact> contacts, Cancell |
| | 1260 | | { |
| 4 | 1261 | | Argument.AssertNotNull(contacts, nameof(contacts)); |
| | 1262 | |
|
| 2 | 1263 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(SetContacts)}"); |
| 2 | 1264 | | scope.Start(); |
| | 1265 | |
|
| | 1266 | | try |
| | 1267 | | { |
| 4 | 1268 | | Response<ContactList> contactList = _pipeline.SendRequest(RequestMethod.Put, new ContactList(contacts), |
| | 1269 | |
|
| 2 | 1270 | | return Response.FromValue(contactList.Value.ToList(), contactList.GetRawResponse()); |
| | 1271 | | } |
| 0 | 1272 | | catch (Exception e) |
| | 1273 | | { |
| 0 | 1274 | | scope.Failed(e); |
| 0 | 1275 | | throw; |
| | 1276 | | } |
| 2 | 1277 | | } |
| | 1278 | |
|
| | 1279 | | /// <summary> |
| | 1280 | | /// Sets the certificate <see cref="CertificateContact"/>s for the key vault, replacing any existing contacts. T |
| | 1281 | | /// </summary> |
| | 1282 | | /// <param name="contacts">The certificate contacts for the vault.</param> |
| | 1283 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1284 | | /// <returns>The updated certificate contacts of the vault.</returns> |
| | 1285 | | /// <exception cref="ArgumentNullException"><paramref name="contacts"/> is null.</exception> |
| | 1286 | | public virtual async Task<Response<IList<CertificateContact>>> SetContactsAsync(IEnumerable<CertificateContact> |
| | 1287 | | { |
| 4 | 1288 | | Argument.AssertNotNull(contacts, nameof(contacts)); |
| | 1289 | |
|
| 2 | 1290 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(SetContacts)}"); |
| 2 | 1291 | | scope.Start(); |
| | 1292 | |
|
| | 1293 | | try |
| | 1294 | | { |
| 4 | 1295 | | Response<ContactList> contactList = await _pipeline.SendRequestAsync(RequestMethod.Put, new ContactList( |
| | 1296 | |
|
| 2 | 1297 | | return Response.FromValue(contactList.Value.ToList(), contactList.GetRawResponse()); |
| | 1298 | | } |
| 0 | 1299 | | catch (Exception e) |
| | 1300 | | { |
| 0 | 1301 | | scope.Failed(e); |
| 0 | 1302 | | throw; |
| | 1303 | | } |
| 2 | 1304 | | } |
| | 1305 | |
|
| | 1306 | | /// <summary> |
| | 1307 | | /// Gets the certificate <see cref="CertificateContact"/>s for the key vaults. This operation requires the certi |
| | 1308 | | /// </summary> |
| | 1309 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1310 | | /// <returns>The certificate contacts of the vault.</returns> |
| | 1311 | | public virtual Response<IList<CertificateContact>> GetContacts(CancellationToken cancellationToken = default) |
| | 1312 | | { |
| 2 | 1313 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetContacts)}"); |
| 2 | 1314 | | scope.Start(); |
| | 1315 | |
|
| | 1316 | | try |
| | 1317 | | { |
| 4 | 1318 | | Response<ContactList> contactList = _pipeline.SendRequest(RequestMethod.Get, () => new ContactList(), ca |
| | 1319 | |
|
| 2 | 1320 | | return Response.FromValue(contactList.Value.ToList(), contactList.GetRawResponse()); |
| | 1321 | | } |
| 0 | 1322 | | catch (Exception e) |
| | 1323 | | { |
| 0 | 1324 | | scope.Failed(e); |
| 0 | 1325 | | throw; |
| | 1326 | | } |
| 2 | 1327 | | } |
| | 1328 | |
|
| | 1329 | | /// <summary> |
| | 1330 | | /// Gets the certificate <see cref="CertificateContact"/>s for the key vaults. This operation requires the certi |
| | 1331 | | /// </summary> |
| | 1332 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1333 | | /// <returns>The certificate contacts of the vault.</returns> |
| | 1334 | | public virtual async Task<Response<IList<CertificateContact>>> GetContactsAsync(CancellationToken cancellationTo |
| | 1335 | | { |
| 2 | 1336 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetContacts)}"); |
| 2 | 1337 | | scope.Start(); |
| | 1338 | |
|
| | 1339 | | try |
| | 1340 | | { |
| 4 | 1341 | | Response<ContactList> contactList = await _pipeline.SendRequestAsync(RequestMethod.Get, () => new Contac |
| | 1342 | |
|
| 2 | 1343 | | return Response.FromValue(contactList.Value.ToList(), contactList.GetRawResponse()); |
| | 1344 | | } |
| 0 | 1345 | | catch (Exception e) |
| | 1346 | | { |
| 0 | 1347 | | scope.Failed(e); |
| 0 | 1348 | | throw; |
| | 1349 | | } |
| 2 | 1350 | | } |
| | 1351 | |
|
| | 1352 | | /// <summary> |
| | 1353 | | /// Deletes all certificate <see cref="CertificateContact"/>s from the key vault, replacing any existing contact |
| | 1354 | | /// </summary> |
| | 1355 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1356 | | /// <returns>The certificate contacts deleted from the vault.</returns> |
| | 1357 | | public virtual Response<IList<CertificateContact>> DeleteContacts(CancellationToken cancellationToken = default) |
| | 1358 | | { |
| 0 | 1359 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(DeleteContacts)}") |
| 0 | 1360 | | scope.Start(); |
| | 1361 | |
|
| | 1362 | | try |
| | 1363 | | { |
| 0 | 1364 | | Response<ContactList> contactList = _pipeline.SendRequest(RequestMethod.Delete, () => new ContactList(), |
| | 1365 | |
|
| 0 | 1366 | | return Response.FromValue(contactList.Value.ToList(), contactList.GetRawResponse()); |
| | 1367 | | } |
| 0 | 1368 | | catch (Exception e) |
| | 1369 | | { |
| 0 | 1370 | | scope.Failed(e); |
| 0 | 1371 | | throw; |
| | 1372 | | } |
| 0 | 1373 | | } |
| | 1374 | |
|
| | 1375 | | /// <summary> |
| | 1376 | | /// Deletes all certificate <see cref="CertificateContact"/>s from the key vault, replacing any existing contact |
| | 1377 | | /// </summary> |
| | 1378 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1379 | | /// <returns>The certificate contacts deleted from the vault.</returns> |
| | 1380 | | public virtual async Task<Response<IList<CertificateContact>>> DeleteContactsAsync(CancellationToken cancellatio |
| | 1381 | | { |
| 0 | 1382 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(DeleteContacts)}") |
| 0 | 1383 | | scope.Start(); |
| | 1384 | |
|
| | 1385 | | try |
| | 1386 | | { |
| 0 | 1387 | | Response<ContactList> contactList = await _pipeline.SendRequestAsync(RequestMethod.Delete, () => new Con |
| | 1388 | |
|
| 0 | 1389 | | return Response.FromValue(contactList.Value.ToList(), contactList.GetRawResponse()); |
| | 1390 | | } |
| 0 | 1391 | | catch (Exception e) |
| | 1392 | | { |
| 0 | 1393 | | scope.Failed(e); |
| 0 | 1394 | | throw; |
| | 1395 | | } |
| 0 | 1396 | | } |
| | 1397 | |
|
| | 1398 | | /// <summary> |
| | 1399 | | /// Merges a certificate or a certificate chain with a key pair currently available in the service. This operati |
| | 1400 | | /// </summary> |
| | 1401 | | /// <param name="mergeCertificateOptions">The details of the certificate or certificate chain to merge into the |
| | 1402 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1403 | | /// <returns>The merged certificate.</returns> |
| | 1404 | | /// <exception cref="ArgumentNullException"><paramref name="mergeCertificateOptions"/> is null.</exception> |
| | 1405 | | public virtual Response<KeyVaultCertificateWithPolicy> MergeCertificate(MergeCertificateOptions mergeCertificate |
| | 1406 | | { |
| 2 | 1407 | | Argument.AssertNotNull(mergeCertificateOptions, nameof(mergeCertificateOptions)); |
| | 1408 | |
|
| 2 | 1409 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(MergeCertificate)} |
| 2 | 1410 | | scope.AddAttribute("certificate", mergeCertificateOptions.Name); |
| 2 | 1411 | | scope.Start(); |
| | 1412 | |
|
| | 1413 | | try |
| | 1414 | | { |
| 4 | 1415 | | Response<KeyVaultCertificateWithPolicy> certificate = _pipeline.SendRequest(RequestMethod.Post, mergeCer |
| | 1416 | |
|
| 2 | 1417 | | return Response.FromValue(certificate.Value, certificate.GetRawResponse()); |
| | 1418 | | } |
| 0 | 1419 | | catch (Exception e) |
| | 1420 | | { |
| 0 | 1421 | | scope.Failed(e); |
| 0 | 1422 | | throw; |
| | 1423 | | } |
| 2 | 1424 | | } |
| | 1425 | |
|
| | 1426 | | /// <summary> |
| | 1427 | | /// Merges a certificate or a certificate chain with a key pair currently available in the service. This operati |
| | 1428 | | /// </summary> |
| | 1429 | | /// <param name="mergeCertificateOptions">The details of the certificate or certificate chain to merge into the |
| | 1430 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 1431 | | /// <returns>The merged certificate.</returns> |
| | 1432 | | /// <exception cref="ArgumentNullException"><paramref name="mergeCertificateOptions"/> is null.</exception> |
| | 1433 | | public virtual async Task<Response<KeyVaultCertificateWithPolicy>> MergeCertificateAsync(MergeCertificateOptions |
| | 1434 | | { |
| 2 | 1435 | | Argument.AssertNotNull(mergeCertificateOptions, nameof(mergeCertificateOptions)); |
| | 1436 | |
|
| 2 | 1437 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(MergeCertificate)} |
| 2 | 1438 | | scope.AddAttribute("certificate", mergeCertificateOptions.Name); |
| 2 | 1439 | | scope.Start(); |
| | 1440 | |
|
| | 1441 | | try |
| | 1442 | | { |
| 4 | 1443 | | Response<KeyVaultCertificateWithPolicy> certificate = await _pipeline.SendRequestAsync(RequestMethod.Pos |
| | 1444 | |
|
| 2 | 1445 | | return Response.FromValue(certificate.Value, certificate.GetRawResponse()); |
| | 1446 | | } |
| 0 | 1447 | | catch (Exception e) |
| | 1448 | | { |
| 0 | 1449 | | scope.Failed(e); |
| 0 | 1450 | | throw; |
| | 1451 | | } |
| 2 | 1452 | | } |
| | 1453 | |
|
| | 1454 | | internal virtual Response<CertificateOperationProperties> GetPendingCertificate(string certificateName, Cancella |
| | 1455 | | { |
| 310 | 1456 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 1457 | |
|
| 310 | 1458 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetPendingCertific |
| 310 | 1459 | | scope.AddAttribute("certificate", certificateName); |
| 310 | 1460 | | scope.Start(); |
| | 1461 | |
|
| | 1462 | | try |
| | 1463 | | { |
| 310 | 1464 | | Response response = _pipeline.GetResponse(RequestMethod.Get, cancellationToken, CertificatesPath, certif |
| 310 | 1465 | | switch (response.Status) |
| | 1466 | | { |
| | 1467 | | case 200: |
| | 1468 | | case 403: |
| 306 | 1469 | | return _pipeline.CreateResponse(response, new CertificateOperationProperties()); |
| | 1470 | |
|
| | 1471 | | case 404: |
| 4 | 1472 | | return Response.FromValue<CertificateOperationProperties>(null, response); |
| | 1473 | |
|
| | 1474 | | default: |
| 0 | 1475 | | throw _pipeline.Diagnostics.CreateRequestFailedException(response); |
| | 1476 | | } |
| | 1477 | | } |
| 0 | 1478 | | catch (Exception e) |
| | 1479 | | { |
| 0 | 1480 | | scope.Failed(e); |
| 0 | 1481 | | throw; |
| | 1482 | | } |
| 310 | 1483 | | } |
| | 1484 | |
|
| | 1485 | | internal virtual async Task<Response<CertificateOperationProperties>> GetPendingCertificateAsync(string certific |
| | 1486 | | { |
| 364 | 1487 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 1488 | |
|
| 364 | 1489 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(GetPendingCertific |
| 364 | 1490 | | scope.AddAttribute("certificate", certificateName); |
| 364 | 1491 | | scope.Start(); |
| | 1492 | |
|
| | 1493 | | try |
| | 1494 | | { |
| 364 | 1495 | | Response response = await _pipeline.GetResponseAsync(RequestMethod.Get, cancellationToken, CertificatesP |
| 364 | 1496 | | switch (response.Status) |
| | 1497 | | { |
| | 1498 | | case 200: |
| | 1499 | | case 403: |
| 360 | 1500 | | return _pipeline.CreateResponse(response, new CertificateOperationProperties()); |
| | 1501 | |
|
| | 1502 | | case 404: |
| 4 | 1503 | | return Response.FromValue<CertificateOperationProperties>(null, response); |
| | 1504 | |
|
| | 1505 | | default: |
| 0 | 1506 | | throw await _pipeline.Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(fal |
| | 1507 | | } |
| | 1508 | | } |
| 0 | 1509 | | catch (Exception e) |
| | 1510 | | { |
| 0 | 1511 | | scope.Failed(e); |
| 0 | 1512 | | throw; |
| | 1513 | | } |
| 364 | 1514 | | } |
| | 1515 | |
|
| | 1516 | | internal virtual Response<CertificateOperationProperties> CancelCertificateOperation(string certificateName, Can |
| | 1517 | | { |
| 2 | 1518 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 1519 | |
|
| 2 | 1520 | | var parameters = new CertificateOperationUpdateParameters(true); |
| | 1521 | |
|
| 2 | 1522 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(CancelCertificateO |
| 2 | 1523 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 1524 | | scope.Start(); |
| | 1525 | |
|
| | 1526 | | try |
| | 1527 | | { |
| 4 | 1528 | | return _pipeline.SendRequest(RequestMethod.Patch, parameters, () => new CertificateOperationProperties() |
| | 1529 | | } |
| 0 | 1530 | | catch (Exception e) |
| | 1531 | | { |
| 0 | 1532 | | scope.Failed(e); |
| 0 | 1533 | | throw; |
| | 1534 | | } |
| 2 | 1535 | | } |
| | 1536 | |
|
| | 1537 | | internal virtual async Task<Response<CertificateOperationProperties>> CancelCertificateOperationAsync(string cer |
| | 1538 | | { |
| 6 | 1539 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 1540 | |
|
| 6 | 1541 | | var parameters = new CertificateOperationUpdateParameters(true); |
| | 1542 | |
|
| 6 | 1543 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(CancelCertificateO |
| 6 | 1544 | | scope.AddAttribute("certificate", certificateName); |
| 6 | 1545 | | scope.Start(); |
| | 1546 | |
|
| | 1547 | | try |
| | 1548 | | { |
| 12 | 1549 | | return await _pipeline.SendRequestAsync(RequestMethod.Patch, parameters, () => new CertificateOperationP |
| | 1550 | | } |
| 0 | 1551 | | catch (Exception e) |
| | 1552 | | { |
| 0 | 1553 | | scope.Failed(e); |
| 0 | 1554 | | throw; |
| | 1555 | | } |
| 6 | 1556 | | } |
| | 1557 | |
|
| | 1558 | | internal virtual Response<CertificateOperationProperties> DeleteCertificateOperation(string certificateName, Can |
| | 1559 | | { |
| 2 | 1560 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 1561 | |
|
| 2 | 1562 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(DeleteCertificateO |
| 2 | 1563 | | scope.AddAttribute("certificate", certificateName); |
| 2 | 1564 | | scope.Start(); |
| | 1565 | |
|
| | 1566 | | try |
| | 1567 | | { |
| 4 | 1568 | | return _pipeline.SendRequest(RequestMethod.Delete, () => new CertificateOperationProperties(), cancellat |
| | 1569 | | } |
| 0 | 1570 | | catch (Exception e) |
| | 1571 | | { |
| 0 | 1572 | | scope.Failed(e); |
| 0 | 1573 | | throw; |
| | 1574 | | } |
| 2 | 1575 | | } |
| | 1576 | |
|
| | 1577 | | internal virtual async Task<Response<CertificateOperationProperties>> DeleteCertificateOperationAsync(string cer |
| | 1578 | | { |
| 6 | 1579 | | Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); |
| | 1580 | |
|
| 6 | 1581 | | using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(CertificateClient)}.{nameof(DeleteCertificateO |
| 6 | 1582 | | scope.AddAttribute("certificate", certificateName); |
| 6 | 1583 | | scope.Start(); |
| | 1584 | |
|
| | 1585 | | try |
| | 1586 | | { |
| 12 | 1587 | | return await _pipeline.SendRequestAsync(RequestMethod.Delete, () => new CertificateOperationProperties() |
| | 1588 | | } |
| 0 | 1589 | | catch (Exception e) |
| | 1590 | | { |
| 0 | 1591 | | scope.Failed(e); |
| 0 | 1592 | | throw; |
| | 1593 | | } |
| 6 | 1594 | | } |
| | 1595 | | } |
| | 1596 | | } |