Class: KeycloakAdmin::ClientRoleClient

Inherits:
Client
  • Object
show all
Defined in:
lib/keycloak-admin/client/client_role_client.rb

Instance Method Summary collapse

Methods inherited from Client

#create_payload, #created_id, #current_token, #execute_http, #headers, #server_url

Constructor Details

#initialize(configuration, realm_client) ⇒ ClientRoleClient

Returns a new instance of ClientRoleClient.

Raises:

  • (ArgumentError)


3
4
5
6
7
# File 'lib/keycloak-admin/client/client_role_client.rb', line 3

def initialize(configuration, realm_client)
  super(configuration)
  raise ArgumentError.new("realm must be defined") unless realm_client.name_defined?
  @realm_client = realm_client
end

Instance Method Details

#clients_url(id) ⇒ Object



16
17
18
# File 'lib/keycloak-admin/client/client_role_client.rb', line 16

def clients_url(id)
  "#{@realm_client.realm_admin_url}/clients/#{id}/roles"
end

#list(client_id) ⇒ Object



9
10
11
12
13
14
# File 'lib/keycloak-admin/client/client_role_client.rb', line 9

def list(client_id)
  response = execute_http do
    RestClient::Resource.new(clients_url(client_id), @configuration.rest_client_options).get(headers)
  end
  JSON.parse(response).map { |role_as_hash| RoleRepresentation.from_hash(role_as_hash) }
end