diff --git a/src/onepassword/__init__.py b/src/onepassword/__init__.py index 473334e..bd9be8d 100644 --- a/src/onepassword/__init__.py +++ b/src/onepassword/__init__.py @@ -20,9 +20,9 @@ "Items", "Vaults", "Groups", + "DesktopAuth", "DEFAULT_INTEGRATION_NAME", "DEFAULT_INTEGRATION_VERSION", - "DesktopAuth", ] for name, obj in inspect.getmembers(sys.modules["onepassword.types"]): diff --git a/src/onepassword/client.py b/src/onepassword/client.py index 290cca9..f5d191c 100644 --- a/src/onepassword/client.py +++ b/src/onepassword/client.py @@ -42,7 +42,6 @@ async def authenticate( authenticated_client.items = Items(inner_client) authenticated_client.vaults = Vaults(inner_client) authenticated_client.groups = Groups(inner_client) - authenticated_client._finalizer = weakref.finalize( cls, core.release_client, client_id ) diff --git a/src/onepassword/groups.py b/src/onepassword/groups.py index 2d01959..5e2c74d 100644 --- a/src/onepassword/groups.py +++ b/src/onepassword/groups.py @@ -14,6 +14,9 @@ def __init__(self, inner_client: InnerClient): self.inner_client = inner_client async def get(self, group_id: str, group_params: GroupGetParams) -> Group: + """ + Get a group by its ID and parameters. + """ response = await self.inner_client.invoke( { "invocation": { diff --git a/src/onepassword/items.py b/src/onepassword/items.py index 591622a..7f27678 100644 --- a/src/onepassword/items.py +++ b/src/onepassword/items.py @@ -71,7 +71,7 @@ async def create_all( async def get(self, vault_id: str, item_id: str) -> Item: """ - Get an item by vault and item ID + Get an item by vault and item ID. """ response = await self.inner_client.invoke( { diff --git a/src/onepassword/items_files.py b/src/onepassword/items_files.py index 6895226..6e3d83f 100644 --- a/src/onepassword/items_files.py +++ b/src/onepassword/items_files.py @@ -12,7 +12,7 @@ def __init__(self, inner_client: InnerClient): async def attach(self, item: Item, file_params: FileCreateParams) -> Item: """ - Attach files to Items + Attach files to Items. """ response = await self.inner_client.invoke( { @@ -34,7 +34,7 @@ async def attach(self, item: Item, file_params: FileCreateParams) -> Item: async def read(self, vault_id: str, item_id: str, attr: FileAttributes) -> bytes: """ - Read file content from the Item + Read file content from the Item. """ response = await self.inner_client.invoke( { @@ -57,7 +57,7 @@ async def read(self, vault_id: str, item_id: str, attr: FileAttributes) -> bytes async def delete(self, item: Item, section_id: str, field_id: str) -> Item: """ - Delete a field file from Item using the section and field IDs + Delete a field file from Item using the section and field IDs. """ response = await self.inner_client.invoke( { @@ -82,7 +82,7 @@ async def replace_document( self, item: Item, doc_params: DocumentCreateParams ) -> Item: """ - Replace the document file within a document item + Replace the document file within a document item. """ response = await self.inner_client.invoke( { diff --git a/src/onepassword/lib/aarch64/libop_uniffi_core.dylib b/src/onepassword/lib/aarch64/libop_uniffi_core.dylib index ec96524..1bd9aeb 100755 Binary files a/src/onepassword/lib/aarch64/libop_uniffi_core.dylib and b/src/onepassword/lib/aarch64/libop_uniffi_core.dylib differ diff --git a/src/onepassword/lib/aarch64/libop_uniffi_core.so b/src/onepassword/lib/aarch64/libop_uniffi_core.so index b2dce11..7a2aa2b 100755 Binary files a/src/onepassword/lib/aarch64/libop_uniffi_core.so and b/src/onepassword/lib/aarch64/libop_uniffi_core.so differ diff --git a/src/onepassword/lib/x86_64/libop_uniffi_core.dylib b/src/onepassword/lib/x86_64/libop_uniffi_core.dylib index 6ebca40..dcd27d1 100755 Binary files a/src/onepassword/lib/x86_64/libop_uniffi_core.dylib and b/src/onepassword/lib/x86_64/libop_uniffi_core.dylib differ diff --git a/src/onepassword/lib/x86_64/libop_uniffi_core.so b/src/onepassword/lib/x86_64/libop_uniffi_core.so index 96944d1..69227f6 100755 Binary files a/src/onepassword/lib/x86_64/libop_uniffi_core.so and b/src/onepassword/lib/x86_64/libop_uniffi_core.so differ diff --git a/src/onepassword/lib/x86_64/op_uniffi_core.dll b/src/onepassword/lib/x86_64/op_uniffi_core.dll index 497d391..c6cc4a0 100644 Binary files a/src/onepassword/lib/x86_64/op_uniffi_core.dll and b/src/onepassword/lib/x86_64/op_uniffi_core.dll differ diff --git a/src/onepassword/secrets.py b/src/onepassword/secrets.py index 8b46dfd..014533f 100644 --- a/src/onepassword/secrets.py +++ b/src/onepassword/secrets.py @@ -73,6 +73,9 @@ def validate_secret_reference(secret_reference: str) -> None: @staticmethod def generate_password(recipe: PasswordRecipe) -> GeneratePasswordResponse: + """ + Generate a password using the provided recipe. + """ response = UniffiCore().invoke_sync( { "invocation": { diff --git a/src/onepassword/types.py b/src/onepassword/types.py index 0119cc3..a3d5121 100644 --- a/src/onepassword/types.py +++ b/src/onepassword/types.py @@ -248,7 +248,9 @@ class GroupAccess(BaseModel): This is used for granting permissions """ - group_id: str + model_config = ConfigDict(populate_by_name=True) + + group_id: str = Field(alias="groupId") """ The group's ID """ @@ -269,11 +271,13 @@ class GroupVaultAccess(BaseModel): Represents a group's access to a 1Password vault. """ - vault_id: str + model_config = ConfigDict(populate_by_name=True) + + vault_id: str = Field(alias="vaultId") """ The vault's ID """ - group_id: str + group_id: str = Field(alias="groupId") """ The group's ID """ @@ -1303,6 +1307,14 @@ class Vault(BaseModel): """ +class VaultCreateParams(BaseModel): + model_config = ConfigDict(populate_by_name=True) + + title: str + description: Optional[str] = Field(default=None) + allow_admins_access: Optional[bool] = Field(alias="allowAdminsAccess", default=None) + + class VaultGetParams(BaseModel): """ Represents the possible query parameters used for retrieving extra information about a vault. @@ -1373,6 +1385,11 @@ class VaultOverview(BaseModel): """ +class VaultUpdateParams(BaseModel): + title: Optional[str] = Field(default=None) + description: Optional[str] = Field(default=None) + + class ItemListFilterByStateInner(BaseModel): """ Generated type representing the anonymous struct variant `ByState` of the `ItemListFilter` Rust enum diff --git a/src/onepassword/vaults.py b/src/onepassword/vaults.py index 2664e33..402bbc7 100644 --- a/src/onepassword/vaults.py +++ b/src/onepassword/vaults.py @@ -1,15 +1,17 @@ # Code generated by op-codegen - DO NO EDIT MANUALLY from .core import InnerClient -from typing import Optional, List +from typing import List, Optional from pydantic import TypeAdapter from .types import ( GroupAccess, GroupVaultAccess, Vault, + VaultCreateParams, VaultGetParams, VaultListParams, VaultOverview, + VaultUpdateParams, ) @@ -21,6 +23,25 @@ class Vaults: def __init__(self, inner_client: InnerClient): self.inner_client = inner_client + async def create(self, params: VaultCreateParams) -> Vault: + """ + Create a new user vault. + """ + response = await self.inner_client.invoke( + { + "invocation": { + "clientId": self.inner_client.client_id, + "parameters": { + "name": "VaultsCreate", + "parameters": {"params": params.model_dump(by_alias=True)}, + }, + } + } + ) + + response = TypeAdapter(Vault).validate_json(response) + return response + async def list( self, params: Optional[VaultListParams] = None ) -> List[VaultOverview]: @@ -35,8 +56,7 @@ async def list( "name": "VaultsList", "parameters": { "params": ( - params.model_dump( - by_alias=True) if params else None + params.model_dump(by_alias=True) if params else None ) }, }, @@ -47,14 +67,17 @@ async def list( response = TypeAdapter(List[VaultOverview]).validate_json(response) return response - async def get_overview(self, vault_uuid: str) -> VaultOverview: + async def get_overview(self, vault_id: str) -> VaultOverview: + """ + Get an overview of a vault by its ID. + """ response = await self.inner_client.invoke( { "invocation": { "clientId": self.inner_client.client_id, "parameters": { "name": "VaultsGetOverview", - "parameters": {"vault_uuid": vault_uuid}, + "parameters": {"vault_id": vault_id}, }, } } @@ -63,7 +86,10 @@ async def get_overview(self, vault_uuid: str) -> VaultOverview: response = TypeAdapter(VaultOverview).validate_json(response) return response - async def get(self, vault_uuid: str, vault_params: VaultGetParams) -> Vault: + async def get(self, vault_id: str, vault_params: VaultGetParams) -> Vault: + """ + Get detailed vault information by vault ID and parameters. + """ response = await self.inner_client.invoke( { "invocation": { @@ -71,7 +97,7 @@ async def get(self, vault_uuid: str, vault_params: VaultGetParams) -> Vault: "parameters": { "name": "VaultsGet", "parameters": { - "vault_uuid": vault_uuid, + "vault_id": vault_id, "vault_params": vault_params.model_dump(by_alias=True), }, }, @@ -82,9 +108,52 @@ async def get(self, vault_uuid: str, vault_params: VaultGetParams) -> Vault: response = TypeAdapter(Vault).validate_json(response) return response + async def update(self, vault_id: str, params: VaultUpdateParams) -> Vault: + """ + Update a vault + """ + response = await self.inner_client.invoke( + { + "invocation": { + "clientId": self.inner_client.client_id, + "parameters": { + "name": "VaultsUpdate", + "parameters": { + "vault_id": vault_id, + "params": params.model_dump(by_alias=True), + }, + }, + } + } + ) + + response = TypeAdapter(Vault).validate_json(response) + return response + + async def delete(self, vault_id: str) -> None: + """ + Delete a vault by its ID. + """ + response = await self.inner_client.invoke( + { + "invocation": { + "clientId": self.inner_client.client_id, + "parameters": { + "name": "VaultsDelete", + "parameters": {"vault_id": vault_id}, + }, + } + } + ) + + return None + async def grant_group_permissions( self, vault_id: str, group_permissions_list: List[GroupAccess] ) -> None: + """ + Grant group permissions to a vault. + """ response = await self.inner_client.invoke( { "invocation": { @@ -108,6 +177,9 @@ async def grant_group_permissions( async def update_group_permissions( self, group_permissions_list: List[GroupVaultAccess] ) -> None: + """ + Update group permissions for vaults. + """ response = await self.inner_client.invoke( { "invocation": { @@ -128,6 +200,9 @@ async def update_group_permissions( return None async def revoke_group_permissions(self, vault_id: str, group_id: str) -> None: + """ + Revoke group permissions from a vault. + """ response = await self.inner_client.invoke( { "invocation": {