-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathtypes.go
More file actions
1319 lines (1200 loc) · 43.7 KB
/
Copy pathtypes.go
File metadata and controls
1319 lines (1200 loc) · 43.7 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
// Code generated by typeshare 1.13.2. DO NOT EDIT.
package onepassword
import (
"encoding/json"
"time"
)
type ErrorMessage string
// Additional attributes for OTP fields.
type AddressFieldDetails struct {
// The street address
Street string `json:"street"`
// The city
City string `json:"city"`
// The country
Country string `json:"country"`
// The ZIP code
Zip string `json:"zip"`
// The state
State string `json:"state"`
}
type DocumentCreateParams struct {
// The name of the file
Name string `json:"name"`
// The content of the file
Content []byte `json:"content"`
}
// Represents an environment variable (name:value pair) and its masked state
type EnvironmentVariable struct {
// An environment variable's name
Name string `json:"name"`
// An environment variable's value
Value string `json:"value"`
// An environment variable's masked state
Masked bool `json:"masked"`
}
type FileAttributes struct {
// The name of the file
Name string `json:"name"`
// The ID of the file retrieved from the server
ID string `json:"id"`
// The size of the file in bytes
Size uint32 `json:"size"`
}
type FileCreateParams struct {
// The name of the file
Name string `json:"name"`
// The content of the file
Content []byte `json:"content"`
// The section id where the file should be stored
SectionID string `json:"sectionId"`
// The field id where the file should be stored
FieldID string `json:"fieldId"`
}
// For future use, if we want to return more information about the generated password.
// Currently, it only returns the password itself.
type GeneratePasswordResponse struct {
// The generated password.
Password string `json:"password"`
}
// Response containing the full set of environment variables from an Environment.
type GetVariablesResponse struct {
// List of environment variables.
Variables []EnvironmentVariable `json:"variables"`
}
type GroupType string
const (
// The owners group, which gives the following permissions:
// - Do everything the Admin group can do
// - See every vault other than the personal vaults
// - Change people's names
// - See billing
// - Change billing
// - Make other people owners
// - Delete a person
GroupTypeOwners GroupType = "owners"
// The administrators group, which gives the following permissions:
// - Perform recovery
// - Create new vaults
// - Invite new members
// - See vault metadata, including the vault name and who has access.
// - Make other people admins
GroupTypeAdministrators GroupType = "administrators"
// The recovery group. It contains recovery keysets, and is added to every vault to allow for recovery.
//
// No one is added to this.
GroupTypeRecovery GroupType = "recovery"
// The external account managers group or EAM is a mandatory group for managed accounts that has
// same permissions as the owners.
GroupTypeExternalAccountManagers GroupType = "externalAccountManagers"
// Members of a team that a user is on.
GroupTypeTeamMembers GroupType = "teamMembers"
// A custom, user defined group.
GroupTypeUserDefined GroupType = "userDefined"
// Support for new or renamed group types
GroupTypeUnsupported GroupType = "unsupported"
)
type GroupState string
const (
// This group is active
GroupStateActive GroupState = "active"
// This group has been deleted
GroupStateDeleted GroupState = "deleted"
// This group is in an unknown state
GroupStateUnsupported GroupState = "unsupported"
)
type VaultAccessorType string
const (
VaultAccessorTypeUser VaultAccessorType = "user"
VaultAccessorTypeGroup VaultAccessorType = "group"
)
// Represents the vault access information.
type VaultAccess struct {
// The vault's UUID.
VaultUuid string `json:"vaultUuid"`
// The vault's accessor type.
AccessorType VaultAccessorType `json:"accessorType"`
// The vault's accessor UUID.
AccessorUuid string `json:"accessorUuid"`
// The permissions granted to this vault
Permissions uint32 `json:"permissions"`
}
type Group struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
GroupType GroupType `json:"groupType"`
State GroupState `json:"state"`
VaultAccess []VaultAccess `json:"vaultAccess,omitempty"`
}
// Represents a group's access to a 1Password vault.
// This is used for granting permissions
type GroupAccess struct {
// The group's ID
GroupID string `json:"groupId"`
// The group's set of permissions for the vault
Permissions uint32 `json:"permissions"`
}
type GroupGetParams struct {
VaultPermissions *bool `json:"vaultPermissions,omitempty"`
}
// Represents a group's access to a 1Password vault.
type GroupVaultAccess struct {
// The vault's ID
VaultID string `json:"vaultId"`
// The group's ID
GroupID string `json:"groupId"`
// The group's set of permissions for the vault
Permissions uint32 `json:"permissions"`
}
type ItemCategory string
const (
ItemCategoryLogin ItemCategory = "Login"
ItemCategorySecureNote ItemCategory = "SecureNote"
ItemCategoryCreditCard ItemCategory = "CreditCard"
ItemCategoryCryptoWallet ItemCategory = "CryptoWallet"
ItemCategoryIdentity ItemCategory = "Identity"
ItemCategoryPassword ItemCategory = "Password"
ItemCategoryDocument ItemCategory = "Document"
ItemCategoryAPICredentials ItemCategory = "ApiCredentials"
ItemCategoryBankAccount ItemCategory = "BankAccount"
ItemCategoryDatabase ItemCategory = "Database"
ItemCategoryDriverLicense ItemCategory = "DriverLicense"
ItemCategoryEmail ItemCategory = "Email"
ItemCategoryMedicalRecord ItemCategory = "MedicalRecord"
ItemCategoryMembership ItemCategory = "Membership"
ItemCategoryOutdoorLicense ItemCategory = "OutdoorLicense"
ItemCategoryPassport ItemCategory = "Passport"
ItemCategoryRewards ItemCategory = "Rewards"
ItemCategoryRouter ItemCategory = "Router"
ItemCategoryServer ItemCategory = "Server"
ItemCategorySSHKey ItemCategory = "SshKey"
ItemCategorySocialSecurityNumber ItemCategory = "SocialSecurityNumber"
ItemCategorySoftwareLicense ItemCategory = "SoftwareLicense"
ItemCategoryPerson ItemCategory = "Person"
ItemCategoryUnsupported ItemCategory = "Unsupported"
)
type ItemFieldType string
const (
ItemFieldTypeText ItemFieldType = "Text"
ItemFieldTypeConcealed ItemFieldType = "Concealed"
ItemFieldTypeCreditCardType ItemFieldType = "CreditCardType"
ItemFieldTypeCreditCardNumber ItemFieldType = "CreditCardNumber"
ItemFieldTypePhone ItemFieldType = "Phone"
ItemFieldTypeURL ItemFieldType = "Url"
ItemFieldTypeTOTP ItemFieldType = "Totp"
ItemFieldTypeEmail ItemFieldType = "Email"
ItemFieldTypeReference ItemFieldType = "Reference"
ItemFieldTypeSSHKey ItemFieldType = "SshKey"
ItemFieldTypeMenu ItemFieldType = "Menu"
ItemFieldTypeMonthYear ItemFieldType = "MonthYear"
ItemFieldTypeAddress ItemFieldType = "Address"
ItemFieldTypeDate ItemFieldType = "Date"
ItemFieldTypeUnsupported ItemFieldType = "Unsupported"
)
// Field type-specific attributes.
type ItemFieldDetailsTypes string
const (
// The computed OTP code and other details
ItemFieldDetailsTypeVariantOTP ItemFieldDetailsTypes = "Otp"
// Computed SSH Key attributes
ItemFieldDetailsTypeVariantSSHKey ItemFieldDetailsTypes = "SshKey"
// Address components
ItemFieldDetailsTypeVariantAddress ItemFieldDetailsTypes = "Address"
)
type ItemFieldDetails struct {
Type ItemFieldDetailsTypes `json:"type"`
content interface{}
}
func (i *ItemFieldDetails) UnmarshalJSON(data []byte) error {
var enum struct {
Tag ItemFieldDetailsTypes `json:"type"`
Content json.RawMessage `json:"content"`
}
if err := json.Unmarshal(data, &enum); err != nil {
return err
}
i.Type = enum.Tag
switch i.Type {
case ItemFieldDetailsTypeVariantOTP:
var res OTPFieldDetails
i.content = &res
case ItemFieldDetailsTypeVariantSSHKey:
var res *SSHKeyAttributes
i.content = &res
case ItemFieldDetailsTypeVariantAddress:
var res *AddressFieldDetails
i.content = &res
}
if err := json.Unmarshal(enum.Content, &i.content); err != nil {
return err
}
return nil
}
func (i ItemFieldDetails) MarshalJSON() ([]byte, error) {
var enum struct {
Tag ItemFieldDetailsTypes `json:"type"`
Content interface{} `json:"content,omitempty"`
}
enum.Tag = i.Type
enum.Content = i.content
return json.Marshal(enum)
}
func (i ItemFieldDetails) OTP() *OTPFieldDetails {
res, _ := i.content.(*OTPFieldDetails)
return res
}
func (i ItemFieldDetails) SSHKey() *SSHKeyAttributes {
res, _ := i.content.(**SSHKeyAttributes)
return *res
}
func (i ItemFieldDetails) Address() *AddressFieldDetails {
res, _ := i.content.(**AddressFieldDetails)
return *res
}
func NewItemFieldDetailsTypeVariantOTP(content *OTPFieldDetails) ItemFieldDetails {
return ItemFieldDetails{
Type: ItemFieldDetailsTypeVariantOTP,
content: content,
}
}
func NewItemFieldDetailsTypeVariantSSHKey(content *SSHKeyAttributes) ItemFieldDetails {
return ItemFieldDetails{
Type: ItemFieldDetailsTypeVariantSSHKey,
content: &content,
}
}
func NewItemFieldDetailsTypeVariantAddress(content *AddressFieldDetails) ItemFieldDetails {
return ItemFieldDetails{
Type: ItemFieldDetailsTypeVariantAddress,
content: &content,
}
}
// Represents a field within an item.
type ItemField struct {
// The field's ID
ID string `json:"id"`
// The field's title
Title string `json:"title"`
// The ID of the section containing the field. Built-in fields such as usernames and passwords don't require a section.
SectionID *string `json:"sectionId,omitempty"`
// The field's type
FieldType ItemFieldType `json:"fieldType"`
// The string representation of the field's value
Value string `json:"value"`
// Field type-specific attributes.
Details *ItemFieldDetails `json:"details,omitempty"`
}
// A section groups together multiple fields in an item.
type ItemSection struct {
// The section's unique ID
ID string `json:"id"`
// The section's title
Title string `json:"title"`
}
// Controls the auto-fill behavior of a website.
//
// For more information, visit <https://support.1password.com/autofill-behavior/>
type AutofillBehavior string
const (
// Auto-fill any page that’s part of the website, including subdomains
AutofillBehaviorAnywhereOnWebsite AutofillBehavior = "AnywhereOnWebsite"
// Auto-fill only if the domain (hostname and port) is an exact match.
AutofillBehaviorExactDomain AutofillBehavior = "ExactDomain"
// Never auto-fill on this website
AutofillBehaviorNever AutofillBehavior = "Never"
)
type Website struct {
// The website URL
URL string `json:"url"`
// The label of the website, e.g. 'website', 'sign-in address'
Label string `json:"label"`
// The auto-fill behavior of the website
//
// For more information, visit <https://support.1password.com/autofill-behavior/>
AutofillBehavior AutofillBehavior `json:"autofillBehavior"`
}
type ItemFile struct {
// the attributes of the file
Attributes FileAttributes `json:"attributes"`
// the section id where the file should be stored
SectionID string `json:"sectionId"`
// the field id where the file should be stored
FieldID string `json:"fieldId"`
}
// Represents an active 1Password item.
type Item struct {
// The item's ID
ID string `json:"id"`
// The item's title
Title string `json:"title"`
// The item's category
Category ItemCategory `json:"category"`
// The ID of the vault where the item is saved
VaultID string `json:"vaultId"`
// The item's fields
Fields []ItemField `json:"fields"`
// The item's sections
Sections []ItemSection `json:"sections"`
// The notes of the item
Notes string `json:"notes"`
// The item's tags
Tags []string `json:"tags"`
// The websites used for autofilling for items of the Login and Password categories.
Websites []Website `json:"websites"`
// The item's version
Version uint32 `json:"version"`
// The item's file fields
Files []ItemFile `json:"files"`
// The document file for the Document item category
Document *FileAttributes `json:"document,omitempty"`
// The time the item was created at
CreatedAt time.Time `json:"createdAt"`
// The time the item was updated at
UpdatedAt time.Time `json:"updatedAt"`
}
type ItemCreateParams struct {
// The item's category
Category ItemCategory `json:"category"`
// The ID of the vault where the item is saved
VaultID string `json:"vaultId"`
// The item's title
Title string `json:"title"`
// The item's fields
Fields []ItemField `json:"fields,omitempty"`
// The item's sections
Sections []ItemSection `json:"sections,omitempty"`
// The item's notes
Notes *string `json:"notes,omitempty"`
// The item's tags
Tags []string `json:"tags,omitempty"`
// The websites used for autofilling for items of the Login and Password categories.
Websites []Website `json:"websites,omitempty"`
// The item's files stored as fields
Files []FileCreateParams `json:"files,omitempty"`
// The document file for the Document item type. Empty when the item isn't of Document type.
Document *DocumentCreateParams `json:"document,omitempty"`
}
// Represents the state of an item in the SDK.
type ItemState string
const (
// The item is active
ItemStateActive ItemState = "active"
// The item is archived meaning it's hidden from regular view and stored in the archive.
ItemStateArchived ItemState = "archived"
)
// Represents a decrypted 1Password item overview.
type ItemOverview struct {
// The item's ID
ID string `json:"id"`
// The item's title
Title string `json:"title"`
// The item's category
Category ItemCategory `json:"category"`
// The ID of the vault where the item is saved
VaultID string `json:"vaultId"`
// The websites used for autofilling for items of the Login and Password categories.
Websites []Website `json:"websites"`
// The item tags
Tags []string `json:"tags"`
// The time the item was created at
CreatedAt time.Time `json:"createdAt"`
// The time the item was updated at
UpdatedAt time.Time `json:"updatedAt"`
// Indicates the state of the item
State ItemState `json:"state"`
}
// The valid duration options for sharing an item
type ItemShareDuration string
const (
// The share will expire in one hour
ItemShareDurationOneHour ItemShareDuration = "OneHour"
// The share will expire in one day
ItemShareDurationOneDay ItemShareDuration = "OneDay"
// The share will expire in seven days
ItemShareDurationSevenDays ItemShareDuration = "SevenDays"
// The share will expire in fourteen days
ItemShareDurationFourteenDays ItemShareDuration = "FourteenDays"
// The share will expire in thirty days
ItemShareDurationThirtyDays ItemShareDuration = "ThirtyDays"
)
// The allowed types of item sharing, enforced by account policy
type AllowedType string
const (
// Allows creating share links with specific recipients
AllowedTypeAuthenticated AllowedType = "Authenticated"
// Allows creating public share links
AllowedTypePublic AllowedType = "Public"
)
// The allowed recipient types of item sharing, enforced by account policy
type AllowedRecipientType string
const (
// Recipients can be specified by email address
AllowedRecipientTypeEmail AllowedRecipientType = "Email"
// Recipients can be specified by domain
AllowedRecipientTypeDomain AllowedRecipientType = "Domain"
)
// The file sharing policy
type ItemShareFiles struct {
// Whether files can be included in item shares
Allowed bool `json:"allowed"`
// The maximum encrypted size (in bytes) an included file can be
MaxSize uint32 `json:"maxSize"`
// The allowed types of item sharing - either "Authenticated" (share to specific users) or "Public" (share to anyone with a link)
AllowedTypes []AllowedType `json:"allowedTypes,omitempty"`
// The allowed recipient types of item sharing - either "Email" or "Domain"
AllowedRecipientTypes []AllowedRecipientType `json:"allowedRecipientTypes,omitempty"`
// The maximum duration that an item can be shared for
MaxExpiry *ItemShareDuration `json:"maxExpiry,omitempty"`
// The default duration that an item is shared for
DefaultExpiry *ItemShareDuration `json:"defaultExpiry,omitempty"`
// The maximum number of times an item can be viewed. A null value means unlimited views
MaxViews *uint32 `json:"maxViews,omitempty"`
}
// The account policy for sharing items, set by your account owner/admin
// This policy is enforced server-side when sharing items
type ItemShareAccountPolicy struct {
// The maximum duration that an item can be shared for
MaxExpiry ItemShareDuration `json:"maxExpiry"`
// The default duration that an item is shared for
DefaultExpiry ItemShareDuration `json:"defaultExpiry"`
// The maximum number of times an item can be viewed. A null value means unlimited views
MaxViews *uint32 `json:"maxViews,omitempty"`
// The allowed types of item sharing - either "Authenticated" (share to specific users) or "Public" (share to anyone with a link)
AllowedTypes []AllowedType `json:"allowedTypes"`
// The allowed recipient types of item sharing - either "Email" or "Domain"
AllowedRecipientTypes []AllowedRecipientType `json:"allowedRecipientTypes"`
// The file sharing policy
Files ItemShareFiles `json:"files"`
}
// Generated type representing the anonymous struct variant `Email` of the `ValidRecipient` Rust enum
type ValidRecipientEmailInner struct {
Email string `json:"email"`
}
// Generated type representing the anonymous struct variant `Domain` of the `ValidRecipient` Rust enum
type ValidRecipientDomainInner struct {
Domain string `json:"domain"`
}
// The validated recipient of an item share
type ValidRecipientTypes string
const (
// This exact email address
ValidRecipientTypeVariantEmail ValidRecipientTypes = "Email"
// Anyone with an email address from the specified domain
ValidRecipientTypeVariantDomain ValidRecipientTypes = "Domain"
)
type ValidRecipient struct {
Type ValidRecipientTypes `json:"type"`
parameters interface{}
}
func (v *ValidRecipient) UnmarshalJSON(data []byte) error {
var enum struct {
Tag ValidRecipientTypes `json:"type"`
Content json.RawMessage `json:"parameters"`
}
if err := json.Unmarshal(data, &enum); err != nil {
return err
}
v.Type = enum.Tag
switch v.Type {
case ValidRecipientTypeVariantEmail:
var res ValidRecipientEmailInner
v.parameters = &res
case ValidRecipientTypeVariantDomain:
var res ValidRecipientDomainInner
v.parameters = &res
}
if err := json.Unmarshal(enum.Content, &v.parameters); err != nil {
return err
}
return nil
}
func (v ValidRecipient) MarshalJSON() ([]byte, error) {
var enum struct {
Tag ValidRecipientTypes `json:"type"`
Content interface{} `json:"parameters,omitempty"`
}
enum.Tag = v.Type
enum.Content = v.parameters
return json.Marshal(enum)
}
func (v ValidRecipient) Email() *ValidRecipientEmailInner {
res, _ := v.parameters.(*ValidRecipientEmailInner)
return res
}
func (v ValidRecipient) Domain() *ValidRecipientDomainInner {
res, _ := v.parameters.(*ValidRecipientDomainInner)
return res
}
func NewValidRecipientTypeVariantEmail(content *ValidRecipientEmailInner) ValidRecipient {
return ValidRecipient{
Type: ValidRecipientTypeVariantEmail,
parameters: content,
}
}
func NewValidRecipientTypeVariantDomain(content *ValidRecipientDomainInner) ValidRecipient {
return ValidRecipient{
Type: ValidRecipientTypeVariantDomain,
parameters: content,
}
}
// The configuration options for sharing an item
// These must respect the account policy on item sharing
type ItemShareParams struct {
// Emails or domains of the item share recipients. If not provided, everyone with the share link will have access
Recipients []ValidRecipient `json:"recipients,omitempty"`
// The duration of the share in seconds. If not provided, defaults to the account policy's default expiry
ExpireAfter *ItemShareDuration `json:"expireAfter,omitempty"`
// Whether the item can only be viewed once per recipient
OneTimeOnly bool `json:"oneTimeOnly"`
}
type Response[T any, E any] struct {
Content *T `json:"content,omitempty"`
Error *E `json:"error,omitempty"`
}
type ItemUpdateFailureReasonTypes string
const (
// Item update operation failed due to bad user input.
ItemUpdateFailureReasonTypeVariantItemValidationError ItemUpdateFailureReasonTypes = "itemValidationError"
// Item update operation is forbidden, permission issue. Make sure you have the correct permissions to update items in this vault.
ItemUpdateFailureReasonTypeVariantItemStatusPermissionError ItemUpdateFailureReasonTypes = "itemStatusPermissionError"
// Item update operation failed due to incorrect version.
ItemUpdateFailureReasonTypeVariantItemStatusIncorrectItemVersion ItemUpdateFailureReasonTypes = "itemStatusIncorrectItemVersion"
// Item update operation failed because a file reference didn't match a known file.
ItemUpdateFailureReasonTypeVariantItemStatusFileNotFound ItemUpdateFailureReasonTypes = "itemStatusFileNotFound"
// Item update request is too big to be sent to the server.
ItemUpdateFailureReasonTypeVariantItemStatusTooBig ItemUpdateFailureReasonTypes = "itemStatusTooBig"
// The item was not found
ItemUpdateFailureReasonTypeVariantItemNotFound ItemUpdateFailureReasonTypes = "itemNotFound"
// Item update operation experienced an internal error.
ItemUpdateFailureReasonTypeVariantInternal ItemUpdateFailureReasonTypes = "internal"
)
type ItemUpdateFailureReason struct {
Type ItemUpdateFailureReasonTypes `json:"type"`
message interface{}
}
func (i *ItemUpdateFailureReason) UnmarshalJSON(data []byte) error {
var enum struct {
Tag ItemUpdateFailureReasonTypes `json:"type"`
Content json.RawMessage `json:"message"`
}
if err := json.Unmarshal(data, &enum); err != nil {
return err
}
i.Type = enum.Tag
switch i.Type {
case ItemUpdateFailureReasonTypeVariantItemValidationError:
var res ErrorMessage
i.message = &res
case ItemUpdateFailureReasonTypeVariantItemStatusPermissionError:
return nil
case ItemUpdateFailureReasonTypeVariantItemStatusIncorrectItemVersion:
return nil
case ItemUpdateFailureReasonTypeVariantItemStatusFileNotFound:
return nil
case ItemUpdateFailureReasonTypeVariantItemStatusTooBig:
return nil
case ItemUpdateFailureReasonTypeVariantItemNotFound:
return nil
case ItemUpdateFailureReasonTypeVariantInternal:
var res ErrorMessage
i.message = &res
}
if err := json.Unmarshal(enum.Content, &i.message); err != nil {
return err
}
return nil
}
func (i ItemUpdateFailureReason) MarshalJSON() ([]byte, error) {
var enum struct {
Tag ItemUpdateFailureReasonTypes `json:"type"`
Content interface{} `json:"message,omitempty"`
}
enum.Tag = i.Type
enum.Content = i.message
return json.Marshal(enum)
}
func (i ItemUpdateFailureReason) ItemValidationError() ErrorMessage {
res, _ := i.message.(*ErrorMessage)
return *res
}
func (i ItemUpdateFailureReason) Internal() ErrorMessage {
res, _ := i.message.(*ErrorMessage)
return *res
}
func NewItemUpdateFailureReasonTypeVariantItemValidationError(content ErrorMessage) ItemUpdateFailureReason {
return ItemUpdateFailureReason{
Type: ItemUpdateFailureReasonTypeVariantItemValidationError,
message: &content,
}
}
func NewItemUpdateFailureReasonTypeVariantItemStatusPermissionError() ItemUpdateFailureReason {
return ItemUpdateFailureReason{
Type: ItemUpdateFailureReasonTypeVariantItemStatusPermissionError,
}
}
func NewItemUpdateFailureReasonTypeVariantItemStatusIncorrectItemVersion() ItemUpdateFailureReason {
return ItemUpdateFailureReason{
Type: ItemUpdateFailureReasonTypeVariantItemStatusIncorrectItemVersion,
}
}
func NewItemUpdateFailureReasonTypeVariantItemStatusFileNotFound() ItemUpdateFailureReason {
return ItemUpdateFailureReason{
Type: ItemUpdateFailureReasonTypeVariantItemStatusFileNotFound,
}
}
func NewItemUpdateFailureReasonTypeVariantItemStatusTooBig() ItemUpdateFailureReason {
return ItemUpdateFailureReason{
Type: ItemUpdateFailureReasonTypeVariantItemStatusTooBig,
}
}
func NewItemUpdateFailureReasonTypeVariantItemNotFound() ItemUpdateFailureReason {
return ItemUpdateFailureReason{
Type: ItemUpdateFailureReasonTypeVariantItemNotFound,
}
}
func NewItemUpdateFailureReasonTypeVariantInternal(content ErrorMessage) ItemUpdateFailureReason {
return ItemUpdateFailureReason{
Type: ItemUpdateFailureReasonTypeVariantInternal,
message: &content,
}
}
type ItemsDeleteAllResponse struct {
IndividualResponses map[string]Response[struct{}, ItemUpdateFailureReason] `json:"individualResponses"`
}
type ItemsGetAllErrorTypes string
const (
ItemsGetAllErrorTypeVariantItemNotFound ItemsGetAllErrorTypes = "itemNotFound"
ItemsGetAllErrorTypeVariantInternal ItemsGetAllErrorTypes = "internal"
)
type ItemsGetAllError struct {
Type ItemsGetAllErrorTypes `json:"type"`
message interface{}
}
func (i *ItemsGetAllError) UnmarshalJSON(data []byte) error {
var enum struct {
Tag ItemsGetAllErrorTypes `json:"type"`
Content json.RawMessage `json:"message"`
}
if err := json.Unmarshal(data, &enum); err != nil {
return err
}
i.Type = enum.Tag
switch i.Type {
case ItemsGetAllErrorTypeVariantItemNotFound:
return nil
case ItemsGetAllErrorTypeVariantInternal:
var res ErrorMessage
i.message = &res
}
if err := json.Unmarshal(enum.Content, &i.message); err != nil {
return err
}
return nil
}
func (i ItemsGetAllError) MarshalJSON() ([]byte, error) {
var enum struct {
Tag ItemsGetAllErrorTypes `json:"type"`
Content interface{} `json:"message,omitempty"`
}
enum.Tag = i.Type
enum.Content = i.message
return json.Marshal(enum)
}
func (i ItemsGetAllError) Internal() ErrorMessage {
res, _ := i.message.(*ErrorMessage)
return *res
}
func NewItemsGetAllErrorTypeVariantItemNotFound() ItemsGetAllError {
return ItemsGetAllError{
Type: ItemsGetAllErrorTypeVariantItemNotFound,
}
}
func NewItemsGetAllErrorTypeVariantInternal(content ErrorMessage) ItemsGetAllError {
return ItemsGetAllError{
Type: ItemsGetAllErrorTypeVariantInternal,
message: &content,
}
}
type ItemsGetAllResponse struct {
IndividualResponses []Response[Item, ItemsGetAllError] `json:"individualResponses"`
}
type ItemsUpdateAllResponse struct {
IndividualResponses []Response[Item, ItemUpdateFailureReason] `json:"individualResponses"`
}
// Additional attributes for OTP fields.
type OTPFieldDetails struct {
// The OTP code, if successfully computed
Code *string `json:"code,omitempty"`
// The error message, if the OTP code could not be computed
ErrorMessage *string `json:"errorMessage,omitempty"`
}
type ResolvedReference struct {
Secret string `json:"secret"`
ItemID string `json:"itemId"`
VaultID string `json:"vaultId"`
}
type ResolveReferenceErrorTypes string
const (
// Error parsing the secret reference
ResolveReferenceErrorTypeVariantParsing ResolveReferenceErrorTypes = "parsing"
// The specified reference cannot be found within the item
ResolveReferenceErrorTypeVariantFieldNotFound ResolveReferenceErrorTypes = "fieldNotFound"
// No vault matched the secret reference query
ResolveReferenceErrorTypeVariantVaultNotFound ResolveReferenceErrorTypes = "vaultNotFound"
// More than one vault matched the secret reference query
ResolveReferenceErrorTypeVariantTooManyVaults ResolveReferenceErrorTypes = "tooManyVaults"
// No item matched the secret reference query
ResolveReferenceErrorTypeVariantItemNotFound ResolveReferenceErrorTypes = "itemNotFound"
// More than one item matched the secret reference query
ResolveReferenceErrorTypeVariantTooManyItems ResolveReferenceErrorTypes = "tooManyItems"
// More than one field matched the provided secret reference
ResolveReferenceErrorTypeVariantTooManyMatchingFields ResolveReferenceErrorTypes = "tooManyMatchingFields"
// No section found within the item for the provided identifier
ResolveReferenceErrorTypeVariantNoMatchingSections ResolveReferenceErrorTypes = "noMatchingSections"
// Incompatiable TOTP query parameters
ResolveReferenceErrorTypeVariantIncompatibleTOTPQueryParameterField ResolveReferenceErrorTypes = "incompatibleTOTPQueryParameterField"
// The totp was not able to be generated
ResolveReferenceErrorTypeVariantUnableToGenerateTOTPCode ResolveReferenceErrorTypes = "unableToGenerateTotpCode"
// Couldn't find attributes specific to an SSH Key field
ResolveReferenceErrorTypeVariantSSHKeyMetadataNotFound ResolveReferenceErrorTypes = "sSHKeyMetadataNotFound"
// Currently only support text files
ResolveReferenceErrorTypeVariantUnsupportedFileFormat ResolveReferenceErrorTypes = "unsupportedFileFormat"
// Trying to convert a non-private key to a private key format
ResolveReferenceErrorTypeVariantIncompatibleSSHKeyQueryParameterField ResolveReferenceErrorTypes = "incompatibleSshKeyQueryParameterField"
// Unable to properly parse a private key string to convert to an internal Private Key type
ResolveReferenceErrorTypeVariantUnableToParsePrivateKey ResolveReferenceErrorTypes = "unableToParsePrivateKey"
// Unable to format a private key to OpenSSH format
ResolveReferenceErrorTypeVariantUnableToFormatPrivateKeyToOpenSSH ResolveReferenceErrorTypes = "unableToFormatPrivateKeyToOpenSsh"
// Other type
ResolveReferenceErrorTypeVariantOther ResolveReferenceErrorTypes = "other"
)
type ResolveReferenceError struct {
Type ResolveReferenceErrorTypes `json:"type"`
message interface{}
}
func (r *ResolveReferenceError) UnmarshalJSON(data []byte) error {
var enum struct {
Tag ResolveReferenceErrorTypes `json:"type"`
Content json.RawMessage `json:"message"`
}
if err := json.Unmarshal(data, &enum); err != nil {
return err
}
r.Type = enum.Tag
switch r.Type {
case ResolveReferenceErrorTypeVariantParsing:
var res ErrorMessage
r.message = &res
case ResolveReferenceErrorTypeVariantFieldNotFound:
return nil
case ResolveReferenceErrorTypeVariantVaultNotFound:
return nil
case ResolveReferenceErrorTypeVariantTooManyVaults:
return nil
case ResolveReferenceErrorTypeVariantItemNotFound:
return nil
case ResolveReferenceErrorTypeVariantTooManyItems:
return nil
case ResolveReferenceErrorTypeVariantTooManyMatchingFields:
return nil
case ResolveReferenceErrorTypeVariantNoMatchingSections:
return nil
case ResolveReferenceErrorTypeVariantIncompatibleTOTPQueryParameterField:
return nil
case ResolveReferenceErrorTypeVariantUnableToGenerateTOTPCode:
var res ErrorMessage
r.message = &res
case ResolveReferenceErrorTypeVariantSSHKeyMetadataNotFound:
return nil
case ResolveReferenceErrorTypeVariantUnsupportedFileFormat:
return nil
case ResolveReferenceErrorTypeVariantIncompatibleSSHKeyQueryParameterField:
return nil
case ResolveReferenceErrorTypeVariantUnableToParsePrivateKey:
return nil
case ResolveReferenceErrorTypeVariantUnableToFormatPrivateKeyToOpenSSH:
return nil
case ResolveReferenceErrorTypeVariantOther:
return nil
}
if err := json.Unmarshal(enum.Content, &r.message); err != nil {
return err
}
return nil
}
func (r ResolveReferenceError) MarshalJSON() ([]byte, error) {
var enum struct {
Tag ResolveReferenceErrorTypes `json:"type"`
Content interface{} `json:"message,omitempty"`
}
enum.Tag = r.Type
enum.Content = r.message
return json.Marshal(enum)
}
func (r ResolveReferenceError) Parsing() ErrorMessage {
res, _ := r.message.(*ErrorMessage)
return *res
}
func (r ResolveReferenceError) UnableToGenerateTOTPCode() ErrorMessage {
res, _ := r.message.(*ErrorMessage)
return *res
}
func NewResolveReferenceErrorTypeVariantParsing(content ErrorMessage) ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantParsing,
message: &content,
}
}
func NewResolveReferenceErrorTypeVariantFieldNotFound() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantFieldNotFound,
}
}
func NewResolveReferenceErrorTypeVariantVaultNotFound() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantVaultNotFound,
}
}
func NewResolveReferenceErrorTypeVariantTooManyVaults() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantTooManyVaults,
}
}
func NewResolveReferenceErrorTypeVariantItemNotFound() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantItemNotFound,
}
}
func NewResolveReferenceErrorTypeVariantTooManyItems() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantTooManyItems,
}
}
func NewResolveReferenceErrorTypeVariantTooManyMatchingFields() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantTooManyMatchingFields,
}
}
func NewResolveReferenceErrorTypeVariantNoMatchingSections() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantNoMatchingSections,
}
}
func NewResolveReferenceErrorTypeVariantIncompatibleTOTPQueryParameterField() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantIncompatibleTOTPQueryParameterField,
}
}
func NewResolveReferenceErrorTypeVariantUnableToGenerateTOTPCode(content ErrorMessage) ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantUnableToGenerateTOTPCode,
message: &content,
}
}
func NewResolveReferenceErrorTypeVariantSSHKeyMetadataNotFound() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantSSHKeyMetadataNotFound,
}
}
func NewResolveReferenceErrorTypeVariantUnsupportedFileFormat() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantUnsupportedFileFormat,
}
}
func NewResolveReferenceErrorTypeVariantIncompatibleSSHKeyQueryParameterField() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantIncompatibleSSHKeyQueryParameterField,
}
}
func NewResolveReferenceErrorTypeVariantUnableToParsePrivateKey() ResolveReferenceError {
return ResolveReferenceError{
Type: ResolveReferenceErrorTypeVariantUnableToParsePrivateKey,
}