Class: KeycloakAdmin::GroupClient
- Inherits:
-
Client
- Object
- Client
- KeycloakAdmin::GroupClient
show all
- Defined in:
- lib/keycloak-admin/client/group_client.rb
Instance Method Summary
collapse
Methods inherited from Client
#create_payload, #created_id, #current_token, #execute_http, #headers, #server_url
Constructor Details
#initialize(configuration, realm_client) ⇒ GroupClient
Returns a new instance of GroupClient.
3
4
5
6
7
|
# File 'lib/keycloak-admin/client/group_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
|
Instance Method Details
#create!(name, path = nil) ⇒ Object
16
17
18
19
|
# File 'lib/keycloak-admin/client/group_client.rb', line 16
def create!(name, path = nil)
response = save(build(name, path))
created_id(response)
end
|
#groups_url(id = nil) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/keycloak-admin/client/group_client.rb', line 29
def groups_url(id=nil)
if id
"#{@realm_client.realm_admin_url}/groups/#{id}"
else
"#{@realm_client.realm_admin_url}/groups"
end
end
|
#list ⇒ Object
9
10
11
12
13
14
|
# File 'lib/keycloak-admin/client/group_client.rb', line 9
def list
response = execute_http do
RestClient::Resource.new(groups_url, @configuration.rest_client_options).get()
end
JSON.parse(response).map { |group_as_hash| GroupRepresentation.from_hash(group_as_hash) }
end
|
#save(group_representation) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/keycloak-admin/client/group_client.rb', line 21
def save(group_representation)
execute_http do
RestClient::Resource.new(groups_url, @configuration.rest_client_options).post(
create_payload(group_representation),
)
end
end
|