Skip to content

Commit 3449d49

Browse files
Update core to version 143bddbd
1 parent 0460d48 commit 3449d49

File tree

12 files changed

+658
-10
lines changed

12 files changed

+658
-10
lines changed

src/onepassword/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .secrets import Secrets
88
from .items import Items
99
from .vaults import Vaults
10+
from .groups import Groups
1011

1112

1213
import sys
@@ -18,6 +19,7 @@
1819
"Secrets",
1920
"Items",
2021
"Vaults",
22+
"Groups",
2123
"DEFAULT_INTEGRATION_NAME",
2224
"DEFAULT_INTEGRATION_VERSION",
2325
]

src/onepassword/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
from .secrets import Secrets
88
from .items import Items
99
from .vaults import Vaults
10+
from .groups import Groups
1011

1112

1213
class Client:
1314
secrets: Secrets
1415
items: Items
1516
vaults: Vaults
17+
groups: Groups
1618

1719
@classmethod
1820
async def authenticate(
@@ -31,6 +33,7 @@ async def authenticate(
3133
authenticated_client.secrets = Secrets(client_id)
3234
authenticated_client.items = Items(client_id)
3335
authenticated_client.vaults = Vaults(client_id)
36+
authenticated_client.groups = Groups(client_id)
3437
authenticated_client._finalizer = weakref.finalize(
3538
cls, _release_client, client_id
3639
)

src/onepassword/errors.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
import json
44

55

6+
class DesktopSessionExpiredException(Exception):
7+
def __init__(self, message):
8+
self.message = message
9+
super().__init__(self.message)
10+
11+
612
class RateLimitExceededException(Exception):
713
def __init__(self, message):
814
self.message = message
@@ -18,6 +24,8 @@ def raise_typed_exception(e: Exception):
1824
error_name = typed_error.get("name")
1925
message = typed_error.get("message")
2026

27+
if error_name == "DesktopSessionExpired":
28+
raise DesktopSessionExpiredException(message)
2129
if error_name == "RateLimitExceeded":
2230
raise RateLimitExceededException(message)
2331
elif message is not None:

src/onepassword/groups.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Code generated by op-codegen - DO NO EDIT MANUALLY
2+
3+
from .core import _invoke, _invoke_sync
4+
from typing import Optional, List
5+
from pydantic import TypeAdapter
6+
from .types import Group, GroupGetParams
7+
8+
9+
class Groups:
10+
"""
11+
The Groups API holds all the operations the SDK client can perform on 1Password groups.
12+
"""
13+
14+
def __init__(self, client_id):
15+
self.client_id = client_id
16+
17+
async def get(self, group_id: str, group_params: GroupGetParams) -> Group:
18+
response = await _invoke(
19+
{
20+
"invocation": {
21+
"clientId": self.client_id,
22+
"parameters": {
23+
"name": "GroupsGet",
24+
"parameters": {
25+
"group_id": group_id,
26+
"group_params": group_params.model_dump(by_alias=True),
27+
},
28+
},
29+
}
30+
}
31+
)
32+
33+
response = TypeAdapter(Group).validate_json(response)
34+
return response

src/onepassword/items.py

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
from pydantic import TypeAdapter
66
from .items_shares import ItemsShares
77
from .items_files import ItemsFiles
8-
from .types import Item, ItemCreateParams, ItemListFilter, ItemOverview
8+
from .types import (
9+
Item,
10+
ItemCreateParams,
11+
ItemListFilter,
12+
ItemOverview,
13+
ItemsDeleteAllResponse,
14+
ItemsGetAllResponse,
15+
ItemsUpdateAllResponse,
16+
)
917

1018

1119
class Items:
@@ -38,6 +46,30 @@ async def create(self, params: ItemCreateParams) -> Item:
3846
response = TypeAdapter(Item).validate_json(response)
3947
return response
4048

49+
async def create_all(
50+
self, vault_id: str, params: List[ItemCreateParams]
51+
) -> ItemsUpdateAllResponse:
52+
"""
53+
Create items in batch, within a single vault.
54+
"""
55+
response = await _invoke(
56+
{
57+
"invocation": {
58+
"clientId": self.client_id,
59+
"parameters": {
60+
"name": "ItemsCreateAll",
61+
"parameters": {
62+
"vault_id": vault_id,
63+
"params": [o.model_dump(by_alias=True) for o in params],
64+
},
65+
},
66+
}
67+
}
68+
)
69+
70+
response = TypeAdapter(ItemsUpdateAllResponse).validate_json(response)
71+
return response
72+
4173
async def get(self, vault_id: str, item_id: str) -> Item:
4274
"""
4375
Get an item by vault and item ID
@@ -57,6 +89,25 @@ async def get(self, vault_id: str, item_id: str) -> Item:
5789
response = TypeAdapter(Item).validate_json(response)
5890
return response
5991

92+
async def get_all(self, vault_id: str, item_ids: List[str]) -> ItemsGetAllResponse:
93+
"""
94+
Get items by vault and their item IDs.
95+
"""
96+
response = await _invoke(
97+
{
98+
"invocation": {
99+
"clientId": self.client_id,
100+
"parameters": {
101+
"name": "ItemsGetAll",
102+
"parameters": {"vault_id": vault_id, "item_ids": item_ids},
103+
},
104+
}
105+
}
106+
)
107+
108+
response = TypeAdapter(ItemsGetAllResponse).validate_json(response)
109+
return response
110+
60111
async def put(self, item: Item) -> Item:
61112
"""
62113
Update an existing item.
@@ -94,6 +145,27 @@ async def delete(self, vault_id: str, item_id: str) -> None:
94145

95146
return None
96147

148+
async def delete_all(
149+
self, vault_id: str, item_ids: List[str]
150+
) -> ItemsDeleteAllResponse:
151+
"""
152+
Delete items in batch, within a single vault.
153+
"""
154+
response = await _invoke(
155+
{
156+
"invocation": {
157+
"clientId": self.client_id,
158+
"parameters": {
159+
"name": "ItemsDeleteAll",
160+
"parameters": {"vault_id": vault_id, "item_ids": item_ids},
161+
},
162+
}
163+
}
164+
)
165+
166+
response = TypeAdapter(ItemsDeleteAllResponse).validate_json(response)
167+
return response
168+
97169
async def archive(self, vault_id: str, item_id: str) -> None:
98170
"""
99171
Archive an item.
682 KB
Binary file not shown.
773 KB
Binary file not shown.
685 KB
Binary file not shown.
766 KB
Binary file not shown.
755 KB
Binary file not shown.

0 commit comments

Comments
 (0)