Class: Datacentred::Request::Roles
- Defined in:
- lib/datacentred/request/roles.rb
Overview
RESTful API requests for the roles endpoints.
Class Method Summary collapse
-
.add_user(role_id, user_id) ⇒ nil
Add new user to this role, giving them the associated permissions.
-
.create(params) ⇒ Hash
Create a new role.
-
.destroy(id) ⇒ nil
Permanently remove the specified role.
-
.list ⇒ [Hash]
List all available roles.
-
.list_users(role_id) ⇒ [Hash]
List all users assigned to this role.
-
.remove_user(role_id, user_id) ⇒ nil
Remove user from this role, revoking the associated permissions.
-
.show(id) ⇒ Hash
Find a role by unique ID.
-
.update(id, params) ⇒ Hash
Update a role by unique ID.
Methods inherited from Base
Class Method Details
.add_user(role_id, user_id) ⇒ nil
Add new user to this role, giving them the associated permissions.
PUT /api/roles/ea894bed9d738d9f/users/82fa8de8f09102cc
87 88 89 |
# File 'lib/datacentred/request/roles.rb', line 87 def add_user(role_id, user_id) put("roles/#{role_id}/users/#{user_id}") end |
.create(params) ⇒ Hash
Create a new role.
POST /api/roles
14 15 16 |
# File 'lib/datacentred/request/roles.rb', line 14 def create(params) post('roles', 'role' => params)['role'] end |
.destroy(id) ⇒ nil
Permanently remove the specified role.
DELETE /api/roles/ea894bed9d738d9f
63 64 65 |
# File 'lib/datacentred/request/roles.rb', line 63 def destroy(id) delete("roles/#{id}") end |
.list ⇒ [Hash]
List all available roles.
GET /api/roles
24 25 26 |
# File 'lib/datacentred/request/roles.rb', line 24 def list get('roles')['roles'] end |
.list_users(role_id) ⇒ [Hash]
List all users assigned to this role.
GET /api/roles/ea894bed9d738d9f/users
74 75 76 |
# File 'lib/datacentred/request/roles.rb', line 74 def list_users(role_id) get("roles/#{role_id}/users")['users'] end |
.remove_user(role_id, user_id) ⇒ nil
Remove user from this role, revoking the associated permissions.
DELETE /api/roles/ea894bed9d738d9f/users/82fa8de8f09102cc
100 101 102 |
# File 'lib/datacentred/request/roles.rb', line 100 def remove_user(role_id, user_id) delete("roles/#{role_id}/users/#{user_id}") end |
.show(id) ⇒ Hash
Find a role by unique ID.
GET /api/roles/ea894bed9d738d9f
36 37 38 |
# File 'lib/datacentred/request/roles.rb', line 36 def show(id) get("roles/#{id}")['role'] end |
.update(id, params) ⇒ Hash
Update a role by unique ID.
PUT /api/roles/ea894bed9d738d9f
50 51 52 |
# File 'lib/datacentred/request/roles.rb', line 50 def update(id, params) put("roles/#{id}", 'role' => params)['role'] end |