nocobase/docs/en-US/api/acl/acl-resource.md

60 lines
1.4 KiB
Markdown
Raw Normal View History

# ACLResource
2023-02-18 15:32:09 +00:00
ACLResource is the resource class in ACL system. In ACL systems, the corresponding resource is created automatically when granting permission to user.
2023-02-18 15:32:09 +00:00
## Class Methods
### `constructor()`
2023-02-18 15:32:09 +00:00
Constructor.
**Signature**
* `constructor(options: AclResourceOptions)`
2023-02-18 15:32:09 +00:00
**Type**
```typescript
type ResourceActions = { [key: string]: RoleActionParams };
interface AclResourceOptions {
2023-02-18 15:32:09 +00:00
name: string; // Name of the resource
role: ACLRole; // Role to which the resource belongs
actions?: ResourceActions;
}
```
2023-02-18 15:32:09 +00:00
**Detailed Information**
2023-02-18 15:32:09 +00:00
Refer to [`aclRole.grantAction`](./acl-role.md#grantaction) for details about `RoleActionParams`.
### `getActions()`
2023-02-18 15:32:09 +00:00
Get all actions of the resource, the return is `ResourceActions` object.
### `getAction()`
2023-02-18 15:32:09 +00:00
Get the parameter configuration of the action by name, the return is `RoleActionParams` object.
**Detailed Information**
2023-02-18 15:32:09 +00:00
Refer to [`aclRole.grantAction`](./acl-role.md#grantaction) for
`RoleActionParams`.
### `setAction()`
2023-02-18 15:32:09 +00:00
Set the parameter configuration of an action inside the resource, the return is `RoleActionParams` object.
2023-02-18 15:32:09 +00:00
**Signature**
* `setAction(name: string, params: RoleActionParams)`
2023-02-18 15:32:09 +00:00
**Detailed Information**
2023-02-18 15:32:09 +00:00
* name - Name of the action to set
* Refer to [`aclRole.grantAction`](./acl-role.md#grantaction) for details about `RoleActionParams`.
### `setActions()`
2023-02-18 15:32:09 +00:00
**Signature**
* `setActions(actions: ResourceActions)`
2023-02-18 15:32:09 +00:00
A shortcut for calling `setAction` in batches.