Class: KeycloakAdmin::ClientClient
- Inherits:
-
Client
- Object
- Client
- KeycloakAdmin::ClientClient
show all
- Defined in:
- lib/keycloak-admin/client/client_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) ⇒ ClientClient
Returns a new instance of ClientClient.
4
5
6
7
8
|
# File 'lib/keycloak-admin/client/client_client.rb', line 4
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
#clients_url(id = nil) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/keycloak-admin/client/client_client.rb', line 63
def clients_url(id=nil)
if id
"#{@realm_client.realm_admin_url}/clients/#{encode_segment(id)}"
else
"#{@realm_client.realm_admin_url}/clients"
end
end
|
#delete(id) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/keycloak-admin/client/client_client.rb', line 39
def delete(id)
execute_http do
resource(clients_url(id)).delete()
end
true
end
|
#find_by_client_id(client_id) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/keycloak-admin/client/client_client.rb', line 32
def find_by_client_id(client_id)
response = execute_http do
resource("#{clients_url}?#{build_query(clientId: client_id)}").get()
end
JSON.parse(response).map { |client_as_hash| ClientRepresentation.from_hash(client_as_hash) }.first
end
|
#get(id) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/keycloak-admin/client/client_client.rb', line 10
def get(id)
response = execute_http do
resource(clients_url(id)).get()
end
ClientRepresentation.from_hash(JSON.parse(response))
end
|
#get_service_account_user(client_id) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/keycloak-admin/client/client_client.rb', line 56
def get_service_account_user(client_id)
response = execute_http do
resource(service_account_user_url(client_id)).get()
end
UserRepresentation.from_hash(JSON.parse(response))
end
|
#list ⇒ Object
25
26
27
28
29
30
|
# File 'lib/keycloak-admin/client/client_client.rb', line 25
def list
response = execute_http do
resource(clients_url).get()
end
JSON.parse(response).map { |client_as_hash| ClientRepresentation.from_hash(client_as_hash) }
end
|
#save(client_representation) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/keycloak-admin/client/client_client.rb', line 17
def save(client_representation)
execute_http do
resource(clients_url).post(
create_payload(client_representation),
)
end
end
|
#service_account_user_url(client_id) ⇒ Object
71
72
73
|
# File 'lib/keycloak-admin/client/client_client.rb', line 71
def service_account_user_url(client_id)
"#{clients_url(client_id)}/service-account-user"
end
|
#update(client_representation) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/keycloak-admin/client/client_client.rb', line 46
def update(client_representation)
execute_http do
resource(clients_url(client_representation.id)).put(
create_payload(client_representation),
)
end
get(client_representation.id)
end
|