Skip to content

Commit 031af57

Browse files
hculea1PasswordSDKBotMOmarMiraj
authored
Update core to version 25955fc5 (#125)
* Update core to version 25955fc5 * Fix Integration test and add _ to finalizer for client.py * Add macos related wheels * add tags to example * remove explicit None fields * Update sdk build number in defaults.py * Add validation of secret reference * Release v0.1.2 * Update release notes * Add release notes and example * Remove secret reference validation * Update README and release notes --------- Co-authored-by: 1PasswordSDKBot <[email protected]> Co-authored-by: Omar Miraj <[email protected]>
1 parent ed25542 commit 031af57

File tree

19 files changed

+182
-160
lines changed

19 files changed

+182
-160
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ To use the 1Password Python SDK in your project:
4646
3. Install the 1Password Python SDK in your project:
4747

4848
```bash
49-
pip install git+https://[email protected]/1Password/onepassword-sdk[email protected]
49+
pip install onepassword-sdk
5050
```
5151

5252
4. Use the Python SDK in your project:
@@ -88,7 +88,7 @@ Operations:
8888
- [x] [Update items](https://developer.1password.com/docs/sdks/manage-items#update-an-item)
8989
- [x] [Delete items](https://developer.1password.com/docs/sdks/manage-items#delete-an-item)
9090
- [x] [List items](https://developer.1password.com/docs/sdks/list-vaults-items/)
91-
- [ ] Add & update tags on items
91+
- [x] Add & update tags on items
9292

9393
Field types:
9494
- [x] API Keys

example/example.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import asyncio
22
import os
3+
34
# [developer-docs.sdk.python.sdk-import]-start
45
from onepassword import *
56
# [developer-docs.sdk.python.sdk-import]-end
67

8+
79
async def main():
810
# [developer-docs.sdk.python.client-initialization]-start
911
# Gets your service account token from the OP_SERVICE_ACCOUNT_TOKEN environment variable.
@@ -23,14 +25,13 @@ async def main():
2325
async for vault in vaults:
2426
print(vault.title)
2527
# [developer-docs.sdk.python.list-vaults]-end
26-
28+
2729
# [developer-docs.sdk.python.list-items]-start
2830
items = await client.items.list_all(vault.id)
2931
async for item in items:
3032
print(item.title)
3133
# [developer-docs.sdk.python.list-items]-end
3234

33-
3435
# [developer-docs.sdk.python.resolve-secret]-start
3536
# Retrieves a secret from 1Password. Takes a secret reference as input and returns the secret to which it points.
3637
value = await client.secrets.resolve("op://vault/item/field")
@@ -42,43 +43,45 @@ async def main():
4243
to_create = ItemCreateParams(
4344
title="MyName",
4445
category="Login",
45-
vault_id="q73bqltug6xoegr3wkk2zkenoq",
46+
vault_id="7turaasywpymt3jecxoxk5roli",
4647
fields=[
4748
ItemField(
4849
id="username",
4950
title="username",
5051
field_type="Text",
51-
section_id=None,
5252
value="mynameisjeff",
53-
details=None,
5453
),
5554
ItemField(
5655
id="password",
5756
title="password",
5857
field_type="Concealed",
59-
section_id=None,
6058
value="jeff",
61-
details=None,
6259
),
6360
ItemField(
6461
id="onetimepassword",
6562
title="one-time-password",
6663
field_type="Totp",
6764
section_id="totpsection",
6865
value="otpauth://totp/my-example-otp?secret=jncrjgbdjnrncbjsr&issuer=1Password",
69-
details=None,
7066
),
7167
],
7268
sections=[
7369
ItemSection(id="", title=""),
7470
ItemSection(id="totpsection", title=""),
7571
],
72+
tags=["test tag 1", "test tag 2"]
7673
)
7774
created_item = await client.items.create(to_create)
7875
# [developer-docs.sdk.python.create-item]-end
7976

8077
print(dict(created_item))
8178

79+
# [developer-docs.sdk.python.resolve-totp-code]-start
80+
# 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")
82+
print(code)
83+
# [developer-docs.sdk.python.resolve-totp-code]-end
84+
8285
# [developer-docs.sdk.python.get-totp-item-crud]-start
8386
# Fetch a totp code from the item
8487
for f in created_item.fields:
@@ -108,5 +111,6 @@ async def main():
108111
await client.items.delete(created_item.vault_id, updated_item.id)
109112
# [developer-docs.sdk.python.delete-item]-end
110113

114+
111115
if __name__ == "__main__":
112116
asyncio.run(main())

setup.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def finalize_options(self):
2323
def get_shared_library_data_to_include():
2424
# Return the correct uniffi C shared library extension for the given platform
2525
include_path = "lib"
26-
machine_type = os.getenv("PYTHON_MACHINE_PLATFORM") or platform.machine().lower()
26+
machine_type = os.getenv("PYTHON_MACHINE_PLATFORM") or platform.machine().lower()
2727
if machine_type in ["x86_64", "amd64"]:
2828
include_path = os.path.join(include_path, "x86_64")
2929
elif machine_type in ["aarch64", "arm64"]:
@@ -49,8 +49,8 @@ def get_shared_library_data_to_include():
4949
name="onepassword-sdk",
5050
version=SDK_VERSION,
5151
author="1Password",
52-
long_description= (Path(__file__).parent / "README.md").read_text(),
53-
long_description_content_type='text/markdown',
52+
long_description=(Path(__file__).parent / "README.md").read_text(),
53+
long_description_content_type="text/markdown",
5454
description="The 1Password Python SDK offers programmatic read access to your secrets in 1Password in an interface native to Python.",
5555
url="https://github.com/1Password/onepassword-sdk-python",
5656
packages=find_packages(
@@ -60,20 +60,20 @@ def get_shared_library_data_to_include():
6060
license_files="LICENSE",
6161
package_dir={"": "src"},
6262
python_requires=">=3.9",
63-
classifiers = [
64-
"Development Status :: 5 - Production/Stable",
65-
"Operating System :: MacOS",
66-
"Operating System :: POSIX :: Linux",
67-
"Operating System :: Microsoft :: Windows",
68-
"Programming Language :: Python :: 3.9",
69-
"Programming Language :: Python :: 3.10",
70-
"Programming Language :: Python :: 3.11",
71-
"Programming Language :: Python :: 3.12",
72-
"License :: OSI Approved :: MIT License"
63+
classifiers=[
64+
"Development Status :: 5 - Production/Stable",
65+
"Operating System :: MacOS",
66+
"Operating System :: POSIX :: Linux",
67+
"Operating System :: Microsoft :: Windows",
68+
"Programming Language :: Python :: 3.9",
69+
"Programming Language :: Python :: 3.10",
70+
"Programming Language :: Python :: 3.11",
71+
"Programming Language :: Python :: 3.12",
72+
"License :: OSI Approved :: MIT License",
7373
],
7474
cmdclass={"bdist_wheel": bdist_wheel},
7575
package_data={"": get_shared_library_data_to_include()},
7676
install_requires=[
77-
"pydantic>=2.5", # Minimum Pydantic version to run the Python SDK
77+
"pydantic>=2.5", # Minimum Pydantic version to run the Python SDK
7878
],
7979
)

src/onepassword/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# AUTO-GENERATED
1+
# Code generated by op-codegen - DO NO EDIT MANUALLY
2+
23
from .client import Client
34
from .defaults import DEFAULT_INTEGRATION_NAME, DEFAULT_INTEGRATION_VERSION
45
from .types import * # noqa F403

src/onepassword/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# AUTO-GENERATED
1+
# Code generated by op-codegen - DO NO EDIT MANUALLY
2+
23
import weakref
34
from .core import _init_client, _release_client
45
from .defaults import new_default_config
@@ -14,12 +15,12 @@ class Client:
1415

1516
@classmethod
1617
async def authenticate(cls, auth, integration_name, integration_version):
17-
# Convert None from os.getEnv to empty string
1818
config = new_default_config(
1919
auth=auth or "",
2020
integration_name=integration_name,
2121
integration_version=integration_version,
2222
)
23+
2324
client_id = int(await _init_client(config))
2425

2526
authenticated_client = cls()

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 = "0010100"
4+
SDK_VERSION = "0010200"
55
DEFAULT_INTEGRATION_NAME = "Unknown"
66
DEFAULT_INTEGRATION_VERSION = "Unknown"
77
DEFAULT_REQUEST_LIBRARY = "reqwest"

src/onepassword/items.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# AUTO-GENERATED
1+
# Code generated by op-codegen - DO NO EDIT MANUALLY
2+
23
from .core import _invoke
34
from json import loads
45
from .iterator import SDKIterator
@@ -19,13 +20,13 @@ async def create(self, params):
1920
"""
2021
response = await _invoke(
2122
{
22-
"clientId": self.client_id,
2323
"invocation": {
24-
"name": "ItemsCreate",
24+
"clientId": self.client_id,
2525
"parameters": {
26-
"params": params.model_dump(by_alias=True),
26+
"name": "ItemsCreate",
27+
"parameters": {"params": params.model_dump(by_alias=True)},
2728
},
28-
},
29+
}
2930
}
3031
)
3132
return Item.model_validate_json(response)
@@ -36,14 +37,13 @@ async def get(self, vault_id, item_id):
3637
"""
3738
response = await _invoke(
3839
{
39-
"clientId": self.client_id,
4040
"invocation": {
41-
"name": "ItemsGet",
41+
"clientId": self.client_id,
4242
"parameters": {
43-
"item_id": item_id,
44-
"vault_id": vault_id,
43+
"name": "ItemsGet",
44+
"parameters": {"vault_id": vault_id, "item_id": item_id},
4545
},
46-
},
46+
}
4747
}
4848
)
4949
return Item.model_validate_json(response)
@@ -54,13 +54,13 @@ async def put(self, item):
5454
"""
5555
response = await _invoke(
5656
{
57-
"clientId": self.client_id,
5857
"invocation": {
59-
"name": "ItemsPut",
58+
"clientId": self.client_id,
6059
"parameters": {
61-
"item": item.model_dump(by_alias=True),
60+
"name": "ItemsPut",
61+
"parameters": {"item": item.model_dump(by_alias=True)},
6262
},
63-
},
63+
}
6464
}
6565
)
6666
return Item.model_validate_json(response)
@@ -69,17 +69,15 @@ async def delete(self, vault_id, item_id):
6969
"""
7070
Delete an item.
7171
"""
72-
7372
await _invoke(
7473
{
75-
"clientId": self.client_id,
7674
"invocation": {
77-
"name": "ItemsDelete",
75+
"clientId": self.client_id,
7876
"parameters": {
79-
"item_id": item_id,
80-
"vault_id": vault_id,
77+
"name": "ItemsDelete",
78+
"parameters": {"vault_id": vault_id, "item_id": item_id},
8179
},
82-
},
80+
}
8381
}
8482
)
8583

@@ -89,17 +87,17 @@ async def list_all(self, vault_id):
8987
"""
9088
response = await _invoke(
9189
{
92-
"clientId": self.client_id,
9390
"invocation": {
94-
"name": "ItemsListAll",
91+
"clientId": self.client_id,
9592
"parameters": {
96-
"vault_id": vault_id,
93+
"name": "ItemsListAll",
94+
"parameters": {"vault_id": vault_id},
9795
},
98-
},
96+
}
9997
}
10098
)
10199
response_data = loads(response)
102100

103101
objects = [ItemOverview.model_validate(data) for data in response_data]
104102

105-
return SDKIterator(objects)
103+
return SDKIterator(objects)
82.4 KB
Binary file not shown.
88.6 KB
Binary file not shown.
79.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)