Freigeben über


UserProxy Class

An interface to interact with a specific user.

This class should not be instantiated directly. Instead, use the get_user_client method.

Inheritance
builtins.object
UserProxy

Constructor

UserProxy(client_connection: CosmosClientConnection, id: str, database_link: str, properties: Dict[str, Any] | None = None)

Parameters

Name Description
client_connection
Required
id
Required
database_link
Required
properties
Default value: None

Variables

Name Description
id
str
user_link
str

Methods

create_permission

Create a permission for the user.

To update or replace an existing permission, use the upsert_permission method.

delete_permission

Delete the specified permission from the user.

If the permission does not already exist, an exception is raised.

get_permission

Get the permission identified by id.

list_permissions

List all permission for the user.

query_permissions

Return all permissions matching the given query.

read

Read user properties.

replace_permission

Replaces the specified permission if it exists for the user.

If the permission does not already exist, an exception is raised.

upsert_permission

Insert or update the specified permission.

If the permission already exists in the container, it is replaced. If the permission does not exist, it is inserted.

create_permission

Create a permission for the user.

To update or replace an existing permission, use the upsert_permission method.

async create_permission(body: Dict[str, Any], **kwargs: Any) -> Permission

Parameters

Name Description
body
Required

A dict-like object representing the permission to create.

Keyword-Only Parameters

Name Description
response_hook

A callable invoked with the response metadata.

Returns

Type Description

A permission object representing the new permission.

Exceptions

Type Description

If the given permission couldn't be created.

delete_permission

Delete the specified permission from the user.

If the permission does not already exist, an exception is raised.

async delete_permission(permission: str | Mapping[str, Any] | Permission, **kwargs: Any) -> None

Parameters

Name Description
permission
Required

The ID (name), dict representing the properties or <xref:azure.cosmos.aio.Permission> instance of the permission to be deleted.

Keyword-Only Parameters

Name Description
response_hook

A callable invoked with the response metadata.

Returns

Type Description

Exceptions

Type Description

The permission wasn't deleted successfully.

The permission does not exist for the user.

get_permission

Get the permission identified by id.

async get_permission(permission: str | Mapping[str, Any] | Permission, **kwargs: Any) -> Permission

Parameters

Name Description
permission
Required

The ID (name), dict representing the properties or <xref:azure.cosmos.aio.Permission> instance of the permission to be retrieved.

Keyword-Only Parameters

Name Description
response_hook

A callable invoked with the response metadata.

Returns

Type Description

The retrieved permission object.

Exceptions

Type Description

If the given permission couldn't be retrieved.

list_permissions

List all permission for the user.

list_permissions(*, max_item_count: int | None = None, **kwargs: Any) -> AsyncItemPaged[Dict[str, Any]]

Keyword-Only Parameters

Name Description
max_item_count
int

Max number of permissions to be returned in the enumeration operation.

response_hook
Callable[[Dict[str, str], <xref:AsyncItemPaged>[Dict[str, Any]], None]

A callable invoked with the response metadata.

Returns

Type Description
<xref:AsyncItemPaged>[Dict[str, Any]]

An AsyncItemPaged of permissions (dicts).

Exceptions

Type Description

If the given permission couldn't be created.

query_permissions

Return all permissions matching the given query.

query_permissions(query: str, *, parameters: List[Dict[str, Any]] | None = None, max_item_count: int | None = None, **kwargs: Any) -> AsyncItemPaged[Dict[str, Any]]

Parameters

Name Description
query
Required
str

The Azure Cosmos DB SQL query to execute.

Keyword-Only Parameters

Name Description
parameters

Optional array of parameters to the query. Ignored if no query is provided.

max_item_count
int

Max number of permissions to be returned in the enumeration operation.

response_hook
Callable[[Dict[str, str], <xref:AsyncItemPaged>[Dict[str, Any]]], None]

A callable invoked with the response metadata.

Returns

Type Description
<xref:AsyncItemPaged>[Dict[str, Any]]

An AsyncItemPaged of permissions (dicts).

Exceptions

Type Description

If the given permission couldn't be created.

read

Read user properties.

async read(**kwargs: Any) -> Dict[str, Any]

Keyword-Only Parameters

Name Description
response_hook

A callable invoked with the response metadata.

Returns

Type Description

A dictionary of the retrieved user properties.

Exceptions

Type Description

If the given user couldn't be retrieved.

replace_permission

Replaces the specified permission if it exists for the user.

If the permission does not already exist, an exception is raised.

async replace_permission(permission: str | Mapping[str, Any] | Permission, body: Dict[str, Any], **kwargs: Any) -> Permission

Parameters

Name Description
permission
Required

The ID (name), dict representing the properties or <xref:azure.cosmos.aio.Permission> instance of the permission to be replaced.

body
Required

A dict-like object representing the permission to replace.

Keyword-Only Parameters

Name Description
response_hook

A callable invoked with the response metadata.

Returns

Type Description

A permission object representing the permission after the replace operation went through.

Exceptions

Type Description

If the replace operation failed or the permission with given id does not exist.

upsert_permission

Insert or update the specified permission.

If the permission already exists in the container, it is replaced. If the permission does not exist, it is inserted.

async upsert_permission(body: Dict[str, Any], **kwargs: Any) -> Permission

Parameters

Name Description
body
Required

A dict-like object representing the permission to update or insert.

Keyword-Only Parameters

Name Description
response_hook

A callable invoked with the response metadata.

Returns

Type Description

A dict representing the upserted permission.

Exceptions

Type Description

If the given permission could not be upserted.