Skip to content

Commit 77421bd

Browse files
1PasswordSDKBotedif2008
authored andcommitted
Update core to version 3260001c
1 parent 38f0cf8 commit 77421bd

File tree

13 files changed

+611
-19
lines changed

13 files changed

+611
-19
lines changed

example/desktop_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async def main():
88
# Connects to the 1Password desktop app.
99
client = await Client.authenticate(
1010
auth=DesktopAuth(
11-
account_name="YourAccountNameAsItAppearsInTheApp" # Set to your 1Password account name.
11+
account_name="YouAccountNameAsShownInDesktopApp" # Set to your 1Password account name.
1212
),
1313
# Set the following to your own integration name and version.
1414
integration_name="My 1Password Integration",
@@ -22,7 +22,7 @@ async def main():
2222
# [developer-docs.sdk.python.list-vaults]-end
2323

2424
# [developer-docs.sdk.python.list-items]-start
25-
overviews = await client.items.list(vault.id)
25+
overviews = await client.items.list(vault_id=vaults[0].id)
2626
for overview in overviews:
2727
print(overview.title)
2828
# [developer-docs.sdk.python.list-items]-end

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
"DesktopAuth",

src/onepassword/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
from .secrets import Secrets
99
from .items import Items
1010
from .vaults import Vaults
11+
from .groups import Groups
1112

1213

1314
class Client:
1415
secrets: Secrets
1516
items: Items
1617
vaults: Vaults
18+
groups: Groups
1719

1820
@classmethod
1921
async def authenticate(
@@ -37,6 +39,8 @@ async def authenticate(
3739
authenticated_client.secrets = Secrets(client_id, core)
3840
authenticated_client.items = Items(client_id, core)
3941
authenticated_client.vaults = Vaults(client_id, core)
42+
authenticated_client.groups = Groups(client_id, core)
43+
4044
authenticated_client._finalizer = weakref.finalize(
4145
cls, core.release_client, client_id
4246
)

src/onepassword/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def new_default_config(auth: DesktopAuth | str, integration_name, integration_ve
3232
"osVersion": DEFAULT_OS_VERSION,
3333
"architecture": platform.machine(),
3434
}
35-
if isinstance(auth, str):
35+
if not isinstance(auth, DesktopAuth):
3636
client_config_dict["serviceAccountToken"] = auth
3737

3838
return client_config_dict

src/onepassword/groups.py

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

src/onepassword/items.py

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
from pydantic import TypeAdapter
55
from .items_shares import ItemsShares
66
from .items_files import ItemsFiles
7-
from .types import Item, ItemCreateParams, ItemListFilter, ItemOverview
7+
from .types import (
8+
Item,
9+
ItemCreateParams,
10+
ItemListFilter,
11+
ItemOverview,
12+
ItemsDeleteAllResponse,
13+
ItemsGetAllResponse,
14+
ItemsUpdateAllResponse,
15+
)
816

917

1018
class Items:
1119
"""
1220
The Items API holds all operations the SDK client can perform on 1Password items.
1321
"""
1422

15-
def __init__(self, client_id, core):
23+
def __init__(self, client_id, core: Core):
1624
self.client_id = client_id
1725
self.core = core
1826
self.shares = ItemsShares(client_id, core)
@@ -37,6 +45,30 @@ async def create(self, params: ItemCreateParams) -> Item:
3745
response = TypeAdapter(Item).validate_json(response)
3846
return response
3947

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

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

94145
return None
95146

147+
async def delete_all(
148+
self, vault_id: str, item_ids: List[str]
149+
) -> ItemsDeleteAllResponse:
150+
"""
151+
Create items in batch, within a single vault.
152+
"""
153+
response = await self.core.invoke(
154+
{
155+
"invocation": {
156+
"clientId": self.client_id,
157+
"parameters": {
158+
"name": "ItemsDeleteAll",
159+
"parameters": {"vault_id": vault_id, "item_ids": item_ids},
160+
},
161+
}
162+
}
163+
)
164+
165+
response = TypeAdapter(ItemsDeleteAllResponse).validate_json(response)
166+
return response
167+
96168
async def archive(self, vault_id: str, item_id: str) -> None:
97169
"""
98170
Archive an item.
1.51 MB
Binary file not shown.
2.14 MB
Binary file not shown.
1.36 MB
Binary file not shown.
1.88 MB
Binary file not shown.

0 commit comments

Comments
 (0)