@azure/keyvault-certificates 4.9.1-alpha.20250210.1 → 4.9.1-alpha.20250211.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -61,12 +61,22 @@ export class CertificateClient {
61
61
  * in the response. No values are returned for the certificates. This operations requires the certificates/list permission.
62
62
  *
63
63
  * Example usage:
64
- * ```ts
65
- * const client = new CertificateClient(url, credentials);
64
+ * ```ts snippet:IndexListCertificates
65
+ * import { DefaultAzureCredential } from "@azure/identity";
66
+ * import { CertificateClient } from "@azure/keyvault-certificates";
67
+ *
68
+ * const credential = new DefaultAzureCredential();
69
+ *
70
+ * const vaultName = "<YOUR KEYVAULT NAME>";
71
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
72
+ *
73
+ * const client = new CertificateClient(keyVaultUrl, credential);
74
+ *
66
75
  * // All in one call
67
76
  * for await (const certificateProperties of client.listPropertiesOfCertificates()) {
68
77
  * console.log(certificateProperties);
69
78
  * }
79
+ *
70
80
  * // By pages
71
81
  * for await (const page of client.listPropertiesOfCertificates().byPage()) {
72
82
  * for (const certificateProperties of page) {
@@ -85,9 +95,20 @@ export class CertificateClient {
85
95
  * vault. This operation requires the certificates/list permission.
86
96
  *
87
97
  * Example usage:
88
- * ```ts
89
- * const client = new CertificateClient(url, credentials);
90
- * for await (const certificateProperties of client.listPropertiesOfCertificateVersions("MyCertificate")) {
98
+ * ```ts snippet:IndexListCertificateVersions
99
+ * import { DefaultAzureCredential } from "@azure/identity";
100
+ * import { CertificateClient } from "@azure/keyvault-certificates";
101
+ *
102
+ * const credential = new DefaultAzureCredential();
103
+ *
104
+ * const vaultName = "<YOUR KEYVAULT NAME>";
105
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
106
+ *
107
+ * const client = new CertificateClient(keyVaultUrl, credential);
108
+ *
109
+ * for await (const certificateProperties of client.listPropertiesOfCertificateVersions(
110
+ * "MyCertificate",
111
+ * )) {
91
112
  * console.log(certificateProperties.version!);
92
113
  * }
93
114
  * ```
@@ -106,25 +127,38 @@ export class CertificateClient {
106
127
  * This operation requires the certificates/delete permission.
107
128
  *
108
129
  * Example usage:
109
- * ```ts
110
- * const client = new CertificateClient(url, credentials);
111
- * const createPoller = await client.beginCreateCertificate("MyCertificate", {
112
- * issuerName: "Self",
113
- * subject: "cn=MyCert"
114
- * });
115
- * await createPoller.pollUntilDone();
130
+ * ```ts snippet:ReadmeSampleDeleteCertificate
131
+ * import { DefaultAzureCredential } from "@azure/identity";
132
+ * import { CertificateClient } from "@azure/keyvault-certificates";
116
133
  *
117
- * const deletePoller = await client.beginDeleteCertificate("MyCertificate");
134
+ * const credential = new DefaultAzureCredential();
118
135
  *
119
- * // Serializing the poller
120
- * const serialized = deletePoller.toString();
136
+ * const vaultName = "<YOUR KEYVAULT NAME>";
137
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
121
138
  *
122
- * // A new poller can be created with:
123
- * // const newPoller = await client.beginDeleteCertificate("MyCertificate", { resumeFrom: serialized });
139
+ * const client = new CertificateClient(keyVaultUrl, credential);
124
140
  *
125
- * // Waiting until it's done
126
- * const deletedCertificate = await deletePoller.pollUntilDone();
127
- * console.log(deletedCertificate);
141
+ * const certificateName = "MyCertificate";
142
+ *
143
+ * const poller = await client.beginDeleteCertificate(certificateName);
144
+ *
145
+ * // You can use the deleted certificate immediately:
146
+ * const deletedCertificate = poller.getResult();
147
+ *
148
+ * // The certificate is being deleted. Only wait for it if you want to restore it or purge it.
149
+ * await poller.pollUntilDone();
150
+ *
151
+ * // You can also get the deleted certificate this way:
152
+ * await client.getDeletedCertificate(certificateName);
153
+ *
154
+ * // Deleted certificates can also be recovered or purged.
155
+ *
156
+ * // recoverDeletedCertificate returns a poller, just like beginDeleteCertificate.
157
+ * // const recoverPoller = await client.beginRecoverDeletedCertificate(certificateName);
158
+ * // await recoverPoller.pollUntilDone();
159
+ *
160
+ * // If a certificate is done and the Key Vault has soft-delete enabled, the certificate can be purged with:
161
+ * await client.purgeDeletedCertificate(certificateName);
128
162
  * ```
129
163
  * Deletes a certificate from a specified key vault.
130
164
  * @param certificateName - The name of the certificate.
@@ -140,13 +174,17 @@ export class CertificateClient {
140
174
  * Deletes all of the certificate contacts. This operation requires the certificates/managecontacts permission.
141
175
  *
142
176
  * Example usage:
143
- * ```ts
144
- * let client = new CertificateClient(url, credentials);
145
- * await client.setContacts([{
146
- * email: "b@b.com",
147
- * name: "b",
148
- * phone: "222222222222"
149
- * }]);
177
+ * ```ts snippet:CertificateClientDeleteContacts
178
+ * import { DefaultAzureCredential } from "@azure/identity";
179
+ * import { CertificateClient } from "@azure/keyvault-certificates";
180
+ *
181
+ * const credential = new DefaultAzureCredential();
182
+ *
183
+ * const vaultName = "<YOUR KEYVAULT NAME>";
184
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
185
+ *
186
+ * const client = new CertificateClient(keyVaultUrl, credential);
187
+ *
150
188
  * await client.deleteContacts();
151
189
  * ```
152
190
  * Deletes all of the certificate contacts
@@ -165,13 +203,24 @@ export class CertificateClient {
165
203
  * Sets the certificate contacts for the key vault. This operation requires the certificates/managecontacts permission.
166
204
  *
167
205
  * Example usage:
168
- * ```ts
169
- * let client = new CertificateClient(url, credentials);
170
- * await client.setContacts([{
171
- * email: "b@b.com",
172
- * name: "b",
173
- * phone: "222222222222"
174
- * }]);
206
+ * ```ts snippet:CertificateClientSetContacts
207
+ * import { DefaultAzureCredential } from "@azure/identity";
208
+ * import { CertificateClient } from "@azure/keyvault-certificates";
209
+ *
210
+ * const credential = new DefaultAzureCredential();
211
+ *
212
+ * const vaultName = "<YOUR KEYVAULT NAME>";
213
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
214
+ *
215
+ * const client = new CertificateClient(keyVaultUrl, credential);
216
+ *
217
+ * await client.setContacts([
218
+ * {
219
+ * email: "b@b.com",
220
+ * name: "b",
221
+ * phone: "222222222222",
222
+ * },
223
+ * ]);
175
224
  * ```
176
225
  * Sets the certificate contacts.
177
226
  * @param contacts - The contacts to use
@@ -192,15 +241,21 @@ export class CertificateClient {
192
241
  * Returns the set of certificate contact resources in the specified key vault. This operation requires the certificates/managecontacts permission.
193
242
  *
194
243
  * Example usage:
195
- * ```ts
196
- * let client = new CertificateClient(url, credentials);
197
- * await client.setContacts([{
198
- * email: "b@b.com",
199
- * name: "b",
200
- * phone: "222222222222"
201
- * }]);
244
+ * ```ts snippet:CertificateClientGetContacts
245
+ * import { DefaultAzureCredential } from "@azure/identity";
246
+ * import { CertificateClient } from "@azure/keyvault-certificates";
247
+ *
248
+ * const credential = new DefaultAzureCredential();
249
+ *
250
+ * const vaultName = "<YOUR KEYVAULT NAME>";
251
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
252
+ *
253
+ * const client = new CertificateClient(keyVaultUrl, credential);
254
+ *
202
255
  * const contacts = await client.getContacts();
203
- * console.log(contacts);
256
+ * for (const contact of contacts) {
257
+ * console.log(contact);
258
+ * }
204
259
  * ```
205
260
  * Sets the certificate contacts.
206
261
  * @param options - The optional parameters
@@ -215,13 +270,24 @@ export class CertificateClient {
215
270
  * Returns the set of certificate issuer resources in the specified key vault. This operation requires the certificates/manageissuers/getissuers permission.
216
271
  *
217
272
  * Example usage:
218
- * ```ts
219
- * const client = new CertificateClient(url, credentials);
273
+ * ```ts snippet:CertificateClientListIssuers
274
+ * import { DefaultAzureCredential } from "@azure/identity";
275
+ * import { CertificateClient } from "@azure/keyvault-certificates";
276
+ *
277
+ * const credential = new DefaultAzureCredential();
278
+ *
279
+ * const vaultName = "<YOUR KEYVAULT NAME>";
280
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
281
+ *
282
+ * const client = new CertificateClient(keyVaultUrl, credential);
283
+ *
220
284
  * await client.createIssuer("IssuerName", "Test");
285
+ *
221
286
  * // All in one call
222
287
  * for await (const issuerProperties of client.listPropertiesOfIssuers()) {
223
288
  * console.log(issuerProperties);
224
289
  * }
290
+ *
225
291
  * // By pages
226
292
  * for await (const page of client.listPropertiesOfIssuers().byPage()) {
227
293
  * for (const issuerProperties of page) {
@@ -240,8 +306,17 @@ export class CertificateClient {
240
306
  * operation requires the certificates/setissuers permission.
241
307
  *
242
308
  * Example usage:
243
- * ```ts
244
- * const client = new CertificateClient(url, credentials);
309
+ * ```ts snippet:CertificateClientCreateIssuer
310
+ * import { DefaultAzureCredential } from "@azure/identity";
311
+ * import { CertificateClient } from "@azure/keyvault-certificates";
312
+ *
313
+ * const credential = new DefaultAzureCredential();
314
+ *
315
+ * const vaultName = "<YOUR KEYVAULT NAME>";
316
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
317
+ *
318
+ * const client = new CertificateClient(keyVaultUrl, credential);
319
+ *
245
320
  * await client.createIssuer("IssuerName", "Test");
246
321
  * ```
247
322
  * Sets the specified certificate issuer.
@@ -287,11 +362,19 @@ export class CertificateClient {
287
362
  * entity. This operation requires the certificates/setissuers permission.
288
363
  *
289
364
  * Example usage:
290
- * ```ts
291
- * const client = new CertificateClient(url, credentials);
292
- * await client.createIssuer("IssuerName", "Test");
365
+ * ```ts snippet:CertificateClientUpdateIssuer
366
+ * import { DefaultAzureCredential } from "@azure/identity";
367
+ * import { CertificateClient } from "@azure/keyvault-certificates";
368
+ *
369
+ * const credential = new DefaultAzureCredential();
370
+ *
371
+ * const vaultName = "<YOUR KEYVAULT NAME>";
372
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
373
+ *
374
+ * const client = new CertificateClient(keyVaultUrl, credential);
375
+ *
293
376
  * await client.updateIssuer("IssuerName", {
294
- * provider: "Provider2"
377
+ * provider: "Provider2",
295
378
  * });
296
379
  * ```
297
380
  * Updates the specified certificate issuer.
@@ -339,9 +422,17 @@ export class CertificateClient {
339
422
  * permission.
340
423
  *
341
424
  * Example usage:
342
- * ```ts
343
- * const client = new CertificateClient(url, credentials);
344
- * await client.createIssuer("IssuerName", "Test");
425
+ * ```ts snippet:CertificateClientGetIssuer
426
+ * import { DefaultAzureCredential } from "@azure/identity";
427
+ * import { CertificateClient } from "@azure/keyvault-certificates";
428
+ *
429
+ * const credential = new DefaultAzureCredential();
430
+ *
431
+ * const vaultName = "<YOUR KEYVAULT NAME>";
432
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
433
+ *
434
+ * const client = new CertificateClient(keyVaultUrl, credential);
435
+ *
345
436
  * const certificateIssuer = await client.getIssuer("IssuerName");
346
437
  * console.log(certificateIssuer);
347
438
  * ```
@@ -360,9 +451,17 @@ export class CertificateClient {
360
451
  * the vault. This operation requires the certificates/manageissuers/deleteissuers permission.
361
452
  *
362
453
  * Example usage:
363
- * ```ts
364
- * const client = new CertificateClient(url, credentials);
365
- * await client.createIssuer("IssuerName", "Provider");
454
+ * ```ts snippet:CertificateClientDeleteIssuer
455
+ * import { DefaultAzureCredential } from "@azure/identity";
456
+ * import { CertificateClient } from "@azure/keyvault-certificates";
457
+ *
458
+ * const credential = new DefaultAzureCredential();
459
+ *
460
+ * const vaultName = "<YOUR KEYVAULT NAME>";
461
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
462
+ *
463
+ * const client = new CertificateClient(keyVaultUrl, credential);
464
+ *
366
465
  * await client.deleteIssuer("IssuerName");
367
466
  * ```
368
467
  * Deletes the specified certificate issuer.
@@ -384,26 +483,31 @@ export class CertificateClient {
384
483
  * This operation requires the certificates/create permission.
385
484
  *
386
485
  * Example usage:
387
- * ```ts
388
- * const client = new CertificateClient(url, credentials);
486
+ * ```ts snippet:ReadmeSampleCreateCertificatePoller
487
+ * import { DefaultAzureCredential } from "@azure/identity";
488
+ * import { CertificateClient } from "@azure/keyvault-certificates";
489
+ *
490
+ * const credential = new DefaultAzureCredential();
491
+ *
492
+ * const vaultName = "<YOUR KEYVAULT NAME>";
493
+ * const url = `https://${vaultName}.vault.azure.net`;
494
+ *
495
+ * const client = new CertificateClient(url, credential);
496
+ *
497
+ * const certificateName = "MyCertificateName";
389
498
  * const certificatePolicy = {
390
499
  * issuerName: "Self",
391
- * subject: "cn=MyCert"
500
+ * subject: "cn=MyCert",
392
501
  * };
393
- * const createPoller = await client.beginCreateCertificate("MyCertificate", certificatePolicy);
394
502
  *
395
- * // The pending certificate can be obtained by calling the following method:
396
- * const pendingCertificate = createPoller.getResult();
503
+ * const poller = await client.beginCreateCertificate(certificateName, certificatePolicy);
397
504
  *
398
- * // Serializing the poller
399
- * const serialized = createPoller.toString();
400
- *
401
- * // A new poller can be created with:
402
- * // const newPoller = await client.beginCreateCertificate("MyCertificate", certificatePolicy, { resumeFrom: serialized });
505
+ * // You can use the pending certificate immediately:
506
+ * const pendingCertificate = poller.getResult();
403
507
  *
404
- * // Waiting until it's done
405
- * const certificate = await createPoller.pollUntilDone();
406
- * console.log(certificate);
508
+ * // Or you can wait until the certificate finishes being signed:
509
+ * const keyVaultCertificate = await poller.pollUntilDone();
510
+ * console.log(keyVaultCertificate);
407
511
  * ```
408
512
  * Creates a certificate
409
513
  * @param certificateName - The name of the certificate
@@ -429,15 +533,21 @@ export class CertificateClient {
429
533
  * Gets the latest information available from a specific certificate, including the certificate's policy. This operation requires the certificates/get permission.
430
534
  *
431
535
  * Example usage:
432
- * ```ts
433
- * const client = new CertificateClient(url, credentials);
434
- * const poller = await client.beginCreateCertificate("MyCertificate", {
435
- * issuerName: "Self",
436
- * subject: "cn=MyCert"
437
- * });
438
- * await poller.pollUntilDone();
439
- * const certificate = await client.getCertificate("MyCertificate");
440
- * console.log(certificate);
536
+ * ```ts snippet:CertificateClientGetCertificate
537
+ * import { DefaultAzureCredential } from "@azure/identity";
538
+ * import { CertificateClient } from "@azure/keyvault-certificates";
539
+ *
540
+ * const credential = new DefaultAzureCredential();
541
+ *
542
+ * const vaultName = "<YOUR KEYVAULT NAME>";
543
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
544
+ *
545
+ * const client = new CertificateClient(keyVaultUrl, credential);
546
+ *
547
+ * const certificateName = "MyCertificate";
548
+ *
549
+ * const result = await client.getCertificate(certificateName);
550
+ * console.log(result.name);
441
551
  * ```
442
552
  * Retrieves a certificate from the certificate's name (includes the certificate policy)
443
553
  * @param certificateName - The name of the certificate
@@ -453,16 +563,29 @@ export class CertificateClient {
453
563
  * Gets information about a specific certificate on a specific version. It won't return the certificate's policy. This operation requires the certificates/get permission.
454
564
  *
455
565
  * Example usage:
456
- * ```ts
457
- * const client = new CertificateClient(url, credentials);
458
- * const poller = await client.beginCreateCertificate("MyCertificate", {
459
- * issuerName: "Self",
460
- * subject: "cn=MyCert"
461
- * });
462
- * await poller.pollUntilDone();
463
- * const certificateWithPolicy = await client.getCertificate("MyCertificate");
464
- * const certificate = await client.getCertificateVersion("MyCertificate", certificateWithPolicy.properties.version!);
465
- * console.log(certificate);
566
+ * ```ts snippet:CertificateClientGetCertificateVersion
567
+ * import { DefaultAzureCredential } from "@azure/identity";
568
+ * import { CertificateClient } from "@azure/keyvault-certificates";
569
+ *
570
+ * const credential = new DefaultAzureCredential();
571
+ *
572
+ * const vaultName = "<YOUR KEYVAULT NAME>";
573
+ * const url = `https://${vaultName}.vault.azure.net`;
574
+ *
575
+ * const client = new CertificateClient(url, credential);
576
+ *
577
+ * const certificateName = "MyCertificateName";
578
+ *
579
+ * const latestCertificate = await client.getCertificate(certificateName);
580
+ * console.log(`Latest version of the certificate ${certificateName}: `, latestCertificate);
581
+ * const specificCertificate = await client.getCertificateVersion(
582
+ * certificateName,
583
+ * latestCertificate.properties.version,
584
+ * );
585
+ * console.log(
586
+ * `The certificate ${certificateName} at the version ${latestCertificate.properties.version}: `,
587
+ * specificCertificate,
588
+ * );
466
589
  * ```
467
590
  * Retrieves a certificate from the certificate's name and a specified version
468
591
  * @param certificateName - The name of the certificate
@@ -483,19 +606,26 @@ export class CertificateClient {
483
606
  * If the certificate is in PEM format the PEM file must contain the key as well as x509 certificates. This operation requires the certificates/import permission.
484
607
  *
485
608
  * Example usage:
486
- * ```ts
487
- * const client = new CertificateClient(url, credentials);
488
- * // See: @azure/keyvault-secrets
609
+ * ```ts snippet:CertificateClientImportCertificate
610
+ * import { DefaultAzureCredential } from "@azure/identity";
611
+ * import { CertificateClient } from "@azure/keyvault-certificates";
612
+ * import { SecretClient } from "@azure/keyvault-secrets";
613
+ * import { isNodeLike } from "@azure/core-util";
614
+ *
615
+ * const credential = new DefaultAzureCredential();
616
+ *
617
+ * const vaultName = "<YOUR KEYVAULT NAME>";
618
+ * const url = `https://${vaultName}.vault.azure.net`;
619
+ *
620
+ * const client = new CertificateClient(url, credential);
621
+ * const secretClient = new SecretClient(url, credential);
622
+ *
489
623
  * const certificateSecret = await secretClient.getSecret("MyCertificate");
490
624
  * const base64EncodedCertificate = certificateSecret.value!;
491
- * let buffer: Uint8Array;
492
- *
493
- * if (isNode) {
494
- * buffer = Buffer.from(base64EncodedCertificate, "base64");
495
- * } else {
496
- * buffer = Uint8Array.from(atob(base64EncodedCertificate), (c) => c.charCodeAt(0));
497
- * }
498
625
  *
626
+ * const buffer = isNodeLike
627
+ * ? Buffer.from(base64EncodedCertificate, "base64")
628
+ * : Uint8Array.from(atob(base64EncodedCertificate), (c) => c.charCodeAt(0));
499
629
  * await client.importCertificate("MyCertificate", buffer);
500
630
  * ```
501
631
  * Imports a certificate from a certificate's secret value
@@ -515,12 +645,17 @@ export class CertificateClient {
515
645
  * The getCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. This operation requires the certificates/get permission.
516
646
  *
517
647
  * Example usage:
518
- * ```ts
519
- * const client = new CertificateClient(url, credentials);
520
- * await client.beginCreateCertificate("MyCertificate", {
521
- * issuerName: "Self",
522
- * subject: "cn=MyCert"
523
- * });
648
+ * ```ts snippet:CertificateClientGetCertificatePolicy
649
+ * import { DefaultAzureCredential } from "@azure/identity";
650
+ * import { CertificateClient } from "@azure/keyvault-certificates";
651
+ *
652
+ * const credential = new DefaultAzureCredential();
653
+ *
654
+ * const vaultName = "<YOUR KEYVAULT NAME>";
655
+ * const url = `https://${vaultName}.vault.azure.net`;
656
+ *
657
+ * const client = new CertificateClient(url, credential);
658
+ *
524
659
  * const policy = await client.getCertificatePolicy("MyCertificate");
525
660
  * console.log(policy);
526
661
  * ```
@@ -554,19 +689,23 @@ export class CertificateClient {
554
689
  * certificate's attributes. This operation requires the certificates/update permission.
555
690
  *
556
691
  * Example usage:
557
- * ```ts
558
- * const client = new CertificateClient(url, credentials);
559
- * await client.beginCreateCertificate("MyCertificate", {
560
- * issuerName: "Self",
561
- * subject: "cn=MyCert"
562
- * });
692
+ * ```ts snippet:CertificateClientUpdateCertificate
693
+ * import { DefaultAzureCredential } from "@azure/identity";
694
+ * import { CertificateClient } from "@azure/keyvault-certificates";
695
+ *
696
+ * const credential = new DefaultAzureCredential();
697
+ *
698
+ * const vaultName = "<YOUR KEYVAULT NAME>";
699
+ * const url = `https://${vaultName}.vault.azure.net`;
700
+ *
701
+ * const client = new CertificateClient(url, credential);
563
702
  *
564
703
  * // You may pass an empty string for version which will update
565
704
  * // the latest version of the certificate
566
705
  * await client.updateCertificateProperties("MyCertificate", "", {
567
706
  * tags: {
568
- * customTag: "value"
569
- * }
707
+ * customTag: "value",
708
+ * },
570
709
  * });
571
710
  * ```
572
711
  * Updates a certificate
@@ -588,11 +727,20 @@ export class CertificateClient {
588
727
  * This function returns a Long Running Operation poller that allows you to wait indefinitely until the certificate is fully recovered.
589
728
  *
590
729
  * Example usage:
591
- * ```ts
592
- * const client = new CertificateClient(url, credentials);
730
+ * ```ts snippet:CertificateClientGetCertificateOperation
731
+ * import { DefaultAzureCredential } from "@azure/identity";
732
+ * import { CertificateClient } from "@azure/keyvault-certificates";
733
+ *
734
+ * const credential = new DefaultAzureCredential();
735
+ *
736
+ * const vaultName = "<YOUR KEYVAULT NAME>";
737
+ * const url = `https://${vaultName}.vault.azure.net`;
738
+ *
739
+ * const client = new CertificateClient(url, credential);
740
+ *
593
741
  * const createPoller = await client.beginCreateCertificate("MyCertificate", {
594
742
  * issuerName: "Self",
595
- * subject: "cn=MyCert"
743
+ * subject: "cn=MyCert",
596
744
  * });
597
745
  *
598
746
  * const poller = await client.getCertificateOperation("MyCertificate");
@@ -623,14 +771,24 @@ export class CertificateClient {
623
771
  * The certificate is no longer created. This operation requires the certificates/update permission.
624
772
  *
625
773
  * Example usage:
626
- * ```ts
627
- * const client = new CertificateClient(url, credentials);
774
+ * ```ts snippet:CertificateClientDeleteCertificateOperation
775
+ * import { DefaultAzureCredential } from "@azure/identity";
776
+ * import { CertificateClient } from "@azure/keyvault-certificates";
777
+ *
778
+ * const credential = new DefaultAzureCredential();
779
+ *
780
+ * const vaultName = "<YOUR KEYVAULT NAME>";
781
+ * const url = `https://${vaultName}.vault.azure.net`;
782
+ *
783
+ * const client = new CertificateClient(url, credential);
784
+ *
628
785
  * await client.beginCreateCertificate("MyCertificate", {
629
786
  * issuerName: "Self",
630
- * subject: "cn=MyCert"
787
+ * subject: "cn=MyCert",
631
788
  * });
632
789
  * await client.deleteCertificateOperation("MyCertificate");
633
- * await client.getCertificateOperation("MyCertificate"); // Throws error: Pending certificate not found: "MyCertificate"
790
+ *
791
+ * await client.getCertificateOperation("MyCertificate");
634
792
  * ```
635
793
  * Delete a certificate's operation
636
794
  * @param certificateName - The name of the certificate
@@ -646,28 +804,41 @@ export class CertificateClient {
646
804
  * Performs the merging of a certificate or certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.
647
805
  *
648
806
  * Example usage:
649
- * ```ts
650
- * const client = new CertificateClient(url, credentials);
807
+ * ```ts snippet:CertificateClientMergeCertificate
808
+ * import { DefaultAzureCredential } from "@azure/identity";
809
+ * import { CertificateClient } from "@azure/keyvault-certificates";
810
+ * import { writeFileSync, readFileSync } from "node:fs";
811
+ * import { execSync } from "node:child_process";
812
+ *
813
+ * const credential = new DefaultAzureCredential();
814
+ *
815
+ * const vaultName = "<YOUR KEYVAULT NAME>";
816
+ * const url = `https://${vaultName}.vault.azure.net`;
817
+ *
818
+ * const client = new CertificateClient(url, credential);
819
+ *
651
820
  * await client.beginCreateCertificate("MyCertificate", {
652
821
  * issuerName: "Unknown",
653
- * subject: "cn=MyCert"
822
+ * subject: "cn=MyCert",
654
823
  * });
655
824
  * const poller = await client.getCertificateOperation("MyCertificate");
656
825
  * const { csr } = poller.getOperationState().certificateOperation!;
657
826
  * const base64Csr = Buffer.from(csr!).toString("base64");
658
- * const wrappedCsr = ["-----BEGIN CERTIFICATE REQUEST-----", base64Csr, "-----END CERTIFICATE REQUEST-----"].join("\n");
827
+ * const wrappedCsr = [
828
+ * "-----BEGIN CERTIFICATE REQUEST-----",
829
+ * base64Csr,
830
+ * "-----END CERTIFICATE REQUEST-----",
831
+ * ].join("\n");
659
832
  *
660
- * const fs = require("fs");
661
- * fs.writeFileSync("test.csr", wrappedCsr);
833
+ * writeFileSync("test.csr", wrappedCsr);
662
834
  *
663
835
  * // Certificate available locally made using:
664
836
  * // openssl genrsa -out ca.key 2048
665
837
  * // openssl req -new -x509 -key ca.key -out ca.crt
666
838
  * // You can read more about how to create a fake certificate authority here: https://gist.github.com/Soarez/9688998
667
839
  *
668
- * const childProcess = require("child_process");
669
- * childProcess.execSync("openssl x509 -req -in test.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out test.crt");
670
- * const base64Crt = fs.readFileSync("test.crt").toString().split("\n").slice(1, -1).join("");
840
+ * execSync("openssl x509 -req -in test.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out test.crt");
841
+ * const base64Crt = readFileSync("test.crt").toString().split("\n").slice(1, -1).join("");
671
842
  *
672
843
  * await client.mergeCertificate("MyCertificate", [Buffer.from(base64Crt)]);
673
844
  * ```
@@ -687,11 +858,20 @@ export class CertificateClient {
687
858
  * This operation requires the certificates/backup permission.
688
859
  *
689
860
  * Example usage:
690
- * ```ts
691
- * const client = new CertificateClient(url, credentials);
861
+ * ```ts snippet:CertificateClientBackupCertificate
862
+ * import { DefaultAzureCredential } from "@azure/identity";
863
+ * import { CertificateClient } from "@azure/keyvault-certificates";
864
+ *
865
+ * const credential = new DefaultAzureCredential();
866
+ *
867
+ * const vaultName = "<YOUR KEYVAULT NAME>";
868
+ * const url = `https://${vaultName}.vault.azure.net`;
869
+ *
870
+ * const client = new CertificateClient(url, credential);
871
+ *
692
872
  * await client.beginCreateCertificate("MyCertificate", {
693
873
  * issuerName: "Self",
694
- * subject: "cn=MyCert"
874
+ * subject: "cn=MyCert",
695
875
  * });
696
876
  * const backup = await client.backupCertificate("MyCertificate");
697
877
  * ```
@@ -709,15 +889,26 @@ export class CertificateClient {
709
889
  * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission.
710
890
  *
711
891
  * Example usage:
712
- * ```ts
713
- * const client = new CertificateClient(url, credentials);
892
+ * ```ts snippet:CertificateClientRestoreCertificateBackup
893
+ * import { DefaultAzureCredential } from "@azure/identity";
894
+ * import { CertificateClient } from "@azure/keyvault-certificates";
895
+ *
896
+ * const credential = new DefaultAzureCredential();
897
+ *
898
+ * const vaultName = "<YOUR KEYVAULT NAME>";
899
+ * const url = `https://${vaultName}.vault.azure.net`;
900
+ *
901
+ * const client = new CertificateClient(url, credential);
902
+ *
714
903
  * await client.beginCreateCertificate("MyCertificate", {
715
904
  * issuerName: "Self",
716
- * subject: "cn=MyCert"
905
+ * subject: "cn=MyCert",
717
906
  * });
718
907
  * const backup = await client.backupCertificate("MyCertificate");
908
+ *
719
909
  * const poller = await client.beginDeleteCertificate("MyCertificate");
720
910
  * await poller.pollUntilDone();
911
+ *
721
912
  * // Some time is required before we're able to restore the certificate
722
913
  * await client.restoreCertificateBackup(backup!);
723
914
  * ```
@@ -736,11 +927,21 @@ export class CertificateClient {
736
927
  * information. This operation requires the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults.
737
928
  *
738
929
  * Example usage:
739
- * ```ts
740
- * const client = new CertificateClient(url, credentials);
930
+ * ```ts snippet:CertificateClientListDeletedCertificates
931
+ * import { DefaultAzureCredential } from "@azure/identity";
932
+ * import { CertificateClient } from "@azure/keyvault-certificates";
933
+ *
934
+ * const credential = new DefaultAzureCredential();
935
+ *
936
+ * const vaultName = "<YOUR KEYVAULT NAME>";
937
+ * const url = `https://${vaultName}.vault.azure.net`;
938
+ *
939
+ * const client = new CertificateClient(url, credential);
940
+ *
741
941
  * for await (const deletedCertificate of client.listDeletedCertificates()) {
742
942
  * console.log(deletedCertificate);
743
943
  * }
944
+ *
744
945
  * for await (const page of client.listDeletedCertificates().byPage()) {
745
946
  * for (const deletedCertificate of page) {
746
947
  * console.log(deletedCertificate);
@@ -758,8 +959,17 @@ export class CertificateClient {
758
959
  * current deletion recovery level. This operation requires the certificates/get permission.
759
960
  *
760
961
  * Example usage:
761
- * ```ts
762
- * const client = new CertificateClient(url, credentials);
962
+ * ```ts snippet:CertificateClientGetDeletedCertificate
963
+ * import { DefaultAzureCredential } from "@azure/identity";
964
+ * import { CertificateClient } from "@azure/keyvault-certificates";
965
+ *
966
+ * const credential = new DefaultAzureCredential();
967
+ *
968
+ * const vaultName = "<YOUR KEYVAULT NAME>";
969
+ * const url = `https://${vaultName}.vault.azure.net`;
970
+ *
971
+ * const client = new CertificateClient(url, credential);
972
+ *
763
973
  * const deletedCertificate = await client.getDeletedCertificate("MyDeletedCertificate");
764
974
  * console.log("Deleted certificate:", deletedCertificate);
765
975
  * ```
@@ -778,10 +988,20 @@ export class CertificateClient {
778
988
  * recovery level does not specify 'Purgeable'. This operation requires the certificate/purge permission.
779
989
  *
780
990
  * Example usage:
781
- * ```ts
782
- * const client = new CertificateClient(url, credentials);
991
+ * ```ts snippet:CertificateClientPurgeDeletedCertificate
992
+ * import { DefaultAzureCredential } from "@azure/identity";
993
+ * import { CertificateClient } from "@azure/keyvault-certificates";
994
+ *
995
+ * const credential = new DefaultAzureCredential();
996
+ *
997
+ * const vaultName = "<YOUR KEYVAULT NAME>";
998
+ * const url = `https://${vaultName}.vault.azure.net`;
999
+ *
1000
+ * const client = new CertificateClient(url, credential);
1001
+ *
783
1002
  * const deletePoller = await client.beginDeleteCertificate("MyCertificate");
784
1003
  * await deletePoller.pollUntilDone();
1004
+ *
785
1005
  * // Deleting a certificate takes time, make sure to wait before purging it
786
1006
  * client.purgeDeletedCertificate("MyCertificate");
787
1007
  * ```
@@ -802,20 +1022,22 @@ export class CertificateClient {
802
1022
  * This operation requires the certificates/recover permission.
803
1023
  *
804
1024
  * Example usage:
805
- * ```ts
806
- * const client = new CertificateClient(url, credentials);
1025
+ * ```ts snippet:CertificateClientRecoverDeletedCertificate
1026
+ * import { DefaultAzureCredential } from "@azure/identity";
1027
+ * import { CertificateClient } from "@azure/keyvault-certificates";
1028
+ *
1029
+ * const credential = new DefaultAzureCredential();
1030
+ *
1031
+ * const vaultName = "<YOUR KEYVAULT NAME>";
1032
+ * const url = `https://${vaultName}.vault.azure.net`;
1033
+ *
1034
+ * const client = new CertificateClient(url, credential);
807
1035
  *
808
1036
  * const deletePoller = await client.beginDeleteCertificate("MyCertificate");
809
1037
  * await deletePoller.pollUntilDone();
810
1038
  *
811
1039
  * const recoverPoller = await client.beginRecoverDeletedCertificate("MyCertificate");
812
1040
  *
813
- * // Serializing the poller
814
- * const serialized = deletePoller.toString();
815
- *
816
- * // A new poller can be created with:
817
- * // const newPoller = await client.beginRecoverDeletedCertificate("MyCertificate", { resumeFrom: serialized });
818
- *
819
1041
  * // Waiting until it's done
820
1042
  * const certificate = await recoverPoller.pollUntilDone();
821
1043
  * console.log(certificate);