From ff8e8df49fae05d45b384b9759323de0fb032e6a Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Wed, 3 Apr 2024 23:00:21 +0300 Subject: [PATCH 1/3] Add generated reference docs --- docs/reference/onepassword/client.md | 35 +++++++ .../onepassword/lib/aarch64/op_uniffi_core.md | 99 +++++++++++++++++++ .../onepassword/lib/x86_64/op_uniffi_core.md | 99 +++++++++++++++++++ docs/reference/onepassword/secrets_api.md | 21 ++++ docs/reference/sidebar.json | 34 +++++++ pydoc-markdown.yml | 9 ++ src/onepassword/client.py | 9 +- src/onepassword/secrets_api.py | 6 +- 8 files changed, 307 insertions(+), 5 deletions(-) create mode 100644 docs/reference/onepassword/client.md create mode 100644 docs/reference/onepassword/lib/aarch64/op_uniffi_core.md create mode 100644 docs/reference/onepassword/lib/x86_64/op_uniffi_core.md create mode 100644 docs/reference/onepassword/secrets_api.md create mode 100644 docs/reference/sidebar.json create mode 100644 pydoc-markdown.yml diff --git a/docs/reference/onepassword/client.md b/docs/reference/onepassword/client.md new file mode 100644 index 00000000..e71eaf30 --- /dev/null +++ b/docs/reference/onepassword/client.md @@ -0,0 +1,35 @@ +--- +sidebar_label: client +title: onepassword.client +--- + +#### SDK\_VERSION + +v0.1.0 + +## Client Objects + +```python +class Client() +``` + +A client + +#### authenticate + +```python +@classmethod +async def authenticate(cls, auth, integration_name, integration_version) +``` + +authenticate returns an authenticated client or errors if any provided information, including the SA token, is incorrect +`integration_name` represents the name of your application and `integration_version` represents the version of your application. + +#### new\_default\_config + +```python +def new_default_config(auth, integration_name, integration_version) +``` + +Generates a configuration dictionary with the user's parameters + diff --git a/docs/reference/onepassword/lib/aarch64/op_uniffi_core.md b/docs/reference/onepassword/lib/aarch64/op_uniffi_core.md new file mode 100644 index 00000000..44ec5fed --- /dev/null +++ b/docs/reference/onepassword/lib/aarch64/op_uniffi_core.md @@ -0,0 +1,99 @@ +--- +sidebar_label: op_uniffi_core +title: onepassword.lib.aarch64.op_uniffi_core +--- + +## \_UniffiRustBuffer Objects + +```python +class _UniffiRustBuffer(ctypes.Structure) +``` + +#### alloc\_with\_builder + +```python +@contextlib.contextmanager +def alloc_with_builder(*args) +``` + +Context-manger to allocate a buffer using a _UniffiRustBufferBuilder. + +The allocated buffer will be automatically freed if an error occurs, ensuring that +we don't accidentally leak it. + +#### consume\_with\_stream + +```python +@contextlib.contextmanager +def consume_with_stream() +``` + +Context-manager to consume a buffer using a _UniffiRustBufferStream. + +The _UniffiRustBuffer will be freed once the context-manager exits, ensuring that we don't +leak it even if an error occurs. + +#### read\_with\_stream + +```python +@contextlib.contextmanager +def read_with_stream() +``` + +Context-manager to read a buffer using a _UniffiRustBufferStream. + +This is like consume_with_stream, but doesn't free the buffer afterwards. +It should only be used with borrowed `_UniffiRustBuffer` data. + +## \_UniffiPointerManagerCPython Objects + +```python +class _UniffiPointerManagerCPython() +``` + +Manage giving out pointers to Python objects on CPython + +This class is used to generate opaque pointers that reference Python objects to pass to Rust. +It assumes a CPython platform. See _UniffiPointerManagerGeneral for the alternative. + +#### new\_pointer + +```python +def new_pointer(obj) +``` + +Get a pointer for an object as a ctypes.c_size_t instance + +Each call to new_pointer() must be balanced with exactly one call to release_pointer() + +This returns a ctypes.c_size_t. This is always the same size as a pointer and can be +interchanged with pointers for FFI function arguments and return values. + +## Error Objects + +```python +class Error(Exception) +``` + +Error type sent over the FFI by UniFFI. + +`uniffi::Error` only supports errors that are enums, so we need to have a single-variant enum here. + +## Error Objects + +```python +class Error() +``` + +## Error Objects + +```python +class Error(_UniffiTempError) +``` + +Any error ocurring in the SDK + +#### Error + +type: ignore + diff --git a/docs/reference/onepassword/lib/x86_64/op_uniffi_core.md b/docs/reference/onepassword/lib/x86_64/op_uniffi_core.md new file mode 100644 index 00000000..b19a3dfb --- /dev/null +++ b/docs/reference/onepassword/lib/x86_64/op_uniffi_core.md @@ -0,0 +1,99 @@ +--- +sidebar_label: op_uniffi_core +title: onepassword.lib.x86_64.op_uniffi_core +--- + +## \_UniffiRustBuffer Objects + +```python +class _UniffiRustBuffer(ctypes.Structure) +``` + +#### alloc\_with\_builder + +```python +@contextlib.contextmanager +def alloc_with_builder(*args) +``` + +Context-manger to allocate a buffer using a _UniffiRustBufferBuilder. + +The allocated buffer will be automatically freed if an error occurs, ensuring that +we don't accidentally leak it. + +#### consume\_with\_stream + +```python +@contextlib.contextmanager +def consume_with_stream() +``` + +Context-manager to consume a buffer using a _UniffiRustBufferStream. + +The _UniffiRustBuffer will be freed once the context-manager exits, ensuring that we don't +leak it even if an error occurs. + +#### read\_with\_stream + +```python +@contextlib.contextmanager +def read_with_stream() +``` + +Context-manager to read a buffer using a _UniffiRustBufferStream. + +This is like consume_with_stream, but doesn't free the buffer afterwards. +It should only be used with borrowed `_UniffiRustBuffer` data. + +## \_UniffiPointerManagerCPython Objects + +```python +class _UniffiPointerManagerCPython() +``` + +Manage giving out pointers to Python objects on CPython + +This class is used to generate opaque pointers that reference Python objects to pass to Rust. +It assumes a CPython platform. See _UniffiPointerManagerGeneral for the alternative. + +#### new\_pointer + +```python +def new_pointer(obj) +``` + +Get a pointer for an object as a ctypes.c_size_t instance + +Each call to new_pointer() must be balanced with exactly one call to release_pointer() + +This returns a ctypes.c_size_t. This is always the same size as a pointer and can be +interchanged with pointers for FFI function arguments and return values. + +## Error Objects + +```python +class Error(Exception) +``` + +Error type sent over the FFI by UniFFI. + +`uniffi::Error` only supports errors that are enums, so we need to have a single-variant enum here. + +## Error Objects + +```python +class Error() +``` + +## Error Objects + +```python +class Error(_UniffiTempError) +``` + +Any error ocurring in the SDK + +#### Error + +type: ignore + diff --git a/docs/reference/onepassword/secrets_api.md b/docs/reference/onepassword/secrets_api.md new file mode 100644 index 00000000..4e753651 --- /dev/null +++ b/docs/reference/onepassword/secrets_api.md @@ -0,0 +1,21 @@ +--- +sidebar_label: secrets_api +title: onepassword.secrets_api +--- + +## Secrets Objects + +```python +class Secrets() +``` + +Secrets represents all operations the SDK client can perform on 1Password secrets. + +#### resolve + +```python +async def resolve(reference) +``` + +resolve returns the secret the provided reference points to. + diff --git a/docs/reference/sidebar.json b/docs/reference/sidebar.json new file mode 100644 index 00000000..d94a5978 --- /dev/null +++ b/docs/reference/sidebar.json @@ -0,0 +1,34 @@ +{ + "items": [ + { + "items": [ + { + "items": [ + { + "items": [ + "reference/onepassword/lib/aarch64/op_uniffi_core" + ], + "label": "onepassword.lib.aarch64", + "type": "category" + }, + { + "items": [ + "reference/onepassword/lib/x86_64/op_uniffi_core" + ], + "label": "onepassword.lib.x86_64", + "type": "category" + } + ], + "label": "onepassword.lib", + "type": "category" + }, + "reference/onepassword/client", + "reference/onepassword/secrets_api" + ], + "label": "onepassword", + "type": "category" + } + ], + "label": "Reference", + "type": "category" +} \ No newline at end of file diff --git a/pydoc-markdown.yml b/pydoc-markdown.yml new file mode 100644 index 00000000..ceeeaa03 --- /dev/null +++ b/pydoc-markdown.yml @@ -0,0 +1,9 @@ +loaders: + - type: python +processors: + - type: filter + skip_empty_modules: true + - type: smart + - type: crossref +renderer: + type: docusaurus diff --git a/src/onepassword/client.py b/src/onepassword/client.py index 60620da4..4d9bbc82 100644 --- a/src/onepassword/client.py +++ b/src/onepassword/client.py @@ -12,11 +12,13 @@ class Client: + """A client""" - """authenticate returns an authenticated client or errors if any provided information, including the SA token, is incorrect""" - """`integration_name` represents the name of your application and `integration_version` represents the version of your application.""" @classmethod async def authenticate(cls, auth, integration_name, integration_version): + """authenticate returns an authenticated client or errors if any provided information, including the SA token, is incorrect + `integration_name` represents the name of your application and `integration_version` represents the version of your application.""" + self = cls() self.config = new_default_config(auth=auth, integration_name=integration_name, integration_version=integration_version) client_id = int(await _init_client(self.config)) @@ -25,8 +27,9 @@ async def authenticate(cls, auth, integration_name, integration_version): return self -# Generates a configuration dictionary with the user's parameters def new_default_config(auth, integration_name, integration_version): + """Generates a configuration dictionary with the user's parameters""" + client_config_dict = { "serviceAccountToken": auth, "programmingLanguage": SDK_LANGUAGE, diff --git a/src/onepassword/secrets_api.py b/src/onepassword/secrets_api.py index 1c377b78..28ed7738 100644 --- a/src/onepassword/secrets_api.py +++ b/src/onepassword/secrets_api.py @@ -1,12 +1,14 @@ from .core import _invoke -"""Secrets represents all operations the SDK client can perform on 1Password secrets.""" class Secrets: + """Secrets represents all operations the SDK client can perform on 1Password secrets.""" + def __init__(self, client_id): self.client_id = client_id - """resolve returns the secret the provided reference points to.""" async def resolve(self, reference): + """resolve returns the secret the provided reference points to.""" + response = await _invoke({ "clientId": self.client_id, "invocation": { From 1b19374325aa1d584cac041ee1bfbd1e3342646e Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Wed, 3 Apr 2024 23:04:08 +0300 Subject: [PATCH 2/3] Remove docs of uniffi internals --- .../onepassword/lib/aarch64/op_uniffi_core.md | 99 ------------------- .../onepassword/lib/x86_64/op_uniffi_core.md | 99 ------------------- 2 files changed, 198 deletions(-) delete mode 100644 docs/reference/onepassword/lib/aarch64/op_uniffi_core.md delete mode 100644 docs/reference/onepassword/lib/x86_64/op_uniffi_core.md diff --git a/docs/reference/onepassword/lib/aarch64/op_uniffi_core.md b/docs/reference/onepassword/lib/aarch64/op_uniffi_core.md deleted file mode 100644 index 44ec5fed..00000000 --- a/docs/reference/onepassword/lib/aarch64/op_uniffi_core.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -sidebar_label: op_uniffi_core -title: onepassword.lib.aarch64.op_uniffi_core ---- - -## \_UniffiRustBuffer Objects - -```python -class _UniffiRustBuffer(ctypes.Structure) -``` - -#### alloc\_with\_builder - -```python -@contextlib.contextmanager -def alloc_with_builder(*args) -``` - -Context-manger to allocate a buffer using a _UniffiRustBufferBuilder. - -The allocated buffer will be automatically freed if an error occurs, ensuring that -we don't accidentally leak it. - -#### consume\_with\_stream - -```python -@contextlib.contextmanager -def consume_with_stream() -``` - -Context-manager to consume a buffer using a _UniffiRustBufferStream. - -The _UniffiRustBuffer will be freed once the context-manager exits, ensuring that we don't -leak it even if an error occurs. - -#### read\_with\_stream - -```python -@contextlib.contextmanager -def read_with_stream() -``` - -Context-manager to read a buffer using a _UniffiRustBufferStream. - -This is like consume_with_stream, but doesn't free the buffer afterwards. -It should only be used with borrowed `_UniffiRustBuffer` data. - -## \_UniffiPointerManagerCPython Objects - -```python -class _UniffiPointerManagerCPython() -``` - -Manage giving out pointers to Python objects on CPython - -This class is used to generate opaque pointers that reference Python objects to pass to Rust. -It assumes a CPython platform. See _UniffiPointerManagerGeneral for the alternative. - -#### new\_pointer - -```python -def new_pointer(obj) -``` - -Get a pointer for an object as a ctypes.c_size_t instance - -Each call to new_pointer() must be balanced with exactly one call to release_pointer() - -This returns a ctypes.c_size_t. This is always the same size as a pointer and can be -interchanged with pointers for FFI function arguments and return values. - -## Error Objects - -```python -class Error(Exception) -``` - -Error type sent over the FFI by UniFFI. - -`uniffi::Error` only supports errors that are enums, so we need to have a single-variant enum here. - -## Error Objects - -```python -class Error() -``` - -## Error Objects - -```python -class Error(_UniffiTempError) -``` - -Any error ocurring in the SDK - -#### Error - -type: ignore - diff --git a/docs/reference/onepassword/lib/x86_64/op_uniffi_core.md b/docs/reference/onepassword/lib/x86_64/op_uniffi_core.md deleted file mode 100644 index b19a3dfb..00000000 --- a/docs/reference/onepassword/lib/x86_64/op_uniffi_core.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -sidebar_label: op_uniffi_core -title: onepassword.lib.x86_64.op_uniffi_core ---- - -## \_UniffiRustBuffer Objects - -```python -class _UniffiRustBuffer(ctypes.Structure) -``` - -#### alloc\_with\_builder - -```python -@contextlib.contextmanager -def alloc_with_builder(*args) -``` - -Context-manger to allocate a buffer using a _UniffiRustBufferBuilder. - -The allocated buffer will be automatically freed if an error occurs, ensuring that -we don't accidentally leak it. - -#### consume\_with\_stream - -```python -@contextlib.contextmanager -def consume_with_stream() -``` - -Context-manager to consume a buffer using a _UniffiRustBufferStream. - -The _UniffiRustBuffer will be freed once the context-manager exits, ensuring that we don't -leak it even if an error occurs. - -#### read\_with\_stream - -```python -@contextlib.contextmanager -def read_with_stream() -``` - -Context-manager to read a buffer using a _UniffiRustBufferStream. - -This is like consume_with_stream, but doesn't free the buffer afterwards. -It should only be used with borrowed `_UniffiRustBuffer` data. - -## \_UniffiPointerManagerCPython Objects - -```python -class _UniffiPointerManagerCPython() -``` - -Manage giving out pointers to Python objects on CPython - -This class is used to generate opaque pointers that reference Python objects to pass to Rust. -It assumes a CPython platform. See _UniffiPointerManagerGeneral for the alternative. - -#### new\_pointer - -```python -def new_pointer(obj) -``` - -Get a pointer for an object as a ctypes.c_size_t instance - -Each call to new_pointer() must be balanced with exactly one call to release_pointer() - -This returns a ctypes.c_size_t. This is always the same size as a pointer and can be -interchanged with pointers for FFI function arguments and return values. - -## Error Objects - -```python -class Error(Exception) -``` - -Error type sent over the FFI by UniFFI. - -`uniffi::Error` only supports errors that are enums, so we need to have a single-variant enum here. - -## Error Objects - -```python -class Error() -``` - -## Error Objects - -```python -class Error(_UniffiTempError) -``` - -Any error ocurring in the SDK - -#### Error - -type: ignore - From fd56534fe329401163ab785238839e8516d57d98 Mon Sep 17 00:00:00 2001 From: Marton Soos Date: Wed, 3 Apr 2024 23:09:25 +0300 Subject: [PATCH 3/3] Add script for generating markdown docs --- scripts/generate_docs.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 scripts/generate_docs.sh diff --git a/scripts/generate_docs.sh b/scripts/generate_docs.sh new file mode 100755 index 00000000..ffc166fc --- /dev/null +++ b/scripts/generate_docs.sh @@ -0,0 +1,2 @@ +pydoc-markdown +rm -rf ./docs/reference/onepassword/lib