Class RolesEntity

java.lang.Object
com.auth0.client.mgmt.RolesEntity

public class RolesEntity extends Object
Class that provides an implementation of the Roles methods of the Management API as defined in https://auth0.com/docs/api/management/v2#!/Roles/

This class is not thread-safe.

See Also:
  • Field Details

    • client

      protected final Auth0HttpClient client
    • baseUrl

      protected final okhttp3.HttpUrl baseUrl
    • tokenProvider

      protected final TokenProvider tokenProvider
  • Method Details

    • list

      public Request<RolesPage> list(RolesFilter filter)
      Request all Roles created by this tenant that can be assigned to a given user or user group. A token with read:roles is needed See https://auth0.com/docs/api/management/v2#!/Roles/get_roles
      Parameters:
      filter - optional filtering and pagination criteria
      Returns:
      a Request to execute
    • get

      public Request<Role> get(String roleId)
      Get a single role created by this tenant that can be assigned to a given user or user group. A token with scope read:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/get_roles_by_id
      Parameters:
      roleId - the id of the user to retrieve.
      Returns:
      a Request to execute.
    • create

      public Request<Role> create(Role role)
      Create a Role. A token with scope create:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/post_roles
      Parameters:
      role - the role data to set
      Returns:
      a Request to execute.
    • delete

      public Request<Void> delete(String roleId)
      Delete an existing Role. A token with scope delete:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/delete_roles_by_id
      Parameters:
      roleId - The id of the role to delete.
      Returns:
      a Request to execute.
    • update

      public Request<Role> update(String roleId, Role role)
      Update an existing Role. A token with scope update:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/patch_roles_by_id
      Parameters:
      roleId - the role id
      role - the role data to set. It can't include id.
      Returns:
      a Request to execute.
    • listUsers

      public Request<UsersPage> listUsers(String roleId, PageFilter filter)
      Lists the users that have been associated with a given role. A token with scope read:users and read:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/get_role_user
      Parameters:
      roleId - the role id
      filter - an optional pagination filter
      Returns:
      a Request to execute
    • assignUsers

      public Request<Void> assignUsers(String roleId, List<String> userIds)
      Assign users to a role. A token with update:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/post_role_users
      Parameters:
      roleId - the role id
      userIds - a list of user ids to assign to the role
      Returns:
      a Request to execute.
    • listPermissions

      public Request<PermissionsPage> listPermissions(String roleId, PageFilter filter)
      Get the permissions associated to the role. A token with read:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/get_permissions
      Parameters:
      roleId - the role id
      filter - an optional pagination filter
      Returns:
      a Request to execute
    • removePermissions

      public Request<Void> removePermissions(String roleId, List<Permission> permissions)
      Un-associate permissions from a role. A token with update:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/delete_role_permission_assignment
      Parameters:
      roleId - the role id
      permissions - a list of permission objects to un-associate from the role
      Returns:
      a Request to execute
    • addPermissions

      public Request<Void> addPermissions(String roleId, List<Permission> permissions)
      Associate permissions with a role. Only the `permission_name` and `resource_server_identifier` Permission attributes should be specified. A token with update:roles is needed. See https://auth0.com/docs/api/management/v2#!/Roles/post_role_permission_assignment
      Parameters:
      roleId - the role id
      permissions - a list of permission objects to associate to the role
      Returns:
      a Request to execute
    • voidRequest

      protected Request<Void> voidRequest(HttpMethod method, Consumer<com.auth0.client.mgmt.RequestBuilder<Void>> customizer)
    • request

      protected <T> Request<T> request(HttpMethod method, com.fasterxml.jackson.core.type.TypeReference<T> target, Consumer<com.auth0.client.mgmt.RequestBuilder<T>> customizer)