@@ -33,88 +33,85 @@ async def main():
3333 # [developer-docs.sdk.python.list-items]-end
3434
3535 # [developer-docs.sdk.python.get-vault-overview]-start
36- # Get vault overview
36+ # Get vault overview
3737 vaultOverview = await client .vaults .get_overview (vault_id )
3838 print (vaultOverview )
3939 # [developer-docs.sdk.python.get-vault-overview]-end
4040
4141 # [developer-docs.sdk.python.get-vault-details]-start
42- # Get vault details
42+ # Get vault details
4343 vault = await client .vaults .get (vaultOverview .id , VaultGetParams (accessors = False ))
4444 print (vault )
4545 # [developer-docs.sdk.python.get-vault-details]-end
4646
47- # [developer-docs.sdk.python.batch-create-items]-start
47+ # [developer-docs.sdk.python.batch-create-items]-start
4848 items_to_create = []
4949 for i in range (1 , 4 ):
50- items_to_create .append (ItemCreateParams (
51- title = "My Login Item {}" .format (i ),
52- category = ItemCategory .LOGIN ,
53- vault_id = vault .id ,
54- fields = [
55- ItemField (
56- id = "username" ,
57- title = "username" ,
58- field_type = ItemFieldType .TEXT ,
59- value = "mynameisjeff" ,
60- ),
61- ItemField (
62- id = "password" ,
63- title = "password" ,
64- field_type = ItemFieldType .CONCEALED ,
65- value = "jeff" ,
66- ),
67- ItemField (
68- id = "onetimepassword" ,
69- title = "one-time-password" ,
70- field_type = ItemFieldType .TOTP ,
71- section_id = "totpsection" ,
72- value = "otpauth://totp/my-example-otp?secret=jncrjgbdjnrncbjsr&issuer=1Password" ,
73- ),
74- ],
75- sections = [
76- ItemSection (
77- id = "" , title = "" ),
78- ItemSection (
79- id = "totpsection" , title = "" ),
80- ],
81- tags = [
82- "test tag 1" , "test tag 2" ],
83- websites = [
84- Website (
85- label = "my custom website" ,
86- url = "https://example.com" ,
87- autofill_behavior = AutofillBehavior .NEVER ,
88- )
89- ],
90- ))
91-
92- # Create all items in the same vault in a single batch
50+ items_to_create .append (
51+ ItemCreateParams (
52+ title = "My Login Item {}" .format (i ),
53+ category = ItemCategory .LOGIN ,
54+ vault_id = vault .id ,
55+ fields = [
56+ ItemField (
57+ id = "username" ,
58+ title = "username" ,
59+ field_type = ItemFieldType .TEXT ,
60+ value = "mynameisjeff" ,
61+ ),
62+ ItemField (
63+ id = "password" ,
64+ title = "password" ,
65+ field_type = ItemFieldType .CONCEALED ,
66+ value = "jeff" ,
67+ ),
68+ ItemField (
69+ id = "onetimepassword" ,
70+ title = "one-time-password" ,
71+ field_type = ItemFieldType .TOTP ,
72+ section_id = "totpsection" ,
73+ value = "otpauth://totp/my-example-otp?secret=jncrjgbdjnrncbjsr&issuer=1Password" ,
74+ ),
75+ ],
76+ sections = [
77+ ItemSection (id = "" , title = "" ),
78+ ItemSection (id = "totpsection" , title = "" ),
79+ ],
80+ tags = ["test tag 1" , "test tag 2" ],
81+ websites = [
82+ Website (
83+ label = "my custom website" ,
84+ url = "https://example.com" ,
85+ autofill_behavior = AutofillBehavior .NEVER ,
86+ )
87+ ],
88+ )
89+ )
90+
91+ # Create all items in the same vault in a single batch
9392 batchCreateResponse = await client .items .create_all (vault .id , items_to_create )
9493
9594 item_ids = []
9695 for res in batchCreateResponse .individual_responses :
9796 if res .content is not None :
98- print ('Created item "{}" ({})' .format (
99- res .content .title , res .content .id ))
97+ print ('Created item "{}" ({})' .format (res .content .title , res .content .id ))
10098 item_ids .append (res .content .id )
10199 elif res .error is not None :
102100 print ("[Batch create] Something went wrong: {}" .format (res .error ))
103101 # [developer-docs.sdk.python.batch-create-items]-end
104102
105103 # [developer-docs.sdk.python.batch-get-items]-start
106- # Get multiple items form the same vault in a single batch
104+ # Get multiple items form the same vault in a single batch
107105 batchGetReponse = await client .items .get_all (vault .id , item_ids )
108106 for res in batchGetReponse .individual_responses :
109107 if res .content is not None :
110- print ('Obtained item "{}" ({})' .format (
111- res .content .title , res .content .id ))
108+ print ('Obtained item "{}" ({})' .format (res .content .title , res .content .id ))
112109 elif res .error is not None :
113110 print ("[Batch get] Something went wrong: {}" .format (res .error ))
114111 # [developer-docs.sdk.python.batch-get-items]-end
115112
116113 # [developer-docs.sdk.python.batch-delete-items]-start
117- # Delete multiple items from the same vault in a single batch
114+ # Delete multiple items from the same vault in a single batch
118115 batchDeleteResponse = await client .items .delete_all (vault .id , item_ids )
119116 for id , res in batchDeleteResponse .individual_responses .items ():
120117 if res .error is not None :
0 commit comments