@folderharbor/sdk
    Preparing search index...

    Methods for reading, listing, and updating roles and their permission and ACL grants.

    Constructors

    Methods

    • Creates a new role.

      Parameters

      • body: FHCreateRole

        The name, and optionally ACLs and permissions, for the new role

      Returns Promise<{ id: number }>

      The new role's ID

      roles:create

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const { id } = await client.admin.roles.create({ name: "testing", acls: [2, 3], permissions: ["logs:read", "config:read"] });
      
    • Deletes a role.

      Parameters

      • roleID: number

        The role's ID

      Returns Promise<void>

      roles:delete

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      await client.admin.roles.delete(2);
      
    • Edits a role's information.

      Note that editing permissions and/or ACLs here overwrites them on the role! If you don't know the existing state of these to properly merge your changes, I suggest using grant instead.

      Parameters

      • roleID: number

        The role's ID

      • body: FHEditRole

        The parts of the role to alter

      Returns Promise<void>

      roles:edit

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      await client.admin.roles.edit(2, { name: "auditor", permissions: ["logs:read"], acls: [1] });
      
    • Gets a role's info from its ID.

      Parameters

      • roleID: number

        The role's ID

      Returns Promise<FHRole>

      The role's information/details

      roles:read

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const role = await client.admin.roles.get(1);
      
    • Grants and revokes ACLs and permissions on a role.

      This is intended for cases where you don't already know the current state of these values (such as in a CLI), as it does not overwrite. If you do know them (such as in a web panel), see edit instead.

      Parameters

      • roleID: number

        The role's ID

      • body: FHGrantToRole

        An array of grantable objects using their IDs, types, and whether to grant or revoke the object

      Returns Promise<void>

      roles:edit

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const grants: FHGrantToRole = [
      { id: 2, type: "acl", revoke: false },
      { id: "config:write", type: "permission", revoke: true }
      ];
      await client.admin.roles.grant(2, grants);
    • Gets the list of roles and their IDs.

      Returns Promise<FHRoleList>

      A list of roles with their corresponding IDs

      roles:list

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const roles = await client.admin.roles.list();