RevokePrivilege()
Revokes a privilege from a role.
pub async fn revoke_privilege(&self, request: RevokePrivilegeRequest) -> Result<()>
Collection-scoped revokes use the v2 privilege RPC; revokes configured with the legacy object_type/object_name surface use the v1 OperatePrivilege RPC. The two surfaces are mutually exclusive.
Request Syntax
let request = RevokePrivilegeRequest::builder()
.role_name("analyst")
.database_name("default")
.collection_name("books")
.privilege("Search")
.build()?;
REQUEST FIELDS:
role_name: StringName of the role losing the privilege. Required.
database_name: StringDatabase that owns the target resource. Required.
collection_name: StringName of the collection the privilege applies to. Required unless the legacy
object_type/object_namesurface is used.privilege: StringName of the privilege to revoke, for example
Search,Query, orInsert. Required.object_type: Option<String>Legacy v1 object type, for example
UserorGlobal. Must be paired withobject_name; mutually exclusive withcollection_name.object_name: Option<String>Legacy v1 object name. Must be paired with
object_type; mutually exclusive withcollection_name.
RETURN TYPE:
Result<()>
RETURNS:
Returns Ok(()) on success; returns an Error on failure.
Example
let request = RevokePrivilegeRequest::builder()
.role_name("analyst")
.database_name("default")
.collection_name("books")
.privilege("Search")
.build()?;
client.revoke_privilege(request).await?;