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 permision, 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 permision, use the upsert_permission method.

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 dict 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.

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

Parameters

Name Description
permission
Required

The ID (name), dict representing the properties or Permission instance of the permission to be replaced.

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.

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

Parameters

Name Description
permission
Required

The ID (name), dict representing the properties or 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

A dict representing the retrieved permission.

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) -> ItemPaged[Dict[str, Any]]

Parameters

Name Description
max_item_count
Required
int

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

Keyword-Only Parameters

Name Description
response_hook

A callable invoked with the response metadata.

Returns

Type Description

An Iterable 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) -> ItemPaged[Dict[str, Any]]

Parameters

Name Description
query
Required
str

The Azure Cosmos DB SQL query to execute.

parameters
Required

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

max_item_count
Required
int

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

Keyword-Only Parameters

Name Description
response_hook

A callable invoked with the response metadata.

Returns

Type Description

An Iterable of permissions (dicts).

Exceptions

Type Description

If the given permission couldn't be created.

read

Read user properties.

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.

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

Parameters

Name Description
permission
Required

The ID (name), dict representing the properties or 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 dict representing the permission after replace 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.

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.