Module: Keycloak::API::RealmResources

Extended by:
ActiveSupport::Concern
Includes:
Concerns::APIUtil
Included in:
Client
Defined in:
lib/keycloak/api/realm_resources.rb

Instance Method Summary collapse

Methods included from Concerns::APIUtil

#admin_realm_url, #delete, #get, #post, #put, #realm_url

Instance Method Details

#create_realm(realm_rep) ⇒ String

Returns realm id.

Parameters:

Returns:

  • (String)

    realm id



9
10
11
12
# File 'lib/keycloak/api/realm_resources.rb', line 9

def create_realm(realm_rep)
  res = post("#{@auth_server_url}/admin/realms/", realm_rep.to_json, headers: {content_type: :json})
  res.headers[:location].split("/")[-1]
end

#delete_realm(realm) ⇒ Object

Parameters:

  • realm (String)

    realm name



15
16
17
18
# File 'lib/keycloak/api/realm_resources.rb', line 15

def delete_realm(realm)
  url = "#{@auth_server_url}/admin/realms/#{realm}"
  delete(url)
end

#find_realm(realm) ⇒ Keycloak::Model::RealmRepresentation

Returns realm representation.

Parameters:

  • realm (String)

    realm name

Returns:



29
30
31
32
# File 'lib/keycloak/api/realm_resources.rb', line 29

def find_realm(realm)
  url = "#{@auth_server_url}/admin/realms/#{realm}"
  Keycloak::Model::RealmRepresentation.new JSON.parse(get(url))
end

#update_realm(realm, realm_rep) ⇒ Object

Parameters:



22
23
24
25
# File 'lib/keycloak/api/realm_resources.rb', line 22

def update_realm(realm, realm_rep)
  url = "#{@auth_server_url}/admin/realms/#{realm}"
  put(url, realm_rep.to_json, headers: {content_type: :json})
end