class KeycloakAdmin::RoleClient

Public Class Methods

new(configuration, realm_client) click to toggle source
Calls superclass method KeycloakAdmin::Client::new
# File lib/keycloak-admin/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

Public Instance Methods

list() click to toggle source
# File lib/keycloak-admin/client/role_client.rb, line 9
def list
  response = execute_http do
    RestClient::Resource.new(roles_url, @configuration.rest_client_options).get(headers)
  end
  JSON.parse(response).map { |role_as_hash| RoleRepresentation.from_hash(role_as_hash) }
end
roles_url(id=nil) click to toggle source
# File lib/keycloak-admin/client/role_client.rb, line 24
def roles_url(id=nil)
  if id
    "#{@realm_client.realm_admin_url}/roles/#{id}"
  else
    "#{@realm_client.realm_admin_url}/roles"
  end
end
save(role_representation) click to toggle source
# File lib/keycloak-admin/client/role_client.rb, line 16
def save(role_representation)
  execute_http do
    RestClient::Resource.new(roles_url, @configuration.rest_client_options).post(
      role_representation.to_json, headers
    )
  end
end