Class: PEClient::Resource::RBACV1::Users
- Defined in:
- lib/pe_client/resources/rbac.v1/users.rb
Overview
With role-based access control (RBAC), you can manage local users and remote users (created on a directory service). Use the users endpoints to get lists of users, create local users, and delete, revoke, and reinstate users in PE.
Constant Summary collapse
- BASE_PATH =
The base path for RBAC API v1 Users endpoints.
"#{RBACV1::BASE_PATH}/users".freeze
- COMMAND_BASE_PATH =
The base path for RBAC API v1 Users command endpoints.
"#{RBACV1::BASE_PATH}/command/users".freeze
Instance Method Summary collapse
-
#add_roles(user_id, role_ids) ⇒ Hash
Assign roles to a user.
-
#create(email:, display_name:, login:, role_ids: [], password: nil) ⇒ Hash
Create a local user.
-
#current ⇒ Hash
Get information about the current authenticated user.
-
#delete(sid) ⇒ Hash
Delete a user from the PE console.
-
#edit(sid, attributes) ⇒ Hash
Edit a local user.
-
#get(sid = nil) ⇒ Hash
Get a list of all local and remote users.
-
#reinstate(user_id) ⇒ Hash
Reinstate a revoked user.
-
#remove_roles(user_id, role_ids) ⇒ Hash
Remove roles from a user.
-
#revoke(user_id) ⇒ Hash
Revoke a user’s PE access.
-
#tokens(sid, limit: nil, offset: nil, order_by: nil, order: nil) ⇒ Hash
Get a list of tokens for a user.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PEClient::Resource::Base
Instance Method Details
#add_roles(user_id, role_ids) ⇒ Hash
Assign roles to a user.
116 117 118 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 116 def add_roles(user_id, role_ids) @client.post "#{COMMAND_BASE_PATH}/add-roles", body: {user_id:, role_ids:} end |
#create(email:, display_name:, login:, role_ids: [], password: nil) ⇒ Hash
Create a local user
82 83 84 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 82 def create(email:, display_name:, login:, role_ids: [], password: nil) @client.post BASE_PATH, body: {email:, display_name:, login:, role_ids:, password:} end |
#current ⇒ Hash
Get information about the current authenticated user.
47 48 49 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 47 def current @client.get "#{BASE_PATH}/current" end |
#delete(sid) ⇒ Hash
Delete a user from the PE console.
105 106 107 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 105 def delete(sid) @client.delete "#{BASE_PATH}/#{sid}" end |
#edit(sid, attributes) ⇒ Hash
Edit a local user
96 97 98 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 96 def edit(sid, attributes) @client.put "#{BASE_PATH}/#{sid}", body: attributes end |
#get(sid = nil) ⇒ Hash
Get a list of all local and remote users. If a user SID is provided, get details for that specific user.
39 40 41 42 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 39 def get(sid = nil) path = sid ? "#{BASE_PATH}/#{sid}" : BASE_PATH @client.get path end |
#reinstate(user_id) ⇒ Hash
Reinstate a revoked user.
144 145 146 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 144 def reinstate(user_id) @client.post "#{COMMAND_BASE_PATH}/reinstate", body: {user_id:} end |
#remove_roles(user_id, role_ids) ⇒ Hash
Remove roles from a user.
126 127 128 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 126 def remove_roles(user_id, role_ids) @client.post "#{COMMAND_BASE_PATH}/remove-roles", body: {user_id:, role_ids:} end |
#revoke(user_id) ⇒ Hash
Revoke a user’s PE access.
135 136 137 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 135 def revoke(user_id) @client.post "#{COMMAND_BASE_PATH}/revoke", body: {user_id:} end |
#tokens(sid, limit: nil, offset: nil, order_by: nil, order: nil) ⇒ Hash
Get a list of tokens for a user.
65 66 67 |
# File 'lib/pe_client/resources/rbac.v1/users.rb', line 65 def tokens(sid, limit: nil, offset: nil, order_by: nil, order: nil) @client.get "#{BASE_PATH}/#{sid}/tokens", params: {limit:, offset:, order_by:, order:}.compact end |