2022-10-31 03:52:17 +00:00
|
|
|
# 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.
|
2022-10-31 03:52:17 +00:00
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
## Class Methods
|
2022-10-31 03:52:17 +00:00
|
|
|
|
|
|
|
### `constructor()`
|
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
Constructor.
|
|
|
|
|
|
|
|
**Signature**
|
2022-10-31 03:52:17 +00:00
|
|
|
* `constructor(options: AclResourceOptions)`
|
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
**Type**
|
2022-10-31 03:52:17 +00:00
|
|
|
```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
|
2022-10-31 03:52:17 +00:00
|
|
|
actions?: ResourceActions;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
**Detailed Information**
|
2022-10-31 03:52:17 +00:00
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
Refer to [`aclRole.grantAction`](./acl-role.md#grantaction) for details about `RoleActionParams`.
|
2022-10-31 03:52:17 +00:00
|
|
|
|
|
|
|
### `getActions()`
|
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
Get all actions of the resource, the return is `ResourceActions` object.
|
2022-10-31 03:52:17 +00:00
|
|
|
|
|
|
|
### `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**
|
2022-10-31 03:52:17 +00:00
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
Refer to [`aclRole.grantAction`](./acl-role.md#grantaction) for
|
|
|
|
`RoleActionParams`.
|
2022-10-31 03:52:17 +00:00
|
|
|
|
|
|
|
### `setAction()`
|
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
Set the parameter configuration of an action inside the resource, the return is `RoleActionParams` object.
|
2022-10-31 03:52:17 +00:00
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
**Signature**
|
2022-10-31 03:52:17 +00:00
|
|
|
* `setAction(name: string, params: RoleActionParams)`
|
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
**Detailed Information**
|
2022-10-31 03:52:17 +00:00
|
|
|
|
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`.
|
2022-10-31 03:52:17 +00:00
|
|
|
|
|
|
|
### `setActions()`
|
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
**Signature**
|
2022-10-31 03:52:17 +00:00
|
|
|
* `setActions(actions: ResourceActions)`
|
|
|
|
|
2023-02-18 15:32:09 +00:00
|
|
|
A shortcut for calling `setAction` in batches.
|