Permission class
Use to read, replace, or delete a given Permission by id.
See Permissions to create, upsert, query, or read all Permissions.
Methods
delete(Request |
Delete the given Permission. Example
|
read(Request |
Read the PermissionDefinition of the given Permission. Example
|
replace(Permission |
Replace the given Permission with the specified PermissionDefinition. Example
|
Property Details
id
id: string
Property Value
string
url
Returns a reference URL to the resource. Used for linking in Permissions.
string url
Property Value
string
user
Method Details
delete(RequestOptions)
Delete the given Permission.
Example
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const user = database.user("<user-id>");
await user.permission("<permission-id>").delete();
function delete(options?: RequestOptions): Promise<PermissionResponse>
Parameters
- options
- RequestOptions
Returns
Promise<PermissionResponse>
read(RequestOptions)
Read the PermissionDefinition of the given Permission.
Example
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const user = database.user("<user-id>");
const { resource: permission } = await user.permission("<permission-id>").read();
function read(options?: RequestOptions): Promise<PermissionResponse>
Parameters
- options
- RequestOptions
Returns
Promise<PermissionResponse>
replace(PermissionDefinition, RequestOptions)
Replace the given Permission with the specified PermissionDefinition.
Example
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const user = database.user("<user-id>");
const { resource: permission } = await user.permission("<permission-id>").read();
permission.resource = "<new-resource-url>";
await user.permission("<permission-id>").replace(permission);
function replace(body: PermissionDefinition, options?: RequestOptions): Promise<PermissionResponse>
Parameters
- body
- PermissionDefinition
The specified PermissionDefinition.
- options
- RequestOptions
Returns
Promise<PermissionResponse>