Class: Wavefront::Account
- Includes:
- Mixin::User
- Defined in:
- lib/wavefront-sdk/account.rb
Overview
Manage and query Wavefront accounts. ‘/account/serviceaccount’ API paths are covered in the Wavefront::ServiceAccount class.
Many of these methods are duplicated in the User class. This reflects the layout of the API.
Instance Attribute Summary
Attributes inherited from CoreApi
Instance Method Summary collapse
-
#add_ingestion_policy(policy_id, id_list) ⇒ Wavefront::Response
POST /api/v2/account/addingestionpolicy Add a specific ingestion policy to multiple accounts.
-
#add_roles(id, role_list) ⇒ Wavefront::Response
POST /api/v2/account/id/addRoles Add specific roles to the account (user or service account).
-
#add_user_groups(id, group_list) ⇒ Wavefront::Response
POST /api/v2/account/id/addUserGroups Adds specific user groups to the account (user or service account).
-
#admins ⇒ Object
GET /api/v2/account/user/admin Get all users with Accounts permission.
-
#business_functions(id) ⇒ Wavefront::Response
GET /api/v2/account/id/businessFunctions Returns business functions of a specific account (user or service account).
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/account/id Deletes an account (user or service account) identified by id.
-
#delete_accounts(id_list) ⇒ Wavefront::Response
POST /api/v2/account/deleteAccounts Deletes multiple accounts (users or service accounts).
-
#describe(id) ⇒ Wavefront::Response
GET /api/v2/account/id Get a specific account (user or service account).
-
#grant(id, permission) ⇒ Wavefront::Response
POST /api/v2/account/id/grant/permission Grants a specific permission to account (user or service account) POST /api/v2/account/grant/permission Grants a specific permission to multiple accounts (users or service accounts).
-
#list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/account Get all accounts (users and service accounts) of a customer.
-
#remove_ingestion_policy(policy_id, id_list) ⇒ Wavefront::Response
POST /api/v2/account/removeingestionpolicies Removes ingestion policies from multiple accounts.
-
#remove_roles(id, role_list) ⇒ Wavefront::Response
POST /api/v2/account/id/removeRoles Removes specific roles from the account (user or service account).
-
#remove_user_groups(id, group_list) ⇒ Wavefront::Response
POST /api/v2/account/id/removeUserGroups Removes specific user groups from the account (user or service account).
-
#revoke(id, permission) ⇒ Wavefront::Response
POST /api/v2/account/id/revoke/permission Revokes a specific permission from account (user or service account) POST /api/v2/account/revoke/permission Revokes a specific permission from multiple accounts (users or service accounts.
-
#update_perms(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/account/user/id Update user with given user groups and permissions.
- #user_create(body, send_email = false) ⇒ Object
-
#user_describe(id) ⇒ Wavefront::Response
GET /api/v2/account/user/id Retrieves a user by identifier (email address).
-
#user_invite(body) ⇒ Wavefront::Response
POST /api/v2/account/user/invite Invite user accounts with given user groups and permissions.
-
#user_list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/account/user Get all user accounts.
-
#user_update(body, modify = true) ⇒ Wavefront::Response
POST /api/v2/account/user Creates or updates a user account.
-
#validate_accounts(id_list) ⇒ Wavefront::Response
POST /api/v2/account/validateAccounts Returns valid accounts (users and service accounts), also invalid identifiers from the given list.
Methods included from Mixin::User
#validate_account_list, #validate_role_list, #validate_user_list, #validate_usergroup_list
Methods inherited from CoreApi
#api_base, #api_path, #hash_for_update, #initialize, #setup_api, #time_to_ms
Methods included from Mixins
#log, #parse_relative_time, #parse_time, #relative_time, #time_multiplier, #valid_relative_time?
Methods included from Validators
#uuid?, #wf_account_id?, #wf_alert_id?, #wf_alert_severity?, #wf_apitoken_id?, #wf_aws_external_id?, #wf_cloudintegration_id?, #wf_dashboard_id?, #wf_derivedmetric_id?, #wf_distribution?, #wf_distribution_count?, #wf_distribution_interval?, #wf_distribution_values?, #wf_epoch?, #wf_event_id?, #wf_granularity?, #wf_ingestionpolicy_id?, #wf_integration_id?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_metricspolicy_id?, #wf_monitoredapplication_id?, #wf_monitoredcluster_id?, #wf_ms_ts?, #wf_name?, #wf_notificant_id?, #wf_permission?, #wf_point?, #wf_point_tag?, #wf_point_tags?, #wf_proxy_id?, #wf_role_id?, #wf_sampling_value?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_serviceaccount_id?, #wf_source_id?, #wf_spansamplingpolicy_id?, #wf_string?, #wf_tag?, #wf_trace?, #wf_ts?, #wf_user_id?, #wf_usergroup_id?, #wf_value?, #wf_version?, #wf_webhook_id?
Constructor Details
This class inherits a constructor from Wavefront::CoreApi
Instance Method Details
#add_ingestion_policy(policy_id, id_list) ⇒ Wavefront::Response
POST /api/v2/account/addingestionpolicy Add a specific ingestion policy to multiple accounts
177 178 179 180 181 182 183 184 |
# File 'lib/wavefront-sdk/account.rb', line 177 def add_ingestion_policy(policy_id, id_list) wf_ingestionpolicy_id?(policy_id) validate_account_list(id_list) api.post('addingestionpolicy', { ingestionPolicyId: policy_id, accounts: id_list }, 'application/json') end |
#add_roles(id, role_list) ⇒ Wavefront::Response
POST /api/v2/account/id/addRoles Add specific roles to the account (user or service account)
81 82 83 84 85 |
# File 'lib/wavefront-sdk/account.rb', line 81 def add_roles(id, role_list) wf_account_id?(id) validate_role_list(role_list) api.post([id, 'addRoles'].uri_concat, role_list, 'application/json') end |
#add_user_groups(id, group_list) ⇒ Wavefront::Response
POST /api/v2/account/id/addUserGroups Adds specific user groups to the account (user or service account)
93 94 95 96 97 98 |
# File 'lib/wavefront-sdk/account.rb', line 93 def add_user_groups(id, group_list) wf_account_id?(id) validate_usergroup_list(group_list) api.post([id, 'addUserGroups'].uri_concat, group_list, 'application/json') end |
#admins ⇒ Object
GET /api/v2/account/user/admin Get all users with Accounts permission
50 51 52 |
# File 'lib/wavefront-sdk/account.rb', line 50 def admins api.get('user/admin') end |
#business_functions(id) ⇒ Wavefront::Response
GET /api/v2/account/id/businessFunctions Returns business functions of a specific account (user or service account).
106 107 108 109 |
# File 'lib/wavefront-sdk/account.rb', line 106 def business_functions(id) wf_account_id?(id) api.get([id, 'businessFunctions'].uri_concat) end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/account/id Deletes an account (user or service account) identified by id
32 33 34 35 |
# File 'lib/wavefront-sdk/account.rb', line 32 def delete(id) wf_account_id?(id) api.delete(id) end |
#delete_accounts(id_list) ⇒ Wavefront::Response
POST /api/v2/account/deleteAccounts Deletes multiple accounts (users or service accounts)
208 209 210 211 |
# File 'lib/wavefront-sdk/account.rb', line 208 def delete_accounts(id_list) validate_account_list(id_list) api.post('deleteAccounts', id_list, 'application/json') end |
#describe(id) ⇒ Wavefront::Response
GET /api/v2/account/id Get a specific account (user or service account)
42 43 44 45 |
# File 'lib/wavefront-sdk/account.rb', line 42 def describe(id) wf_account_id?(id) api.get(id) end |
#grant(id, permission) ⇒ Wavefront::Response
POST /api/v2/account/id/grant/permission Grants a specific permission to account (user or service account) POST /api/v2/account/grant/permission Grants a specific permission to multiple accounts (users or service accounts)
146 147 148 149 150 151 152 |
# File 'lib/wavefront-sdk/account.rb', line 146 def grant(id, ) if id.is_a?(String) grant_to_id(id, ) else grant_to_multiple(id, ) end end |
#list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/account Get all accounts (users and service accounts) of a customer
23 24 25 |
# File 'lib/wavefront-sdk/account.rb', line 23 def list(offset = 0, limit = 100) api.get('', offset: offset, limit: limit) end |
#remove_ingestion_policy(policy_id, id_list) ⇒ Wavefront::Response
POST /api/v2/account/removeingestionpolicies Removes ingestion policies from multiple accounts. The API path says “policies” but I’ve made the method name “policy” for consistency.
193 194 195 196 197 198 199 200 |
# File 'lib/wavefront-sdk/account.rb', line 193 def remove_ingestion_policy(policy_id, id_list) wf_ingestionpolicy_id?(policy_id) validate_account_list(id_list) api.post('removeingestionpolicies', { ingestionPolicyId: policy_id, accounts: id_list }, 'application/json') end |
#remove_roles(id, role_list) ⇒ Wavefront::Response
POST /api/v2/account/id/removeRoles Removes specific roles from the account (user or service account)
117 118 119 120 121 |
# File 'lib/wavefront-sdk/account.rb', line 117 def remove_roles(id, role_list) wf_account_id?(id) validate_role_list(role_list) api.post([id, 'removeRoles'].uri_concat, role_list, 'application/json') end |
#remove_user_groups(id, group_list) ⇒ Wavefront::Response
POST /api/v2/account/id/removeUserGroups Removes specific user groups from the account (user or service account)
129 130 131 132 133 134 |
# File 'lib/wavefront-sdk/account.rb', line 129 def remove_user_groups(id, group_list) wf_account_id?(id) validate_usergroup_list(group_list) api.post([id, 'removeUserGroups'].uri_concat, group_list, 'application/json') end |
#revoke(id, permission) ⇒ Wavefront::Response
POST /api/v2/account/id/revoke/permission Revokes a specific permission from account (user or service account) POST /api/v2/account/revoke/permission Revokes a specific permission from multiple accounts (users or service accounts
163 164 165 166 167 168 169 |
# File 'lib/wavefront-sdk/account.rb', line 163 def revoke(id, ) if id.is_a?(String) revoke_from_id(id, ) else revoke_from_multiple(id, ) end end |
#update_perms(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/account/user/id Update user with given user groups and permissions.
65 66 67 68 69 70 71 72 73 |
# File 'lib/wavefront-sdk/account.rb', line 65 def update_perms(id, body, modify = true) wf_account_id?(id) raise ArgumentError unless body.is_a?(Hash) return api.put(['user', id], body, 'application/json') unless modify api.put(['user', id], hash_for_update(describe(id).response, body), 'application/json') end |
#user_create(body, send_email = false) ⇒ Object
223 224 225 226 227 228 229 |
# File 'lib/wavefront-sdk/account.rb', line 223 def user_create(body, send_email = false) raise ArgumentError unless body.is_a?(Hash) uri = send_email ? "?sendEmail=#{send_email}" : 'user' api.post(uri, body, 'application/json') end |
#user_describe(id) ⇒ Wavefront::Response
GET /api/v2/account/user/id Retrieves a user by identifier (email address)
254 255 256 257 |
# File 'lib/wavefront-sdk/account.rb', line 254 def user_describe(id) wf_user_id?(id) api.get(['user', id].uri_concat) end |
#user_invite(body) ⇒ Wavefront::Response
POST /api/v2/account/user/invite Invite user accounts with given user groups and permissions.
266 267 268 269 270 271 |
# File 'lib/wavefront-sdk/account.rb', line 266 def user_invite(body) raise ArgumentError unless body.is_a?(Array) raise ArgumentError unless body.first.is_a?(Hash) api.post('user/invite', body, 'application/json') end |
#user_list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/account/user Get all user accounts
219 220 221 |
# File 'lib/wavefront-sdk/account.rb', line 219 def user_list(offset = 0, limit = 100) api.get('user', offset: offset, limit: limit) end |
#user_update(body, modify = true) ⇒ Wavefront::Response
POST /api/v2/account/user Creates or updates a user account
239 240 241 242 243 244 245 246 247 |
# File 'lib/wavefront-sdk/account.rb', line 239 def user_update(body, modify = true) raise ArgumentError unless body.is_a?(Hash) return api.post('user', body, 'application/json') unless modify api.post('user', hash_for_update(describe(id).response, body), 'application/json') end |
#validate_accounts(id_list) ⇒ Wavefront::Response
POST /api/v2/account/validateAccounts Returns valid accounts (users and service accounts), also invalid identifiers from the given list
279 280 281 282 283 |
# File 'lib/wavefront-sdk/account.rb', line 279 def validate_accounts(id_list) raise ArgumentError unless id_list.is_a?(Array) api.post('validateAccounts', id_list, 'application/json') end |