Class: KeycloakAdmin::ClientAuthzScopeClient
- Inherits:
-
Client
- Object
- Client
- KeycloakAdmin::ClientAuthzScopeClient
show all
- Defined in:
- lib/keycloak-admin/client/client_authz_scope_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, client_id, resource_id = nil) ⇒ ClientAuthzScopeClient
Returns a new instance of ClientAuthzScopeClient.
4
5
6
7
8
9
10
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 4
def initialize(configuration, realm_client, client_id, resource_id = nil)
super(configuration)
raise ArgumentError.new("realm must be defined") unless realm_client.name_defined?
@realm_client = realm_client
@client_id = client_id
@resource_id = resource_id
end
|
Instance Method Details
#authz_scopes_url(client_id, resource_id = nil, id = nil) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 46
def authz_scopes_url(client_id, resource_id = nil, id = nil)
if resource_id
"#{@realm_client.realm_admin_url}/clients/#{encode_segment(client_id)}/authz/resource-server/resource/#{encode_segment(resource_id)}/scopes"
elsif id
"#{@realm_client.realm_admin_url}/clients/#{encode_segment(client_id)}/authz/resource-server/scope/#{encode_segment(id)}"
else
"#{@realm_client.realm_admin_url}/clients/#{encode_segment(client_id)}/authz/resource-server/scope"
end
end
|
#build(name, display_name, icon_uri) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 64
def build(name, display_name, icon_uri)
scope = ClientAuthzScopeRepresentation.new
scope.name = name
scope.icon_uri = icon_uri
scope.display_name = display_name
scope
end
|
#create!(name, display_name, icon_uri) ⇒ Object
12
13
14
15
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 12
def create!(name, display_name, icon_uri)
response = save(build(name, display_name, icon_uri))
ClientAuthzScopeRepresentation.from_hash(JSON.parse(response))
end
|
#delete(scope_id) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 24
def delete(scope_id)
execute_http do
resource(authz_scopes_url(@client_id, nil, scope_id)).delete()
end
true
end
|
#get(scope_id) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 31
def get(scope_id)
response = execute_http do
resource(authz_scopes_url(@client_id, nil, scope_id)).get()
end
ClientAuthzScopeRepresentation.from_hash(JSON.parse(response))
end
|
#list ⇒ Object
17
18
19
20
21
22
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 17
def list
response = execute_http do
resource(authz_scopes_url(@client_id, @resource_id)).get()
end
JSON.parse(response).map { |role_as_hash| ClientAuthzScopeRepresentation.from_hash(role_as_hash) }
end
|
#save(scope_representation) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 56
def save(scope_representation)
execute_http do
resource(authz_scopes_url(@client_id)).post(
create_payload(scope_representation),
)
end
end
|
#search(name) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/keycloak-admin/client/client_authz_scope_client.rb', line 38
def search(name)
url = "#{authz_scopes_url(@client_id)}?#{build_query(first: 0, max: 11, deep: false, name: name)}"
response = execute_http do
resource(url).get()
end
JSON.parse(response).map { |role_as_hash| ClientAuthzScopeRepresentation.from_hash(role_as_hash) }
end
|