@ibm-cloud/secrets-manager 2.0.9 → 2.0.10

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.
@@ -52,1215 +52,1342 @@ 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);
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
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);
1265
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('listSecretTasks 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('listSecretTasks() result:');
734
+ // begin-list_secret_tasks
735
+
736
+ const params = {
737
+ secretId: secretIdForGetSecretLink,
738
+ };
739
+
740
+ let res;
741
+ try {
742
+ res = await secretsManagerService.listSecretTasks(params);
743
+ console.log(JSON.stringify(res.result, null, 2));
744
+ } catch (err) {
745
+ console.warn(err);
746
+ }
747
+
748
+ // end-list_secret_tasks
749
+ });
750
+
751
+ test('getSecretTask request example', async () => {
752
+ consoleLogMock.mockImplementation((output) => {
753
+ originalLog(output);
754
+ });
755
+ consoleWarnMock.mockImplementation((output) => {
756
+ // if an error occurs, display the message and then fail the test
757
+ originalWarn(output);
758
+ expect(true).toBeFalsy();
759
+ });
760
+
761
+ originalLog('getSecretTask() result:');
762
+ // begin-get_secret_task
763
+
764
+ const params = {
765
+ secretId: secretIdForGetSecretLink,
766
+ id: secretIdForGetSecretLink,
767
+ };
768
+
769
+ let res;
770
+ try {
771
+ res = await secretsManagerService.getSecretTask(params);
772
+ console.log(JSON.stringify(res.result, null, 2));
773
+ } catch (err) {
774
+ console.warn(err);
775
+ }
776
+
777
+ // end-get_secret_task
778
+ });
779
+
780
+ test('replaceSecretTask request example', async () => {
781
+ consoleLogMock.mockImplementation((output) => {
782
+ originalLog(output);
783
+ });
784
+ consoleWarnMock.mockImplementation((output) => {
785
+ // if an error occurs, display the message and then fail the test
786
+ originalWarn(output);
787
+ expect(true).toBeFalsy();
788
+ });
789
+
790
+ originalLog('replaceSecretTask() result:');
791
+ // begin-replace_secret_task
792
+
793
+ // Request models needed by this operation.
794
+
795
+ // CustomCredentialsNewCredentials
796
+ const customCredentialsNewCredentialsModel = {
797
+ id: 'b49ad24d-81d4-5ebc-b9b9-b0937d1c84d5',
798
+ payload: { token: 'xF9v7OztItL5DOnFgHfS9NCT1sLTUew8KYZcZfxI' },
799
+ };
800
+
801
+ // SecretTaskPrototypeUpdateSecretTaskCredentialsCreated
802
+ const secretTaskPrototypeModel = {
803
+ status: 'credentials_created',
804
+ credentials: customCredentialsNewCredentialsModel,
805
+ };
806
+
807
+ const params = {
808
+ secretId: secretIdForGetSecretLink,
809
+ id: secretIdForGetSecretLink,
810
+ taskPut: secretTaskPrototypeModel,
811
+ };
812
+
813
+ let res;
814
+ try {
815
+ res = await secretsManagerService.replaceSecretTask(params);
816
+ console.log(JSON.stringify(res.result, null, 2));
817
+ } catch (err) {
818
+ console.warn(err);
819
+ }
820
+
821
+ // end-replace_secret_task
822
+ });
823
+
824
+ test('listSecretsLocks request example', async () => {
825
+ consoleLogMock.mockImplementation((output) => {
826
+ originalLog(output);
827
+ });
828
+ consoleWarnMock.mockImplementation((output) => {
829
+ // if an error occurs, display the message and then fail the test
830
+ originalWarn(output);
831
+ expect(true).toBeFalsy();
832
+ });
833
+
834
+ originalLog('listSecretsLocks() result:');
835
+ // begin-list_secrets_locks
836
+
837
+ const params = {
838
+ limit: 10,
839
+ search: 'example',
840
+ groups: ['default', 'cac40995-c37a-4dcb-9506-472869077634'],
841
+ };
842
+
843
+ const allResults = [];
844
+ try {
845
+ const pager = new SecretsManagerV2.SecretsLocksPager(secretsManagerService, params);
846
+ while (pager.hasNext()) {
847
+ const nextPage = await pager.getNext();
848
+ expect(nextPage).not.toBeNull();
849
+ allResults.push(...nextPage);
850
+ }
851
+ console.log(JSON.stringify(allResults, null, 2));
852
+ } catch (err) {
853
+ console.warn(err);
854
+ }
855
+
856
+ // end-list_secrets_locks
857
+ });
858
+
859
+ test('listSecretLocks request example', async () => {
860
+ consoleLogMock.mockImplementation((output) => {
861
+ originalLog(output);
862
+ });
863
+ consoleWarnMock.mockImplementation((output) => {
864
+ // if an error occurs, display the message and then fail the test
865
+ originalWarn(output);
866
+ expect(true).toBeFalsy();
867
+ });
868
+
869
+ originalLog('listSecretLocks() result:');
870
+ // begin-list_secret_locks
871
+
872
+ const params = {
873
+ id: secretIdForGetSecretLink,
874
+ limit: 10,
875
+ sort: 'name',
876
+ search: 'example',
877
+ };
878
+
879
+ const allResults = [];
880
+ try {
881
+ const pager = new SecretsManagerV2.SecretLocksPager(secretsManagerService, params);
882
+ while (pager.hasNext()) {
883
+ const nextPage = await pager.getNext();
884
+ expect(nextPage).not.toBeNull();
885
+ allResults.push(...nextPage);
886
+ }
887
+ console.log(JSON.stringify(allResults, null, 2));
888
+ } catch (err) {
889
+ console.warn(err);
890
+ }
891
+
892
+ // end-list_secret_locks
893
+ });
894
+
895
+ test('createSecretVersionLocksBulk request example', async () => {
896
+ consoleLogMock.mockImplementation((output) => {
897
+ originalLog(output);
898
+ });
899
+ consoleWarnMock.mockImplementation((output) => {
900
+ // if an error occurs, display the message and then fail the test
901
+ originalWarn(output);
902
+ expect(true).toBeFalsy();
903
+ });
904
+
905
+ originalLog('createSecretVersionLocksBulk() result:');
906
+ // begin-create_secret_version_locks_bulk
907
+
908
+ // Request models needed by this operation.
909
+
910
+ // SecretLockPrototype
911
+ const secretLockPrototypeModel = {
912
+ name: 'lock-example-1',
913
+ description: 'lock for consumer 1',
914
+ attributes: { key: 'value' },
915
+ };
916
+
917
+ const params = {
918
+ secretId: secretIdForGetSecretLink,
919
+ id: secretVersionIdForGetSecretVersionLink,
920
+ locks: [secretLockPrototypeModel],
921
+ };
922
+
923
+ let res;
924
+ try {
925
+ res = await secretsManagerService.createSecretVersionLocksBulk(params);
926
+ console.log(JSON.stringify(res.result, null, 2));
927
+ } catch (err) {
928
+ console.warn(err);
929
+ }
930
+
931
+ // end-create_secret_version_locks_bulk
932
+ });
933
+
934
+ test('listSecretVersionLocks request example', async () => {
935
+ consoleLogMock.mockImplementation((output) => {
936
+ originalLog(output);
937
+ });
938
+ consoleWarnMock.mockImplementation((output) => {
939
+ // if an error occurs, display the message and then fail the test
940
+ originalWarn(output);
941
+ expect(true).toBeFalsy();
942
+ });
943
+
944
+ originalLog('listSecretVersionLocks() result:');
945
+ // begin-list_secret_version_locks
946
+
947
+ const params = {
948
+ secretId: secretIdForGetSecretLink,
949
+ id: secretVersionIdForGetSecretVersionLink,
950
+ limit: 10,
951
+ sort: 'name',
952
+ search: 'example',
953
+ };
954
+
955
+ const allResults = [];
956
+ try {
957
+ const pager = new SecretsManagerV2.SecretVersionLocksPager(secretsManagerService, params);
958
+ while (pager.hasNext()) {
959
+ const nextPage = await pager.getNext();
960
+ expect(nextPage).not.toBeNull();
961
+ allResults.push(...nextPage);
962
+ }
963
+ console.log(JSON.stringify(allResults, null, 2));
964
+ } catch (err) {
965
+ console.warn(err);
966
+ }
967
+
968
+ // end-list_secret_version_locks
969
+ });
970
+
971
+ test('listConfigurations request example', async () => {
972
+ consoleLogMock.mockImplementation((output) => {
973
+ originalLog(output);
974
+ });
975
+ consoleWarnMock.mockImplementation((output) => {
976
+ // if an error occurs, display the message and then fail the test
977
+ originalWarn(output);
978
+ expect(true).toBeFalsy();
979
+ });
980
+
981
+ originalLog('listConfigurations() result:');
982
+ // begin-list_configurations
983
+
984
+ const params = {
985
+ limit: 10,
986
+ sort: 'config_type',
987
+ search: 'example',
988
+ secretTypes: ['iam_credentials', 'public_cert', 'private_cert', 'custom_credentials'],
989
+ };
990
+
991
+ const allResults = [];
992
+ try {
993
+ const pager = new SecretsManagerV2.ConfigurationsPager(secretsManagerService, params);
994
+ while (pager.hasNext()) {
995
+ const nextPage = await pager.getNext();
996
+ expect(nextPage).not.toBeNull();
997
+ allResults.push(...nextPage);
998
+ }
999
+ console.log(JSON.stringify(allResults, null, 2));
1000
+ } catch (err) {
1001
+ console.warn(err);
1002
+ }
1003
+
1004
+ // end-list_configurations
1005
+ });
1006
+
1007
+ test('getConfiguration request example', async () => {
1008
+ consoleLogMock.mockImplementation((output) => {
1009
+ originalLog(output);
1010
+ });
1011
+ consoleWarnMock.mockImplementation((output) => {
1012
+ // if an error occurs, display the message and then fail the test
1013
+ originalWarn(output);
1014
+ expect(true).toBeFalsy();
1015
+ });
1016
+
1017
+ originalLog('getConfiguration() result:');
1018
+ // begin-get_configuration
1019
+
1020
+ const params = {
1021
+ name: configurationNameForGetConfigurationLink,
1022
+ xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
1023
+ };
1024
+
1025
+ let res;
1026
+ try {
1027
+ res = await secretsManagerService.getConfiguration(params);
1028
+ console.log(JSON.stringify(res.result, null, 2));
1029
+ } catch (err) {
1030
+ console.warn(err);
1031
+ }
1032
+
1033
+ // end-get_configuration
1034
+ });
1035
+
1036
+ test('updateConfiguration request example', async () => {
1037
+ consoleLogMock.mockImplementation((output) => {
1038
+ originalLog(output);
1039
+ });
1040
+ consoleWarnMock.mockImplementation((output) => {
1041
+ // if an error occurs, display the message and then fail the test
1042
+ originalWarn(output);
1043
+ expect(true).toBeFalsy();
1044
+ });
1045
+
1046
+ originalLog('updateConfiguration() result:');
1047
+ // begin-update_configuration
1048
+
1049
+ // Request models needed by this operation.
1050
+
1051
+ // PublicCertificateConfigurationDNSCloudInternetServicesPatch
1052
+ const configurationPatchModel = {
1053
+ cloud_internet_services_apikey: '5ipu_ykv0PMp2MhxQnDMn7VzrkSlBwi3BOI8uthi_EXZ',
1054
+ cloud_internet_services_crn: 'crn:v1:bluemix:public:internet-svcs:global:a/128e84fcca45c1224aae525d31ef2b52:009a0357-1460-42b4-b903-10580aba7dd8::',
1055
+ };
1056
+
1057
+ const params = {
1058
+ name: configurationNameForGetConfigurationLink,
1059
+ configurationPatch: configurationPatchModel,
1060
+ xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
1061
+ };
1062
+
1063
+ let res;
1064
+ try {
1065
+ res = await secretsManagerService.updateConfiguration(params);
1066
+ console.log(JSON.stringify(res.result, null, 2));
1067
+ } catch (err) {
1068
+ console.warn(err);
1069
+ }
1070
+
1071
+ // end-update_configuration
1072
+ });
1073
+
1074
+ test('createConfigurationAction request example', async () => {
1075
+ consoleLogMock.mockImplementation((output) => {
1076
+ originalLog(output);
1077
+ });
1078
+ consoleWarnMock.mockImplementation((output) => {
1079
+ // if an error occurs, display the message and then fail the test
1080
+ originalWarn(output);
1081
+ expect(true).toBeFalsy();
1082
+ });
1083
+
1084
+ originalLog('createConfigurationAction() result:');
1085
+ // begin-create_configuration_action
1086
+
1087
+ // Request models needed by this operation.
1088
+
1089
+ // PrivateCertificateConfigurationActionRotateCRLPrototype
1090
+ const configurationActionPrototypeModel = {
1091
+ action_type: 'private_cert_configuration_action_rotate_crl',
1092
+ };
1093
+
1094
+ const params = {
1095
+ name: configurationNameForGetConfigurationLink,
1096
+ configActionPrototype: configurationActionPrototypeModel,
1097
+ xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
1098
+ };
1099
+
1100
+ let res;
1101
+ try {
1102
+ res = await secretsManagerService.createConfigurationAction(params);
1103
+ console.log(JSON.stringify(res.result, null, 2));
1104
+ } catch (err) {
1105
+ console.warn(err);
1106
+ }
1107
+
1108
+ // end-create_configuration_action
1109
+ });
1110
+
1111
+ test('createNotificationsRegistration request example', async () => {
1112
+ consoleLogMock.mockImplementation((output) => {
1113
+ originalLog(output);
1114
+ });
1115
+ consoleWarnMock.mockImplementation((output) => {
1116
+ // if an error occurs, display the message and then fail the test
1117
+ originalWarn(output);
1118
+ expect(true).toBeFalsy();
1119
+ });
1120
+
1121
+ originalLog('createNotificationsRegistration() result:');
1122
+ // begin-create_notifications_registration
1123
+
1124
+ const params = {
1125
+ eventNotificationsInstanceCrn: 'crn:v1:bluemix:public:event-notifications:us-south:a/22018f3c34ff4ff193698d15ca316946:578ad1a4-2fd8-4e66-95d5-79a842ba91f8::',
1126
+ eventNotificationsSourceName: 'My Secrets Manager',
1127
+ eventNotificationsSourceDescription: 'Optional description of this source in an Event Notifications instance.',
1128
+ };
1129
+
1130
+ let res;
1131
+ try {
1132
+ res = await secretsManagerService.createNotificationsRegistration(params);
1133
+ console.log(JSON.stringify(res.result, null, 2));
1134
+ } catch (err) {
1135
+ console.warn(err);
1136
+ }
1137
+
1138
+ // end-create_notifications_registration
1139
+ });
1140
+
1141
+ test('getNotificationsRegistration request example', async () => {
1142
+ consoleLogMock.mockImplementation((output) => {
1143
+ originalLog(output);
1144
+ });
1145
+ consoleWarnMock.mockImplementation((output) => {
1146
+ // if an error occurs, display the message and then fail the test
1147
+ originalWarn(output);
1148
+ expect(true).toBeFalsy();
1149
+ });
1150
+
1151
+ originalLog('getNotificationsRegistration() result:');
1152
+ // begin-get_notifications_registration
1153
+
1154
+ let res;
1155
+ try {
1156
+ res = await secretsManagerService.getNotificationsRegistration({});
1157
+ console.log(JSON.stringify(res.result, null, 2));
1158
+ } catch (err) {
1159
+ console.warn(err);
1160
+ }
1161
+
1162
+ // end-get_notifications_registration
1163
+ });
1164
+
1165
+ test('getNotificationsRegistrationTest 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
+ // begin-get_notifications_registration_test
1176
+
1177
+ try {
1178
+ await secretsManagerService.getNotificationsRegistrationTest({});
1179
+ } catch (err) {
1180
+ console.warn(err);
1181
+ }
1182
+
1183
+ // end-get_notifications_registration_test
1184
+ });
1185
+
1186
+ test('deleteSecretGroup request example', async () => {
1187
+ consoleLogMock.mockImplementation((output) => {
1188
+ originalLog(output);
1189
+ });
1190
+ consoleWarnMock.mockImplementation((output) => {
1191
+ // if an error occurs, display the message and then fail the test
1192
+ originalWarn(output);
1193
+ expect(true).toBeFalsy();
1194
+ });
1195
+
1196
+ // begin-delete_secret_group
1197
+
1198
+ const params = {
1199
+ id: secretGroupIdForGetSecretGroupLink,
1200
+ };
1201
+
1202
+ try {
1203
+ await secretsManagerService.deleteSecretGroup(params);
1204
+ } catch (err) {
1205
+ console.warn(err);
1206
+ }
1207
+
1208
+ // end-delete_secret_group
1209
+ });
1210
+
1211
+ test('deleteSecretVersionData request example', async () => {
1212
+ consoleLogMock.mockImplementation((output) => {
1213
+ originalLog(output);
1214
+ });
1215
+ consoleWarnMock.mockImplementation((output) => {
1216
+ // if an error occurs, display the message and then fail the test
1217
+ originalWarn(output);
1218
+ expect(true).toBeFalsy();
1219
+ });
1220
+
1221
+ // begin-delete_secret_version_data
1222
+
1223
+ const params = {
1224
+ secretId: secretIdForGetSecretLink,
1225
+ id: secretVersionIdForGetSecretVersionLink,
1226
+ };
1227
+
1228
+ try {
1229
+ await secretsManagerService.deleteSecretVersionData(params);
1230
+ } catch (err) {
1231
+ console.warn(err);
1232
+ }
1233
+
1234
+ // end-delete_secret_version_data
1235
+ });
1236
+
1237
+ test('deleteSecretLocksBulk request example', async () => {
1238
+ consoleLogMock.mockImplementation((output) => {
1239
+ originalLog(output);
1240
+ });
1241
+ consoleWarnMock.mockImplementation((output) => {
1242
+ // if an error occurs, display the message and then fail the test
1243
+ originalWarn(output);
1244
+ expect(true).toBeFalsy();
1245
+ });
1246
+
1247
+ originalLog('deleteSecretLocksBulk() result:');
1248
+ // begin-delete_secret_locks_bulk
1249
+
1250
+ const params = {
1251
+ id: secretIdForGetSecretLink,
1252
+ name: ['lock-example-1'],
1253
+ };
1254
+
1255
+ let res;
1256
+ try {
1257
+ res = await secretsManagerService.deleteSecretLocksBulk(params);
1258
+ console.log(JSON.stringify(res.result, null, 2));
1259
+ } catch (err) {
1260
+ console.warn(err);
1261
+ }
1262
+
1263
+ // end-delete_secret_locks_bulk
1264
+ });
1265
+
1266
+ test('deleteSecretVersionLocksBulk request example', async () => {
1267
+ consoleLogMock.mockImplementation((output) => {
1268
+ originalLog(output);
1269
+ });
1270
+ consoleWarnMock.mockImplementation((output) => {
1271
+ // if an error occurs, display the message and then fail the test
1272
+ originalWarn(output);
1273
+ expect(true).toBeFalsy();
1274
+ });
1275
+
1276
+ originalLog('deleteSecretVersionLocksBulk() result:');
1277
+ // begin-delete_secret_version_locks_bulk
1278
+
1279
+ const params = {
1280
+ secretId: secretIdForGetSecretLink,
1281
+ id: secretVersionIdForGetSecretVersionLink,
1282
+ name: ['lock-example-1'],
1283
+ };
1284
+
1285
+ let res;
1286
+ try {
1287
+ res = await secretsManagerService.deleteSecretVersionLocksBulk(params);
1288
+ console.log(JSON.stringify(res.result, null, 2));
1289
+ } catch (err) {
1290
+ console.warn(err);
1291
+ }
1292
+
1293
+ // end-delete_secret_version_locks_bulk
1294
+ });
1295
+
1296
+ test('deleteSecret request example', async () => {
1297
+ consoleLogMock.mockImplementation((output) => {
1298
+ originalLog(output);
1299
+ });
1300
+ consoleWarnMock.mockImplementation((output) => {
1301
+ // if an error occurs, display the message and then fail the test
1302
+ originalWarn(output);
1303
+ expect(true).toBeFalsy();
1304
+ });
1305
+
1306
+ // begin-delete_secret
1307
+
1308
+ const params = {
1309
+ id: secretIdForGetSecretLink,
1310
+ };
1311
+
1312
+ try {
1313
+ await secretsManagerService.deleteSecret(params);
1314
+ } catch (err) {
1315
+ console.warn(err);
1316
+ }
1317
+
1318
+ // end-delete_secret
1319
+ });
1320
+
1321
+ test('deleteSecretTask request example', async () => {
1322
+ consoleLogMock.mockImplementation((output) => {
1323
+ originalLog(output);
1324
+ });
1325
+ consoleWarnMock.mockImplementation((output) => {
1326
+ // if an error occurs, display the message and then fail the test
1327
+ originalWarn(output);
1328
+ expect(true).toBeFalsy();
1329
+ });
1330
+
1331
+ // begin-delete_secret_task
1332
+
1333
+ const params = {
1334
+ secretId: secretIdForGetSecretLink,
1335
+ id: secretIdForGetSecretLink,
1336
+ };
1337
+
1338
+ try {
1339
+ await secretsManagerService.deleteSecretTask(params);
1340
+ } catch (err) {
1341
+ console.warn(err);
1342
+ }
1343
+
1344
+ // end-delete_secret_task
1345
+ });
1346
+
1347
+ test('deleteConfiguration request example', async () => {
1348
+ consoleLogMock.mockImplementation((output) => {
1349
+ originalLog(output);
1350
+ });
1351
+ consoleWarnMock.mockImplementation((output) => {
1352
+ // if an error occurs, display the message and then fail the test
1353
+ originalWarn(output);
1354
+ expect(true).toBeFalsy();
1355
+ });
1356
+
1357
+ // begin-delete_configuration
1358
+
1359
+ const params = {
1360
+ name: configurationNameForGetConfigurationLink,
1361
+ xSmAcceptConfigurationType: 'public_cert_configuration_dns_cloud_internet_services',
1362
+ };
1363
+
1364
+ try {
1365
+ await secretsManagerService.deleteConfiguration(params);
1366
+ } catch (err) {
1367
+ console.warn(err);
1368
+ }
1369
+
1370
+ // end-delete_configuration
1371
+ });
1372
+
1373
+ test('deleteNotificationsRegistration request example', async () => {
1374
+ consoleLogMock.mockImplementation((output) => {
1375
+ originalLog(output);
1376
+ });
1377
+ consoleWarnMock.mockImplementation((output) => {
1378
+ // if an error occurs, display the message and then fail the test
1379
+ originalWarn(output);
1380
+ expect(true).toBeFalsy();
1381
+ });
1382
+
1383
+ // begin-delete_notifications_registration
1384
+
1385
+ try {
1386
+ await secretsManagerService.deleteNotificationsRegistration({});
1387
+ } catch (err) {
1388
+ console.warn(err);
1389
+ }
1390
+
1391
+ // end-delete_notifications_registration
1392
+ });
1266
1393
  });