Skip to content

Commit c96b15f

Browse files
Update core to version cde2cf9c
1 parent 5aedbae commit c96b15f

File tree

11 files changed

+243
-38
lines changed

11 files changed

+243
-38
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: 90 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
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 .types import (
8+
Item,
9+
ItemCreateParams,
10+
ItemOverview,
11+
ItemsGetAllResponse,
12+
ItemsUpdateAllResponse,
13+
)
714

815

916
class Items:
@@ -14,9 +21,9 @@ class Items:
1421
def __init__(self, client_id):
1522
self.client_id = client_id
1623

17-
async def create(self, params):
24+
async def create(self, params: ItemCreateParams) -> Item:
1825
"""
19-
Create a new item
26+
Create a new item.
2027
"""
2128
response = await _invoke(
2229
{
@@ -29,9 +36,35 @@ async def create(self, params):
2936
}
3037
}
3138
)
32-
return Item.model_validate_json(response)
3339

34-
async def get(self, vault_id, item_id):
40+
response = TypeAdapter(Item).validate_json(response)
41+
return response
42+
43+
async def create_all(
44+
self, vault_id: str, params: list[ItemCreateParams]
45+
) -> ItemsUpdateAllResponse:
46+
"""
47+
Create items in batch, within a single vault.
48+
"""
49+
response = await _invoke(
50+
{
51+
"invocation": {
52+
"clientId": self.client_id,
53+
"parameters": {
54+
"name": "ItemsCreateAll",
55+
"parameters": {
56+
"vault_id": vault_id,
57+
"params": [o.model_dump(by_alias=True) for o in params],
58+
},
59+
},
60+
}
61+
}
62+
)
63+
64+
response = TypeAdapter(ItemsUpdateAllResponse).validate_json(response)
65+
return response
66+
67+
async def get(self, vault_id: str, item_id: str) -> Item:
3568
"""
3669
Get an item by vault and item ID
3770
"""
@@ -46,9 +79,30 @@ async def get(self, vault_id, item_id):
4679
}
4780
}
4881
)
49-
return Item.model_validate_json(response)
5082

51-
async def put(self, item):
83+
response = TypeAdapter(Item).validate_json(response)
84+
return response
85+
86+
async def get_all(self, vault_id: str, item_ids: list[str]) -> ItemsGetAllResponse:
87+
"""
88+
Get items by vault and their item IDs.
89+
"""
90+
response = await _invoke(
91+
{
92+
"invocation": {
93+
"clientId": self.client_id,
94+
"parameters": {
95+
"name": "ItemsGetAll",
96+
"parameters": {"vault_id": vault_id, "item_ids": item_ids},
97+
},
98+
}
99+
}
100+
)
101+
102+
response = TypeAdapter(ItemsGetAllResponse).validate_json(response)
103+
return response
104+
105+
async def put(self, item: Item) -> Item:
52106
"""
53107
Update an existing item.
54108
"""
@@ -63,13 +117,15 @@ async def put(self, item):
63117
}
64118
}
65119
)
66-
return Item.model_validate_json(response)
67120

68-
async def delete(self, vault_id, item_id):
121+
response = TypeAdapter(Item).validate_json(response)
122+
return response
123+
124+
async def delete(self, vault_id: str, item_id: str):
69125
"""
70126
Delete an item.
71127
"""
72-
await _invoke(
128+
response = await _invoke(
73129
{
74130
"invocation": {
75131
"clientId": self.client_id,
@@ -81,7 +137,27 @@ async def delete(self, vault_id, item_id):
81137
}
82138
)
83139

84-
async def list_all(self, vault_id):
140+
return None
141+
142+
async def archive(self, vault_id: str, item_id: str):
143+
"""
144+
Archive an item.
145+
"""
146+
response = await _invoke(
147+
{
148+
"invocation": {
149+
"clientId": self.client_id,
150+
"parameters": {
151+
"name": "ItemsArchive",
152+
"parameters": {"vault_id": vault_id, "item_id": item_id},
153+
},
154+
}
155+
}
156+
)
157+
158+
return None
159+
160+
async def list_all(self, vault_id: str) -> SDKIterator[ItemOverview]:
85161
"""
86162
List all items
87163
"""
@@ -97,8 +173,5 @@ async def list_all(self, vault_id):
97173
}
98174
)
99175

100-
response_data = loads(response)
101-
102-
objects = [ItemOverview.model_validate(data) for data in response_data]
103-
104-
return SDKIterator(objects)
176+
response = TypeAdapter(list[ItemOverview]).validate_json(response)
177+
return SDKIterator(response)
288 KB
Binary file not shown.
329 KB
Binary file not shown.
326 KB
Binary file not shown.
326 KB
Binary file not shown.
340 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)