Module: Code42::API::Role
- Included in:
- Client
- Defined in:
- lib/code42/api/role.rb
Instance Method Summary collapse
-
#assign_role(attrs = {}) ⇒ Code42::Role
Assigns a role to a user.
- #create_role(name, permissions) ⇒ Object
- #delete_role(id) ⇒ Object
- #role(id) ⇒ Object
- #roles(attrs = {}) ⇒ Object
-
#unassign_role(id, role_name) ⇒ Object
Unassign a role from a user.
- #update_role(id, attrs = {}) ⇒ Object
-
#user_roles(id = 'my') ⇒ Code42::RoleCollection
Returns a list of roles for a given user.
Instance Method Details
#assign_role(attrs = {}) ⇒ Code42::Role
Assigns a role to a user
11 12 13 |
# File 'lib/code42/api/role.rb', line 11 def assign_role(attrs = {}) object_from_response(Code42::Role, :post, 'UserRole', attrs) end |
#create_role(name, permissions) ⇒ Object
40 41 42 |
# File 'lib/code42/api/role.rb', line 40 def create_role(name, ) object_from_response(Code42::Role, :post, "role", role_name: name, permissions: ) end |
#delete_role(id) ⇒ Object
48 49 50 |
# File 'lib/code42/api/role.rb', line 48 def delete_role(id) delete("Role/#{id}") end |
#role(id) ⇒ Object
36 37 38 |
# File 'lib/code42/api/role.rb', line 36 def role(id) object_from_response(Code42::Role, :get, "role/#{id}") end |
#roles(attrs = {}) ⇒ Object
32 33 34 |
# File 'lib/code42/api/role.rb', line 32 def roles(attrs = {}) collection_from_response(Code42::RoleCollection, Code42::Role, :get, "role", attrs) end |
#unassign_role(id, role_name) ⇒ Object
Unassign a role from a user
28 29 30 |
# File 'lib/code42/api/role.rb', line 28 def unassign_role(id, role_name) delete('UserRole', { :userId => id, :roleName => role_name }) end |
#update_role(id, attrs = {}) ⇒ Object
44 45 46 |
# File 'lib/code42/api/role.rb', line 44 def update_role(id, attrs = {}) object_from_response(Code42::Role, :put, "role/#{id}", attrs) end |
#user_roles(id = 'my') ⇒ Code42::RoleCollection
Returns a list of roles for a given user
18 19 20 |
# File 'lib/code42/api/role.rb', line 18 def user_roles(id = 'my') collection_from_response(Code42::RoleCollection, Code42::Role, :get, "userRole/#{id}") end |