Class: LoginRadius::RoleApi
- Inherits:
-
Object
- Object
- LoginRadius::RoleApi
- Includes:
- RequestClient
- Defined in:
- lib/login_radius/api/account/role_api.rb
Overview
RoleApi module
Constant Summary
Constants included from RequestClient
LoginRadius::RequestClient::API_V2_BASE_URL, LoginRadius::RequestClient::API_V2_BASE_URL_CONFIG, LoginRadius::RequestClient::INIT_VECTOR, LoginRadius::RequestClient::KEY_SIZE
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
-
#site_name ⇒ Object
Returns the value of attribute site_name.
Instance Method Summary collapse
-
#add_role_permissions(permissions_model, role) ⇒ Object
This API is used to add permissions to a given role.
-
#assign_roles_by_uid(account_roles_model, uid) ⇒ Object
This API is used to assign your desired roles to a given user.
-
#create_roles(roles_model) ⇒ Object
This API creates a role with permissions.
-
#delete_additional_permission_from_role_context_by_uid(context_name, role_context_additional_permission_remove_role_model, uid) ⇒ Object
This API Deletes Additional Permissions from Context.
-
#delete_role(role) ⇒ Object
This API is used to delete the role.
-
#delete_role_context_by_uid(context_name, uid) ⇒ Object
This API Deletes the specified Role Context.
-
#delete_roles_from_role_context_by_uid(context_name, role_context_remove_role_model, uid) ⇒ Object
This API Deletes the specified Role from a Context.
-
#get_role_context_by_context_name(context_name) ⇒ Object
The API is used to retrieve role context by the context name.
-
#get_role_context_by_uid(uid) ⇒ Object
This API Gets the contexts that have been configured and the associated roles and permissions.
-
#get_roles_by_uid(uid) ⇒ Object
API is used to retrieve all the assigned roles of a particular User.
-
#get_roles_list ⇒ Object
This API retrieves the complete list of created roles with permissions of your app.
-
#initialize ⇒ RoleApi
constructor
Initializes a LoginRadius Account object with an apikey and secret Takes in a hash containing site_name(required), api_key(required), api_secret(required).
-
#remove_role_permissions(permissions_model, role) ⇒ Object
API is used to remove permissions from a role.
-
#unassign_roles_by_uid(account_roles_model, uid) ⇒ Object
This API is used to unassign roles from a user.
-
#update_role_context_by_uid(account_role_context_model, uid) ⇒ Object
This API creates a Context with a set of Roles.
Methods included from RequestClient
#build_new_uri_obj, #create_hash_secret, #delete_request, #getValidationMessage, #get_request, #get_sott, #isNullOrWhiteSpace, #local_generate_sott, #post_request, #put_request
Constructor Details
#initialize ⇒ RoleApi
Initializes a LoginRadius Account object with an apikey and secret Takes in a hash containing site_name(required), api_key(required), api_secret(required)
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/login_radius/api/account/role_api.rb', line 16 def initialize @site_name = ENV['SITE_NAME'] @api_key = ENV['API_KEY'] @api_secret = ENV['API_SECRET'] raise LoginRadius::Error.new, "'site_name' is a required option for Account class initialization." \ unless @site_name != '' && @site_name != nil raise LoginRadius::Error.new, "'api_key' is a required option for Account class initialization." \ unless @api_key != '' && @api_key != nil raise LoginRadius::Error.new, "'api_secret is a required option for Account class initialization." \ unless @api_secret != '' && @api_secret != nil end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/login_radius/api/account/role_api.rb', line 12 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
12 13 14 |
# File 'lib/login_radius/api/account/role_api.rb', line 12 def api_secret @api_secret end |
#site_name ⇒ Object
Returns the value of attribute site_name.
12 13 14 |
# File 'lib/login_radius/api/account/role_api.rb', line 12 def site_name @site_name end |
Instance Method Details
#add_role_permissions(permissions_model, role) ⇒ Object
This API is used to add permissions to a given role.
41.4
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/login_radius/api/account/role_api.rb', line 291 def (, role) if .blank? raise LoginRadius::Error.new, getValidationMessage('permissions_model') end if isNullOrWhiteSpace(role) raise LoginRadius::Error.new, getValidationMessage('role') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/role/' + role + '/permission' put_request(resource_path, query_parameters, ) end |
#assign_roles_by_uid(account_roles_model, uid) ⇒ Object
This API is used to assign your desired roles to a given user.
18.7
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/login_radius/api/account/role_api.rb', line 54 def assign_roles_by_uid(account_roles_model, uid) if account_roles_model.blank? raise LoginRadius::Error.new, getValidationMessage('account_roles_model') end if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/' + uid + '/role' put_request(resource_path, query_parameters, account_roles_model) end |
#create_roles(roles_model) ⇒ Object
This API creates a role with permissions.
41.2
252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/login_radius/api/account/role_api.rb', line 252 def create_roles(roles_model) if roles_model.blank? raise LoginRadius::Error.new, getValidationMessage('roles_model') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/role' post_request(resource_path, query_parameters, roles_model) end |
#delete_additional_permission_from_role_context_by_uid(context_name, role_context_additional_permission_remove_role_model, uid) ⇒ Object
This API Deletes Additional Permissions from Context.
18.14
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/login_radius/api/account/role_api.rb', line 212 def (context_name, , uid) if isNullOrWhiteSpace(context_name) raise LoginRadius::Error.new, getValidationMessage('context_name') end if .blank? raise LoginRadius::Error.new, getValidationMessage('role_context_additional_permission_remove_role_model') end if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/' + uid + '/rolecontext/' + context_name + '/additionalpermission' delete_request(resource_path, query_parameters, ) end |
#delete_role(role) ⇒ Object
This API is used to delete the role.
41.3
271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/login_radius/api/account/role_api.rb', line 271 def delete_role(role) if isNullOrWhiteSpace(role) raise LoginRadius::Error.new, getValidationMessage('role') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/role/' + role delete_request(resource_path, query_parameters, {}) end |
#delete_role_context_by_uid(context_name, uid) ⇒ Object
This API Deletes the specified Role Context
18.12
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/login_radius/api/account/role_api.rb', line 161 def delete_role_context_by_uid(context_name, uid) if isNullOrWhiteSpace(context_name) raise LoginRadius::Error.new, getValidationMessage('context_name') end if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/' + uid + '/rolecontext/' + context_name delete_request(resource_path, query_parameters, {}) end |
#delete_roles_from_role_context_by_uid(context_name, role_context_remove_role_model, uid) ⇒ Object
This API Deletes the specified Role from a Context.
18.13
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/login_radius/api/account/role_api.rb', line 185 def delete_roles_from_role_context_by_uid(context_name, role_context_remove_role_model, uid) if isNullOrWhiteSpace(context_name) raise LoginRadius::Error.new, getValidationMessage('context_name') end if role_context_remove_role_model.blank? raise LoginRadius::Error.new, getValidationMessage('role_context_remove_role_model') end if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/' + uid + '/rolecontext/' + context_name + '/role' delete_request(resource_path, query_parameters, role_context_remove_role_model) end |
#get_role_context_by_context_name(context_name) ⇒ Object
The API is used to retrieve role context by the context name.
18.10
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/login_radius/api/account/role_api.rb', line 118 def get_role_context_by_context_name(context_name) if isNullOrWhiteSpace(context_name) raise LoginRadius::Error.new, getValidationMessage('context_name') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/rolecontext/' + context_name get_request(resource_path, query_parameters, {}) end |
#get_role_context_by_uid(uid) ⇒ Object
This API Gets the contexts that have been configured and the associated roles and permissions.
18.9
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/login_radius/api/account/role_api.rb', line 99 def get_role_context_by_uid(uid) if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/' + uid + '/rolecontext' get_request(resource_path, query_parameters, {}) end |
#get_roles_by_uid(uid) ⇒ Object
API is used to retrieve all the assigned roles of a particular User.
18.6
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/login_radius/api/account/role_api.rb', line 34 def get_roles_by_uid(uid) if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/' + uid + '/role' get_request(resource_path, query_parameters, {}) end |
#get_roles_list ⇒ Object
This API retrieves the complete list of created roles with permissions of your app.
41.1
236 237 238 239 240 241 242 243 244 |
# File 'lib/login_radius/api/account/role_api.rb', line 236 def get_roles_list() query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/role' get_request(resource_path, query_parameters, {}) end |
#remove_role_permissions(permissions_model, role) ⇒ Object
API is used to remove permissions from a role.
41.5
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/login_radius/api/account/role_api.rb', line 314 def (, role) if .blank? raise LoginRadius::Error.new, getValidationMessage('permissions_model') end if isNullOrWhiteSpace(role) raise LoginRadius::Error.new, getValidationMessage('role') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/role/' + role + '/permission' delete_request(resource_path, query_parameters, ) end |
#unassign_roles_by_uid(account_roles_model, uid) ⇒ Object
This API is used to unassign roles from a user.
18.8
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/login_radius/api/account/role_api.rb', line 77 def unassign_roles_by_uid(account_roles_model, uid) if account_roles_model.blank? raise LoginRadius::Error.new, getValidationMessage('account_roles_model') end if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/' + uid + '/role' delete_request(resource_path, query_parameters, account_roles_model) end |
#update_role_context_by_uid(account_role_context_model, uid) ⇒ Object
This API creates a Context with a set of Roles
18.11
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/login_radius/api/account/role_api.rb', line 138 def update_role_context_by_uid(account_role_context_model, uid) if account_role_context_model.blank? raise LoginRadius::Error.new, getValidationMessage('account_role_context_model') end if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/account/' + uid + '/rolecontext' put_request(resource_path, query_parameters, account_role_context_model) end |