diff --git a/example/desktop_app.py b/example/desktop_app.py index 0c6b1e4..b66caab 100644 --- a/example/desktop_app.py +++ b/example/desktop_app.py @@ -8,7 +8,7 @@ async def main(): # Connects to the 1Password desktop app. client = await Client.authenticate( auth=DesktopAuth( - account_name="YourAccountNameAsItAppearsInTheApp" # Set to your 1Password account name. + account_name="YouAccountNameAsShownInDesktopApp" # Set to your 1Password account name. ), # Set the following to your own integration name and version. integration_name="My 1Password Integration", @@ -22,7 +22,7 @@ async def main(): # [developer-docs.sdk.python.list-vaults]-end # [developer-docs.sdk.python.list-items]-start - overviews = await client.items.list(vault.id) + overviews = await client.items.list(vault_id=vaults[0].id) for overview in overviews: print(overview.title) # [developer-docs.sdk.python.list-items]-end diff --git a/src/onepassword/__init__.py b/src/onepassword/__init__.py index 26d4fcb..473334e 100644 --- a/src/onepassword/__init__.py +++ b/src/onepassword/__init__.py @@ -7,6 +7,7 @@ from .secrets import Secrets from .items import Items from .vaults import Vaults +from .groups import Groups import sys @@ -18,6 +19,7 @@ "Secrets", "Items", "Vaults", + "Groups", "DEFAULT_INTEGRATION_NAME", "DEFAULT_INTEGRATION_VERSION", "DesktopAuth", diff --git a/src/onepassword/client.py b/src/onepassword/client.py index 88f1e72..0b3d319 100644 --- a/src/onepassword/client.py +++ b/src/onepassword/client.py @@ -2,18 +2,20 @@ from __future__ import annotations import weakref -from .core import Core, UniffiCore +from .core import UniffiCore from .desktop_core import DesktopCore from .defaults import new_default_config, DesktopAuth from .secrets import Secrets from .items import Items from .vaults import Vaults +from .groups import Groups class Client: secrets: Secrets items: Items vaults: Vaults + groups: Groups @classmethod async def authenticate( @@ -37,6 +39,8 @@ async def authenticate( authenticated_client.secrets = Secrets(client_id, core) authenticated_client.items = Items(client_id, core) authenticated_client.vaults = Vaults(client_id, core) + authenticated_client.groups = Groups(client_id, core) + authenticated_client._finalizer = weakref.finalize( cls, core.release_client, client_id ) diff --git a/src/onepassword/defaults.py b/src/onepassword/defaults.py index 8e30ba1..1cd626a 100644 --- a/src/onepassword/defaults.py +++ b/src/onepassword/defaults.py @@ -32,7 +32,7 @@ def new_default_config(auth: DesktopAuth | str, integration_name, integration_ve "osVersion": DEFAULT_OS_VERSION, "architecture": platform.machine(), } - if isinstance(auth, str): + if not isinstance(auth, DesktopAuth): client_config_dict["serviceAccountToken"] = auth return client_config_dict diff --git a/src/onepassword/desktop_core.py b/src/onepassword/desktop_core.py index 9ea81a2..a100a43 100644 --- a/src/onepassword/desktop_core.py +++ b/src/onepassword/desktop_core.py @@ -5,7 +5,6 @@ import base64 from pathlib import Path from ctypes import c_uint8, c_size_t, c_int32, POINTER, byref, c_void_p -from .core import UniffiCore from onepassword.errors import raise_typed_exception diff --git a/src/onepassword/groups.py b/src/onepassword/groups.py new file mode 100644 index 0000000..c3f4a7a --- /dev/null +++ b/src/onepassword/groups.py @@ -0,0 +1,34 @@ +# Code generated by op-codegen - DO NO EDIT MANUALLY + +from .core import Core +from pydantic import TypeAdapter +from .types import Group, GroupGetParams + + +class Groups: + """ + The Groups API holds all the operations the SDK client can perform on 1Password groups. + """ + + def __init__(self, client_id, core: Core): + self.client_id = client_id + self.core = core + + async def get(self, group_id: str, group_params: GroupGetParams) -> Group: + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "GroupsGet", + "parameters": { + "group_id": group_id, + "group_params": group_params.model_dump(by_alias=True), + }, + }, + } + } + ) + + response = TypeAdapter(Group).validate_json(response) + return response diff --git a/src/onepassword/items.py b/src/onepassword/items.py index 5c1f190..f25cffa 100644 --- a/src/onepassword/items.py +++ b/src/onepassword/items.py @@ -1,10 +1,19 @@ # Code generated by op-codegen - DO NO EDIT MANUALLY -from typing import Optional, List +from .core import Core +from typing import List from pydantic import TypeAdapter from .items_shares import ItemsShares from .items_files import ItemsFiles -from .types import Item, ItemCreateParams, ItemListFilter, ItemOverview +from .types import ( + Item, + ItemCreateParams, + ItemListFilter, + ItemOverview, + ItemsDeleteAllResponse, + ItemsGetAllResponse, + ItemsUpdateAllResponse, +) class Items: @@ -12,7 +21,7 @@ class Items: The Items API holds all operations the SDK client can perform on 1Password items. """ - def __init__(self, client_id, core): + def __init__(self, client_id, core: Core): self.client_id = client_id self.core = core self.shares = ItemsShares(client_id, core) @@ -37,6 +46,30 @@ async def create(self, params: ItemCreateParams) -> Item: response = TypeAdapter(Item).validate_json(response) return response + async def create_all( + self, vault_id: str, params: List[ItemCreateParams] + ) -> ItemsUpdateAllResponse: + """ + Create items in batch, within a single vault. + """ + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "ItemsCreateAll", + "parameters": { + "vault_id": vault_id, + "params": [o.model_dump(by_alias=True) for o in params], + }, + }, + } + } + ) + + response = TypeAdapter(ItemsUpdateAllResponse).validate_json(response) + return response + async def get(self, vault_id: str, item_id: str) -> Item: """ Get an item by vault and item ID @@ -56,6 +89,25 @@ async def get(self, vault_id: str, item_id: str) -> Item: response = TypeAdapter(Item).validate_json(response) return response + async def get_all(self, vault_id: str, item_ids: List[str]) -> ItemsGetAllResponse: + """ + Get items by vault and their item IDs. + """ + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "ItemsGetAll", + "parameters": {"vault_id": vault_id, "item_ids": item_ids}, + }, + } + } + ) + + response = TypeAdapter(ItemsGetAllResponse).validate_json(response) + return response + async def put(self, item: Item) -> Item: """ Update an existing item. @@ -93,6 +145,27 @@ async def delete(self, vault_id: str, item_id: str) -> None: return None + async def delete_all( + self, vault_id: str, item_ids: List[str] + ) -> ItemsDeleteAllResponse: + """ + Create items in batch, within a single vault. + """ + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "ItemsDeleteAll", + "parameters": {"vault_id": vault_id, "item_ids": item_ids}, + }, + } + } + ) + + response = TypeAdapter(ItemsDeleteAllResponse).validate_json(response) + return response + async def archive(self, vault_id: str, item_id: str) -> None: """ Archive an item. diff --git a/src/onepassword/items_files.py b/src/onepassword/items_files.py index 68d83ff..d8c56ff 100644 --- a/src/onepassword/items_files.py +++ b/src/onepassword/items_files.py @@ -1,13 +1,13 @@ # Code generated by op-codegen - DO NO EDIT MANUALLY from .core import Core -from typing import Optional, List +from typing import List from pydantic import TypeAdapter from .types import DocumentCreateParams, FileAttributes, FileCreateParams, Item class ItemsFiles: - def __init__(self, client_id, core): + def __init__(self, client_id, core: Core): self.client_id = client_id self.core = core diff --git a/src/onepassword/items_shares.py b/src/onepassword/items_shares.py index 31eaada..715630d 100644 --- a/src/onepassword/items_shares.py +++ b/src/onepassword/items_shares.py @@ -1,6 +1,6 @@ # Code generated by op-codegen - DO NO EDIT MANUALLY -from typing import Optional, List +from typing import List from pydantic import TypeAdapter from .types import Item, ItemShareAccountPolicy, ItemShareParams, ValidRecipient diff --git a/src/onepassword/lib/aarch64/libop_uniffi_core.dylib b/src/onepassword/lib/aarch64/libop_uniffi_core.dylib index aed0646..dbc529c 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 bb1a6aa..603d85a 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 06a99e3..d98ae8f 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 1680d0e..82c9070 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 3d15fa3..1ec59a5 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 758a967..ffbd7d5 100644 --- a/src/onepassword/secrets.py +++ b/src/onepassword/secrets.py @@ -1,7 +1,7 @@ # Code generated by op-codegen - DO NO EDIT MANUALLY -from .core import Core -from typing import Optional, List +from .core import Core, UniffiCore +from typing import List from pydantic import TypeAdapter from .types import GeneratePasswordResponse, PasswordRecipe, ResolveAllResponse @@ -12,7 +12,7 @@ class Secrets: Use secret reference URIs to securely load secrets from 1Password: op:///[/]/ """ - def __init__(self, client_id, core): + def __init__(self, client_id, core: Core): self.client_id = client_id self.core = core @@ -59,7 +59,7 @@ def validate_secret_reference(secret_reference: str) -> None: """ Validate the secret reference to ensure there are no syntax errors. """ - response = self.core.invoke_sync( + response = UniffiCore().invoke_sync( { "invocation": { "parameters": { @@ -74,7 +74,7 @@ def validate_secret_reference(secret_reference: str) -> None: @staticmethod def generate_password(recipe: PasswordRecipe) -> GeneratePasswordResponse: - response = self.core.invoke_sync( + response = UniffiCore().invoke_sync( { "invocation": { "parameters": { diff --git a/src/onepassword/types.py b/src/onepassword/types.py index 012fbec..63433d0 100644 --- a/src/onepassword/types.py +++ b/src/onepassword/types.py @@ -140,6 +140,149 @@ class GeneratePasswordResponse(BaseModel): """ +class GroupType(str, Enum): + OWNERS = "owners" + """ + The owners group, which gives the following permissions: + - Do everything the Admin group can do + - See every vault other than the personal vaults + - Change people's names + - See billing + - Change billing + - Make other people owners + - Delete a person + """ + ADMINISTRATORS = "administrators" + """ + The administrators group, which gives the following permissions: + - Perform recovery + - Create new vaults + - Invite new members + - See vault metadata, including the vault name and who has access. + - Make other people admins + """ + RECOVERY = "recovery" + """ + The recovery group. It contains recovery keysets, and is added to every vault to allow for recovery. + + No one is added to this. + """ + EXTERNALACCOUNTMANAGERS = "externalAccountManagers" + """ + The external account managers group or EAM is a mandatory group for managed accounts that has + same permissions as the owners. + """ + TEAMMEMBERS = "teamMembers" + """ + Members of a team that a user is on. + """ + USERDEFINED = "userDefined" + """ + A custom, user defined group. + """ + UNSUPPORTED = "unsupported" + """ + Support for new or renamed group types + """ + + +class GroupState(str, Enum): + ACTIVE = "active" + """ + This group is active + """ + DELETED = "deleted" + """ + This group has been deleted + """ + UNSUPPORTED = "unsupported" + """ + This group is in an unknown state + """ + + +class VaultAccessorType(str, Enum): + USER = "user" + GROUP = "group" + + +class VaultAccess(BaseModel): + """ + Represents the vault access information. + """ + + model_config = ConfigDict(populate_by_name=True) + + vault_uuid: str = Field(alias="vaultUuid") + """ + The vault's UUID. + """ + accessor_type: VaultAccessorType = Field(alias="accessorType") + """ + The vault's accessor type. + """ + accessor_uuid: str = Field(alias="accessorUuid") + """ + The vault's accessor UUID. + """ + permissions: int + """ + The permissions granted to this vault + """ + + +class Group(BaseModel): + model_config = ConfigDict(populate_by_name=True) + + id: str + title: str + description: str + group_type: GroupType = Field(alias="groupType") + state: GroupState + vault_access: Optional[List[VaultAccess]] = Field(alias="vaultAccess", default=None) + + +class GroupAccess(BaseModel): + """ + Represents a group's access to a 1Password vault. + This is used for granting permissions + """ + + group_id: str + """ + The group's ID + """ + permissions: int + """ + The group's set of permissions for the vault + """ + + +class GroupGetParams(BaseModel): + model_config = ConfigDict(populate_by_name=True) + + vault_permissions: Optional[bool] = Field(alias="vaultPermissions", default=None) + + +class GroupVaultAccess(BaseModel): + """ + Represents a group's access to a 1Password vault. + """ + + vault_id: str + """ + The vault's ID + """ + group_id: str + """ + The group's ID + """ + permissions: int + """ + The group's set of permissions for the vault + """ + + class ItemCategory(str, Enum): LOGIN = "Login" SECURENOTE = "SecureNote" @@ -717,6 +860,147 @@ class ItemShareParams(BaseModel): """ +class Response(BaseModel, Generic[T, E]): + content: Optional[T] = Field(default=None) + error: Optional[E] = Field(default=None) + + +class ItemUpdateFailureReasonTypes(str, Enum): + ITEM_VALIDATION_ERROR = "itemValidationError" + ITEM_STATUS_PERMISSION_ERROR = "itemStatusPermissionError" + ITEM_STATUS_INCORRECT_ITEM_VERSION = "itemStatusIncorrectItemVersion" + ITEM_STATUS_FILE_NOT_FOUND = "itemStatusFileNotFound" + ITEM_STATUS_TOO_BIG = "itemStatusTooBig" + ITEM_NOT_FOUND = "itemNotFound" + INTERNAL = "internal" + + +class ItemUpdateFailureReasonItemValidationError(BaseModel): + """ + Item update operation failed due to bad user input. + """ + + type: Literal[ItemUpdateFailureReasonTypes.ITEM_VALIDATION_ERROR] = ( + ItemUpdateFailureReasonTypes.ITEM_VALIDATION_ERROR + ) + message: ErrorMessage + + +class ItemUpdateFailureReasonItemStatusPermissionError(BaseModel): + """ + Item update operation is forbidden, permission issue. Make sure you have the correct permissions to update items in this vault. + """ + + type: Literal[ItemUpdateFailureReasonTypes.ITEM_STATUS_PERMISSION_ERROR] = ( + ItemUpdateFailureReasonTypes.ITEM_STATUS_PERMISSION_ERROR + ) + + +class ItemUpdateFailureReasonItemStatusIncorrectItemVersion(BaseModel): + """ + Item update operation failed due to incorrect version. + """ + + type: Literal[ItemUpdateFailureReasonTypes.ITEM_STATUS_INCORRECT_ITEM_VERSION] = ( + ItemUpdateFailureReasonTypes.ITEM_STATUS_INCORRECT_ITEM_VERSION + ) + + +class ItemUpdateFailureReasonItemStatusFileNotFound(BaseModel): + """ + Item update operation failed because a file reference didn't match a known file. + """ + + type: Literal[ItemUpdateFailureReasonTypes.ITEM_STATUS_FILE_NOT_FOUND] = ( + ItemUpdateFailureReasonTypes.ITEM_STATUS_FILE_NOT_FOUND + ) + + +class ItemUpdateFailureReasonItemStatusTooBig(BaseModel): + """ + Item update request is too big to be sent to the server. + """ + + type: Literal[ItemUpdateFailureReasonTypes.ITEM_STATUS_TOO_BIG] = ( + ItemUpdateFailureReasonTypes.ITEM_STATUS_TOO_BIG + ) + + +class ItemUpdateFailureReasonItemNotFound(BaseModel): + """ + The item was not found + """ + + type: Literal[ItemUpdateFailureReasonTypes.ITEM_NOT_FOUND] = ( + ItemUpdateFailureReasonTypes.ITEM_NOT_FOUND + ) + + +class ItemUpdateFailureReasonInternal(BaseModel): + """ + Item update operation experienced an internal error. + """ + + type: Literal[ItemUpdateFailureReasonTypes.INTERNAL] = ( + ItemUpdateFailureReasonTypes.INTERNAL + ) + message: ErrorMessage + + +ItemUpdateFailureReason = Union[ + ItemUpdateFailureReasonItemValidationError, + ItemUpdateFailureReasonItemStatusPermissionError, + ItemUpdateFailureReasonItemStatusIncorrectItemVersion, + ItemUpdateFailureReasonItemStatusFileNotFound, + ItemUpdateFailureReasonItemStatusTooBig, + ItemUpdateFailureReasonItemNotFound, + ItemUpdateFailureReasonInternal, +] + + +class ItemsDeleteAllResponse(BaseModel): + model_config = ConfigDict(populate_by_name=True) + + individual_responses: Dict[str, Response[None, ItemUpdateFailureReason]] = Field( + alias="individualResponses" + ) + + +class ItemsGetAllErrorTypes(str, Enum): + ITEM_NOT_FOUND = "itemNotFound" + INTERNAL = "internal" + + +class ItemsGetAllErrorItemNotFound(BaseModel): + type: Literal[ItemsGetAllErrorTypes.ITEM_NOT_FOUND] = ( + ItemsGetAllErrorTypes.ITEM_NOT_FOUND + ) + + +class ItemsGetAllErrorInternal(BaseModel): + type: Literal[ItemsGetAllErrorTypes.INTERNAL] = ItemsGetAllErrorTypes.INTERNAL + message: ErrorMessage + + +ItemsGetAllError = Union[ItemsGetAllErrorItemNotFound, ItemsGetAllErrorInternal] + + +class ItemsGetAllResponse(BaseModel): + model_config = ConfigDict(populate_by_name=True) + + individual_responses: List[Response[Item, ItemsGetAllError]] = Field( + alias="individualResponses" + ) + + +class ItemsUpdateAllResponse(BaseModel): + model_config = ConfigDict(populate_by_name=True) + + individual_responses: List[Response[Item, ItemUpdateFailureReason]] = Field( + alias="individualResponses" + ) + + class OtpFieldDetails(BaseModel): """ Additional attributes for OTP fields. @@ -734,11 +1018,6 @@ class OtpFieldDetails(BaseModel): """ -class Response(BaseModel, Generic[T, E]): - content: Optional[T] = Field(default=None) - error: Optional[E] = Field(default=None) - - class ResolvedReference(BaseModel): model_config = ConfigDict(populate_by_name=True) @@ -971,20 +1250,110 @@ class SshKeyAttributes(BaseModel): """ +class VaultType(str, Enum): + """ + Represents the vault type. + """ + + PERSONAL = "personal" + EVERYONE = "everyone" + TRANSFER = "transfer" + USERCREATED = "userCreated" + UNSUPPORTED = "unsupported" + + +class Vault(BaseModel): + """ + Represents regular vault information together with the vault's access information. + """ + + model_config = ConfigDict(populate_by_name=True) + + id: str + """ + The vault's ID. + """ + title: str + """ + The vault's title. + """ + description: str + """ + The description of the vault. + """ + vault_type: VaultType = Field(alias="vaultType") + """ + The type of the vault. + """ + active_item_count: int = Field(alias="activeItemCount") + """ + The number of active items within the vault. + """ + content_version: int = Field(alias="contentVersion") + """ + The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated). + """ + attribute_version: int = Field(alias="attributeVersion") + """ + The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its title or icon. + """ + access: Optional[List[VaultAccess]] = Field(default=None) + """ + The access information associated with the vault. + """ + + +class VaultGetParams(BaseModel): + """ + Represents the possible query parameters used for retrieving extra information about a vault. + """ + + accessors: Optional[bool] = Field(default=None) + """ + The vault's accessor params. + """ + + +class VaultListParams(BaseModel): + model_config = ConfigDict(populate_by_name=True) + + decrypt_details: Optional[bool] = Field(alias="decryptDetails", default=None) + + class VaultOverview(BaseModel): """ - Represents a decrypted 1Password vault. + Holds information about a 1Password Vault. """ model_config = ConfigDict(populate_by_name=True) id: str """ - The vault's ID + The vault's ID. """ title: str """ - The vault's title + The vault's title. + """ + description: str + """ + The description of this vault. + """ + vault_type: VaultType = Field(alias="vaultType") + """ + The type of the vault. + """ + active_item_count: int = Field(alias="activeItemCount") + """ + The number of active items within the vault. + """ + content_version: int = Field(alias="contentVersion") + """ + The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated). + """ + attribute_version: int = Field(alias="attributeVersion") + """ + The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its title or icon. """ created_at: Annotated[ datetime, @@ -1160,7 +1529,18 @@ class WordListType(str, Enum): Three (random) letter "words" """ -class VaultListParams(BaseModel): - model_config = ConfigDict(populate_by_name=True) - decrypt_details: Optional[bool] = Field(alias="decryptDetails", default=None) +ARCHIVE_ITEMS: int = 256 +CREATE_ITEMS: int = 128 +DELETE_ITEMS: int = 512 +EXPORT_ITEMS: int = 4194304 +IMPORT_ITEMS: int = 2097152 +MANAGE_VAULT: int = 2 +NO_ACCESS: int = 0 +PRINT_ITEMS: int = 8388608 +READ_ITEMS: int = 32 +RECOVER_VAULT: int = 1 +REVEAL_ITEM_PASSWORD: int = 16 +SEND_ITEMS: int = 1048576 +UPDATE_ITEMS: int = 64 +UPDATE_ITEM_HISTORY: int = 1024 diff --git a/src/onepassword/vaults.py b/src/onepassword/vaults.py index f851fa5..45ff05a 100644 --- a/src/onepassword/vaults.py +++ b/src/onepassword/vaults.py @@ -3,7 +3,14 @@ from .core import Core from typing import Optional, List from pydantic import TypeAdapter -from .types import VaultOverview, VaultListParams +from .types import ( + GroupAccess, + GroupVaultAccess, + Vault, + VaultGetParams, + VaultListParams, + VaultOverview, +) class Vaults: @@ -11,22 +18,120 @@ class Vaults: The Vaults API holds all the operations the SDK client can perform on 1Password vaults. """ - def __init__(self, client_id, core): + def __init__(self, client_id, core: Core): self.client_id = client_id self.core = core async def list(self, params: Optional[VaultListParams] = None) -> List[VaultOverview]: """ - List all vaults + List information about vaults that's configurable based on some input parameters. """ response = await self.core.invoke( { "invocation": { "clientId": self.client_id, - "parameters": {"name": "VaultsList", "parameters": {"params": params.model_dump(by_alias=True) if params else {}}}, + "parameters": { + "name": "VaultsList", + "parameters": {"params": params.model_dump(by_alias=True) if params else None}, + }, } } ) response = TypeAdapter(List[VaultOverview]).validate_json(response) return response + + async def get_overview(self, vault_uuid: str) -> VaultOverview: + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "VaultsGetOverview", + "parameters": {"vault_uuid": vault_uuid}, + }, + } + } + ) + + response = TypeAdapter(VaultOverview).validate_json(response) + return response + + async def get(self, vault_uuid: str, vault_params: VaultGetParams) -> Vault: + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "VaultsGet", + "parameters": { + "vault_uuid": vault_uuid, + "vault_params": vault_params.model_dump(by_alias=True), + }, + }, + } + } + ) + + response = TypeAdapter(Vault).validate_json(response) + return response + + async def grant_group_permissions( + self, vault_id: str, group_permissions_list: List[GroupAccess] + ) -> None: + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "VaultsGrantGroupPermissions", + "parameters": { + "vault_id": vault_id, + "group_permissions_list": [ + o.model_dump(by_alias=True) + for o in group_permissions_list + ], + }, + }, + } + } + ) + + return None + + async def update_group_permissions( + self, group_permissions_list: List[GroupVaultAccess] + ) -> None: + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "VaultsUpdateGroupPermissions", + "parameters": { + "group_permissions_list": [ + o.model_dump(by_alias=True) + for o in group_permissions_list + ] + }, + }, + } + } + ) + + return None + + async def revoke_group_permissions(self, vault_id: str, group_id: str) -> None: + response = await self.core.invoke( + { + "invocation": { + "clientId": self.client_id, + "parameters": { + "name": "VaultsRevokeGroupPermissions", + "parameters": {"vault_id": vault_id, "group_id": group_id}, + }, + } + } + ) + + return None