org.keycloak.services.resources.admin

## Class RoleContainerResource

- java.lang.Object
- - org.keycloak.services.resources.admin.RoleResource
  - - org.keycloak.services.resources.admin.RoleContainerResource

-     public class RoleContainerResource
      extends RoleResource

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AdminPermissionEvaluator` | `auth`
    `protected RoleContainerModel` | `roleContainer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RoleContainerResource(KeycloakSession session, javax.ws.rs.core.UriInfo uriInfo, RealmModel realm, AdminPermissionEvaluator auth, RoleContainerModel roleContainer, AdminEventBuilder adminEvent)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addComposites(String roleName, List<RoleRepresentation> roles)` Add a composite to the role
    `javax.ws.rs.core.Response` | `createRole(RoleRepresentation rep)` Create a new role for the realm or client
    `void` | `deleteComposites(String roleName, List<RoleRepresentation> roles)` Remove roles from the role's composite
    `void` | `deleteRole(String roleName)` Delete a role by name
    `Stream<RoleRepresentation>` | `getClientRoleComposites(String roleName, String clientUuid)` Get client-level roles for the client that are in the role's composite
    `Stream<GroupRepresentation>` | `getGroupsInRole(String roleName, Integer firstResult, Integer maxResults, boolean briefRepresentation)` Returns a stream of groups that have the specified role name
    `ManagementPermissionReference` | `getManagementPermissions(String roleName)` Return object stating whether role Authorization permissions have been initialized or not and a reference
    `Stream<RoleRepresentation>` | `getRealmRoleComposites(String roleName)` Get realm-level roles of the role's composite
    `RoleRepresentation` | `getRole(String roleName)` Get a role by name
    `Stream<RoleRepresentation>` | `getRoleComposites(String roleName)` Get composites of the role
    `Stream<RoleRepresentation>` | `getRoles(String search, Integer firstResult, Integer maxResults, boolean briefRepresentation)` Get all roles for the realm or client
    `Stream<UserRepresentation>` | `getUsersInRole(String roleName, Integer firstResult, Integer maxResults)` Returns a stream of users that have the specified role name.
    `ManagementPermissionReference` | `setManagementPermissionsEnabled(String roleName, ManagementPermissionReference ref)` Return object stating whether role Authorization permissions have been initialized or not and a reference
    `javax.ws.rs.core.Response` | `updateRole(String roleName, RoleRepresentation rep)` Update a role by name

    - ### Methods inherited from class org.keycloak.services.resources.admin.RoleResource

      `addComposites, deleteComposites, deleteRole, getClientRoleComposites, getRealmRoleComposites, getRole, updateRole`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### auth

          protected AdminPermissionEvaluator auth

    - #### roleContainer

          protected RoleContainerModel roleContainer

  - ### Constructor Detail

    - #### RoleContainerResource

          public RoleContainerResource(KeycloakSession session,
                                       javax.ws.rs.core.UriInfo uriInfo,
                                       RealmModel realm,
                                       AdminPermissionEvaluator auth,
                                       RoleContainerModel roleContainer,
                                       AdminEventBuilder adminEvent)

  - ### Method Detail

    - #### getRoles

          @GET
           @Produces(value="application/json")
          public Stream<RoleRepresentation> getRoles(@QueryParam(value="search") @DefaultValue(value="")
                                                                                               String search,
                                                                                               @QueryParam(value="first")
                                                                                               Integer firstResult,
                                                                                               @QueryParam(value="max")
                                                                                               Integer maxResults,
                                                                                               @QueryParam(value="briefRepresentation") @DefaultValue(value="true")
                                                                                               boolean briefRepresentation)

      Get all roles for the realm or client
      Returns:

    - #### createRole

          @POST
           @Consumes(value="application/json")
          public javax.ws.rs.core.Response createRole(RoleRepresentation rep)

      Create a new role for the realm or client
      Parameters:
        `rep` -
      Returns:

    - #### getRole

          @Path(value="{role-name}")
           @GET
           @Produces(value="application/json")
          public RoleRepresentation getRole(@PathParam(value="role-name")
                                                                                                                  String roleName)

      Get a role by name
      Parameters:
        `roleName` - role's name (not id!)
      Returns:

    - #### deleteRole

          @Path(value="{role-name}")
           @DELETE
          public void deleteRole(@PathParam(value="role-name")
                                                                     String roleName)

      Delete a role by name
      Parameters:
        `roleName` - role's name (not id!)

    - #### updateRole

          @Path(value="{role-name}")
           @PUT
           @Consumes(value="application/json")
          public javax.ws.rs.core.Response updateRole(@PathParam(value="role-name")
                                                                                                                            String roleName,
                                                                                                                            RoleRepresentation rep)

      Update a role by name
      Parameters:
        `roleName` - role's name (not id!)
        `rep` -
      Returns:

    - #### addComposites

          @Path(value="{role-name}/composites")
           @POST
           @Consumes(value="application/json")
          public void addComposites(@PathParam(value="role-name")
                                                                                                                      String roleName,
                                                                                                                      List<RoleRepresentation> roles)

      Add a composite to the role
      Parameters:
        `roleName` - role's name (not id!)
        `roles` -

    - #### getRoleComposites

          @Path(value="{role-name}/composites")
           @GET
           @Produces(value="application/json")
          public Stream<RoleRepresentation> getRoleComposites(@PathParam(value="role-name")
                                                                                                                                               String roleName)

      Get composites of the role
      Parameters:
        `roleName` - role's name (not id!)
      Returns:

    - #### getRealmRoleComposites

          @Path(value="{role-name}/composites/realm")
           @GET
           @Produces(value="application/json")
          public Stream<RoleRepresentation> getRealmRoleComposites(@PathParam(value="role-name")
                                                                                                                                                          String roleName)

      Get realm-level roles of the role's composite
      Parameters:
        `roleName` - role's name (not id!)
      Returns:

    - #### getClientRoleComposites

          @Path(value="{role-name}/composites/clients/{clientUuid}")
           @GET
           @Produces(value="application/json")
          public Stream<RoleRepresentation> getClientRoleComposites(@PathParam(value="role-name")
                                                                                                                                                                          String roleName,
                                                                                                                                                                          @PathParam(value="clientUuid")
                                                                                                                                                                          String clientUuid)

      Get client-level roles for the client that are in the role's composite
      Parameters:
        `roleName` - role's name (not id!)
        `clientUuid` -
      Returns:

    - #### deleteComposites

          @Path(value="{role-name}/composites")
           @DELETE
           @Consumes(value="application/json")
          public void deleteComposites(@PathParam(value="role-name")
                                                                                                                           String roleName,
                                                                                                                           List<RoleRepresentation> roles)

      Remove roles from the role's composite
      Parameters:
        `roleName` - role's name (not id!)
        `roles` - roles to remove

    - #### getManagementPermissions

          @Path(value="{role-name}/management/permissions")
           @GET
           @Produces(value="application/json")
          public ManagementPermissionReference getManagementPermissions(@PathParam(value="role-name")
                                                                                                                                                                     String roleName)

      Return object stating whether role Authorization permissions have been initialized or not and a reference
      Parameters:
        `roleName` -
      Returns:

    - #### setManagementPermissionsEnabled

          @Path(value="{role-name}/management/permissions")
           @PUT
           @Produces(value="application/json")
           @Consumes(value="application/json")
          public ManagementPermissionReference setManagementPermissionsEnabled(@PathParam(value="role-name")
                                                                                                                                                                                                                 String roleName,
                                                                                                                                                                                                                 ManagementPermissionReference ref)

      Return object stating whether role Authorization permissions have been initialized or not and a reference
      Parameters:
        `roleName` -
      Returns:
        initialized manage permissions reference

    - #### getUsersInRole

          @Path(value="{role-name}/users")
           @GET
           @Produces(value="application/json")
          public Stream<UserRepresentation> getUsersInRole(@PathParam(value="role-name")
                                                                                                                                       String roleName,
                                                                                                                                       @QueryParam(value="first")
                                                                                                                                       Integer firstResult,
                                                                                                                                       @QueryParam(value="max")
                                                                                                                                       Integer maxResults)

      Returns a stream of users that have the specified role name.
      Parameters:
        `roleName` - the role name.
        `firstResult` - first result to return. Ignored if negative or `null`.
        `maxResults` - maximum number of results to return. Ignored if negative or `null`.
      Returns:
        a non-empty `Stream` of users.

    - #### getGroupsInRole

          @Path(value="{role-name}/groups")
           @GET
           @Produces(value="application/json")
          public Stream<GroupRepresentation> getGroupsInRole(@PathParam(value="role-name")
                                                                                                                                          String roleName,
                                                                                                                                          @QueryParam(value="first")
                                                                                                                                          Integer firstResult,
                                                                                                                                          @QueryParam(value="max")
                                                                                                                                          Integer maxResults,
                                                                                                                                          @QueryParam(value="briefRepresentation") @DefaultValue(value="true")
                                                                                                                                          boolean briefRepresentation)

      Returns a stream of groups that have the specified role name
      Parameters:
        `roleName` - the role name.
        `firstResult` - first result to return. Ignored if negative or `null`.
        `maxResults` - maximum number of results to return. Ignored if negative or `null`.
        `briefRepresentation` - if false, return a full representation of the `GroupRepresentation` objects.
      Returns:
        a non-empty `Stream` of groups.

Copyright © 2021 JBoss by Red Hat. All rights reserved.