Skip to content

Commit cf29c5d

Browse files
authored
Merge pull request #126 from 1Password/sdk-core/2024-10-14-48363fb1
Update core to version 48363fb1
2 parents 031af57 + 9f4c62a commit cf29c5d

File tree

11 files changed

+57
-11
lines changed

11 files changed

+57
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Field types:
100100
- [ ] SSH public keys, fingerprint and key type
101101
- [x] One-time passwords
102102
- [x] URLs
103-
- [ ] Websites (used to suggest and autofill logins)
103+
- [x] Websites (used to suggest and autofill logins)
104104
- [x] Phone numbers
105105
- [x] Credit card types
106106
- [ ] Files attachments and Document items

example/example.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ async def main():
6969
ItemSection(id="", title=""),
7070
ItemSection(id="totpsection", title=""),
7171
],
72-
tags=["test tag 1", "test tag 2"]
72+
tags=["test tag 1", "test tag 2"],
73+
websites=[
74+
Website(
75+
label="my custom website",
76+
url="https://example.com",
77+
autofill_behavior="AnywhereOnWebsite",
78+
)
79+
],
7380
)
7481
created_item = await client.items.create(to_create)
7582
# [developer-docs.sdk.python.create-item]-end
@@ -78,7 +85,9 @@ async def main():
7885

7986
# [developer-docs.sdk.python.resolve-totp-code]-start
8087
# Retrieves a secret from 1Password. Takes a secret reference as input and returns the secret to which it points.
81-
code = await client.secrets.resolve(f"op://{created_item.vault_id}/{created_item.id}/TOTP_onetimepassword?attribute=totp")
88+
code = await client.secrets.resolve(
89+
f"op://{created_item.vault_id}/{created_item.id}/TOTP_onetimepassword?attribute=totp"
90+
)
8291
print(code)
8392
# [developer-docs.sdk.python.resolve-totp-code]-end
8493

@@ -102,6 +111,13 @@ async def main():
102111
# [developer-docs.sdk.python.update-item]-start
103112
# Update a field in your item
104113
item.fields[0].value = "new_value"
114+
item.websites.append(
115+
Website(
116+
label="my custom website 2",
117+
url="https://example2.com",
118+
autofill_behavior="Never",
119+
),
120+
)
105121
updated_item = await client.items.put(item)
106122
# [developer-docs.sdk.python.update-item]-end
107123

src/onepassword/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import platform
22

33
SDK_LANGUAGE = "Python"
4-
SDK_VERSION = "0010200"
4+
SDK_VERSION = "0010301"
55
DEFAULT_INTEGRATION_NAME = "Unknown"
66
DEFAULT_INTEGRATION_VERSION = "Unknown"
77
DEFAULT_REQUEST_LIBRARY = "reqwest"
-7 KB
Binary file not shown.
84.5 KB
Binary file not shown.
-40 Bytes
Binary file not shown.
59.5 KB
Binary file not shown.
23 KB
Binary file not shown.

src/onepassword/types.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,28 @@ class ItemSection(BaseModel):
9999
"""
100100

101101

102+
AutofillBehavior = Literal["AnywhereOnWebsite", "ExactDomain", "Never"]
103+
104+
105+
class Website(BaseModel):
106+
model_config = ConfigDict(populate_by_name=True)
107+
108+
url: str
109+
"""
110+
The website URL
111+
"""
112+
label: str
113+
"""
114+
The label of the website, e.g. 'website', 'sign-in address'
115+
"""
116+
autofill_behavior: Annotated[AutofillBehavior, Field(alias="autofillBehavior")]
117+
"""
118+
The auto-fill behavior of the website
119+
120+
For more information, visit https://support.1password.com/autofill-behavior/
121+
"""
122+
123+
102124
class Item(BaseModel):
103125
"""
104126
Represents a 1Password item.
@@ -134,6 +156,10 @@ class Item(BaseModel):
134156
"""
135157
The item's tags
136158
"""
159+
websites: List[Website]
160+
"""
161+
The websites used for autofilling for items of the Login and Password categories.
162+
"""
137163
version: int
138164
"""
139165
The item's version
@@ -167,6 +193,10 @@ class ItemCreateParams(BaseModel):
167193
"""
168194
The item's tags
169195
"""
196+
websites: Optional[List[Website]] = None
197+
"""
198+
The websites used for autofilling for items of the Login and Password categories.
199+
"""
170200

171201

172202
class ItemOverview(BaseModel):
@@ -192,6 +222,10 @@ class ItemOverview(BaseModel):
192222
"""
193223
The ID of the vault where the item is saved
194224
"""
225+
websites: List[Website]
226+
"""
227+
The websites used for autofilling for items of the Login and Password categories.
228+
"""
195229

196230

197231
class OtpFieldDetails(BaseModel):

src/release/RELEASE-NOTES

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
The v0.1.2 release of the Python SDK brings:
2-
* Support for item tags. You can now create, get, and edit tags within your 1Password items using item CRUD functions.
3-
* Support for fetching one-time password codes using secret references. You can now fetch your TOTP code with the `secrets.resolve` function, using a secret reference for the TOTP field in your item. For example: "op://vault/item/field?=attribute=totp"
4-
* PyPI wheels for the Python SDK. You can now install the Python SDK via `pip install onepassword-sdk`
5-
* Full support for optional values. You no longer have to manually set `details: None` or `section: None` when instantiating `ItemCreateParams`.
6-
* Item creation now only requires specifying the vault ID, item category, and item title.
1+
The v0.1.3 release of the Python SDK brings:
2+
* Support for item websites. You can now create, get, and edit websites within your 1Password items using item CRUD functions.

0 commit comments

Comments
 (0)