Class: KeycloakAdmin::ClientRoleMappingsClient

Inherits:
Client
  • Object
show all
Defined in:
lib/keycloak-admin/client/client_role_mappings_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, user_resource, client_id) ⇒ ClientRoleMappingsClient

Returns a new instance of ClientRoleMappingsClient.



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

def initialize(configuration, user_resource, client_id)
  super(configuration)
  @user_resource = user_resource
  @client_id = client_id
end

Instance Method Details

#base_urlObject



28
29
30
# File 'lib/keycloak-admin/client/client_role_mappings_client.rb', line 28

def base_url
  "#{@user_resource.resource_url}/role-mappings/clients/#{@client_id}"
end

#list_availableObject



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

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

#list_available_urlObject



24
25
26
# File 'lib/keycloak-admin/client/client_role_mappings_client.rb', line 24

def list_available_url
  "#{@user_resource.resource_url}/role-mappings/clients/#{@client_id}/available"
end

#save(role_representation_list) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/keycloak-admin/client/client_role_mappings_client.rb', line 16

def save(role_representation_list)
  execute_http do
    RestClient::Resource.new(base_url, @configuration.rest_client_options).post(
      create_payload(role_representation_list), headers
    )
  end
end