@ibm-cloud/secrets-manager 2.0.7 → 2.0.9

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.
@@ -2,7 +2,7 @@
2
2
  * @jest-environment node
3
3
  */
4
4
  /**
5
- * (C) Copyright IBM Corp. 2024.
5
+ * (C) Copyright IBM Corp. 2025.
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -52,1215 +52,1215 @@ const consoleLogMock = jest.spyOn(console, 'log');
52
52
  const consoleWarnMock = jest.spyOn(console, 'warn');
53
53
 
54
54
  describe('SecretsManagerV2', () => {
55
- // Service instance
56
- let secretsManagerService;
57
-
58
- // Variables to hold link values
59
- let configurationNameForGetConfigurationLink;
60
- let secretGroupIdForGetSecretGroupLink;
61
- let secretIdForCreateSecretVersionLink;
62
- let secretIdForCreateSecretVersionLocksLink;
63
- let secretIdForGetSecretLink;
64
- let secretIdForGetSecretVersionLink;
65
- let secretIdForListSecretLocksLink;
66
- let secretIdForListSecretVersionLocksLink;
67
- let secretNameLink;
68
- let secretVersionIdForCreateSecretVersionLocksLink;
69
- let secretVersionIdForDeleteSecretVersionLocksLink;
70
- let secretVersionIdForGetSecretVersionLink;
71
- let secretVersionIdForGetSecretVersionMetadataLink;
72
- let secretVersionIdForListSecretVersionLocksLink;
73
- let secretVersionIdForUpdateSecretVersionMetadataLink;
74
-
75
- // To access additional configuration values, uncomment this line and extract the values from config
76
- // const config = readExternalSources(SecretsManagerV2.DEFAULT_SERVICE_NAME);
77
-
78
- test('Initialize service', async () => {
79
- // begin-common
80
-
81
- secretsManagerService = SecretsManagerV2.newInstance();
82
-
83
- // end-common
84
- });
85
-
86
- test('createSecretGroup request example', async () => {
87
- consoleLogMock.mockImplementation((output) => {
88
- originalLog(output);
55
+ // Service instance
56
+ let secretsManagerService;
57
+
58
+ // Variables to hold link values
59
+ let configurationNameForGetConfigurationLink;
60
+ let secretGroupIdForGetSecretGroupLink;
61
+ let secretIdForCreateSecretVersionLink;
62
+ let secretIdForCreateSecretVersionLocksLink;
63
+ let secretIdForGetSecretLink;
64
+ let secretIdForGetSecretVersionLink;
65
+ let secretIdForListSecretLocksLink;
66
+ let secretIdForListSecretVersionLocksLink;
67
+ let secretNameLink;
68
+ let secretVersionIdForCreateSecretVersionLocksLink;
69
+ let secretVersionIdForDeleteSecretVersionLocksLink;
70
+ let secretVersionIdForGetSecretVersionLink;
71
+ let secretVersionIdForGetSecretVersionMetadataLink;
72
+ let secretVersionIdForListSecretVersionLocksLink;
73
+ let secretVersionIdForUpdateSecretVersionMetadataLink;
74
+
75
+ // To access additional configuration values, uncomment this line and extract the values from config
76
+ // const config = readExternalSources(SecretsManagerV2.DEFAULT_SERVICE_NAME);
77
+
78
+ test('Initialize service', async () => {
79
+ // begin-common
80
+
81
+ secretsManagerService = SecretsManagerV2.newInstance();
82
+
83
+ // end-common
84
+ });
85
+
86
+ test('createSecretGroup request example', async () => {
87
+ consoleLogMock.mockImplementation((output) => {
88
+ originalLog(output);
89
+ });
90
+ consoleWarnMock.mockImplementation((output) => {
91
+ // if an error occurs, display the message and then fail the test
92
+ originalWarn(output);
93
+ expect(true).toBeFalsy();
94
+ });
95
+
96
+ originalLog('createSecretGroup() result:');
97
+ // begin-create_secret_group
98
+
99
+ const params = {
100
+ name: 'my-secret-group',
101
+ };
102
+
103
+ let res;
104
+ try {
105
+ res = await secretsManagerService.createSecretGroup(params);
106
+ console.log(JSON.stringify(res.result, null, 2));
107
+ } catch (err) {
108
+ console.warn(err);
109
+ }
110
+
111
+ // end-create_secret_group
112
+ const responseBody = res.result;
113
+ secretGroupIdForGetSecretGroupLink = responseBody.id;
114
+ });
115
+
116
+ test('createSecret request example', async () => {
117
+ consoleLogMock.mockImplementation((output) => {
118
+ originalLog(output);
119
+ });
120
+ consoleWarnMock.mockImplementation((output) => {
121
+ // if an error occurs, display the message and then fail the test
122
+ originalWarn(output);
123
+ expect(true).toBeFalsy();
124
+ });
125
+
126
+ originalLog('createSecret() result:');
127
+ // begin-create_secret
128
+
129
+ // Request models needed by this operation.
130
+
131
+ // ArbitrarySecretPrototype
132
+ const secretPrototypeModel = {
133
+ custom_metadata: {metadata_custom_key: 'metadata_custom_value'},
134
+ description: 'Description of my arbitrary secret.',
135
+ expiration_date: '2030-10-05T11:49:42Z',
136
+ labels: ['dev', 'us-south'],
137
+ name: 'example-arbitrary-secret',
138
+ secret_group_id: 'default',
139
+ secret_type: 'arbitrary',
140
+ payload: 'secret-data',
141
+ version_custom_metadata: {custom_version_key: 'custom_version_value'},
142
+ };
143
+
144
+ const params = {
145
+ secretPrototype: secretPrototypeModel,
146
+ };
147
+
148
+ let res;
149
+ try {
150
+ res = await secretsManagerService.createSecret(params);
151
+ console.log(JSON.stringify(res.result, null, 2));
152
+ } catch (err) {
153
+ console.warn(err);
154
+ }
155
+
156
+ // end-create_secret
157
+ const responseBody = res.result;
158
+ secretIdForGetSecretLink = responseBody.id;
159
+ secretIdForGetSecretVersionLink = responseBody.id;
160
+ });
161
+
162
+ test('updateSecretMetadata request example', async () => {
163
+ consoleLogMock.mockImplementation((output) => {
164
+ originalLog(output);
165
+ });
166
+ consoleWarnMock.mockImplementation((output) => {
167
+ // if an error occurs, display the message and then fail the test
168
+ originalWarn(output);
169
+ expect(true).toBeFalsy();
170
+ });
171
+
172
+ originalLog('updateSecretMetadata() result:');
173
+ // begin-update_secret_metadata
174
+
175
+ // Request models needed by this operation.
176
+
177
+ // ArbitrarySecretMetadataPatch
178
+ const secretMetadataPatchModel = {
179
+ name: 'updated-arbitrary-secret-name-example',
180
+ description: 'updated Arbitrary Secret description',
181
+ labels: ['dev', 'us-south'],
182
+ custom_metadata: {metadata_custom_key: 'metadata_custom_value'},
183
+ };
184
+
185
+ const params = {
186
+ id: secretIdForGetSecretLink,
187
+ secretMetadataPatch: secretMetadataPatchModel,
188
+ };
189
+
190
+ let res;
191
+ try {
192
+ res = await secretsManagerService.updateSecretMetadata(params);
193
+ console.log(JSON.stringify(res.result, null, 2));
194
+ } catch (err) {
195
+ console.warn(err);
196
+ }
197
+
198
+ // end-update_secret_metadata
199
+ const responseBody = res.result;
200
+ secretNameLink = responseBody.name;
201
+ });
202
+
203
+ test('listSecretVersions request example', async () => {
204
+ consoleLogMock.mockImplementation((output) => {
205
+ originalLog(output);
206
+ });
207
+ consoleWarnMock.mockImplementation((output) => {
208
+ // if an error occurs, display the message and then fail the test
209
+ originalWarn(output);
210
+ expect(true).toBeFalsy();
211
+ });
212
+
213
+ originalLog('listSecretVersions() result:');
214
+ // begin-list_secret_versions
215
+
216
+ const params = {
217
+ secretId: secretIdForGetSecretLink,
218
+ };
219
+
220
+ let res;
221
+ try {
222
+ res = await secretsManagerService.listSecretVersions(params);
223
+ console.log(JSON.stringify(res.result, null, 2));
224
+ } catch (err) {
225
+ console.warn(err);
226
+ }
227
+
228
+ // end-list_secret_versions
229
+ const responseBody = res.result;
230
+ secretVersionIdForGetSecretVersionLink = responseBody.versions[0].id;
231
+ secretIdForCreateSecretVersionLink = responseBody.versions[0].secret_id;
232
+ secretVersionIdForGetSecretVersionMetadataLink = responseBody.versions[0].id;
233
+ secretVersionIdForUpdateSecretVersionMetadataLink = responseBody.versions[0].id;
234
+ secretIdForCreateSecretVersionLocksLink = responseBody.versions[0].secret_id;
235
+ secretVersionIdForCreateSecretVersionLocksLink = responseBody.versions[0].id;
236
+ secretVersionIdForDeleteSecretVersionLocksLink = responseBody.versions[0].id;
237
+ });
238
+
239
+ test('createSecretLocksBulk request example', async () => {
240
+ consoleLogMock.mockImplementation((output) => {
241
+ originalLog(output);
242
+ });
243
+ consoleWarnMock.mockImplementation((output) => {
244
+ // if an error occurs, display the message and then fail the test
245
+ originalWarn(output);
246
+ expect(true).toBeFalsy();
247
+ });
248
+
249
+ originalLog('createSecretLocksBulk() result:');
250
+ // begin-create_secret_locks_bulk
251
+
252
+ // Request models needed by this operation.
253
+
254
+ // SecretLockPrototype
255
+ const secretLockPrototypeModel = {
256
+ name: 'lock-example-1',
257
+ description: 'lock for consumer 1',
258
+ attributes: {key: 'value'},
259
+ };
260
+
261
+ const params = {
262
+ id: secretIdForGetSecretLink,
263
+ locks: [secretLockPrototypeModel],
264
+ };
265
+
266
+ let res;
267
+ try {
268
+ res = await secretsManagerService.createSecretLocksBulk(params);
269
+ console.log(JSON.stringify(res.result, null, 2));
270
+ } catch (err) {
271
+ console.warn(err);
272
+ }
273
+
274
+ // end-create_secret_locks_bulk
275
+ const responseBody = res.result;
276
+ secretIdForListSecretLocksLink = responseBody.secret_id;
277
+ secretIdForListSecretVersionLocksLink = responseBody.secret_id;
278
+ secretVersionIdForListSecretVersionLocksLink = responseBody.versions[0].version_id;
279
+ });
280
+
281
+ test('createConfiguration request example', async () => {
282
+ consoleLogMock.mockImplementation((output) => {
283
+ originalLog(output);
284
+ });
285
+ consoleWarnMock.mockImplementation((output) => {
286
+ // if an error occurs, display the message and then fail the test
287
+ originalWarn(output);
288
+ expect(true).toBeFalsy();
289
+ });
290
+
291
+ originalLog('createConfiguration() result:');
292
+ // begin-create_configuration
293
+
294
+ // Request models needed by this operation.
295
+
296
+ // PublicCertificateConfigurationDNSCloudInternetServicesPrototype
297
+ const configurationPrototypeModel = {
298
+ config_type: 'public_cert_configuration_dns_cloud_internet_services',
299
+ name: 'example-cloud-internet-services-config',
300
+ cloud_internet_services_apikey: '5ipu_ykv0PMp2MhxQnDMn7VzrkSlBwi3BOI8uthi_EXZ',
301
+ cloud_internet_services_crn: 'crn:v1:bluemix:public:internet-svcs:global:a/128e84fcca45c1224aae525d31ef2b52:009a0357-1460-42b4-b903-10580aba7dd8::',
302
+ };
303
+
304
+ const params = {
305
+ configurationPrototype: configurationPrototypeModel,
306
+ };
307
+
308
+ let res;
309
+ try {
310
+ res = await secretsManagerService.createConfiguration(params);
311
+ console.log(JSON.stringify(res.result, null, 2));
312
+ } catch (err) {
313
+ console.warn(err);
314
+ }
315
+
316
+ // end-create_configuration
317
+ const responseBody = res.result;
318
+ configurationNameForGetConfigurationLink = responseBody.name;
319
+ });
320
+
321
+ test('listSecretGroups request example', async () => {
322
+ consoleLogMock.mockImplementation((output) => {
323
+ originalLog(output);
324
+ });
325
+ consoleWarnMock.mockImplementation((output) => {
326
+ // if an error occurs, display the message and then fail the test
327
+ originalWarn(output);
328
+ expect(true).toBeFalsy();
329
+ });
330
+
331
+ originalLog('listSecretGroups() result:');
332
+ // begin-list_secret_groups
333
+
334
+ let res;
335
+ try {
336
+ res = await secretsManagerService.listSecretGroups({});
337
+ console.log(JSON.stringify(res.result, null, 2));
338
+ } catch (err) {
339
+ console.warn(err);
340
+ }
341
+
342
+ // end-list_secret_groups
343
+ });
344
+
345
+ test('getSecretGroup request example', async () => {
346
+ consoleLogMock.mockImplementation((output) => {
347
+ originalLog(output);
348
+ });
349
+ consoleWarnMock.mockImplementation((output) => {
350
+ // if an error occurs, display the message and then fail the test
351
+ originalWarn(output);
352
+ expect(true).toBeFalsy();
353
+ });
354
+
355
+ originalLog('getSecretGroup() result:');
356
+ // begin-get_secret_group
357
+
358
+ const params = {
359
+ id: secretGroupIdForGetSecretGroupLink,
360
+ };
361
+
362
+ let res;
363
+ try {
364
+ res = await secretsManagerService.getSecretGroup(params);
365
+ console.log(JSON.stringify(res.result, null, 2));
366
+ } catch (err) {
367
+ console.warn(err);
368
+ }
369
+
370
+ // end-get_secret_group
371
+ });
372
+
373
+ test('updateSecretGroup request example', async () => {
374
+ consoleLogMock.mockImplementation((output) => {
375
+ originalLog(output);
376
+ });
377
+ consoleWarnMock.mockImplementation((output) => {
378
+ // if an error occurs, display the message and then fail the test
379
+ originalWarn(output);
380
+ expect(true).toBeFalsy();
381
+ });
382
+
383
+ originalLog('updateSecretGroup() result:');
384
+ // begin-update_secret_group
385
+
386
+ const params = {
387
+ id: secretGroupIdForGetSecretGroupLink,
388
+ };
389
+
390
+ let res;
391
+ try {
392
+ res = await secretsManagerService.updateSecretGroup(params);
393
+ console.log(JSON.stringify(res.result, null, 2));
394
+ } catch (err) {
395
+ console.warn(err);
396
+ }
397
+
398
+ // end-update_secret_group
399
+ });
400
+
401
+ test('listSecrets request example', async () => {
402
+ consoleLogMock.mockImplementation((output) => {
403
+ originalLog(output);
404
+ });
405
+ consoleWarnMock.mockImplementation((output) => {
406
+ // if an error occurs, display the message and then fail the test
407
+ originalWarn(output);
408
+ expect(true).toBeFalsy();
409
+ });
410
+
411
+ originalLog('listSecrets() result:');
412
+ // begin-list_secrets
413
+
414
+ const params = {
415
+ limit: 10,
416
+ sort: 'created_at',
417
+ search: 'example',
418
+ groups: ['default', 'cac40995-c37a-4dcb-9506-472869077634'],
419
+ secretTypes: ['arbitrary', 'kv'],
420
+ matchAllLabels: ['dev', 'us-south'],
421
+ };
422
+
423
+ const allResults = [];
424
+ try {
425
+ const pager = new SecretsManagerV2.SecretsPager(secretsManagerService, params);
426
+ while (pager.hasNext()) {
427
+ const nextPage = await pager.getNext();
428
+ expect(nextPage).not.toBeNull();
429
+ allResults.push(...nextPage);
430
+ }
431
+ console.log(JSON.stringify(allResults, null, 2));
432
+ } catch (err) {
433
+ console.warn(err);
434
+ }
435
+
436
+ // end-list_secrets
437
+ });
438
+
439
+ test('getSecret request example', async () => {
440
+ consoleLogMock.mockImplementation((output) => {
441
+ originalLog(output);
442
+ });
443
+ consoleWarnMock.mockImplementation((output) => {
444
+ // if an error occurs, display the message and then fail the test
445
+ originalWarn(output);
446
+ expect(true).toBeFalsy();
447
+ });
448
+
449
+ originalLog('getSecret() result:');
450
+ // begin-get_secret
451
+
452
+ const params = {
453
+ id: secretIdForGetSecretLink,
454
+ };
455
+
456
+ let res;
457
+ try {
458
+ res = await secretsManagerService.getSecret(params);
459
+ console.log(JSON.stringify(res.result, null, 2));
460
+ } catch (err) {
461
+ console.warn(err);
462
+ }
463
+
464
+ // end-get_secret
465
+ });
466
+
467
+ test('getSecretMetadata request example', async () => {
468
+ consoleLogMock.mockImplementation((output) => {
469
+ originalLog(output);
470
+ });
471
+ consoleWarnMock.mockImplementation((output) => {
472
+ // if an error occurs, display the message and then fail the test
473
+ originalWarn(output);
474
+ expect(true).toBeFalsy();
475
+ });
476
+
477
+ originalLog('getSecretMetadata() result:');
478
+ // begin-get_secret_metadata
479
+
480
+ const params = {
481
+ id: secretIdForGetSecretLink,
482
+ };
483
+
484
+ let res;
485
+ try {
486
+ res = await secretsManagerService.getSecretMetadata(params);
487
+ console.log(JSON.stringify(res.result, null, 2));
488
+ } catch (err) {
489
+ console.warn(err);
490
+ }
491
+
492
+ // end-get_secret_metadata
493
+ });
494
+
495
+ test('createSecretAction request example', async () => {
496
+ consoleLogMock.mockImplementation((output) => {
497
+ originalLog(output);
498
+ });
499
+ consoleWarnMock.mockImplementation((output) => {
500
+ // if an error occurs, display the message and then fail the test
501
+ originalWarn(output);
502
+ expect(true).toBeFalsy();
503
+ });
504
+
505
+ originalLog('createSecretAction() result:');
506
+ // begin-create_secret_action
507
+
508
+ // Request models needed by this operation.
509
+
510
+ // PrivateCertificateActionRevokePrototype
511
+ const secretActionPrototypeModel = {
512
+ action_type: 'private_cert_action_revoke_certificate',
513
+ };
514
+
515
+ const params = {
516
+ id: secretIdForGetSecretLink,
517
+ secretActionPrototype: secretActionPrototypeModel,
518
+ };
519
+
520
+ let res;
521
+ try {
522
+ res = await secretsManagerService.createSecretAction(params);
523
+ console.log(JSON.stringify(res.result, null, 2));
524
+ } catch (err) {
525
+ console.warn(err);
526
+ }
527
+
528
+ // end-create_secret_action
529
+ });
530
+
531
+ test('getSecretByNameType request example', async () => {
532
+ consoleLogMock.mockImplementation((output) => {
533
+ originalLog(output);
534
+ });
535
+ consoleWarnMock.mockImplementation((output) => {
536
+ // if an error occurs, display the message and then fail the test
537
+ originalWarn(output);
538
+ expect(true).toBeFalsy();
539
+ });
540
+
541
+ originalLog('getSecretByNameType() result:');
542
+ // begin-get_secret_by_name_type
543
+
544
+ const params = {
545
+ secretType: 'arbitrary',
546
+ name: secretNameLink,
547
+ secretGroupName: 'default',
548
+ };
549
+
550
+ let res;
551
+ try {
552
+ res = await secretsManagerService.getSecretByNameType(params);
553
+ console.log(JSON.stringify(res.result, null, 2));
554
+ } catch (err) {
555
+ console.warn(err);
556
+ }
557
+
558
+ // end-get_secret_by_name_type
559
+ });
560
+
561
+ test('createSecretVersion request example', async () => {
562
+ consoleLogMock.mockImplementation((output) => {
563
+ originalLog(output);
564
+ });
565
+ consoleWarnMock.mockImplementation((output) => {
566
+ // if an error occurs, display the message and then fail the test
567
+ originalWarn(output);
568
+ expect(true).toBeFalsy();
569
+ });
570
+
571
+ originalLog('createSecretVersion() result:');
572
+ // begin-create_secret_version
573
+
574
+ // Request models needed by this operation.
575
+
576
+ // ArbitrarySecretVersionPrototype
577
+ const secretVersionPrototypeModel = {
578
+ payload: 'updated secret credentials',
579
+ custom_metadata: {metadata_custom_key: 'metadata_custom_value'},
580
+ version_custom_metadata: {custom_version_key: 'custom_version_value'},
581
+ };
582
+
583
+ const params = {
584
+ secretId: secretIdForGetSecretLink,
585
+ secretVersionPrototype: secretVersionPrototypeModel,
586
+ };
587
+
588
+ let res;
589
+ try {
590
+ res = await secretsManagerService.createSecretVersion(params);
591
+ console.log(JSON.stringify(res.result, null, 2));
592
+ } catch (err) {
593
+ console.warn(err);
594
+ }
595
+
596
+ // end-create_secret_version
597
+ });
598
+
599
+ test('getSecretVersion request example', async () => {
600
+ consoleLogMock.mockImplementation((output) => {
601
+ originalLog(output);
602
+ });
603
+ consoleWarnMock.mockImplementation((output) => {
604
+ // if an error occurs, display the message and then fail the test
605
+ originalWarn(output);
606
+ expect(true).toBeFalsy();
607
+ });
608
+
609
+ originalLog('getSecretVersion() result:');
610
+ // begin-get_secret_version
611
+
612
+ const params = {
613
+ secretId: secretIdForGetSecretLink,
614
+ id: secretVersionIdForGetSecretVersionLink,
615
+ };
616
+
617
+ let res;
618
+ try {
619
+ res = await secretsManagerService.getSecretVersion(params);
620
+ console.log(JSON.stringify(res.result, null, 2));
621
+ } catch (err) {
622
+ console.warn(err);
623
+ }
624
+
625
+ // end-get_secret_version
626
+ });
627
+
628
+ test('getSecretVersionMetadata request example', async () => {
629
+ consoleLogMock.mockImplementation((output) => {
630
+ originalLog(output);
631
+ });
632
+ consoleWarnMock.mockImplementation((output) => {
633
+ // if an error occurs, display the message and then fail the test
634
+ originalWarn(output);
635
+ expect(true).toBeFalsy();
636
+ });
637
+
638
+ originalLog('getSecretVersionMetadata() result:');
639
+ // begin-get_secret_version_metadata
640
+
641
+ const params = {
642
+ secretId: secretIdForGetSecretLink,
643
+ id: secretVersionIdForGetSecretVersionLink,
644
+ };
645
+
646
+ let res;
647
+ try {
648
+ res = await secretsManagerService.getSecretVersionMetadata(params);
649
+ console.log(JSON.stringify(res.result, null, 2));
650
+ } catch (err) {
651
+ console.warn(err);
652
+ }
653
+
654
+ // end-get_secret_version_metadata
655
+ });
656
+
657
+ test('updateSecretVersionMetadata request example', async () => {
658
+ consoleLogMock.mockImplementation((output) => {
659
+ originalLog(output);
660
+ });
661
+ consoleWarnMock.mockImplementation((output) => {
662
+ // if an error occurs, display the message and then fail the test
663
+ originalWarn(output);
664
+ expect(true).toBeFalsy();
665
+ });
666
+
667
+ originalLog('updateSecretVersionMetadata() result:');
668
+ // begin-update_secret_version_metadata
669
+
670
+ const params = {
671
+ secretId: secretIdForGetSecretLink,
672
+ id: secretVersionIdForGetSecretVersionLink,
673
+ };
674
+
675
+ let res;
676
+ try {
677
+ res = await secretsManagerService.updateSecretVersionMetadata(params);
678
+ console.log(JSON.stringify(res.result, null, 2));
679
+ } catch (err) {
680
+ console.warn(err);
681
+ }
682
+
683
+ // end-update_secret_version_metadata
684
+ });
685
+
686
+ test('createSecretVersionAction request example', async () => {
687
+ consoleLogMock.mockImplementation((output) => {
688
+ originalLog(output);
689
+ });
690
+ consoleWarnMock.mockImplementation((output) => {
691
+ // if an error occurs, display the message and then fail the test
692
+ originalWarn(output);
693
+ expect(true).toBeFalsy();
694
+ });
695
+
696
+ originalLog('createSecretVersionAction() result:');
697
+ // begin-create_secret_version_action
698
+
699
+ // Request models needed by this operation.
700
+
701
+ // PrivateCertificateVersionActionRevokePrototype
702
+ const secretVersionActionPrototypeModel = {
703
+ action_type: 'private_cert_action_revoke_certificate',
704
+ };
705
+
706
+ const params = {
707
+ secretId: secretIdForGetSecretLink,
708
+ id: secretVersionIdForGetSecretVersionLink,
709
+ secretVersionActionPrototype: secretVersionActionPrototypeModel,
710
+ };
711
+
712
+ let res;
713
+ try {
714
+ res = await secretsManagerService.createSecretVersionAction(params);
715
+ console.log(JSON.stringify(res.result, null, 2));
716
+ } catch (err) {
717
+ console.warn(err);
718
+ }
719
+
720
+ // end-create_secret_version_action
721
+ });
722
+
723
+ test('listSecretsLocks request example', async () => {
724
+ consoleLogMock.mockImplementation((output) => {
725
+ originalLog(output);
726
+ });
727
+ consoleWarnMock.mockImplementation((output) => {
728
+ // if an error occurs, display the message and then fail the test
729
+ originalWarn(output);
730
+ expect(true).toBeFalsy();
731
+ });
732
+
733
+ originalLog('listSecretsLocks() result:');
734
+ // begin-list_secrets_locks
735
+
736
+ const params = {
737
+ limit: 10,
738
+ search: 'example',
739
+ groups: ['default', 'cac40995-c37a-4dcb-9506-472869077634'],
740
+ };
741
+
742
+ const allResults = [];
743
+ try {
744
+ const pager = new SecretsManagerV2.SecretsLocksPager(secretsManagerService, params);
745
+ while (pager.hasNext()) {
746
+ const nextPage = await pager.getNext();
747
+ expect(nextPage).not.toBeNull();
748
+ allResults.push(...nextPage);
749
+ }
750
+ console.log(JSON.stringify(allResults, null, 2));
751
+ } catch (err) {
752
+ console.warn(err);
753
+ }
754
+
755
+ // end-list_secrets_locks
756
+ });
757
+
758
+ test('listSecretLocks request example', async () => {
759
+ consoleLogMock.mockImplementation((output) => {
760
+ originalLog(output);
761
+ });
762
+ consoleWarnMock.mockImplementation((output) => {
763
+ // if an error occurs, display the message and then fail the test
764
+ originalWarn(output);
765
+ expect(true).toBeFalsy();
766
+ });
767
+
768
+ originalLog('listSecretLocks() result:');
769
+ // begin-list_secret_locks
770
+
771
+ const params = {
772
+ id: secretIdForGetSecretLink,
773
+ limit: 10,
774
+ sort: 'name',
775
+ search: 'example',
776
+ };
777
+
778
+ const allResults = [];
779
+ try {
780
+ const pager = new SecretsManagerV2.SecretLocksPager(secretsManagerService, params);
781
+ while (pager.hasNext()) {
782
+ const nextPage = await pager.getNext();
783
+ expect(nextPage).not.toBeNull();
784
+ allResults.push(...nextPage);
785
+ }
786
+ console.log(JSON.stringify(allResults, null, 2));
787
+ } catch (err) {
788
+ console.warn(err);
789
+ }
790
+
791
+ // end-list_secret_locks
792
+ });
793
+
794
+ test('createSecretVersionLocksBulk request example', async () => {
795
+ consoleLogMock.mockImplementation((output) => {
796
+ originalLog(output);
797
+ });
798
+ consoleWarnMock.mockImplementation((output) => {
799
+ // if an error occurs, display the message and then fail the test
800
+ originalWarn(output);
801
+ expect(true).toBeFalsy();
802
+ });
803
+
804
+ originalLog('createSecretVersionLocksBulk() result:');
805
+ // begin-create_secret_version_locks_bulk
806
+
807
+ // Request models needed by this operation.
808
+
809
+ // SecretLockPrototype
810
+ const secretLockPrototypeModel = {
811
+ name: 'lock-example-1',
812
+ description: 'lock for consumer 1',
813
+ attributes: {key: 'value'},
814
+ };
815
+
816
+ const params = {
817
+ secretId: secretIdForGetSecretLink,
818
+ id: secretVersionIdForGetSecretVersionLink,
819
+ locks: [secretLockPrototypeModel],
820
+ };
821
+
822
+ let res;
823
+ try {
824
+ res = await secretsManagerService.createSecretVersionLocksBulk(params);
825
+ console.log(JSON.stringify(res.result, null, 2));
826
+ } catch (err) {
827
+ console.warn(err);
828
+ }
829
+
830
+ // end-create_secret_version_locks_bulk
831
+ });
832
+
833
+ test('listSecretVersionLocks request example', async () => {
834
+ consoleLogMock.mockImplementation((output) => {
835
+ originalLog(output);
836
+ });
837
+ consoleWarnMock.mockImplementation((output) => {
838
+ // if an error occurs, display the message and then fail the test
839
+ originalWarn(output);
840
+ expect(true).toBeFalsy();
841
+ });
842
+
843
+ originalLog('listSecretVersionLocks() result:');
844
+ // begin-list_secret_version_locks
845
+
846
+ const params = {
847
+ secretId: secretIdForGetSecretLink,
848
+ id: secretVersionIdForGetSecretVersionLink,
849
+ limit: 10,
850
+ sort: 'name',
851
+ search: 'example',
852
+ };
853
+
854
+ const allResults = [];
855
+ try {
856
+ const pager = new SecretsManagerV2.SecretVersionLocksPager(secretsManagerService, params);
857
+ while (pager.hasNext()) {
858
+ const nextPage = await pager.getNext();
859
+ expect(nextPage).not.toBeNull();
860
+ allResults.push(...nextPage);
861
+ }
862
+ console.log(JSON.stringify(allResults, null, 2));
863
+ } catch (err) {
864
+ console.warn(err);
865
+ }
866
+
867
+ // end-list_secret_version_locks
868
+ });
869
+
870
+ test('listConfigurations request example', async () => {
871
+ consoleLogMock.mockImplementation((output) => {
872
+ originalLog(output);
873
+ });
874
+ consoleWarnMock.mockImplementation((output) => {
875
+ // if an error occurs, display the message and then fail the test
876
+ originalWarn(output);
877
+ expect(true).toBeFalsy();
878
+ });
879
+
880
+ originalLog('listConfigurations() result:');
881
+ // begin-list_configurations
882
+
883
+ const params = {
884
+ limit: 10,
885
+ sort: 'config_type',
886
+ search: 'example',
887
+ secretTypes: ['iam_credentials', 'public_cert', 'private_cert'],
888
+ };
889
+
890
+ const allResults = [];
891
+ try {
892
+ const pager = new SecretsManagerV2.ConfigurationsPager(secretsManagerService, params);
893
+ while (pager.hasNext()) {
894
+ const nextPage = await pager.getNext();
895
+ expect(nextPage).not.toBeNull();
896
+ allResults.push(...nextPage);
897
+ }
898
+ console.log(JSON.stringify(allResults, null, 2));
899
+ } catch (err) {
900
+ console.warn(err);
901
+ }
902
+
903
+ // end-list_configurations
904
+ });
905
+
906
+ test('getConfiguration request example', async () => {
907
+ consoleLogMock.mockImplementation((output) => {
908
+ originalLog(output);
909
+ });
910
+ consoleWarnMock.mockImplementation((output) => {
911
+ // if an error occurs, display the message and then fail the test
912
+ originalWarn(output);
913
+ expect(true).toBeFalsy();
914
+ });
915
+
916
+ originalLog('getConfiguration() result:');
917
+ // begin-get_configuration
918
+
919
+ const params = {
920
+ name: configurationNameForGetConfigurationLink,
921
+ xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
922
+ };
923
+
924
+ let res;
925
+ try {
926
+ res = await secretsManagerService.getConfiguration(params);
927
+ console.log(JSON.stringify(res.result, null, 2));
928
+ } catch (err) {
929
+ console.warn(err);
930
+ }
931
+
932
+ // end-get_configuration
933
+ });
934
+
935
+ test('updateConfiguration request example', async () => {
936
+ consoleLogMock.mockImplementation((output) => {
937
+ originalLog(output);
938
+ });
939
+ consoleWarnMock.mockImplementation((output) => {
940
+ // if an error occurs, display the message and then fail the test
941
+ originalWarn(output);
942
+ expect(true).toBeFalsy();
943
+ });
944
+
945
+ originalLog('updateConfiguration() result:');
946
+ // begin-update_configuration
947
+
948
+ // Request models needed by this operation.
949
+
950
+ // PublicCertificateConfigurationDNSCloudInternetServicesPatch
951
+ const configurationPatchModel = {
952
+ cloud_internet_services_apikey: '5ipu_ykv0PMp2MhxQnDMn7VzrkSlBwi3BOI8uthi_EXZ',
953
+ cloud_internet_services_crn: 'crn:v1:bluemix:public:internet-svcs:global:a/128e84fcca45c1224aae525d31ef2b52:009a0357-1460-42b4-b903-10580aba7dd8::',
954
+ };
955
+
956
+ const params = {
957
+ name: configurationNameForGetConfigurationLink,
958
+ configurationPatch: configurationPatchModel,
959
+ xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
960
+ };
961
+
962
+ let res;
963
+ try {
964
+ res = await secretsManagerService.updateConfiguration(params);
965
+ console.log(JSON.stringify(res.result, null, 2));
966
+ } catch (err) {
967
+ console.warn(err);
968
+ }
969
+
970
+ // end-update_configuration
971
+ });
972
+
973
+ test('createConfigurationAction request example', async () => {
974
+ consoleLogMock.mockImplementation((output) => {
975
+ originalLog(output);
976
+ });
977
+ consoleWarnMock.mockImplementation((output) => {
978
+ // if an error occurs, display the message and then fail the test
979
+ originalWarn(output);
980
+ expect(true).toBeFalsy();
981
+ });
982
+
983
+ originalLog('createConfigurationAction() result:');
984
+ // begin-create_configuration_action
985
+
986
+ // Request models needed by this operation.
987
+
988
+ // PrivateCertificateConfigurationActionRotateCRLPrototype
989
+ const configurationActionPrototypeModel = {
990
+ action_type: 'private_cert_configuration_action_rotate_crl',
991
+ };
992
+
993
+ const params = {
994
+ name: configurationNameForGetConfigurationLink,
995
+ configActionPrototype: configurationActionPrototypeModel,
996
+ xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
997
+ };
998
+
999
+ let res;
1000
+ try {
1001
+ res = await secretsManagerService.createConfigurationAction(params);
1002
+ console.log(JSON.stringify(res.result, null, 2));
1003
+ } catch (err) {
1004
+ console.warn(err);
1005
+ }
1006
+
1007
+ // end-create_configuration_action
1008
+ });
1009
+
1010
+ test('createNotificationsRegistration request example', async () => {
1011
+ consoleLogMock.mockImplementation((output) => {
1012
+ originalLog(output);
1013
+ });
1014
+ consoleWarnMock.mockImplementation((output) => {
1015
+ // if an error occurs, display the message and then fail the test
1016
+ originalWarn(output);
1017
+ expect(true).toBeFalsy();
1018
+ });
1019
+
1020
+ originalLog('createNotificationsRegistration() result:');
1021
+ // begin-create_notifications_registration
1022
+
1023
+ const params = {
1024
+ eventNotificationsInstanceCrn: 'crn:v1:bluemix:public:event-notifications:us-south:a/22018f3c34ff4ff193698d15ca316946:578ad1a4-2fd8-4e66-95d5-79a842ba91f8::',
1025
+ eventNotificationsSourceName: 'My Secrets Manager',
1026
+ eventNotificationsSourceDescription: 'Optional description of this source in an Event Notifications instance.',
1027
+ };
1028
+
1029
+ let res;
1030
+ try {
1031
+ res = await secretsManagerService.createNotificationsRegistration(params);
1032
+ console.log(JSON.stringify(res.result, null, 2));
1033
+ } catch (err) {
1034
+ console.warn(err);
1035
+ }
1036
+
1037
+ // end-create_notifications_registration
1038
+ });
1039
+
1040
+ test('getNotificationsRegistration request example', async () => {
1041
+ consoleLogMock.mockImplementation((output) => {
1042
+ originalLog(output);
1043
+ });
1044
+ consoleWarnMock.mockImplementation((output) => {
1045
+ // if an error occurs, display the message and then fail the test
1046
+ originalWarn(output);
1047
+ expect(true).toBeFalsy();
1048
+ });
1049
+
1050
+ originalLog('getNotificationsRegistration() result:');
1051
+ // begin-get_notifications_registration
1052
+
1053
+ let res;
1054
+ try {
1055
+ res = await secretsManagerService.getNotificationsRegistration({});
1056
+ console.log(JSON.stringify(res.result, null, 2));
1057
+ } catch (err) {
1058
+ console.warn(err);
1059
+ }
1060
+
1061
+ // end-get_notifications_registration
1062
+ });
1063
+
1064
+ test('getNotificationsRegistrationTest request example', async () => {
1065
+ consoleLogMock.mockImplementation((output) => {
1066
+ originalLog(output);
1067
+ });
1068
+ consoleWarnMock.mockImplementation((output) => {
1069
+ // if an error occurs, display the message and then fail the test
1070
+ originalWarn(output);
1071
+ expect(true).toBeFalsy();
1072
+ });
1073
+
1074
+ // begin-get_notifications_registration_test
1075
+
1076
+ try {
1077
+ await secretsManagerService.getNotificationsRegistrationTest({});
1078
+ } catch (err) {
1079
+ console.warn(err);
1080
+ }
1081
+
1082
+ // end-get_notifications_registration_test
1083
+ });
1084
+
1085
+ test('deleteSecretGroup request example', async () => {
1086
+ consoleLogMock.mockImplementation((output) => {
1087
+ originalLog(output);
1088
+ });
1089
+ consoleWarnMock.mockImplementation((output) => {
1090
+ // if an error occurs, display the message and then fail the test
1091
+ originalWarn(output);
1092
+ expect(true).toBeFalsy();
1093
+ });
1094
+
1095
+ // begin-delete_secret_group
1096
+
1097
+ const params = {
1098
+ id: secretGroupIdForGetSecretGroupLink,
1099
+ };
1100
+
1101
+ try {
1102
+ await secretsManagerService.deleteSecretGroup(params);
1103
+ } catch (err) {
1104
+ console.warn(err);
1105
+ }
1106
+
1107
+ // end-delete_secret_group
1108
+ });
1109
+
1110
+ test('deleteSecretVersionData request example', async () => {
1111
+ consoleLogMock.mockImplementation((output) => {
1112
+ originalLog(output);
1113
+ });
1114
+ consoleWarnMock.mockImplementation((output) => {
1115
+ // if an error occurs, display the message and then fail the test
1116
+ originalWarn(output);
1117
+ expect(true).toBeFalsy();
1118
+ });
1119
+
1120
+ // begin-delete_secret_version_data
1121
+
1122
+ const params = {
1123
+ secretId: secretIdForGetSecretLink,
1124
+ id: secretVersionIdForGetSecretVersionLink,
1125
+ };
1126
+
1127
+ try {
1128
+ await secretsManagerService.deleteSecretVersionData(params);
1129
+ } catch (err) {
1130
+ console.warn(err);
1131
+ }
1132
+
1133
+ // end-delete_secret_version_data
1134
+ });
1135
+
1136
+ test('deleteSecretLocksBulk request example', async () => {
1137
+ consoleLogMock.mockImplementation((output) => {
1138
+ originalLog(output);
1139
+ });
1140
+ consoleWarnMock.mockImplementation((output) => {
1141
+ // if an error occurs, display the message and then fail the test
1142
+ originalWarn(output);
1143
+ expect(true).toBeFalsy();
1144
+ });
1145
+
1146
+ originalLog('deleteSecretLocksBulk() result:');
1147
+ // begin-delete_secret_locks_bulk
1148
+
1149
+ const params = {
1150
+ id: secretIdForGetSecretLink,
1151
+ name: ['lock-example-1'],
1152
+ };
1153
+
1154
+ let res;
1155
+ try {
1156
+ res = await secretsManagerService.deleteSecretLocksBulk(params);
1157
+ console.log(JSON.stringify(res.result, null, 2));
1158
+ } catch (err) {
1159
+ console.warn(err);
1160
+ }
1161
+
1162
+ // end-delete_secret_locks_bulk
1163
+ });
1164
+
1165
+ test('deleteSecretVersionLocksBulk request example', async () => {
1166
+ consoleLogMock.mockImplementation((output) => {
1167
+ originalLog(output);
1168
+ });
1169
+ consoleWarnMock.mockImplementation((output) => {
1170
+ // if an error occurs, display the message and then fail the test
1171
+ originalWarn(output);
1172
+ expect(true).toBeFalsy();
1173
+ });
1174
+
1175
+ originalLog('deleteSecretVersionLocksBulk() result:');
1176
+ // begin-delete_secret_version_locks_bulk
1177
+
1178
+ const params = {
1179
+ secretId: secretIdForGetSecretLink,
1180
+ id: secretVersionIdForGetSecretVersionLink,
1181
+ name: ['lock-example-1'],
1182
+ };
1183
+
1184
+ let res;
1185
+ try {
1186
+ res = await secretsManagerService.deleteSecretVersionLocksBulk(params);
1187
+ console.log(JSON.stringify(res.result, null, 2));
1188
+ } catch (err) {
1189
+ console.warn(err);
1190
+ }
1191
+
1192
+ // end-delete_secret_version_locks_bulk
1193
+ });
1194
+
1195
+ test('deleteSecret request example', async () => {
1196
+ consoleLogMock.mockImplementation((output) => {
1197
+ originalLog(output);
1198
+ });
1199
+ consoleWarnMock.mockImplementation((output) => {
1200
+ // if an error occurs, display the message and then fail the test
1201
+ originalWarn(output);
1202
+ expect(true).toBeFalsy();
1203
+ });
1204
+
1205
+ // begin-delete_secret
1206
+
1207
+ const params = {
1208
+ id: secretIdForGetSecretLink,
1209
+ };
1210
+
1211
+ try {
1212
+ await secretsManagerService.deleteSecret(params);
1213
+ } catch (err) {
1214
+ console.warn(err);
1215
+ }
1216
+
1217
+ // end-delete_secret
1218
+ });
1219
+
1220
+ test('deleteConfiguration request example', async () => {
1221
+ consoleLogMock.mockImplementation((output) => {
1222
+ originalLog(output);
1223
+ });
1224
+ consoleWarnMock.mockImplementation((output) => {
1225
+ // if an error occurs, display the message and then fail the test
1226
+ originalWarn(output);
1227
+ expect(true).toBeFalsy();
1228
+ });
1229
+
1230
+ // begin-delete_configuration
1231
+
1232
+ const params = {
1233
+ name: configurationNameForGetConfigurationLink,
1234
+ xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
1235
+ };
1236
+
1237
+ try {
1238
+ await secretsManagerService.deleteConfiguration(params);
1239
+ } catch (err) {
1240
+ console.warn(err);
1241
+ }
1242
+
1243
+ // end-delete_configuration
1244
+ });
1245
+
1246
+ test('deleteNotificationsRegistration request example', async () => {
1247
+ consoleLogMock.mockImplementation((output) => {
1248
+ originalLog(output);
1249
+ });
1250
+ consoleWarnMock.mockImplementation((output) => {
1251
+ // if an error occurs, display the message and then fail the test
1252
+ originalWarn(output);
1253
+ expect(true).toBeFalsy();
1254
+ });
1255
+
1256
+ // begin-delete_notifications_registration
1257
+
1258
+ try {
1259
+ await secretsManagerService.deleteNotificationsRegistration({});
1260
+ } catch (err) {
1261
+ console.warn(err);
1262
+ }
1263
+
1264
+ // end-delete_notifications_registration
89
1265
  });
90
- consoleWarnMock.mockImplementation((output) => {
91
- // if an error occurs, display the message and then fail the test
92
- originalWarn(output);
93
- expect(true).toBeFalsy();
94
- });
95
-
96
- originalLog('createSecretGroup() result:');
97
- // begin-create_secret_group
98
-
99
- const params = {
100
- name: 'my-secret-group',
101
- };
102
-
103
- let res;
104
- try {
105
- res = await secretsManagerService.createSecretGroup(params);
106
- console.log(JSON.stringify(res.result, null, 2));
107
- } catch (err) {
108
- console.warn(err);
109
- }
110
-
111
- // end-create_secret_group
112
- const responseBody = res.result;
113
- secretGroupIdForGetSecretGroupLink = responseBody.id;
114
- });
115
-
116
- test('createSecret request example', async () => {
117
- consoleLogMock.mockImplementation((output) => {
118
- originalLog(output);
119
- });
120
- consoleWarnMock.mockImplementation((output) => {
121
- // if an error occurs, display the message and then fail the test
122
- originalWarn(output);
123
- expect(true).toBeFalsy();
124
- });
125
-
126
- originalLog('createSecret() result:');
127
- // begin-create_secret
128
-
129
- // Request models needed by this operation.
130
-
131
- // ArbitrarySecretPrototype
132
- const secretPrototypeModel = {
133
- custom_metadata: { metadata_custom_key: 'metadata_custom_value' },
134
- description: 'Description of my arbitrary secret.',
135
- expiration_date: '2030-10-05T11:49:42Z',
136
- labels: ['dev', 'us-south'],
137
- name: 'example-arbitrary-secret',
138
- secret_group_id: 'default',
139
- secret_type: 'arbitrary',
140
- payload: 'secret-data',
141
- version_custom_metadata: { custom_version_key: 'custom_version_value' },
142
- };
143
-
144
- const params = {
145
- secretPrototype: secretPrototypeModel,
146
- };
147
-
148
- let res;
149
- try {
150
- res = await secretsManagerService.createSecret(params);
151
- console.log(JSON.stringify(res.result, null, 2));
152
- } catch (err) {
153
- console.warn(err);
154
- }
155
-
156
- // end-create_secret
157
- const responseBody = res.result;
158
- secretIdForGetSecretLink = responseBody.id;
159
- secretIdForGetSecretVersionLink = responseBody.id;
160
- });
161
-
162
- test('updateSecretMetadata request example', async () => {
163
- consoleLogMock.mockImplementation((output) => {
164
- originalLog(output);
165
- });
166
- consoleWarnMock.mockImplementation((output) => {
167
- // if an error occurs, display the message and then fail the test
168
- originalWarn(output);
169
- expect(true).toBeFalsy();
170
- });
171
-
172
- originalLog('updateSecretMetadata() result:');
173
- // begin-update_secret_metadata
174
-
175
- // Request models needed by this operation.
176
-
177
- // ArbitrarySecretMetadataPatch
178
- const secretMetadataPatchModel = {
179
- name: 'updated-arbitrary-secret-name-example',
180
- description: 'updated Arbitrary Secret description',
181
- labels: ['dev', 'us-south'],
182
- custom_metadata: { metadata_custom_key: 'metadata_custom_value' },
183
- };
184
-
185
- const params = {
186
- id: secretIdForGetSecretLink,
187
- secretMetadataPatch: secretMetadataPatchModel,
188
- };
189
-
190
- let res;
191
- try {
192
- res = await secretsManagerService.updateSecretMetadata(params);
193
- console.log(JSON.stringify(res.result, null, 2));
194
- } catch (err) {
195
- console.warn(err);
196
- }
197
-
198
- // end-update_secret_metadata
199
- const responseBody = res.result;
200
- secretNameLink = responseBody.name;
201
- });
202
-
203
- test('listSecretVersions request example', async () => {
204
- consoleLogMock.mockImplementation((output) => {
205
- originalLog(output);
206
- });
207
- consoleWarnMock.mockImplementation((output) => {
208
- // if an error occurs, display the message and then fail the test
209
- originalWarn(output);
210
- expect(true).toBeFalsy();
211
- });
212
-
213
- originalLog('listSecretVersions() result:');
214
- // begin-list_secret_versions
215
-
216
- const params = {
217
- secretId: secretIdForGetSecretLink,
218
- };
219
-
220
- let res;
221
- try {
222
- res = await secretsManagerService.listSecretVersions(params);
223
- console.log(JSON.stringify(res.result, null, 2));
224
- } catch (err) {
225
- console.warn(err);
226
- }
227
-
228
- // end-list_secret_versions
229
- const responseBody = res.result;
230
- secretVersionIdForGetSecretVersionLink = responseBody.versions[0].id;
231
- secretIdForCreateSecretVersionLink = responseBody.versions[0].secret_id;
232
- secretVersionIdForGetSecretVersionMetadataLink = responseBody.versions[0].id;
233
- secretVersionIdForUpdateSecretVersionMetadataLink = responseBody.versions[0].id;
234
- secretIdForCreateSecretVersionLocksLink = responseBody.versions[0].secret_id;
235
- secretVersionIdForCreateSecretVersionLocksLink = responseBody.versions[0].id;
236
- secretVersionIdForDeleteSecretVersionLocksLink = responseBody.versions[0].id;
237
- });
238
-
239
- test('createSecretLocksBulk request example', async () => {
240
- consoleLogMock.mockImplementation((output) => {
241
- originalLog(output);
242
- });
243
- consoleWarnMock.mockImplementation((output) => {
244
- // if an error occurs, display the message and then fail the test
245
- originalWarn(output);
246
- expect(true).toBeFalsy();
247
- });
248
-
249
- originalLog('createSecretLocksBulk() result:');
250
- // begin-create_secret_locks_bulk
251
-
252
- // Request models needed by this operation.
253
-
254
- // SecretLockPrototype
255
- const secretLockPrototypeModel = {
256
- name: 'lock-example-1',
257
- description: 'lock for consumer 1',
258
- attributes: { key: 'value' },
259
- };
260
-
261
- const params = {
262
- id: secretIdForGetSecretLink,
263
- locks: [secretLockPrototypeModel],
264
- };
265
-
266
- let res;
267
- try {
268
- res = await secretsManagerService.createSecretLocksBulk(params);
269
- console.log(JSON.stringify(res.result, null, 2));
270
- } catch (err) {
271
- console.warn(err);
272
- }
273
-
274
- // end-create_secret_locks_bulk
275
- const responseBody = res.result;
276
- secretIdForListSecretLocksLink = responseBody.secret_id;
277
- secretIdForListSecretVersionLocksLink = responseBody.secret_id;
278
- secretVersionIdForListSecretVersionLocksLink = responseBody.versions[0].version_id;
279
- });
280
-
281
- test('createConfiguration request example', async () => {
282
- consoleLogMock.mockImplementation((output) => {
283
- originalLog(output);
284
- });
285
- consoleWarnMock.mockImplementation((output) => {
286
- // if an error occurs, display the message and then fail the test
287
- originalWarn(output);
288
- expect(true).toBeFalsy();
289
- });
290
-
291
- originalLog('createConfiguration() result:');
292
- // begin-create_configuration
293
-
294
- // Request models needed by this operation.
295
-
296
- // PublicCertificateConfigurationDNSCloudInternetServicesPrototype
297
- const configurationPrototypeModel = {
298
- config_type: 'public_cert_configuration_dns_cloud_internet_services',
299
- name: 'example-cloud-internet-services-config',
300
- cloud_internet_services_apikey: '5ipu_ykv0PMp2MhxQnDMn7VzrkSlBwi3BOI8uthi_EXZ',
301
- cloud_internet_services_crn: 'crn:v1:bluemix:public:internet-svcs:global:a/128e84fcca45c1224aae525d31ef2b52:009a0357-1460-42b4-b903-10580aba7dd8::',
302
- };
303
-
304
- const params = {
305
- configurationPrototype: configurationPrototypeModel,
306
- };
307
-
308
- let res;
309
- try {
310
- res = await secretsManagerService.createConfiguration(params);
311
- console.log(JSON.stringify(res.result, null, 2));
312
- } catch (err) {
313
- console.warn(err);
314
- }
315
-
316
- // end-create_configuration
317
- const responseBody = res.result;
318
- configurationNameForGetConfigurationLink = responseBody.name;
319
- });
320
-
321
- test('listSecretGroups request example', async () => {
322
- consoleLogMock.mockImplementation((output) => {
323
- originalLog(output);
324
- });
325
- consoleWarnMock.mockImplementation((output) => {
326
- // if an error occurs, display the message and then fail the test
327
- originalWarn(output);
328
- expect(true).toBeFalsy();
329
- });
330
-
331
- originalLog('listSecretGroups() result:');
332
- // begin-list_secret_groups
333
-
334
- let res;
335
- try {
336
- res = await secretsManagerService.listSecretGroups({});
337
- console.log(JSON.stringify(res.result, null, 2));
338
- } catch (err) {
339
- console.warn(err);
340
- }
341
-
342
- // end-list_secret_groups
343
- });
344
-
345
- test('getSecretGroup request example', async () => {
346
- consoleLogMock.mockImplementation((output) => {
347
- originalLog(output);
348
- });
349
- consoleWarnMock.mockImplementation((output) => {
350
- // if an error occurs, display the message and then fail the test
351
- originalWarn(output);
352
- expect(true).toBeFalsy();
353
- });
354
-
355
- originalLog('getSecretGroup() result:');
356
- // begin-get_secret_group
357
-
358
- const params = {
359
- id: secretGroupIdForGetSecretGroupLink,
360
- };
361
-
362
- let res;
363
- try {
364
- res = await secretsManagerService.getSecretGroup(params);
365
- console.log(JSON.stringify(res.result, null, 2));
366
- } catch (err) {
367
- console.warn(err);
368
- }
369
-
370
- // end-get_secret_group
371
- });
372
-
373
- test('updateSecretGroup request example', async () => {
374
- consoleLogMock.mockImplementation((output) => {
375
- originalLog(output);
376
- });
377
- consoleWarnMock.mockImplementation((output) => {
378
- // if an error occurs, display the message and then fail the test
379
- originalWarn(output);
380
- expect(true).toBeFalsy();
381
- });
382
-
383
- originalLog('updateSecretGroup() result:');
384
- // begin-update_secret_group
385
-
386
- const params = {
387
- id: secretGroupIdForGetSecretGroupLink,
388
- };
389
-
390
- let res;
391
- try {
392
- res = await secretsManagerService.updateSecretGroup(params);
393
- console.log(JSON.stringify(res.result, null, 2));
394
- } catch (err) {
395
- console.warn(err);
396
- }
397
-
398
- // end-update_secret_group
399
- });
400
-
401
- test('listSecrets request example', async () => {
402
- consoleLogMock.mockImplementation((output) => {
403
- originalLog(output);
404
- });
405
- consoleWarnMock.mockImplementation((output) => {
406
- // if an error occurs, display the message and then fail the test
407
- originalWarn(output);
408
- expect(true).toBeFalsy();
409
- });
410
-
411
- originalLog('listSecrets() result:');
412
- // begin-list_secrets
413
-
414
- const params = {
415
- limit: 10,
416
- sort: 'created_at',
417
- search: 'example',
418
- groups: ['default', 'cac40995-c37a-4dcb-9506-472869077634'],
419
- secretTypes: ['arbitrary', 'kv'],
420
- matchAllLabels: ['dev', 'us-south'],
421
- };
422
-
423
- const allResults = [];
424
- try {
425
- const pager = new SecretsManagerV2.SecretsPager(secretsManagerService, params);
426
- while (pager.hasNext()) {
427
- const nextPage = await pager.getNext();
428
- expect(nextPage).not.toBeNull();
429
- allResults.push(...nextPage);
430
- }
431
- console.log(JSON.stringify(allResults, null, 2));
432
- } catch (err) {
433
- console.warn(err);
434
- }
435
-
436
- // end-list_secrets
437
- });
438
-
439
- test('getSecret request example', async () => {
440
- consoleLogMock.mockImplementation((output) => {
441
- originalLog(output);
442
- });
443
- consoleWarnMock.mockImplementation((output) => {
444
- // if an error occurs, display the message and then fail the test
445
- originalWarn(output);
446
- expect(true).toBeFalsy();
447
- });
448
-
449
- originalLog('getSecret() result:');
450
- // begin-get_secret
451
-
452
- const params = {
453
- id: secretIdForGetSecretLink,
454
- };
455
-
456
- let res;
457
- try {
458
- res = await secretsManagerService.getSecret(params);
459
- console.log(JSON.stringify(res.result, null, 2));
460
- } catch (err) {
461
- console.warn(err);
462
- }
463
-
464
- // end-get_secret
465
- });
466
-
467
- test('getSecretMetadata request example', async () => {
468
- consoleLogMock.mockImplementation((output) => {
469
- originalLog(output);
470
- });
471
- consoleWarnMock.mockImplementation((output) => {
472
- // if an error occurs, display the message and then fail the test
473
- originalWarn(output);
474
- expect(true).toBeFalsy();
475
- });
476
-
477
- originalLog('getSecretMetadata() result:');
478
- // begin-get_secret_metadata
479
-
480
- const params = {
481
- id: secretIdForGetSecretLink,
482
- };
483
-
484
- let res;
485
- try {
486
- res = await secretsManagerService.getSecretMetadata(params);
487
- console.log(JSON.stringify(res.result, null, 2));
488
- } catch (err) {
489
- console.warn(err);
490
- }
491
-
492
- // end-get_secret_metadata
493
- });
494
-
495
- test('createSecretAction request example', async () => {
496
- consoleLogMock.mockImplementation((output) => {
497
- originalLog(output);
498
- });
499
- consoleWarnMock.mockImplementation((output) => {
500
- // if an error occurs, display the message and then fail the test
501
- originalWarn(output);
502
- expect(true).toBeFalsy();
503
- });
504
-
505
- originalLog('createSecretAction() result:');
506
- // begin-create_secret_action
507
-
508
- // Request models needed by this operation.
509
-
510
- // PrivateCertificateActionRevokePrototype
511
- const secretActionPrototypeModel = {
512
- action_type: 'private_cert_action_revoke_certificate',
513
- };
514
-
515
- const params = {
516
- id: secretIdForGetSecretLink,
517
- secretActionPrototype: secretActionPrototypeModel,
518
- };
519
-
520
- let res;
521
- try {
522
- res = await secretsManagerService.createSecretAction(params);
523
- console.log(JSON.stringify(res.result, null, 2));
524
- } catch (err) {
525
- console.warn(err);
526
- }
527
-
528
- // end-create_secret_action
529
- });
530
-
531
- test('getSecretByNameType request example', async () => {
532
- consoleLogMock.mockImplementation((output) => {
533
- originalLog(output);
534
- });
535
- consoleWarnMock.mockImplementation((output) => {
536
- // if an error occurs, display the message and then fail the test
537
- originalWarn(output);
538
- expect(true).toBeFalsy();
539
- });
540
-
541
- originalLog('getSecretByNameType() result:');
542
- // begin-get_secret_by_name_type
543
-
544
- const params = {
545
- secretType: 'arbitrary',
546
- name: secretNameLink,
547
- secretGroupName: 'default',
548
- };
549
-
550
- let res;
551
- try {
552
- res = await secretsManagerService.getSecretByNameType(params);
553
- console.log(JSON.stringify(res.result, null, 2));
554
- } catch (err) {
555
- console.warn(err);
556
- }
557
-
558
- // end-get_secret_by_name_type
559
- });
560
-
561
- test('createSecretVersion request example', async () => {
562
- consoleLogMock.mockImplementation((output) => {
563
- originalLog(output);
564
- });
565
- consoleWarnMock.mockImplementation((output) => {
566
- // if an error occurs, display the message and then fail the test
567
- originalWarn(output);
568
- expect(true).toBeFalsy();
569
- });
570
-
571
- originalLog('createSecretVersion() result:');
572
- // begin-create_secret_version
573
-
574
- // Request models needed by this operation.
575
-
576
- // ArbitrarySecretVersionPrototype
577
- const secretVersionPrototypeModel = {
578
- payload: 'updated secret credentials',
579
- custom_metadata: { metadata_custom_key: 'metadata_custom_value' },
580
- version_custom_metadata: { custom_version_key: 'custom_version_value' },
581
- };
582
-
583
- const params = {
584
- secretId: secretIdForGetSecretLink,
585
- secretVersionPrototype: secretVersionPrototypeModel,
586
- };
587
-
588
- let res;
589
- try {
590
- res = await secretsManagerService.createSecretVersion(params);
591
- console.log(JSON.stringify(res.result, null, 2));
592
- } catch (err) {
593
- console.warn(err);
594
- }
595
-
596
- // end-create_secret_version
597
- });
598
-
599
- test('getSecretVersion request example', async () => {
600
- consoleLogMock.mockImplementation((output) => {
601
- originalLog(output);
602
- });
603
- consoleWarnMock.mockImplementation((output) => {
604
- // if an error occurs, display the message and then fail the test
605
- originalWarn(output);
606
- expect(true).toBeFalsy();
607
- });
608
-
609
- originalLog('getSecretVersion() result:');
610
- // begin-get_secret_version
611
-
612
- const params = {
613
- secretId: secretIdForGetSecretLink,
614
- id: secretVersionIdForGetSecretVersionLink,
615
- };
616
-
617
- let res;
618
- try {
619
- res = await secretsManagerService.getSecretVersion(params);
620
- console.log(JSON.stringify(res.result, null, 2));
621
- } catch (err) {
622
- console.warn(err);
623
- }
624
-
625
- // end-get_secret_version
626
- });
627
-
628
- test('getSecretVersionMetadata request example', async () => {
629
- consoleLogMock.mockImplementation((output) => {
630
- originalLog(output);
631
- });
632
- consoleWarnMock.mockImplementation((output) => {
633
- // if an error occurs, display the message and then fail the test
634
- originalWarn(output);
635
- expect(true).toBeFalsy();
636
- });
637
-
638
- originalLog('getSecretVersionMetadata() result:');
639
- // begin-get_secret_version_metadata
640
-
641
- const params = {
642
- secretId: secretIdForGetSecretLink,
643
- id: secretVersionIdForGetSecretVersionLink,
644
- };
645
-
646
- let res;
647
- try {
648
- res = await secretsManagerService.getSecretVersionMetadata(params);
649
- console.log(JSON.stringify(res.result, null, 2));
650
- } catch (err) {
651
- console.warn(err);
652
- }
653
-
654
- // end-get_secret_version_metadata
655
- });
656
-
657
- test('updateSecretVersionMetadata request example', async () => {
658
- consoleLogMock.mockImplementation((output) => {
659
- originalLog(output);
660
- });
661
- consoleWarnMock.mockImplementation((output) => {
662
- // if an error occurs, display the message and then fail the test
663
- originalWarn(output);
664
- expect(true).toBeFalsy();
665
- });
666
-
667
- originalLog('updateSecretVersionMetadata() result:');
668
- // begin-update_secret_version_metadata
669
-
670
- const params = {
671
- secretId: secretIdForGetSecretLink,
672
- id: secretVersionIdForGetSecretVersionLink,
673
- };
674
-
675
- let res;
676
- try {
677
- res = await secretsManagerService.updateSecretVersionMetadata(params);
678
- console.log(JSON.stringify(res.result, null, 2));
679
- } catch (err) {
680
- console.warn(err);
681
- }
682
-
683
- // end-update_secret_version_metadata
684
- });
685
-
686
- test('createSecretVersionAction request example', async () => {
687
- consoleLogMock.mockImplementation((output) => {
688
- originalLog(output);
689
- });
690
- consoleWarnMock.mockImplementation((output) => {
691
- // if an error occurs, display the message and then fail the test
692
- originalWarn(output);
693
- expect(true).toBeFalsy();
694
- });
695
-
696
- originalLog('createSecretVersionAction() result:');
697
- // begin-create_secret_version_action
698
-
699
- // Request models needed by this operation.
700
-
701
- // PrivateCertificateVersionActionRevokePrototype
702
- const secretVersionActionPrototypeModel = {
703
- action_type: 'private_cert_action_revoke_certificate',
704
- };
705
-
706
- const params = {
707
- secretId: secretIdForGetSecretLink,
708
- id: secretVersionIdForGetSecretVersionLink,
709
- secretVersionActionPrototype: secretVersionActionPrototypeModel,
710
- };
711
-
712
- let res;
713
- try {
714
- res = await secretsManagerService.createSecretVersionAction(params);
715
- console.log(JSON.stringify(res.result, null, 2));
716
- } catch (err) {
717
- console.warn(err);
718
- }
719
-
720
- // end-create_secret_version_action
721
- });
722
-
723
- test('listSecretsLocks request example', async () => {
724
- consoleLogMock.mockImplementation((output) => {
725
- originalLog(output);
726
- });
727
- consoleWarnMock.mockImplementation((output) => {
728
- // if an error occurs, display the message and then fail the test
729
- originalWarn(output);
730
- expect(true).toBeFalsy();
731
- });
732
-
733
- originalLog('listSecretsLocks() result:');
734
- // begin-list_secrets_locks
735
-
736
- const params = {
737
- limit: 10,
738
- search: 'example',
739
- groups: ['default', 'cac40995-c37a-4dcb-9506-472869077634'],
740
- };
741
-
742
- const allResults = [];
743
- try {
744
- const pager = new SecretsManagerV2.SecretsLocksPager(secretsManagerService, params);
745
- while (pager.hasNext()) {
746
- const nextPage = await pager.getNext();
747
- expect(nextPage).not.toBeNull();
748
- allResults.push(...nextPage);
749
- }
750
- console.log(JSON.stringify(allResults, null, 2));
751
- } catch (err) {
752
- console.warn(err);
753
- }
754
-
755
- // end-list_secrets_locks
756
- });
757
-
758
- test('listSecretLocks request example', async () => {
759
- consoleLogMock.mockImplementation((output) => {
760
- originalLog(output);
761
- });
762
- consoleWarnMock.mockImplementation((output) => {
763
- // if an error occurs, display the message and then fail the test
764
- originalWarn(output);
765
- expect(true).toBeFalsy();
766
- });
767
-
768
- originalLog('listSecretLocks() result:');
769
- // begin-list_secret_locks
770
-
771
- const params = {
772
- id: secretIdForGetSecretLink,
773
- limit: 10,
774
- sort: 'name',
775
- search: 'example',
776
- };
777
-
778
- const allResults = [];
779
- try {
780
- const pager = new SecretsManagerV2.SecretLocksPager(secretsManagerService, params);
781
- while (pager.hasNext()) {
782
- const nextPage = await pager.getNext();
783
- expect(nextPage).not.toBeNull();
784
- allResults.push(...nextPage);
785
- }
786
- console.log(JSON.stringify(allResults, null, 2));
787
- } catch (err) {
788
- console.warn(err);
789
- }
790
-
791
- // end-list_secret_locks
792
- });
793
-
794
- test('createSecretVersionLocksBulk request example', async () => {
795
- consoleLogMock.mockImplementation((output) => {
796
- originalLog(output);
797
- });
798
- consoleWarnMock.mockImplementation((output) => {
799
- // if an error occurs, display the message and then fail the test
800
- originalWarn(output);
801
- expect(true).toBeFalsy();
802
- });
803
-
804
- originalLog('createSecretVersionLocksBulk() result:');
805
- // begin-create_secret_version_locks_bulk
806
-
807
- // Request models needed by this operation.
808
-
809
- // SecretLockPrototype
810
- const secretLockPrototypeModel = {
811
- name: 'lock-example-1',
812
- description: 'lock for consumer 1',
813
- attributes: { key: 'value' },
814
- };
815
-
816
- const params = {
817
- secretId: secretIdForGetSecretLink,
818
- id: secretVersionIdForGetSecretVersionLink,
819
- locks: [secretLockPrototypeModel],
820
- };
821
-
822
- let res;
823
- try {
824
- res = await secretsManagerService.createSecretVersionLocksBulk(params);
825
- console.log(JSON.stringify(res.result, null, 2));
826
- } catch (err) {
827
- console.warn(err);
828
- }
829
-
830
- // end-create_secret_version_locks_bulk
831
- });
832
-
833
- test('listSecretVersionLocks request example', async () => {
834
- consoleLogMock.mockImplementation((output) => {
835
- originalLog(output);
836
- });
837
- consoleWarnMock.mockImplementation((output) => {
838
- // if an error occurs, display the message and then fail the test
839
- originalWarn(output);
840
- expect(true).toBeFalsy();
841
- });
842
-
843
- originalLog('listSecretVersionLocks() result:');
844
- // begin-list_secret_version_locks
845
-
846
- const params = {
847
- secretId: secretIdForGetSecretLink,
848
- id: secretVersionIdForGetSecretVersionLink,
849
- limit: 10,
850
- sort: 'name',
851
- search: 'example',
852
- };
853
-
854
- const allResults = [];
855
- try {
856
- const pager = new SecretsManagerV2.SecretVersionLocksPager(secretsManagerService, params);
857
- while (pager.hasNext()) {
858
- const nextPage = await pager.getNext();
859
- expect(nextPage).not.toBeNull();
860
- allResults.push(...nextPage);
861
- }
862
- console.log(JSON.stringify(allResults, null, 2));
863
- } catch (err) {
864
- console.warn(err);
865
- }
866
-
867
- // end-list_secret_version_locks
868
- });
869
-
870
- test('listConfigurations request example', async () => {
871
- consoleLogMock.mockImplementation((output) => {
872
- originalLog(output);
873
- });
874
- consoleWarnMock.mockImplementation((output) => {
875
- // if an error occurs, display the message and then fail the test
876
- originalWarn(output);
877
- expect(true).toBeFalsy();
878
- });
879
-
880
- originalLog('listConfigurations() result:');
881
- // begin-list_configurations
882
-
883
- const params = {
884
- limit: 10,
885
- sort: 'config_type',
886
- search: 'example',
887
- secretTypes: ['iam_credentials', 'public_cert', 'private_cert'],
888
- };
889
-
890
- const allResults = [];
891
- try {
892
- const pager = new SecretsManagerV2.ConfigurationsPager(secretsManagerService, params);
893
- while (pager.hasNext()) {
894
- const nextPage = await pager.getNext();
895
- expect(nextPage).not.toBeNull();
896
- allResults.push(...nextPage);
897
- }
898
- console.log(JSON.stringify(allResults, null, 2));
899
- } catch (err) {
900
- console.warn(err);
901
- }
902
-
903
- // end-list_configurations
904
- });
905
-
906
- test('getConfiguration request example', async () => {
907
- consoleLogMock.mockImplementation((output) => {
908
- originalLog(output);
909
- });
910
- consoleWarnMock.mockImplementation((output) => {
911
- // if an error occurs, display the message and then fail the test
912
- originalWarn(output);
913
- expect(true).toBeFalsy();
914
- });
915
-
916
- originalLog('getConfiguration() result:');
917
- // begin-get_configuration
918
-
919
- const params = {
920
- name: configurationNameForGetConfigurationLink,
921
- xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
922
- };
923
-
924
- let res;
925
- try {
926
- res = await secretsManagerService.getConfiguration(params);
927
- console.log(JSON.stringify(res.result, null, 2));
928
- } catch (err) {
929
- console.warn(err);
930
- }
931
-
932
- // end-get_configuration
933
- });
934
-
935
- test('updateConfiguration request example', async () => {
936
- consoleLogMock.mockImplementation((output) => {
937
- originalLog(output);
938
- });
939
- consoleWarnMock.mockImplementation((output) => {
940
- // if an error occurs, display the message and then fail the test
941
- originalWarn(output);
942
- expect(true).toBeFalsy();
943
- });
944
-
945
- originalLog('updateConfiguration() result:');
946
- // begin-update_configuration
947
-
948
- // Request models needed by this operation.
949
-
950
- // PublicCertificateConfigurationDNSCloudInternetServicesPatch
951
- const configurationPatchModel = {
952
- cloud_internet_services_apikey: '5ipu_ykv0PMp2MhxQnDMn7VzrkSlBwi3BOI8uthi_EXZ',
953
- cloud_internet_services_crn: 'crn:v1:bluemix:public:internet-svcs:global:a/128e84fcca45c1224aae525d31ef2b52:009a0357-1460-42b4-b903-10580aba7dd8::',
954
- };
955
-
956
- const params = {
957
- name: configurationNameForGetConfigurationLink,
958
- configurationPatch: configurationPatchModel,
959
- xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
960
- };
961
-
962
- let res;
963
- try {
964
- res = await secretsManagerService.updateConfiguration(params);
965
- console.log(JSON.stringify(res.result, null, 2));
966
- } catch (err) {
967
- console.warn(err);
968
- }
969
-
970
- // end-update_configuration
971
- });
972
-
973
- test('createConfigurationAction request example', async () => {
974
- consoleLogMock.mockImplementation((output) => {
975
- originalLog(output);
976
- });
977
- consoleWarnMock.mockImplementation((output) => {
978
- // if an error occurs, display the message and then fail the test
979
- originalWarn(output);
980
- expect(true).toBeFalsy();
981
- });
982
-
983
- originalLog('createConfigurationAction() result:');
984
- // begin-create_configuration_action
985
-
986
- // Request models needed by this operation.
987
-
988
- // PrivateCertificateConfigurationActionRotateCRLPrototype
989
- const configurationActionPrototypeModel = {
990
- action_type: 'private_cert_configuration_action_rotate_crl',
991
- };
992
-
993
- const params = {
994
- name: configurationNameForGetConfigurationLink,
995
- configActionPrototype: configurationActionPrototypeModel,
996
- xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
997
- };
998
-
999
- let res;
1000
- try {
1001
- res = await secretsManagerService.createConfigurationAction(params);
1002
- console.log(JSON.stringify(res.result, null, 2));
1003
- } catch (err) {
1004
- console.warn(err);
1005
- }
1006
-
1007
- // end-create_configuration_action
1008
- });
1009
-
1010
- test('createNotificationsRegistration request example', async () => {
1011
- consoleLogMock.mockImplementation((output) => {
1012
- originalLog(output);
1013
- });
1014
- consoleWarnMock.mockImplementation((output) => {
1015
- // if an error occurs, display the message and then fail the test
1016
- originalWarn(output);
1017
- expect(true).toBeFalsy();
1018
- });
1019
-
1020
- originalLog('createNotificationsRegistration() result:');
1021
- // begin-create_notifications_registration
1022
-
1023
- const params = {
1024
- eventNotificationsInstanceCrn: 'crn:v1:bluemix:public:event-notifications:us-south:a/22018f3c34ff4ff193698d15ca316946:578ad1a4-2fd8-4e66-95d5-79a842ba91f8::',
1025
- eventNotificationsSourceName: 'My Secrets Manager',
1026
- eventNotificationsSourceDescription: 'Optional description of this source in an Event Notifications instance.',
1027
- };
1028
-
1029
- let res;
1030
- try {
1031
- res = await secretsManagerService.createNotificationsRegistration(params);
1032
- console.log(JSON.stringify(res.result, null, 2));
1033
- } catch (err) {
1034
- console.warn(err);
1035
- }
1036
-
1037
- // end-create_notifications_registration
1038
- });
1039
-
1040
- test('getNotificationsRegistration request example', async () => {
1041
- consoleLogMock.mockImplementation((output) => {
1042
- originalLog(output);
1043
- });
1044
- consoleWarnMock.mockImplementation((output) => {
1045
- // if an error occurs, display the message and then fail the test
1046
- originalWarn(output);
1047
- expect(true).toBeFalsy();
1048
- });
1049
-
1050
- originalLog('getNotificationsRegistration() result:');
1051
- // begin-get_notifications_registration
1052
-
1053
- let res;
1054
- try {
1055
- res = await secretsManagerService.getNotificationsRegistration({});
1056
- console.log(JSON.stringify(res.result, null, 2));
1057
- } catch (err) {
1058
- console.warn(err);
1059
- }
1060
-
1061
- // end-get_notifications_registration
1062
- });
1063
-
1064
- test('getNotificationsRegistrationTest request example', async () => {
1065
- consoleLogMock.mockImplementation((output) => {
1066
- originalLog(output);
1067
- });
1068
- consoleWarnMock.mockImplementation((output) => {
1069
- // if an error occurs, display the message and then fail the test
1070
- originalWarn(output);
1071
- expect(true).toBeFalsy();
1072
- });
1073
-
1074
- // begin-get_notifications_registration_test
1075
-
1076
- try {
1077
- await secretsManagerService.getNotificationsRegistrationTest({});
1078
- } catch (err) {
1079
- console.warn(err);
1080
- }
1081
-
1082
- // end-get_notifications_registration_test
1083
- });
1084
-
1085
- test('deleteSecretGroup request example', async () => {
1086
- consoleLogMock.mockImplementation((output) => {
1087
- originalLog(output);
1088
- });
1089
- consoleWarnMock.mockImplementation((output) => {
1090
- // if an error occurs, display the message and then fail the test
1091
- originalWarn(output);
1092
- expect(true).toBeFalsy();
1093
- });
1094
-
1095
- // begin-delete_secret_group
1096
-
1097
- const params = {
1098
- id: secretGroupIdForGetSecretGroupLink,
1099
- };
1100
-
1101
- try {
1102
- await secretsManagerService.deleteSecretGroup(params);
1103
- } catch (err) {
1104
- console.warn(err);
1105
- }
1106
-
1107
- // end-delete_secret_group
1108
- });
1109
-
1110
- test('deleteSecretVersionData request example', async () => {
1111
- consoleLogMock.mockImplementation((output) => {
1112
- originalLog(output);
1113
- });
1114
- consoleWarnMock.mockImplementation((output) => {
1115
- // if an error occurs, display the message and then fail the test
1116
- originalWarn(output);
1117
- expect(true).toBeFalsy();
1118
- });
1119
-
1120
- // begin-delete_secret_version_data
1121
-
1122
- const params = {
1123
- secretId: secretIdForGetSecretLink,
1124
- id: secretVersionIdForGetSecretVersionLink,
1125
- };
1126
-
1127
- try {
1128
- await secretsManagerService.deleteSecretVersionData(params);
1129
- } catch (err) {
1130
- console.warn(err);
1131
- }
1132
-
1133
- // end-delete_secret_version_data
1134
- });
1135
-
1136
- test('deleteSecretLocksBulk request example', async () => {
1137
- consoleLogMock.mockImplementation((output) => {
1138
- originalLog(output);
1139
- });
1140
- consoleWarnMock.mockImplementation((output) => {
1141
- // if an error occurs, display the message and then fail the test
1142
- originalWarn(output);
1143
- expect(true).toBeFalsy();
1144
- });
1145
-
1146
- originalLog('deleteSecretLocksBulk() result:');
1147
- // begin-delete_secret_locks_bulk
1148
-
1149
- const params = {
1150
- id: secretIdForGetSecretLink,
1151
- name: ['lock-example-1'],
1152
- };
1153
-
1154
- let res;
1155
- try {
1156
- res = await secretsManagerService.deleteSecretLocksBulk(params);
1157
- console.log(JSON.stringify(res.result, null, 2));
1158
- } catch (err) {
1159
- console.warn(err);
1160
- }
1161
-
1162
- // end-delete_secret_locks_bulk
1163
- });
1164
-
1165
- test('deleteSecretVersionLocksBulk request example', async () => {
1166
- consoleLogMock.mockImplementation((output) => {
1167
- originalLog(output);
1168
- });
1169
- consoleWarnMock.mockImplementation((output) => {
1170
- // if an error occurs, display the message and then fail the test
1171
- originalWarn(output);
1172
- expect(true).toBeFalsy();
1173
- });
1174
-
1175
- originalLog('deleteSecretVersionLocksBulk() result:');
1176
- // begin-delete_secret_version_locks_bulk
1177
-
1178
- const params = {
1179
- secretId: secretIdForGetSecretLink,
1180
- id: secretVersionIdForGetSecretVersionLink,
1181
- name: ['lock-example-1'],
1182
- };
1183
-
1184
- let res;
1185
- try {
1186
- res = await secretsManagerService.deleteSecretVersionLocksBulk(params);
1187
- console.log(JSON.stringify(res.result, null, 2));
1188
- } catch (err) {
1189
- console.warn(err);
1190
- }
1191
-
1192
- // end-delete_secret_version_locks_bulk
1193
- });
1194
-
1195
- test('deleteSecret request example', async () => {
1196
- consoleLogMock.mockImplementation((output) => {
1197
- originalLog(output);
1198
- });
1199
- consoleWarnMock.mockImplementation((output) => {
1200
- // if an error occurs, display the message and then fail the test
1201
- originalWarn(output);
1202
- expect(true).toBeFalsy();
1203
- });
1204
-
1205
- // begin-delete_secret
1206
-
1207
- const params = {
1208
- id: secretIdForGetSecretLink,
1209
- };
1210
-
1211
- try {
1212
- await secretsManagerService.deleteSecret(params);
1213
- } catch (err) {
1214
- console.warn(err);
1215
- }
1216
-
1217
- // end-delete_secret
1218
- });
1219
-
1220
- test('deleteConfiguration request example', async () => {
1221
- consoleLogMock.mockImplementation((output) => {
1222
- originalLog(output);
1223
- });
1224
- consoleWarnMock.mockImplementation((output) => {
1225
- // if an error occurs, display the message and then fail the test
1226
- originalWarn(output);
1227
- expect(true).toBeFalsy();
1228
- });
1229
-
1230
- // begin-delete_configuration
1231
-
1232
- const params = {
1233
- name: configurationNameForGetConfigurationLink,
1234
- xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
1235
- };
1236
-
1237
- try {
1238
- await secretsManagerService.deleteConfiguration(params);
1239
- } catch (err) {
1240
- console.warn(err);
1241
- }
1242
-
1243
- // end-delete_configuration
1244
- });
1245
-
1246
- test('deleteNotificationsRegistration request example', async () => {
1247
- consoleLogMock.mockImplementation((output) => {
1248
- originalLog(output);
1249
- });
1250
- consoleWarnMock.mockImplementation((output) => {
1251
- // if an error occurs, display the message and then fail the test
1252
- originalWarn(output);
1253
- expect(true).toBeFalsy();
1254
- });
1255
-
1256
- // begin-delete_notifications_registration
1257
-
1258
- try {
1259
- await secretsManagerService.deleteNotificationsRegistration({});
1260
- } catch (err) {
1261
- console.warn(err);
1262
- }
1263
-
1264
- // end-delete_notifications_registration
1265
- });
1266
1266
  });