Module: Keycloak::API::ClientResources
- Extended by:
- ActiveSupport::Concern
- Includes:
- Concerns::APIUtil
- Included in:
- Client
- Defined in:
- lib/keycloak/api/client_resources.rb
Instance Method Summary collapse
- #client_resources_url ⇒ Object
-
#create_client(client_rep) ⇒ String
Id of client.
-
#find_client_by_client_id(client_id) ⇒ Keycloak::Model::ClientRepresentation
Client representation.
-
#find_client_by_id(id) ⇒ Keycloak::Model::ClientRepresentation
Client representation.
- #update_client(id, client_rep) ⇒ Object
Methods included from Concerns::APIUtil
#admin_realm_url, #delete, #get, #post, #put, #realm_url
Instance Method Details
#client_resources_url ⇒ Object
7 8 9 |
# File 'lib/keycloak/api/client_resources.rb', line 7 def client_resources_url "#{admin_realm_url}/clients" end |
#create_client(client_rep) ⇒ String
Returns id of client.
31 32 33 34 |
# 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) ⇒ Keycloak::Model::ClientRepresentation
Returns client representation.
13 14 15 16 17 18 |
# 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) ⇒ Keycloak::Model::ClientRepresentation
Returns client representation.
22 23 24 25 26 27 |
# 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) ⇒ Object
38 39 40 41 |
# 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 |