permit.api.roles.create()
Creates a new role.
Parameters
roleData
- An object that contains the information about the new role. The payload is defined below.
Payload
key
- A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role.
name
- The name of the role.
description
- optional - The description string explaining what this role represents, or what permissions are granted to it.
permissions
- optional - The list of action keys that define what actions this resource role is permitted to do.
Implementation
import io.permit.sdk.openapi.models.RoleCreate;
import io.permit.sdk.openapi.models.RoleRead;
RoleRead admin = permit.api.roles.create(
new RoleCreate("admin","Admin")
.withDescription("an admin role")
.withPermissions(
new ArrayList<>(Arrays.asList("document:create", "document:read"))
)
);