-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathProgram.cs
More file actions
1139 lines (966 loc) · 55.8 KB
/
Copy pathProgram.cs
File metadata and controls
1139 lines (966 loc) · 55.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// _ __
// | |/ /___ ___ _ __ ___ _ _ ®
// | ' </ -_) -_) '_ \/ -_) '_|
// |_|\_\___\___| .__/\___|_|
// |_|
//
// Keeper SDK
// Copyright 2021 Keeper Security Inc.
// Contact: ops@keepersecurity.com
//
using System;
using System.Threading.Tasks;
using KeeperSecurity.Vault;
using KeeperSecurity.Utils;
using Sample.RecordsExamples;
using Sample.AttachmentsExamples;
using Enterprise;
using System.Collections.Generic;
namespace Sample
{
internal static class Program
{
private static async Task Main()
{
Console.CancelKeyPress += (s, e) => { Environment.Exit(-1); };
try
{
// Authenticate once from Main - all examples share this vault
var vault = await AuthenticateAndGetVault.GetVault(enablePersistentLogin: true, autoKeepAlive: false, usePushNotifications: true);
// var vault = await AuthenticateAndGetVault.GetVault();
if (vault == null)
{
Console.WriteLine("Could not authenticate. Exiting.");
return;
}
// var getRecords = new GetRecordsExample();
// await getRecords.GetRecordsWithName( "Google");
// // Shared folder without full sync: use ResolveAuthAsync so auth matches a prior GetVault in the same run.
// var authStep = await AuthenticateAndGetVault.ResolveAuthAsync(enablePersistentLogin: true, autoKeepAlive: true, usePushNotifications : false);
// await SharedFolderExamples.ShareFolderSkipSyncExample.PutTeamToSharedFolder(
// authStep, "<shared_folder_uid>", "<team_name_or_uid>", new SharedFolderUserOptions
// {
// ManageRecords = false,
// ManageUsers = true,
// Expiration = DateTimeOffset.Now.AddMinutes(10)
// });
// // Add Record Example
// await AddRecordExample.AddRecord(vault, name: "<recordName_here>", type: "bankCard", folderUid: "<folderUid_here>");
// // Passphrase Example (SDK PassphraseGenerator + UpdateRecord)
// await PassphraseRecordExample.UpdateRecordPassphrase(
// vault,
// recordUid: "<recordUid_here>",
// options: new PassphraseGenerationOptions
// {
// WordCount = 5,
// Separator = "-",
// UseCaps = true,
// UseDigits = true
// });
// // Update Record Example
// await UpdateRecordExample.UpdateRecord(
// vault,
// recordUid: "<recordUid_here>",
// newTitle: "UpdatedAddEx2",
// newRecordType: "serverCredentials"
// );
// // Delete Record Example
// await DeleteRecordExample.DeleteRecord(vault, recordUid: "<recordUid_here>");
// // List Records Example
// await ListRecordExample.ListAllRecords(vault);
// // Get Record Details Example
// var getRecord = new GetRecordExample();
// await getRecord.GetRecordDetails(vault, recordUid: "<recordUid_here>");
// // Get Record History Example
// var getRecordHistory = new GetRecordHistoryExample();
// await getRecordHistory.GetRecordHistory1(vault, recordUid: "<recordUid_here>");
// // Upload Attachment Example
// await UploadAttachmentExample.UploadAttachment(
// vault,
// recordUid: "<recordUid_here>",
// filePath: "<file_path_here>",
// thumbnailPath: "<thumbnail_path_here>"
// );
// // Download Attachment Example
// await DownloadAttachmentExample.DownloadAttachment(
// vault,
// recordUid: "<recordUid_here>",
// attachmentIdentifier: "<attachment id or name or title>",
// destinationPath: "<destination file path here>"
// );
// // Remove Attachment Example
// await RemoveAttachmentExample.RemoveAttachment(
// vault,
// recordUid: "<recordUid_here>",
// attachmentId: "<attachment_id_or_name_or_title>"
// );
// // List Folders Example
// await FoldersExample.ListFolderExample.ListFolder(vault);
// // Move Folder Example
// await FoldersExample.MoveFolderExample.MoveExistingFolder(
// vault,
// folderUid: "<folderUid_here>",
// newParentFolderUid: "<newParentFolderUid_here>",
// link: false
// );
// // Remove Folder Example
// await FoldersExample.RemoveFolderExample.RemoveFolder(
// vault,
// folderUid: "<folderUid_here>"
// );
// // List Keeper NSF Records Example
// await KeeperNSFExamples.ListKeeperNSFRecordsExample.ListAll(vault);
// // Get Keeper NSF Record Example
// await KeeperNSFExamples.GetKeeperNSFRecordExample.ShowDetails(
// vault,
// recordUidOrTitle: "<recordUid_or_title_here>"
// );
// // Create Keeper NSF Record Example
// await KeeperNSFExamples.CreateKeeperNSFRecordExample.Create(
// vault,
// title: "TestNSFrec1",
// recordType: "login",
// folderUid: "",
// notes: "hello1",
// fields: new Dictionary<string, object>
// {
// { "login", "a1@examples" },
// { "password", "A123" }
// }
// );
// Create Keeper NSF Records (batch) Example - all common record types
// await KeeperNSFExamples.CreateKeeperNSFRecordsBatchExample.CreateBatch(
// vault,
// defaultFolderUid: "");
// Or load the embedded sample JSON (same as PowerCommander -DownloadSampleRecords):
// await KeeperNSFExamples.CreateKeeperNSFRecordsBatchExample.CreateBatchFromSampleFile(
// vault,
// defaultFolderUid: "mGeYFviQ9Vwr9dm4302_CQ");
//
// PowerCommander: nsf-records-add -DownloadSampleRecords
// PowerCommander: nsf-records-add -FilePath .\nsf-records-batch.sample.json
// // Update Keeper NSF Record Example
// await KeeperNSFExamples.UpdateKeeperNSFRecordExample.Update(
// vault,
// recordUid: "<recordUid_here>",
// title: "<newTitle_here>",
// recordType: "login",
// notes: "<newNotes_here>",
// fields: new Dictionary<string, object>
// {
// { "login", "<updatedUsername_here>" },
// { "password", "<updatedPassword_here>" }
// }
// );
// // Update Keeper NSF Records (batch) Example
// await KeeperNSFExamples.UpdateKeeperNSFRecordsBatchExample.UpdateBatch(
// vault,
// new[]
// {
// new KeeperNSFRecordUpdateRequest
// {
// RecordUid = "<recordUid_1>",
// Title = "Updated Title 1",
// Fields = new Dictionary<string, object> { { "login", "a@example.com" } },
// },
// new KeeperNSFRecordUpdateRequest
// {
// RecordUid = "<recordUid_2>",
// Notes = "Updated via batch",
// },
// });
//
// PowerCommander: nsf-records-update -DownloadSampleRecords
// PowerCommander: nsf-records-update -FilePath .\nsf-records-update-batch.sample.json
// // Remove Keeper NSF Record Example (dryRun defaults to true — set false to confirm)
// await KeeperNSFExamples.RemoveKeeperNSFRecordExample.Remove(
// vault,
// recordUidOrTitle: "<recordUid_or_title_here>",
// folderUidOrName: "<folderUid_or_name_here>",
// operation: KeeperNSFRecordRemoveOperation.FolderTrash,
// dryRun: true
// );
// // Remove Keeper NSF Records (batch) Example (dryRun defaults to true — set false to confirm)
// await KeeperNSFExamples.RemoveKeeperNSFRecordsBatchExample.RemoveBatch(
// vault,
// KeeperNSFExamples.RemoveKeeperNSFRecordsBatchExample.BuildSampleRemovals(),
// dryRun: true
// );
//
// PowerCommander: nsf-records-rm -DownloadSampleRemovals
// PowerCommander: nsf-records-rm -FilePath .\nsf-records-remove-batch.sample.json
// // List Keeper NSF Folders Example
// await KeeperNSFExamples.ListKeeperNSFFoldersExample.ListAll(vault);
// // Create Keeper NSF Folder Example
// await KeeperNSFExamples.CreateKeeperNSFFolderExample.Create(
// vault,
// folderName: "<folderName_here>",
// parentFolderUid: "<parentFolderUid_here>",
// color: "#FF5733",
// inheritPermissions: true
// );
// // Create Keeper NSF Folders (batch) Example
// await KeeperNSFExamples.CreateKeeperNSFFoldersBatchExample.CreateBatch(
// vault,
// KeeperNSFExamples.CreateKeeperNSFFoldersBatchExample.BuildSampleFolders()
// );
//
// PowerCommander: nsf-mkdirs -DownloadSampleFolders
// PowerCommander: nsf-mkdirs -FilePath .\nsf-folders-batch.sample.json
// // Update Keeper NSF Folder Example
// await KeeperNSFExamples.UpdateKeeperNSFFolderExample.RenameOrRecolor(
// vault,
// folderUidOrName: "<folderUid_or_name_here>",
// newName: "<newFolderName_here>",
// color: "#33FF57"
// );
// // Update Keeper NSF Folders (batch) Example
// await KeeperNSFExamples.UpdateKeeperNSFFoldersBatchExample.UpdateBatch(
// vault,
// KeeperNSFExamples.UpdateKeeperNSFFoldersBatchExample.BuildSampleUpdates()
// );
//
// PowerCommander: nsf-folders-update -DownloadSampleFolders
// PowerCommander: nsf-folders-update -FilePath .\nsf-folders-update-batch.sample.json
// // Remove Keeper NSF Folder Example (dryRun defaults to true — set false to confirm)
// await KeeperNSFExamples.RemoveKeeperNSFFolderExample.Remove(
// vault,
// folderUidOrName: "<folderUid_or_name_here>",
// operation: KeeperNSFFolderRemoveOperation.FolderTrash,
// dryRun: true
// );
// // Remove Keeper NSF Folders (batch) Example
// await KeeperNSFExamples.RemoveKeeperNSFFoldersBatchExample.RemoveBatch(
// vault,
// KeeperNSFExamples.RemoveKeeperNSFFoldersBatchExample.BuildSampleRemovals(),
// dryRun: true
// );
//
// PowerCommander: nsf-rmdirs -DownloadSampleFolders
// PowerCommander: nsf-rmdirs -FilePath .\nsf-folders-remove-batch.sample.json
// // Link Keeper NSF Record to Folder Example
// await KeeperNSFExamples.LinkKeeperNSFRecordToFolderExample.Link(
// vault,
// recordUidOrTitle: "<recordUid_or_title_here>",
// folderUidOrName: "<folderUid_or_name_here>"
// );
// // Link Keeper NSF Records to Folders (batch) Example
// await KeeperNSFExamples.LinkKeeperNSFRecordsToFoldersBatchExample.LinkBatch(
// vault,
// KeeperNSFExamples.LinkKeeperNSFRecordsToFoldersBatchExample.BuildSampleLinks()
// );
//
// PowerCommander: nsf-lns -DownloadSampleLinks
// PowerCommander: nsf-lns -FilePath .\nsf-folder-records-link-batch.sample.json
// // Unlink Keeper NSF Records from Folders (batch) Example
// await KeeperNSFExamples.UnlinkKeeperNSFRecordsFromFoldersBatchExample.UnlinkBatch(
// vault,
// KeeperNSFExamples.UnlinkKeeperNSFRecordsFromFoldersBatchExample.BuildSampleUnlinks()
// );
//
// PowerCommander: nsf-unln -DownloadSampleUnlinks
// PowerCommander: nsf-unln -FilePath .\nsf-folder-records-unlink-batch.sample.json
// // Keep Keeper NSF Record in Folder Example
// await KeeperNSFExamples.KeepKeeperNSFRecordInFolderExample.KeepInFolder(
// vault,
// recordUid: "<recordUid_here>",
// keepFolderUid: "<folderUid_here>"
// );
// // Get Keeper NSF Shortcuts Example
// await KeeperNSFExamples.GetKeeperNSFShortcutsExample.ListShortcuts(
// vault,
// recordUid: "<recordUid_here>",
// folderUid: "<folderUid_here>"
// );
// // Share Keeper NSF Record Example
// await KeeperNSFExamples.ShareKeeperNSFRecordExample.Share(
// vault,
// recordUid: "<recordUid_here>",
// userEmail: "<userEmail_here>",
// role: "viewer"
// );
// // Share Keeper NSF Records (batch) Example
// await KeeperNSFExamples.ShareKeeperNSFRecordsBatchExample.ShareBatch(
// vault,
// KeeperNSFExamples.ShareKeeperNSFRecordsBatchExample.BuildSampleShares()
// );
// // Unshare Keeper NSF Record Example
// await KeeperNSFExamples.UnshareKeeperNSFRecordExample.Unshare(
// vault,
// recordUid: "<recordUid_here>",
// userEmail: "<userEmail_here>"
// );
// // Unshare Keeper NSF Records (batch) Example
// await KeeperNSFExamples.UnshareKeeperNSFRecordsBatchExample.UnshareBatch(
// vault,
// KeeperNSFExamples.UnshareKeeperNSFRecordsBatchExample.BuildSampleUnshares()
// );
// // Transfer Keeper NSF Record Ownership Example
// await KeeperNSFExamples.TransferKeeperNSFRecordOwnershipExample.Transfer(
// vault,
// recordUidOrTitles: new[] { "<recordUid_or_title_here>" },
// newOwnerEmail: "<newOwnerEmail_here>"
// );
// // Grant Keeper NSF Folder Access Example
// await KeeperNSFExamples.GrantKeeperNSFFolderAccessExample.Grant(
// vault,
// folderUid: "<folderUid_here>",
// userEmail: "<userEmail_here>",
// role: "viewer"
// );
// // Grant Keeper NSF Folder Accesses (batch) Example
// await KeeperNSFExamples.GrantKeeperNSFFolderAccessesBatchExample.GrantBatch(
// vault,
// KeeperNSFExamples.GrantKeeperNSFFolderAccessesBatchExample.BuildSampleGrants()
// );
//
// PowerCommander: nsf-share-folders -DownloadSampleAccesses
// PowerCommander: nsf-share-folders -FilePath .\nsf-folders-access-grant-batch.sample.json
// // Update Keeper NSF Folder Accesses (batch) Example
// await KeeperNSFExamples.UpdateKeeperNSFFolderAccessesBatchExample.UpdateBatch(
// vault,
// KeeperNSFExamples.UpdateKeeperNSFFolderAccessesBatchExample.BuildSampleUpdates()
// );
//
// PowerCommander: nsf-update-folder-access -DownloadSampleAccesses
// PowerCommander: nsf-update-folder-access -FilePath .\nsf-folders-access-update-batch.sample.json
// // Revoke Keeper NSF Folder Access Example
// await KeeperNSFExamples.RevokeKeeperNSFFolderAccessExample.Revoke(
// vault,
// folderUid: "<folderUid_here>",
// userEmail: "<userEmail_here>"
// );
// // Revoke Keeper NSF Folder Accesses (batch) Example
// await KeeperNSFExamples.RevokeKeeperNSFFolderAccessesBatchExample.RevokeBatch(
// vault,
// KeeperNSFExamples.RevokeKeeperNSFFolderAccessesBatchExample.BuildSampleRevokes()
// );
//
// PowerCommander: nsf-unshare-folders -DownloadSampleAccesses
// PowerCommander: nsf-unshare-folders -FilePath .\nsf-folders-access-revoke-batch.sample.json
// // Update Keeper NSF Record Permissions Example (dryRun defaults to true — set false to apply)
// await KeeperNSFExamples.UpdateKeeperNSFRecordPermissionsExample.UpdatePermissions(
// vault,
// folderUid: "<folderUid_here>",
// action: "grant",
// role: "viewer",
// recursive: false,
// dryRun: true
// );
// // Create Shared Folder Example
// var options = new SharedFolderOptions
// {
// ManageRecords = true,
// ManageUsers = false,
// CanShare = true
// };
// await FoldersExample.CreateFolder.CreateNewFolder(
// vault,
// folderName: "NewFolderFromSDK",
// parentFolderUid: "<parentFolderUid_if_any>",
// sharedFolderOptions: options
// );
// // List Shared Folders Example
// await SharedFolderExamples.ListSharedFolder.ListAllSharedFolders(vault);
// // Change Record Permissions of a Shared Folder Example
// var permissions = new SharedFolderRecordOptions
// {
// CanEdit = true,
// CanShare = true,
// Expiration = DateTimeOffset.Now.AddMinutes(5)
// };
// await SharedFolderExamples.SharedFolderPermissions.ManageSharedFolderPermissions1(
// vault,
// sharedFolderUid: "<sharedFolderUid_here>",
// recordUid: "<recordUid_here>",
// permissionsOptions: permissions
// );
// Share Shared Folder to User Example
// var userOptions = new SharedFolderUserOptions
// {
// ManageRecords = true,
// ManageUsers = true,
// Expiration = DateTimeOffset.Now.AddMinutes(10)
// };
// await SharedFolderToUserExamples.ShareFolderToUser.ShareFolderWithUser(
// vault,
// sharedFolderUid: "<sharedFolderUid_here>",
// userId: "<userEmail_here>",
// userType: UserType.User,
// options: userOptions
// );
// // One-Time Share Record Example
// await OneTimeShareExamples.OneTimeShare.ShareRecordOneTime(
// vault,
// recordUid: "<recordUid_here>",
// expireIn: TimeSpan.FromMinutes(2),
// shareName: "<shareName_here>"
// );
// // List One-Time Shares for a Record Example
// await OneTimeShareListExamples.OneTimeShareList.GetOneTimeShareList(
// vault,
// recordUid: "<recordUid_here>"
// );
// // One-Time Share Remove
// await RemoveOneTimeShareExamples.RemoveOneTimeShare.RemoveOneTimeShareRecord(
// vault,
// recordUid: "<recordUid_here>",
// clientIds: new[] { "<clientId_here>" }
// );
// // Share Record to User Example
// var shareOptions = new SharedFolderRecordOptions
// {
// CanEdit = true,
// CanShare = true,
// Expiration = DateTimeOffset.Now.AddMinutes(10)
// };
// await ShareRecordExamples.ShareRecordToUser.ShareRecordToUserWithPermissions(
// vault,
// recordUid: "<recordUid_here>",
// username: "<userEmail_here>",
// options: shareOptions
// );
// // Remove User From Specified Record Example
// await ShareRecordExamples.RevokeShareRecordToUser.RemoveShareRecordToUser(
// vault,
// recordUid: "<recordUid_here>",
// username: "<userEmail_here>"
// );
// // Remove User from All Shares Example
// await ShareRecordExamples.RevokeAllSharesToUser.RemoveAllSharesToUser(
// vault,
// username: "<userEmail_here>"
// );
// // Transfer Ownership Example
// await TransferOwnershipExamples.TransferOwnership.TransferRecordToUser(
// vault,
// recordUid: "<recordUid_here>",
// username: "<userEmail_here>"
// );
// // All RecordType Example
// await RecordTypeExamples.RecordTypeInfoExample.RecordTypeInfo(vault);
// // Specified Record Type Info Example
// await RecordTypeExamples.RecordTypeInfoExample.RecordTypeInfo(
// vault,
// recordTypeName: "<recordTypeName_here>"
// );
// // Create RecordType Example
// var recordTypeData = "{\"$id\":\"SDKEX1\",\"description\":\"My SDK record\",\"categories\":[\"note\"],\"fields\":[{\"$ref\":\"login\"},{\"$ref\":\"password\"}]}";
// await RecordTypeExamples.CreateRecordTypeExample.CreateRecordType(
// vault,
// recordTypeData: recordTypeData
// );
// // Update RecordType Example
// var updateRecordTypeData = "{\"$id\":\"SDKEX0\",\"description\":\"My SDK First record\",\"categories\":[\"note\"],\"fields\":[{\"$ref\":\"login\"},{\"$ref\":\"password\"}]}";
// await RecordTypeExamples.UpdateRecordTypeExample.UpdateRecordType(
// vault,
// recordTypeId: "<recordTypeId_here>",
// recordTypeData: updateRecordTypeData
// );
// // Delete RecordType Example
// await RecordTypeExamples.DeleteRecordTypeExample.DeleteRecordType(
// vault,
// recordTypeId: "<recordTypeId_here>"
// );
// // Import Example
// string filename = @"C:\<SomePath>\Test.json";
// var json = File.ReadAllText(filename);
// var result = await ImportExportExamples.ImportExample.Import(vault, json);
// // Export to Json Example
// IEnumerable<string> recordUids = new List<string>
// {
// "<recordUId_here>",
// "<recordUId_here>"
// };
// await ImportExportExamples.ExportToJsonExample.ExportToJson(
// vault,
// recordUids: recordUids,
// includeSharedFolders: true,
// logger: null
// );
// // Export to File Example
// IEnumerable<string> recordUids1 = new List<string>
// {
// "<recordUId_here>",
// "<recordUId_here>"
// };
// await ImportExportExamples.ExportToFileExample.ExportToFile(
// vault,
// filename: "<filePath_here>",
// recordUids: recordUids1,
// includeSharedFolders: true,
// logger: null
// );
// // DownloadMembership To FileObject Example
// var options1 = new DownloadMembershipOptions
// {
// FoldersOnly = true,
// ForceManageUsers = true,
// ForceManageRecords = true,
// SubFolderHandling = "flatten" // or "ignore"
// };
// await ImportExportExamples.DownloadMembershipToFileObjectExample.DownloadMembershipToFileObject(
// vault,
// options1
// );
// // DownloadMembership To Json Example
// var options2 = new DownloadMembershipOptions
// {
// FoldersOnly = true,
// ForceManageUsers = true,
// ForceManageRecords = true,
// SubFolderHandling = "flatten" // or "ignore"
// };
// await ImportExportExamples.DownloadMembershipToJsonExample.DownloadToJson(
// vault,
// options2
// );
// // DownloadMembership To File Example
// var options3 = new DownloadMembershipOptions
// {
// FoldersOnly = true,
// ForceManageUsers = true,
// ForceManageRecords = true,
// SubFolderHandling = "flatten" // or "ignore"
// };
// await ImportExportExamples.DownloadMembershipToFileExample.DownloadToFile(
// vault,
// filename: "<filePath_here>",
// options3
// );
// // Merge DownloadMembership Example
// var options4 = new DownloadMembershipOptions
// {
// FoldersOnly = true,
// ForceManageUsers = true,
// ForceManageRecords = true,
// SubFolderHandling = "flatten" // or "ignore"
// };
// await ImportExportExamples.DownloadMembershipToMergeExample.MergeDownloadMembershipFile(
// vault,
// filename: "<filePath_here>",
// options4
// );
// // Load Record Type Example ---- issue not able to pass the input.
// string jsonPath = @"C:\<path_to_file>\RecordType.json";
// string loadRecordTypeData = File.ReadAllText(jsonPath);
// await ImportExportExamples.LoadRecordTypeExample.LoadRecordType(
// vault,
// recordTypeData: loadRecordTypeData
// );
// // App Llist Example
// await SecretManagerExamples.AppListExample.AppList(vault);
// // App Create Example
// await SecretManagerExamples.AppCreateExample.AppCreate(
// vault,
// applicationName: "<appName_here>"
// );
// // App View Example
// await SecretManagerExamples.AppViewExample.AppView(
// vault,
// applicationUid: "<appUid_here>"
// );
// // App Delete Example
// await SecretManagerExamples.AppDeleteExample.AppDelete(
// vault,
// applicationUid: "<appUid_here>"
// );
// // App Share Example
// var userShareOptions = new SharedFolderUserOptions
// {
// ManageRecords = true,
// ManageUsers = true,
// Expiration = DateTimeOffset.Now.AddMinutes(10)
// };
// await SecretManagerExamples.AppShareExample.AddUserToSharedFolder(
// vault,
// sharedFolderUid: "<shareFolderUid_here>",
// userId: "<userEmail_here>",
// userType: UserType.User,
// options: userShareOptions
// );
// var recordShareOptions = new SharedFolderRecordOptions
// {
// CanEdit = true,
// CanShare = true,
// Expiration = DateTimeOffset.Now.AddMinutes(10)
// };
// await SecretManagerExamples.AppShareExample.ShareRecordToUser(
// vault,
// recordUid: "<recordUid_here>",
// username: "<userEmail_here>",
// options: recordShareOptions
// );
// // App Un Share Example
// await SecretManagerExamples.AppUnShareExample.RemoveUserToSharedFolder(
// vault,
// sharedFolderUid: "<recordUid_here>",
// userId: "<userEmail_here>",
// userType: UserType.User
// );
// await SecretManagerExamples.AppUnShareExample.RevokeShareToUser(
// vault,
// recordUid: "<recordUid_here>",
// username: "<userEmail_here>"
// );
// // Add Client Example
// await SecretManagerExamples.AddClientExample.AddClient(
// vault,
// applicationId: "<appUid_here>",
// unlockIp: true,
// firstAccessExpireInMinutes: 60,
// accessExpiresInMinutes: null,
// name: "<clientName_here>",
// appClientType: Enterprise.AppClientType.General
// );
// List PAM Gateways Example
await PAMExamples.GatewayExamples.ListGatewaysExample.ListGateways(
vault,
onlineOnly: false,
ignoreRouterDown: true,
verbose: false
);
// // Create PAM Gateway Example
// await PAMExamples.GatewayExamples.CreateGatewayExample.CreateGateway(
// vault,
// gatewayName: "<gatewayName_here>",
// applicationId: "<ksmAppUid_or_title_here>",
// tokenExpiresInMinutes: 60,
// configInit: null // or "json" / "b64" for initialized config
// );
// // Edit PAM Gateway Example
// await PAMExamples.GatewayExamples.EditGatewayExample.EditGateway(
// vault,
// gatewayId: "<gatewayUid_or_name_here>",
// newName: "<newGatewayName_here>",
// nodeNameOrId: null // optional: node ID or display name
// );
// // Set PAM Gateway Max Instances Example
// await PAMExamples.GatewayExamples.SetGatewayMaxInstancesExample.SetMaxInstances(
// vault,
// gatewayId: "<gatewayUid_or_name_here>",
// maxInstances: 3
// );
// // Remove PAM Gateway Example
// await PAMExamples.GatewayExamples.RemoveGatewayExample.RemoveGateway(
// vault,
// gatewayId: "<gatewayUid_or_name_here>"
// );
// // List PAM Rotations Example
// await PAMExamples.RotationExamples.ListRotationsExample.ListRotations(
// vault,
// verbose: false
// );
// // PAM Rotation Info Example
// await PAMExamples.RotationExamples.RotationInfoExample.ShowRotationInfo(
// vault,
// recordId: "<pamUserUid_or_title_here>"
// );
// // Edit PAM Rotation Example (general pamUser)
// await PAMExamples.RotationExamples.EditRotationExample.EditRotation(
// vault,
// recordId: "<pamUserUid_or_title_here>",
// configId: "<pamConfigUid_or_title_here>",
// resourceId: "<pamResourceUid_or_title_here>",
// onDemand: true,
// // scheduleCron: "0 0 4 * * ?",
// // complexity: "32,5,5,5,5",
// enable: true
// );
// // List PAM Rotation Scripts Example
// await PAMExamples.RotationExamples.ListRotationScriptsExample.ListScripts(
// vault,
// pattern: null // optional: record UID or title filter
// );
// // Add PAM Rotation Script Example
// await PAMExamples.RotationExamples.AddRotationScriptExample.AddScript(
// vault,
// recordId: "<pamUserUid_or_title_here>",
// scriptFilePath: @"C:\path\to\rotate.ps1",
// runCommand: "powershell -File rotate.ps1",
// addCredentialUids: null // or new[] { "<credentialUid_here>" }
// );
// // Edit PAM Rotation Script Example
// await PAMExamples.RotationExamples.EditRotationScriptExample.EditScript(
// vault,
// recordId: "<pamUserUid_or_title_here>",
// scriptId: "<scriptUid_or_name_here>",
// runCommand: "powershell -File rotate.ps1",
// addCredentialUids: null,
// removeCredentialUids: null
// );
// // Remove PAM Rotation Script Example
// await PAMExamples.RotationExamples.RemoveRotationScriptExample.RemoveScript(
// vault,
// recordId: "<pamUserUid_or_title_here>",
// scriptId: "<scriptUid_or_name_here>"
// );
// // Remove Client Example
// await SecretManagerExamples.RemoveClientExample.RemoveClient(
// vault,
// applicationId: "<appUid_here>",
// deviceId: "<deviceId_here>"
// );
// // Share Folder or Record to App
// await SecretManagerExamples.SecretManagerShareExample.SecretManagerShare(
// vault,
// applicationId: "<appUid_here>",
// sharedFolderOrRecordUid: "<shareFolder_or_recordUId_here>",
// canEdit: true
// );
// // BreachWatch List Example
// await BreachWatchExamples.BreachWatchListExample.BreachWatchList(vault);
// // BreachScan and Store Example
// await BreachWatchExamples.BreachWatchScanExample.BreachWatchScan(
// vault,
// recordUid: "<recordUid_here>",
// recordKey: "<recordKey_here>".Base64UrlDecode(),
// password: "<password_here>"
// );
// // BreachWatch Password Scan Example
// var passwords = new List<(string Password, byte[] Euid)>
// {
// ("123", null),
// ("MPass!", null),
// ("admin", null)
// };
// await Sample.BreachWatchExamples.BreachWatchPasswordExample.BreachWatchPassword(vault, passwords);
// // BreachWatch Ignore Example
// await BreachWatchExamples.BreachWatchIgnoreExample.IgnoreRecord(vault, recordUid: "<recordUid_here>");
// await BreachWatchExamples.BreachWatchIgnoreExample.CheckIfIgnored(vault, recordUid: "<recordUid_here>");
// // Enterprise Get Data Example
// await EnterpriseManagementExamples.EnterpriseDownExample.EnterpriseGetData(vault);
// // Enterprise User View Example
// await EnterpriseManagementExamples.EnterpriseUserExamples.EnterpriseUserViewExample.ViewUser(vault, email: "<userEmail_here>");
// // Enterprise Add User Example
// await EnterpriseManagementExamples.EnterpriseUserExamples.EnterpriseAddUserExample.InviteUser(vault, email: "<userEmail_here>", fullName: "<fullName_here>", nodeNameOrId: "<nodeNameOrId_here>");
// // Create instance
// var examples = new EnterpriseManagementExamples.EnterpriseUserExamples.EnterpriseEditUserExamples();
// // Call methods
// await examples.AddUsersToTeams(
// vault,
// new[] { "<userEmail_here>" },
// new[] { "<teamUid_here>" }
// );
// await examples.RemoveUsersFromTeams(
// vault,
// new[] { "<userEmail_here>" },
// new[] { "<teamUid_here>" }
// );
// // Enterprise Delete User Example
// await EnterpriseManagementExamples.EnterpriseUserExamples.EnterpriseDeleteUserExample.DeleteUser(vault, email: "<userEmail_here>");
// // Enterprise User Lock/Unlock Example
// await EnterpriseManagementExamples.EnterpriseUserExamples.EnterpriseUserLockUnlockExample.LockUnlockUser(vault, email: "<userEmail_here>", locked: true);
// await EnterpriseManagementExamples.EnterpriseUserExamples.EnterpriseUserLockUnlockExample.LockUnlockUser(vault, email: "<userEmail_here>", locked: false);
// // Enterprise Node View Example
// await EnterpriseManagementExamples.EnterpriseNodeExamples.EnterpriseNodeView.ViewNode(vault, nodeNameOrId: "<nodeNameOrId_here>");
// // Enterprise Node Add Example
// await EnterpriseManagementExamples.EnterpriseNodeExamples.EnterpriseNodeAdd.AddNode(vault, nodeName: "<nodeName_here>", parentNodeNameOrId: "<parentNodeNameOrId_here>");
// // Enterprise Node Edit Example
// await EnterpriseManagementExamples.EnterpriseNodeExamples.EnterpriseNodeEdit.EditNode(vault, nodeNameOrId: "<nodeNameOrId_here>", newName: "<newNodeName_here>", newParentNodeIdentifier: "<newParentNodeIdentifier_here>");
// // Enterprise Node Delete Example
// await EnterpriseManagementExamples.EnterpriseNodeExamples.EnterpriseNodeDelete.DeleteNode(vault, nodeNameOrId: "<nodeNameOrId_here>");
// // Enterprise Role View Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.EnterpriseRoleView.ViewRole(vault, roleNameOrId: "<roleNameOrId_here>");
// // Enterprise Role Add Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.EnterpriseRoleAdd.AddRole(vault, roleName: "<roleNameOrId_here>", nodeNameOrId: "<nodeNameOrId_here>", newUserInherit: true);
// // Enterprise Role Update Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.EnterpriseRoleUpdateExample.EnterpriseUpdateRole(vault, roleNameOrId: "Test12", newUserInherit: false, visibleBelow: true, displayName: "UTest12");
// // Enterprise Role Delete Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.EnterpriseRoleDeleteExample.EnterpriseDeleteRole(vault, roleNameOrId: "70411693853162");
// // Enterprise Role Admin Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.EnterpriseRoleAdminExample.EnterpriseAddAdmin(vault, roleNameOrId: "", userName: "<userEmail_here>");
// // Enterprise Role Membership Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.EnterpriseRoleMembershipExample.EnterpriseRemoveRoleMembership(vault, roleNameOrId: "<roleNameOrId_here>", userName: "<userEmail_here>");
// // Enterprise Team View Example
// await EnterpriseManagementExamples.EnterpriseTeamExamples.EnterpriseTeamViewExample.EnterpriseTeamView(vault, teamNameOrId: "<teamNameOrId_here>");
// // Enterprise Team Add Example
// EnterpriseTeam newTeam = new EnterpriseTeam
// {
// Name = "<teamName_here>",
// RestrictEdit = false,
// RestrictSharing = true,
// RestrictView = false,
// };
// await EnterpriseManagementExamples.EnterpriseTeamExamples.EnterpriseTeamAddExample.EnterpriseTeamAdd(vault, newTeam: newTeam);
// // Enterprise Team Update Example
// EnterpriseTeam updateTeam = new EnterpriseTeam
// {
// Name = "<teamName_here>",
// RestrictEdit = true,
// RestrictSharing = true,
// RestrictView = false,
// };
// await EnterpriseManagementExamples.EnterpriseTeamExamples.EnterpriseTeamUpdateExample.EnterpriseTeamUpdate(vault, updateTeam: updateTeam);
// // Enterprise Team Delete Example
// await EnterpriseManagementExamples.EnterpriseTeamExamples.EnterpriseTeamDeleteExample.EnterpriseTeamDelete(vault, teamNameOrId: "<teamName_here>");
// // Enterprise Team Membership Examples
// // Add Users to Teams Example
// await EnterpriseManagementExamples.EnterpriseTeamExamples.EnterpriseTeamMembershipExample.AddUsersToTeams(
// vault,
// new[] { "<userEmail_here>", "user_email_here" },
// new[] { "<teamUid_here>" }
// );
// // Remove Users from Teams Example
// await EnterpriseManagementExamples.EnterpriseTeamExamples.EnterpriseTeamMembershipExample.RemoveUsersFromTeams(
// vault,
// new[] { "<userEmail_here>", "user_email_here" },
// new[] { "<teamUid_here>" }
// );
// // Enterprise List Teams Example
// await EnterpriseManagementExamples.EnterpriseTeamExamples.EnterpriseTeamsListExample.EnterpriseTeamsList(vault);
// // Enterprise Role Team Management Example
// // Add Team to Role Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.EnterpriseRoleTeamManagementExample.AddTeamToRoleExample(vault, roleNameOrId: "<roleNameOrId_here>", teamNameOrId: "<teamNameOrId_here>");
// // Remove Team to Role Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.EnterpriseRoleTeamManagementExample.RemoveTeamFromRoleExample(vault, roleNameOrId: "<roleNameOrId_here>", teamNameOrid: "<teamNameOrId_here>");
// // Trash List Example
// await TrashExamples.TrashList.TrashListAsync(vault);
// // Trash Restore Example
// await TrashExamples.TrashRestore.TrashRestoreAsync(vault, new List<string> { "<recordUid_here>" });
// // Login Example
// await LoginExamples.LoginExample.LoginAsync();
// await LoginExamples.LogoutExample.LogoutAsync(vault);
// await LoginExamples.WhoamiExample.WhoamiAsync(vault);
// // Enterprise Role Managed Node Management Example
// // Add Managed Node to Role Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.RoleManagedNodeAddExample.RoleManagedNodeAdd(vault, roleNameOrId: "<roleNameOrId_here>", nodeNameOrId: "<nodeNameOrId_here>", cascadeNodeManagement: true);
// // Update Managed Node to Role Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.RoleManagedNodeUpdateExample.RoleManagedNodeUpdate(vault, roleNameOrId: "<roleNameOrId_here>", nodeNameOrId: "<nodeNameOrId_here>", cascadeNodeManagement: false);
// // Remove Managed Node from Role Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.RoleManagedNodeRemoveExample.RoleManagedNodeRemove(vault, roleNameOrId: "<roleNameOrId_here>", nodeNameOrId: "<nodeNameOrId_here>");
// // Add Privilege to Managed Node Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.RoleManagedNodePrivilegeAddExample.RoleManagedNodePrivilegeAdd(vault, roleNameOrId: "<roleNameOrId_here>", nodeNameOrId: "<nodeNameOrId_here>", privileges: new List<RoleManagedNodePrivilege> { RoleManagedNodePrivilege.MANAGE_USER, RoleManagedNodePrivilege.TRANSFER_ACCOUNT });
// // Remove Privilege from Managed Node Example
// await EnterpriseManagementExamples.EnterpriseRoleExamples.RoleManagedNodePrivilegeRemoveExample.RoleManagedNodePrivilegeRemove(vault, roleNameOrId: "<roleNameOrId_here>", nodeNameOrId: "<nodeNameOrId_here>", privileges: new List<RoleManagedNodePrivilege> { RoleManagedNodePrivilege.MANAGE_USER, RoleManagedNodePrivilege.TRANSFER_ACCOUNT });
// // Add Enforcement to Role Example
// // JSON value for TWO_FACTOR_BY_IP - IPs in this range don't require 2FA
// var enforcementsToAdd = new Dictionary<RoleEnforcementPolicies, string> {
// { RoleEnforcementPolicies.RESTRICT_FILE_UPLOAD, "true" },
// { RoleEnforcementPolicies.RESTRICT_IP_ADDRESSES, "1.1.1.1" },
// { RoleEnforcementPolicies.MASTER_PASSWORD_MINIMUM_LENGTH, "10"},
// { RoleEnforcementPolicies.RESTRICT_OFFLINE_ACCESS, "true"},
// { RoleEnforcementPolicies.RESTRICT_DOMAIN_ACCESS, "192.168.1.100/app123"},
// { RoleEnforcementPolicies.GENERATED_PASSWORD_COMPLEXITY, "google.com|12|4|1|3|1"},
// { RoleEnforcementPolicies.MASTER_PASSWORD_MINIMUM_LOWER, "5"},
// { RoleEnforcementPolicies.REQUIRE_TWO_FACTOR, "true"},
// { RoleEnforcementPolicies.RESTRICT_SHARING_RECORD_ATTACHMENTS, "true"},
// { RoleEnforcementPolicies.LOGOUT_TIMER_DESKTOP, "100"},
// { RoleEnforcementPolicies.RESTRICT_IMPORT, "true"},