UserProxy Class
An interface to interact with a specific user.
This class should not be instantiated directly. Instead, use the <xref:DatabaseProxy.get_user_client> method.
- Inheritance
-
builtins.objectUserProxy
Constructor
UserProxy(client_connection: azure.cosmos._cosmos_client_connection.CosmosClientConnection, id: str, database_link: str, properties: Optional[Dict[str, Any]] = None)
Parameters
- client_connection
- id
- database_link
- properties
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 propertes. |
| 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) -> azure.cosmos.permission.Permission
Parameters
- body
A dict-like object representing the permission to create.
- response_hook
- <xref:Callable>
A callable invoked with the response metadata.
Returns
A dict representing the new permission.
Return type
Exceptions
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, **kwargs: Any) -> None
Parameters
- permission
The ID (name), dict representing the properties or <xref:azure.cosmos.user.Permission> instance of the permission to be replaced.
- response_hook
- <xref:Callable>
A callable invoked with the response metadata.
Return type
Exceptions
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, **kwargs: Any) -> azure.cosmos.permission.Permission
Parameters
- permission
The ID (name), dict representing the properties or <xref:azure.cosmos.user.Permission> instance of the permission to be retrieved.
- response_hook
- <xref:Callable>
A callable invoked with the response metadata.
Returns
A dict representing the retrieved permission.
Return type
Exceptions
If the given permission couldn't be retrieved.
list_permissions
List all permission for the user.
list_permissions(max_item_count: Optional[int] = None, **kwargs: Any) -> Iterable[Dict[str, Any]]
Parameters
- max_item_count
Max number of permissions to be returned in the enumeration operation.
- response_hook
- <xref:Callable>
A callable invoked with the response metadata.
Returns
An Iterable of permissions (dicts).
Return type
Exceptions
If the given permission couldn't be created.
query_permissions
Return all permissions matching the given query.
query_permissions(query: str, parameters: Optional[List[str]] = None, max_item_count: Optional[int] = None, **kwargs: Any) -> Iterable[Dict[str, Any]]
Parameters
- query
The Azure Cosmos DB SQL query to execute.
- parameters
Optional array of parameters to the query. Ignored if no query is provided.
- max_item_count
Max number of permissions to be returned in the enumeration operation.
- response_hook
- <xref:Callable>
A callable invoked with the response metadata.
Returns
An Iterable of permissions (dicts).
Return type
Exceptions
If the given permission couldn't be created.
read
Read user propertes.
read(**kwargs: Any) -> Dict[str, Any]
Parameters
- response_hook
- <xref:Callable>
A callable invoked with the response metadata.
Returns
A dictionary of the retrieved user properties.
Return type
Exceptions
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, body: Dict[str, Any], **kwargs: Any) -> azure.cosmos.permission.Permission
Parameters
- permission
The ID (name), dict representing the properties or <xref:azure.cosmos.user.Permission> instance of the permission to be replaced.
- body
A dict-like object representing the permission to replace.
- response_hook
- <xref:Callable>
A callable invoked with the response metadata.
Returns
A dict representing the permission after replace went through.
Return type
Exceptions
If the replace 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) -> azure.cosmos.permission.Permission
Parameters
- body
A dict-like object representing the permission to update or insert.
- response_hook
- <xref:Callable>
A callable invoked with the response metadata.
Returns
A dict representing the upserted permission.
Return type
Exceptions
If the given permission could not be upserted.
Feedback
Submit and view feedback for