Class: KeycloakAdmin::RealmClient

Inherits:
Client
  • Object
show all
Defined in:
lib/keycloak-admin/client/realm_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_name = nil) ⇒ RealmClient

Returns a new instance of RealmClient.



3
4
5
6
# File 'lib/keycloak-admin/client/realm_client.rb', line 3

def initialize(configuration, realm_name=nil)
  super(configuration)
  @realm_name = realm_name
end

Instance Method Details

#attack_detectionsObject



90
91
92
# File 'lib/keycloak-admin/client/realm_client.rb', line 90

def attack_detections
  AttackDetectionClient.new(@configuration, self)
end

#authz_permissions(client_id, type, resource_id = nil) ⇒ Object



110
111
112
# File 'lib/keycloak-admin/client/realm_client.rb', line 110

def authz_permissions(client_id, type, resource_id = nil)
  ClientAuthzPermissionClient.new(@configuration, self, client_id, type, resource_id)
end

#authz_policies(client_id, type) ⇒ Object



114
115
116
# File 'lib/keycloak-admin/client/realm_client.rb', line 114

def authz_policies(client_id, type)
  ClientAuthzPolicyClient.new(@configuration, self, client_id, type)
end

#authz_resources(client_id) ⇒ Object



106
107
108
# File 'lib/keycloak-admin/client/realm_client.rb', line 106

def authz_resources(client_id)
  ClientAuthzResourceClient.new(@configuration, self, client_id)
end

#authz_scopes(client_id, resource_id = nil) ⇒ Object



102
103
104
# File 'lib/keycloak-admin/client/realm_client.rb', line 102

def authz_scopes(client_id, resource_id = nil)
  ClientAuthzScopeClient.new(@configuration, self, client_id, resource_id)
end

#client_rolesObject



82
83
84
# File 'lib/keycloak-admin/client/realm_client.rb', line 82

def client_roles
  ClientRoleClient.new(@configuration, self)
end

#clientsObject



66
67
68
# File 'lib/keycloak-admin/client/realm_client.rb', line 66

def clients
  ClientClient.new(@configuration, self)
end

#configurable_tokenObject



62
63
64
# File 'lib/keycloak-admin/client/realm_client.rb', line 62

def configurable_token
  ConfigurableTokenClient.new(@configuration, self)
end

#deleteObject



15
16
17
18
19
20
# File 'lib/keycloak-admin/client/realm_client.rb', line 15

def delete
  execute_http do
    RestClient::Resource.new(realm_admin_url, @configuration.rest_client_options).delete(headers)
  end
  true
end

#group(group_id) ⇒ Object



74
75
76
# File 'lib/keycloak-admin/client/realm_client.rb', line 74

def group(group_id)
  GroupResource.new(@configuration, self, group_id)
end

#groupsObject



70
71
72
# File 'lib/keycloak-admin/client/realm_client.rb', line 70

def groups
  GroupClient.new(@configuration, self)
end

#identity_providersObject



94
95
96
# File 'lib/keycloak-admin/client/realm_client.rb', line 94

def identity_providers
  IdentityProviderClient.new(@configuration, self)
end

#listObject



8
9
10
11
12
13
# File 'lib/keycloak-admin/client/realm_client.rb', line 8

def list
  response = execute_http do
    RestClient::Resource.new(realm_list_url, @configuration.rest_client_options).get(headers)
  end
  JSON.parse(response).map { |realm_as_hash| RealmRepresentation.from_hash(realm_as_hash) }
end

#name_defined?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/keycloak-admin/client/realm_client.rb', line 118

def name_defined?
  !@realm_name.nil?
end

#realm_admin_urlObject



46
47
48
49
50
51
52
# File 'lib/keycloak-admin/client/realm_client.rb', line 46

def realm_admin_url
  if @realm_name
    "#{server_url}/admin/realms/#{@realm_name}"
  else
    "#{server_url}/admin/realms"
  end
end

#realm_list_urlObject



54
55
56
# File 'lib/keycloak-admin/client/realm_client.rb', line 54

def realm_list_url
  "#{server_url}/admin/realms"
end

#realm_urlObject



38
39
40
41
42
43
44
# File 'lib/keycloak-admin/client/realm_client.rb', line 38

def realm_url
  if @realm_name
    "#{server_url}/realms/#{@realm_name}"
  else
    "#{server_url}/realms"
  end
end

#rolesObject



78
79
80
# File 'lib/keycloak-admin/client/realm_client.rb', line 78

def roles
  RoleClient.new(@configuration, self)
end

#save(realm_representation) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/keycloak-admin/client/realm_client.rb', line 22

def save(realm_representation)
  execute_http do
    RestClient::Resource.new(realm_list_url, @configuration.rest_client_options).post(
      create_payload(realm_representation), headers
    )
  end
end

#tokenObject



58
59
60
# File 'lib/keycloak-admin/client/realm_client.rb', line 58

def token
  TokenClient.new(@configuration, self)
end

#update(realm_representation_body) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/keycloak-admin/client/realm_client.rb', line 30

def update(realm_representation_body)
  execute_http do
    RestClient::Resource.new(realm_admin_url, @configuration.rest_client_options).put(
      create_payload(realm_representation_body), headers
    )
  end
end

#user(user_id) ⇒ Object



98
99
100
# File 'lib/keycloak-admin/client/realm_client.rb', line 98

def user(user_id)
  UserResource.new(@configuration, self, user_id)
end

#usersObject



86
87
88
# File 'lib/keycloak-admin/client/realm_client.rb', line 86

def users
  UserClient.new(@configuration, self)
end