Skip to content

Commit e354f21

Browse files
Update core to version c976aaee
1 parent 5aedbae commit e354f21

File tree

12 files changed

+376
-37
lines changed

12 files changed

+376
-37
lines changed

src/onepassword/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
for name, obj in inspect.getmembers(sys.modules["onepassword.types"]):
2525
# Add all classes and instances of typing.Literal defined in types.py.
2626
if (
27-
inspect.isclass(obj)
28-
and inspect.getmodule(obj) == sys.modules["onepassword.types"]
29-
) or type(eval(name)) == typing._LiteralGenericAlias:
27+
(
28+
inspect.isclass(obj)
29+
and inspect.getmodule(obj) == sys.modules["onepassword.types"]
30+
)
31+
or isinstance(obj, int)
32+
or type(obj) == typing._LiteralGenericAlias
33+
):
3034
__all__.append(name)

src/onepassword/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Code generated by op-codegen - DO NO EDIT MANUALLY
22

3+
from __future__ import annotations
34
import weakref
45
from .core import _init_client, _release_client
56
from .defaults import new_default_config
@@ -14,7 +15,9 @@ class Client:
1415
vaults: Vaults
1516

1617
@classmethod
17-
async def authenticate(cls, auth, integration_name, integration_version):
18+
async def authenticate(
19+
cls, auth: str, integration_name: str, integration_version: str
20+
) -> Client:
1821
config = new_default_config(
1922
auth=auth or "",
2023
integration_name=integration_name,

src/onepassword/items.py

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Code generated by op-codegen - DO NO EDIT MANUALLY
22

33
from .core import _invoke, _invoke_sync
4-
from json import loads
54
from .iterator import SDKIterator
6-
from .types import Item, ItemOverview
5+
from typing import Optional
6+
from pydantic import TypeAdapter
7+
from .items_shares import ItemsShares
8+
from .types import Item, ItemCreateParams, ItemOverview
79

810

911
class Items:
@@ -13,10 +15,11 @@ class Items:
1315

1416
def __init__(self, client_id):
1517
self.client_id = client_id
18+
self.shares = ItemsShares(client_id)
1619

17-
async def create(self, params):
20+
async def create(self, params: ItemCreateParams) -> Item:
1821
"""
19-
Create a new item
22+
Create a new item.
2023
"""
2124
response = await _invoke(
2225
{
@@ -29,9 +32,11 @@ async def create(self, params):
2932
}
3033
}
3134
)
32-
return Item.model_validate_json(response)
3335

34-
async def get(self, vault_id, item_id):
36+
response = TypeAdapter(Item).validate_json(response)
37+
return response
38+
39+
async def get(self, vault_id: str, item_id: str) -> Item:
3540
"""
3641
Get an item by vault and item ID
3742
"""
@@ -46,9 +51,11 @@ async def get(self, vault_id, item_id):
4651
}
4752
}
4853
)
49-
return Item.model_validate_json(response)
5054

51-
async def put(self, item):
55+
response = TypeAdapter(Item).validate_json(response)
56+
return response
57+
58+
async def put(self, item: Item) -> Item:
5259
"""
5360
Update an existing item.
5461
"""
@@ -63,13 +70,15 @@ async def put(self, item):
6370
}
6471
}
6572
)
66-
return Item.model_validate_json(response)
6773

68-
async def delete(self, vault_id, item_id):
74+
response = TypeAdapter(Item).validate_json(response)
75+
return response
76+
77+
async def delete(self, vault_id: str, item_id: str):
6978
"""
7079
Delete an item.
7180
"""
72-
await _invoke(
81+
response = await _invoke(
7382
{
7483
"invocation": {
7584
"clientId": self.client_id,
@@ -81,7 +90,27 @@ async def delete(self, vault_id, item_id):
8190
}
8291
)
8392

84-
async def list_all(self, vault_id):
93+
return None
94+
95+
async def archive(self, vault_id: str, item_id: str):
96+
"""
97+
Archive an item.
98+
"""
99+
response = await _invoke(
100+
{
101+
"invocation": {
102+
"clientId": self.client_id,
103+
"parameters": {
104+
"name": "ItemsArchive",
105+
"parameters": {"vault_id": vault_id, "item_id": item_id},
106+
},
107+
}
108+
}
109+
)
110+
111+
return None
112+
113+
async def list_all(self, vault_id: str) -> SDKIterator[ItemOverview]:
85114
"""
86115
List all items
87116
"""
@@ -97,8 +126,5 @@ async def list_all(self, vault_id):
97126
}
98127
)
99128

100-
response_data = loads(response)
101-
102-
objects = [ItemOverview.model_validate(data) for data in response_data]
103-
104-
return SDKIterator(objects)
129+
response = TypeAdapter(list[ItemOverview]).validate_json(response)
130+
return SDKIterator(response)

src/onepassword/items_shares.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Code generated by op-codegen - DO NO EDIT MANUALLY
2+
3+
from .core import _invoke, _invoke_sync
4+
from .iterator import SDKIterator
5+
from typing import Optional
6+
from pydantic import TypeAdapter
7+
from .types import Item, ItemShareAccountPolicy, ItemShareParams, ValidRecipient
8+
9+
10+
class ItemsShares:
11+
def __init__(self, client_id):
12+
self.client_id = client_id
13+
14+
async def get_account_policy(
15+
self, vault_id: str, item_id: str
16+
) -> ItemShareAccountPolicy:
17+
"""
18+
Get the item sharing policy of your account.
19+
"""
20+
response = await _invoke(
21+
{
22+
"invocation": {
23+
"clientId": self.client_id,
24+
"parameters": {
25+
"name": "ItemsSharesGetAccountPolicy",
26+
"parameters": {"vault_id": vault_id, "item_id": item_id},
27+
},
28+
}
29+
}
30+
)
31+
32+
response = TypeAdapter(ItemShareAccountPolicy).validate_json(response)
33+
return response
34+
35+
async def validate_recipients(
36+
self, policy: ItemShareAccountPolicy, recipients: list[str]
37+
) -> list[ValidRecipient]:
38+
"""
39+
Validate the recipients of an item sharing link.
40+
"""
41+
response = await _invoke(
42+
{
43+
"invocation": {
44+
"clientId": self.client_id,
45+
"parameters": {
46+
"name": "ItemsSharesValidateRecipients",
47+
"parameters": {
48+
"policy": policy.model_dump(by_alias=True),
49+
"recipients": recipients,
50+
},
51+
},
52+
}
53+
}
54+
)
55+
56+
response = TypeAdapter(list[ValidRecipient]).validate_json(response)
57+
return response
58+
59+
async def create(
60+
self, item: Item, policy: ItemShareAccountPolicy, params: ItemShareParams
61+
) -> str:
62+
"""
63+
Create a new item sharing link.
64+
"""
65+
response = await _invoke(
66+
{
67+
"invocation": {
68+
"clientId": self.client_id,
69+
"parameters": {
70+
"name": "ItemsSharesCreate",
71+
"parameters": {
72+
"item": item.model_dump(by_alias=True),
73+
"policy": policy.model_dump(by_alias=True),
74+
"params": params.model_dump(by_alias=True),
75+
},
76+
},
77+
}
78+
}
79+
)
80+
81+
response = TypeAdapter(str).validate_json(response)
82+
return response
535 KB
Binary file not shown.
601 KB
Binary file not shown.
600 KB
Binary file not shown.
634 KB
Binary file not shown.
635 KB
Binary file not shown.

src/onepassword/secrets.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Code generated by op-codegen - DO NO EDIT MANUALLY
22

33
from .core import _invoke, _invoke_sync
4-
from json import loads
54
from .iterator import SDKIterator
6-
from .types import GeneratePasswordResponse
5+
from typing import Optional
6+
from pydantic import TypeAdapter
7+
from .types import GeneratePasswordResponse, PasswordRecipe
78

89

910
class Secrets:
@@ -15,7 +16,7 @@ class Secrets:
1516
def __init__(self, client_id):
1617
self.client_id = client_id
1718

18-
async def resolve(self, secret_reference):
19+
async def resolve(self, secret_reference: str) -> str:
1920
"""
2021
Resolve returns the secret the provided secret reference points to.
2122
"""
@@ -30,14 +31,16 @@ async def resolve(self, secret_reference):
3031
}
3132
}
3233
)
33-
return str(loads(response))
34+
35+
response = TypeAdapter(str).validate_json(response)
36+
return response
3437

3538
@staticmethod
36-
def validate_secret_reference(secret_reference):
39+
def validate_secret_reference(secret_reference: str):
3740
"""
3841
Validate the secret reference to ensure there are no syntax errors.
3942
"""
40-
_invoke_sync(
43+
response = _invoke_sync(
4144
{
4245
"invocation": {
4346
"parameters": {
@@ -48,8 +51,10 @@ def validate_secret_reference(secret_reference):
4851
}
4952
)
5053

54+
return None
55+
5156
@staticmethod
52-
def generate_password(recipe):
57+
def generate_password(recipe: PasswordRecipe) -> GeneratePasswordResponse:
5358
response = _invoke_sync(
5459
{
5560
"invocation": {
@@ -60,4 +65,6 @@ def generate_password(recipe):
6065
}
6166
}
6267
)
63-
return GeneratePasswordResponse.model_validate_json(response)
68+
69+
response = TypeAdapter(GeneratePasswordResponse).validate_json(response)
70+
return response

0 commit comments

Comments
 (0)