Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release candidate 0.1.4 #133

Merged
merged 11 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ async def main():
print(item.title)
# [developer-docs.sdk.python.list-items]-end

# [developer-docs.sdk.python.validate-secret-reference]-start
# Validate secret reference to ensure no syntax errors
try:
Secrets.validate_secret_reference("op://vault/item/field")
except Exception as error:
print(error)
# [developer-docs.sdk.python.validate-secret-reference]-end

# [developer-docs.sdk.python.resolve-secret]-start
# Retrieves a secret from 1Password. Takes a secret reference as input and returns the secret to which it points.
value = await client.secrets.resolve("op://vault/item/field")
Expand All @@ -42,25 +50,25 @@ async def main():
# Create an Item and add it to your vault.
to_create = ItemCreateParams(
title="MyName",
category="Login",
category=ItemCategory.LOGIN,
vault_id="7turaasywpymt3jecxoxk5roli",
fields=[
ItemField(
id="username",
title="username",
field_type="Text",
field_type=ItemFieldType.TEXT,
value="mynameisjeff",
),
ItemField(
id="password",
title="password",
field_type="Concealed",
field_type=ItemFieldType.CONCEALED,
value="jeff",
),
ItemField(
id="onetimepassword",
title="one-time-password",
field_type="Totp",
field_type=ItemFieldType.TOTP,
section_id="totpsection",
value="otpauth://totp/my-example-otp?secret=jncrjgbdjnrncbjsr&issuer=1Password",
),
Expand All @@ -74,7 +82,7 @@ async def main():
Website(
label="my custom website",
url="https://example.com",
autofill_behavior="AnywhereOnWebsite",
autofill_behavior=AutofillBehavior.NEVER,
)
],
)
Expand Down Expand Up @@ -115,7 +123,7 @@ async def main():
Website(
label="my custom website 2",
url="https://example2.com",
autofill_behavior="Never",
autofill_behavior=AutofillBehavior.NEVER,
),
)
updated_item = await client.items.put(item)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def get_shared_library_data_to_include():
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
"License :: OSI Approved :: MIT License",
],
cmdclass={"bdist_wheel": bdist_wheel},
Expand Down
2 changes: 1 addition & 1 deletion src/onepassword/build_number.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SDK_BUILD_NUMBER = "0010301"
SDK_BUILD_NUMBER = "0010401"
1 change: 1 addition & 0 deletions src/onepassword/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async def _init_client(client_config):
async def _invoke(invoke_config):
return await core.invoke(json.dumps(invoke_config))


# Invoke calls specified business logic from the SDK core.
def _invoke_sync(invoke_config):
return core.invoke_sync(json.dumps(invoke_config))
Expand Down
3 changes: 2 additions & 1 deletion src/onepassword/items.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code generated by op-codegen - DO NO EDIT MANUALLY

from .core import _invoke
from .core import _invoke, _invoke_sync

Check failure on line 3 in src/onepassword/items.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F401)

src/onepassword/items.py:3:28: F401 `.core._invoke_sync` imported but unused

Check failure on line 3 in src/onepassword/items.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F401)

src/onepassword/items.py:3:28: F401 `.core._invoke_sync` imported but unused
from json import loads
from .iterator import SDKIterator
from .types import Item, ItemOverview
Expand Down Expand Up @@ -96,6 +96,7 @@
}
}
)

response_data = loads(response)

objects = [ItemOverview.model_validate(data) for data in response_data]
Expand Down
Binary file modified src/onepassword/lib/aarch64/libop_uniffi_core.dylib
Binary file not shown.
Binary file modified src/onepassword/lib/aarch64/libop_uniffi_core.so
Binary file not shown.
18 changes: 18 additions & 0 deletions src/onepassword/lib/aarch64/op_uniffi_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ def _uniffi_check_api_checksums(lib):
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_op_uniffi_core_checksum_func_invoke() != 29143:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_op_uniffi_core_checksum_func_invoke_sync() != 49373:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_op_uniffi_core_checksum_func_release_client() != 57155:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")

Expand All @@ -496,6 +498,11 @@ def _uniffi_check_api_checksums(lib):
_UniffiRustBuffer,
)
_UniffiLib.uniffi_op_uniffi_core_fn_func_invoke.restype = ctypes.c_void_p
_UniffiLib.uniffi_op_uniffi_core_fn_func_invoke_sync.argtypes = (
_UniffiRustBuffer,
ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.uniffi_op_uniffi_core_fn_func_invoke_sync.restype = _UniffiRustBuffer
_UniffiLib.uniffi_op_uniffi_core_fn_func_release_client.argtypes = (
_UniffiRustBuffer,
ctypes.POINTER(_UniffiRustCallStatus),
Expand Down Expand Up @@ -775,6 +782,9 @@ def _uniffi_check_api_checksums(lib):
_UniffiLib.uniffi_op_uniffi_core_checksum_func_invoke.argtypes = (
)
_UniffiLib.uniffi_op_uniffi_core_checksum_func_invoke.restype = ctypes.c_uint16
_UniffiLib.uniffi_op_uniffi_core_checksum_func_invoke_sync.argtypes = (
)
_UniffiLib.uniffi_op_uniffi_core_checksum_func_invoke_sync.restype = ctypes.c_uint16
_UniffiLib.uniffi_op_uniffi_core_checksum_func_release_client.argtypes = (
)
_UniffiLib.uniffi_op_uniffi_core_checksum_func_release_client.restype = ctypes.c_uint16
Expand Down Expand Up @@ -949,6 +959,13 @@ def invoke(invocation: "str"):
_UniffiConverterTypeError,
)

def invoke_sync(invocation: "str") -> "str":
_UniffiConverterString.check_lower(invocation)

return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeError,_UniffiLib.uniffi_op_uniffi_core_fn_func_invoke_sync,
_UniffiConverterString.lower(invocation)))


def release_client(client_id: "str"):
_UniffiConverterString.check_lower(client_id)

Expand All @@ -961,6 +978,7 @@ def release_client(client_id: "str"):
"Error",
"init_client",
"invoke",
"invoke_sync",
"release_client",
]

Binary file modified src/onepassword/lib/x86_64/libop_uniffi_core.dylib
Binary file not shown.
Binary file modified src/onepassword/lib/x86_64/libop_uniffi_core.so
Binary file not shown.
Binary file modified src/onepassword/lib/x86_64/op_uniffi_core.dll
Binary file not shown.
18 changes: 18 additions & 0 deletions src/onepassword/lib/x86_64/op_uniffi_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ def _uniffi_check_api_checksums(lib):
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_op_uniffi_core_checksum_func_invoke() != 29143:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_op_uniffi_core_checksum_func_invoke_sync() != 49373:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_op_uniffi_core_checksum_func_release_client() != 57155:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")

Expand All @@ -496,6 +498,11 @@ def _uniffi_check_api_checksums(lib):
_UniffiRustBuffer,
)
_UniffiLib.uniffi_op_uniffi_core_fn_func_invoke.restype = ctypes.c_void_p
_UniffiLib.uniffi_op_uniffi_core_fn_func_invoke_sync.argtypes = (
_UniffiRustBuffer,
ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.uniffi_op_uniffi_core_fn_func_invoke_sync.restype = _UniffiRustBuffer
_UniffiLib.uniffi_op_uniffi_core_fn_func_release_client.argtypes = (
_UniffiRustBuffer,
ctypes.POINTER(_UniffiRustCallStatus),
Expand Down Expand Up @@ -775,6 +782,9 @@ def _uniffi_check_api_checksums(lib):
_UniffiLib.uniffi_op_uniffi_core_checksum_func_invoke.argtypes = (
)
_UniffiLib.uniffi_op_uniffi_core_checksum_func_invoke.restype = ctypes.c_uint16
_UniffiLib.uniffi_op_uniffi_core_checksum_func_invoke_sync.argtypes = (
)
_UniffiLib.uniffi_op_uniffi_core_checksum_func_invoke_sync.restype = ctypes.c_uint16
_UniffiLib.uniffi_op_uniffi_core_checksum_func_release_client.argtypes = (
)
_UniffiLib.uniffi_op_uniffi_core_checksum_func_release_client.restype = ctypes.c_uint16
Expand Down Expand Up @@ -949,6 +959,13 @@ def invoke(invocation: "str"):
_UniffiConverterTypeError,
)

def invoke_sync(invocation: "str") -> "str":
_UniffiConverterString.check_lower(invocation)

return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeError,_UniffiLib.uniffi_op_uniffi_core_fn_func_invoke_sync,
_UniffiConverterString.lower(invocation)))


def release_client(client_id: "str"):
_UniffiConverterString.check_lower(client_id)

Expand All @@ -961,6 +978,7 @@ def release_client(client_id: "str"):
"Error",
"init_client",
"invoke",
"invoke_sync",
"release_client",
]

18 changes: 17 additions & 1 deletion src/onepassword/secrets.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Code generated by op-codegen - DO NO EDIT MANUALLY

from .core import _invoke
from .core import _invoke, _invoke_sync
from json import loads
from .iterator import SDKIterator

Check failure on line 5 in src/onepassword/secrets.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F401)

src/onepassword/secrets.py:5:23: F401 `.iterator.SDKIterator` imported but unused

Check failure on line 5 in src/onepassword/secrets.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F401)

src/onepassword/secrets.py:5:23: F401 `.iterator.SDKIterator` imported but unused


class Secrets:
Expand Down Expand Up @@ -30,3 +30,19 @@
}
)
return str(loads(response))

@staticmethod
def validate_secret_reference(secret_reference):
"""
Validate the secret reference to ensure there are no syntax errors.
"""
_invoke_sync(
{
"invocation": {
"parameters": {
"name": "ValidateSecretReference",
"parameters": {"secret_reference": secret_reference},
}
}
}
)
2 changes: 1 addition & 1 deletion src/onepassword/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def test_invalid_resolve():
async def test_client_construction_no_auth():
with pytest.raises(
Exception,
match="invalid user input: encountered the following errors: service account token was not specified; service account token had invalid format",
match="invalid user input: encountered the following errors: service account token was not specified",
):
await onepassword.Client.authenticate(
auth="",
Expand Down
Loading
Loading