Skip to content

Commit 03be2e3

Browse files
Update core to version 010d4339
1 parent 5aedbae commit 03be2e3

File tree

7 files changed

+60
-2
lines changed

7 files changed

+60
-2
lines changed

src/onepassword/items.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .core import _invoke, _invoke_sync
44
from json import loads
55
from .iterator import SDKIterator
6-
from .types import Item, ItemOverview
6+
from .types import Item, ItemOverview, ItemsGetAllResponse
77

88

99
class Items:
@@ -48,6 +48,26 @@ async def get(self, vault_id, item_id):
4848
)
4949
return Item.model_validate_json(response)
5050

51+
async def get_all(self, vault_id, item_ids):
52+
"""
53+
Get items by vault and their item IDs.
54+
"""
55+
response = await _invoke(
56+
{
57+
"invocation": {
58+
"clientId": self.client_id,
59+
"parameters": {
60+
"name": "ItemsGetAll",
61+
"parameters": {
62+
"vault_id": vault_id,
63+
"item_ids": [o.model_dump(by_alias=True) for o in item_ids],
64+
},
65+
},
66+
}
67+
}
68+
)
69+
return ItemsGetAllResponse.model_validate_json(response)
70+
5171
async def put(self, item):
5272
"""
5373
Update an existing item.
@@ -81,6 +101,22 @@ async def delete(self, vault_id, item_id):
81101
}
82102
)
83103

104+
async def archive(self, vault_id, item_id):
105+
"""
106+
Archive an item.
107+
"""
108+
await _invoke(
109+
{
110+
"invocation": {
111+
"clientId": self.client_id,
112+
"parameters": {
113+
"name": "ItemsArchive",
114+
"parameters": {"vault_id": vault_id, "item_id": item_id},
115+
},
116+
}
117+
}
118+
)
119+
84120
async def list_all(self, vault_id):
85121
"""
86122
List all items
176 KB
Binary file not shown.
240 KB
Binary file not shown.
205 KB
Binary file not shown.
201 KB
Binary file not shown.
240 KB
Binary file not shown.

src/onepassword/types.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
from enum import Enum
88
from pydantic import BaseModel, ConfigDict, Field
9-
from typing import List, Literal, Optional, Union
9+
from typing import Generic, List, Literal, Optional, TypeVar, Union
10+
11+
E = TypeVar("E")
12+
T = TypeVar("T")
1013

1114

1215
class GeneratePasswordResponse(BaseModel):
@@ -56,6 +59,8 @@ class ItemFieldType(str, Enum):
5659
PHONE = "Phone"
5760
URL = "Url"
5861
TOTP = "Totp"
62+
EMAIL = "Email"
63+
REFERENCE = "Reference"
5964
UNSUPPORTED = "Unsupported"
6065

6166

@@ -256,6 +261,23 @@ class ItemOverview(BaseModel):
256261
"""
257262

258263

264+
class Response(BaseModel, Generic[T, E]):
265+
content: Optional[T] = Field(default=None)
266+
error: Optional[E] = Field(default=None)
267+
268+
269+
class ItemsGetAllError(str, Enum):
270+
ITEMNOTFOUND = "itemNotFound"
271+
272+
273+
class ItemsGetAllResponse(BaseModel):
274+
model_config = ConfigDict(populate_by_name=True)
275+
276+
individual_responses: List[Response[Item, ItemsGetAllError]] = Field(
277+
alias="individualResponses"
278+
)
279+
280+
259281
class OtpFieldDetails(BaseModel):
260282
"""
261283
Additional attributes for OTP fields.

0 commit comments

Comments
 (0)