Module: ILO_SDK::AccountServiceHelper
- Included in:
- Client
- Defined in:
- lib/ilo-sdk/helpers/account_service_helper.rb
Overview
Contains helper methods for Account Service actions
Instance Method Summary collapse
-
#change_password(username, password) ⇒ Object
Change the password for a user.
-
#create_user(username, password) ⇒ Object
Create a user.
-
#delete_user(username) ⇒ Object
Delete a specific user.
-
#get_users ⇒ String[]
Get the users.
-
#userhref(uri, username) ⇒ String
Get the HREF for a user with a specific username.
Instance Method Details
#change_password(username, password) ⇒ Object
Change the password for a user
53 54 55 56 57 58 59 |
# File 'lib/ilo-sdk/helpers/account_service_helper.rb', line 53 def change_password(username, password) new_action = { 'Password' => password } userhref = userhref('/redfish/v1/AccountService/Accounts/', username) response = rest_patch(userhref, body: new_action) response_handler(response) true end |
#create_user(username, password) ⇒ Object
Create a user
41 42 43 44 45 46 |
# File 'lib/ilo-sdk/helpers/account_service_helper.rb', line 41 def create_user(username, password) new_action = { 'UserName' => username, 'Password' => password, 'Oem' => { 'Hp' => { 'LoginName' => username } } } response = rest_post('/redfish/v1/AccountService/Accounts/', body: new_action) response_handler(response) true end |
#delete_user(username) ⇒ Object
Delete a specific user
65 66 67 68 69 70 |
# File 'lib/ilo-sdk/helpers/account_service_helper.rb', line 65 def delete_user(username) userhref = userhref('/redfish/v1/AccountService/Accounts/', username) response = rest_delete(userhref) response_handler(response) true end |
#get_users ⇒ String[]
Get the users
31 32 33 34 |
# File 'lib/ilo-sdk/helpers/account_service_helper.rb', line 31 def get_users response = rest_get('/redfish/v1/AccountService/Accounts/') response_handler(response)['Items'].collect { |user| user['UserName'] } end |
#userhref(uri, username) ⇒ String
Get the HREF for a user with a specific username
20 21 22 23 24 25 26 |
# File 'lib/ilo-sdk/helpers/account_service_helper.rb', line 20 def userhref(uri, username) response = rest_get(uri) items = response_handler(response)['Items'] items.each do |it| return it['links']['self']['href'] if it['UserName'] == username end end |