File tree Expand file tree Collapse file tree 3 files changed +20
-21
lines changed
Expand file tree Collapse file tree 3 files changed +20
-21
lines changed Original file line number Diff line number Diff line change 22import os
33from onepassword import *
44
5-
65async def main ():
76 # Gets your service account token from the OP_SERVICE_ACCOUNT_TOKEN environment variable.
87 token = os .getenv ("OP_SERVICE_ACCOUNT_TOKEN" )
@@ -16,15 +15,15 @@ async def main():
1615 )
1716
1817 # Retrieves a secret from 1Password. Takes a secret reference as input and returns the secret to which it points.
19- value = await client .secrets .resolve ("op://vault/item/field" )
20- print (value )
18+ # value = await client.secrets.resolve("op://vault/item/field")
19+ # print(value)
2120
2221 # Create an Item and add it to your vault.
2322 to_create = Item (
2423 id = "" ,
2524 title = "MyName" ,
2625 category = "Login" ,
27- vault_id = "vault_id " ,
26+ vault_id = "q73bqltug6xoegr3wkk2zkenoq " ,
2827 fields = [
2928 ItemField (
3029 id = "username" ,
@@ -48,7 +47,7 @@ async def main():
4847 print (dict (created_item ))
4948
5049 # Retrieve an item from your vault.
51- item = await client .items .get (" vault_id" , created_item .id )
50+ item = await client .items .get (created_item . vault_id , created_item .id )
5251
5352 print (dict (item ))
5453
@@ -59,7 +58,7 @@ async def main():
5958 print (dict (updated_item ))
6059
6160 # Delete a item from your vault.
62- await client .items .delete (" vault_id" , updated_item .id )
61+ await client .items .delete (created_item . vault_id , updated_item .id )
6362
6463
6564if __name__ == "__main__" :
Original file line number Diff line number Diff line change 55from .secrets import Secrets
66from .items import Items
77
8+ import sys , inspect , typing
89
910__all__ = [
1011 "Client" ,
1415 "DEFAULT_INTEGRATION_VERSION" ,
1516]
1617
17- if hasattr (types , "__all__" ):
18- __all__ += types .__all__
18+ for name , obj in inspect .getmembers (sys .modules ["onepassword.types" ]):
19+ if inspect .isclass (obj ) or type (eval (name )) == typing ._LiteralGenericAlias :
20+ __all__ .append (name )
Original file line number Diff line number Diff line change 22Generated by typeshare 1.9.2
33"""
44
5- from __future__ import annotations
6-
75from pydantic import BaseModel
86from typing import List , Literal , Optional
97
108
11- class Item (BaseModel ):
12- id : str
13- title : str
14- category : ItemCategory
15- vault_id : str
16- fields : List [ItemField ]
17- sections : List [ItemSection ]
18-
19-
209ItemCategory = Literal [
2110 "Login" ,
2211 "SecureNote" ,
@@ -45,6 +34,9 @@ class Item(BaseModel):
4534]
4635
4736
37+ ItemFieldType = Literal ["Text" , "Concealed" , "Unsupported" ]
38+
39+
4840class ItemField (BaseModel ):
4941 id : str
5042 title : str
@@ -53,9 +45,15 @@ class ItemField(BaseModel):
5345 value : str
5446
5547
56- ItemFieldType = Literal ["Text" , "Concealed" , "Unsupported" ]
48+ class ItemSection (BaseModel ):
49+ id : str
50+ title : str
5751
5852
59- class ItemSection (BaseModel ):
53+ class Item (BaseModel ):
6054 id : str
6155 title : str
56+ category : ItemCategory
57+ vault_id : str
58+ fields : List [ItemField ]
59+ sections : List [ItemSection ]
You can’t perform that action at this time.
0 commit comments