module Keycloak::API::ClientResources
Public Instance Methods
client_resources_url()
click to toggle source
# File lib/keycloak/api/client_resources.rb, line 7 def client_resources_url "#{admin_realm_url}/clients" end
create_client(client_rep)
click to toggle source
@param client_rep [Keycloak::Model::UserRepresentation] client representation @return [String] id of client
# File lib/keycloak/api/client_resources.rb, line 31 def create_client(client_rep) res = post(client_resources_url, client_rep.to_json, headers: {content_type: :json}) res.headers[:location].split("/")[-1] end
find_client_by_client_id(client_id)
click to toggle source
@param client_id [String] client-id (not id of client) @return [Keycloak::Model::ClientRepresentation] client representation
# File lib/keycloak/api/client_resources.rb, line 13 def find_client_by_client_id(client_id) data = JSON.parse(get(client_resources_url, params: { clientId: client_id }).body) data[0] && Model::ClientRepresentation.new(data[0]) rescue RestClient::NotFound nil end
find_client_by_id(id)
click to toggle source
@param id [String] id of client (not client-id) @return [Keycloak::Model::ClientRepresentation] client representation
# File lib/keycloak/api/client_resources.rb, line 22 def find_client_by_id(id) url = client_resources_url + "/#{id}" Model::ClientRepresentation.new JSON.parse(get(url).body) rescue RestClient::NotFound nil end
update_client(id, client_rep)
click to toggle source
@param id [String] id of client (not client-id) @param client_rep [Keycloak::Model::UserRepresentation] client representation
# File lib/keycloak/api/client_resources.rb, line 38 def update_client(id, client_rep) url = client_resources_url + "/#{id}" put(url, client_rep.to_json, headers: {content_type: :json}) end