class KeycloakAdmin::Client
Public Class Methods
new(configuration)
click to toggle source
# File lib/keycloak-admin/client/client.rb, line 4 def initialize(configuration) @configuration = configuration end
Public Instance Methods
created_id(response)
click to toggle source
# File lib/keycloak-admin/client/client.rb, line 32 def created_id(response) unless response.net_http_res.is_a? Net::HTTPCreated raise "Create method returned status #{response.net_http_res.message} (Code: #{response.net_http_res.code}); expected status: Created (201)" end (_head, _separator, id) = response.headers[:location].rpartition('/') id end
current_token()
click to toggle source
# File lib/keycloak-admin/client/client.rb, line 12 def current_token @current_token ||= KeycloakAdmin.realm(@configuration.client_realm_name).token.get end
execute_http() { || ... }
click to toggle source
# File lib/keycloak-admin/client/client.rb, line 24 def execute_http yield rescue RestClient::Exceptions::Timeout => e raise rescue RestClient::ExceptionWithResponse => e http_error(e.response) end
headers()
click to toggle source
# File lib/keycloak-admin/client/client.rb, line 16 def headers { Authorization: "Bearer #{current_token.access_token}", content_type: :json, accept: :json } end
server_url()
click to toggle source
# File lib/keycloak-admin/client/client.rb, line 8 def server_url @configuration.server_url end
Private Instance Methods
http_error(response)
click to toggle source
# File lib/keycloak-admin/client/client.rb, line 42 def http_error(response) raise "Keycloak: The request failed with response code #{response.code} and message: #{response.body}" end