class Wavefront::Account

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.

Public Instance Methods

add_ingestion_policy(policy_id, id_list) click to toggle source

POST /api/v2/account/addingestionpolicy Add a specific ingestion policy to multiple accounts @param policy_id [String] ID of the ingestion policy @param id_list [Array] list of accounts to be put in policy @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 149
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) click to toggle source

POST /api/v2/account/{id}/addRoles Add specific roles to the account (user or service account) @param id [String] ID of the account @param role_list [Array] list of roles to add @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 53
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) click to toggle source

POST /api/v2/account/{id}/addUserGroups Adds specific user groups to the account (user or service account) @param id [String] ID of the account @param group_list [Array] list of groups to add @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 65
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
business_functions(id) click to toggle source

GET /api/v2/account/{id}/businessFunctions Returns business functions of a specific account (user or service account). @param id [String] user ID @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 78
def business_functions(id)
  wf_account_id?(id)
  api.get([id, 'businessFunctions'].uri_concat)
end
delete(id) click to toggle source

DELETE /api/v2/account/{id} Deletes an account (user or service account) identified by id @param id [String] ID of the account @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 32
def delete(id)
  wf_account_id?(id)
  api.delete(id)
end
delete_accounts(id_list) click to toggle source

POST /api/v2/account/deleteAccounts Deletes multiple accounts (users or service accounts) @param id [String] ID of the account @param group_list [Array] list of accounts to delete @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 180
def delete_accounts(id_list)
  validate_account_list(id_list)
  api.post('deleteAccounts', id_list, 'application/json')
end
describe(id) click to toggle source

GET /api/v2/account/{id} Get a specific account (user or service account) @param id [String] ID of the proxy @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 42
def describe(id)
  wf_account_id?(id)
  api.get(id)
end
grant(id, permission) click to toggle source

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) @param id_list [Array,String] single account ID or list of

account IDs

@param permission [String] permission group to grant to user. @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 118
def grant(id, permission)
  if id.is_a?(String)
    grant_to_id(id, permission)
  else
    grant_to_multiple(id, permission)
  end
end
list(offset = 0, limit = 100) click to toggle source

GET /api/v2/account Get all accounts (users and service accounts) of a customer @param offset [Int] account at which the list begins @param limit [Int] the number of accounts to return @return [Wavefront::Response]

# 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) click to toggle source

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. @param policy_id [String] ID of the ingestion policy @param id_list [Array] list of accounts to be put in policy @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 165
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) click to toggle source

POST /api/v2/account/{id}/removeRoles Removes specific roles from the account (user or service account) @param id [String] ID of the account @param role_list [Array] list of roles to remove @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 89
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) click to toggle source

POST /api/v2/account/{id}/removeUserGroups Removes specific user groups from the account (user or service account) @param id [String] ID of the account @param group_list [Array] list of groups to remove @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 101
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) click to toggle source

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 @param id [String,Array] ID of the user, or list of user IDs @param permission [String] permission group to revoke from user. @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 135
def revoke(id, permission)
  if id.is_a?(String)
    revoke_from_id(id, permission)
  else
    revoke_from_multiple(id, permission)
  end
end
user_create(body, send_email = false) click to toggle source
# File lib/wavefront-sdk/account.rb, line 195
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) click to toggle source

GET /api/v2/account/user/{id} Retrieves a user by identifier (email address) @param id [String] ID of the proxy @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 226
def user_describe(id)
  wf_user_id?(id)
  api.get(['user', id].uri_concat)
end
user_invite(body) click to toggle source

POST /api/v2/account/user/invite Invite user accounts with given user groups and permissions. @param body [Array] array of hashes, each hash describing a user.

See API docs for more details. It is your responsibility to validate
the data which describes each user.

@return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 238
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) click to toggle source

GET /api/v2/account/user Get all user accounts @param offset [Int] user account at which the list begins @param limit [Int] the number of user accounts to return @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 191
def user_list(offset = 0, limit = 100)
  api.get('user', offset: offset, limit: limit)
end
user_update(body, modify = true) click to toggle source

POST /api/v2/account/user Creates or updates a user account @param id [String] a Wavefront user ID @param body [Hash] key-value hash of the parameters you wish to change @param modify [true, false] if true, use {#describe()} to get a hash

describing the existing object, and modify that with the new body. If
false, pass the new body straight through.

@return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 211
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) click to toggle source

POST /api/v2/account/validateAccounts Returns valid accounts (users and service accounts), also invalid identifiers from the given list @param id_list [Array] list of user IDs @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 251
def validate_accounts(id_list)
  raise ArgumentError unless id_list.is_a?(Array)

  api.post('validateAccounts', id_list, 'application/json')
end

Private Instance Methods

grant_to_id(id, permission) click to toggle source

@param id [String] ID of the user @param permission [String] permission group to grant to user. @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 263
def grant_to_id(id, permission)
  wf_account_id?(id)
  wf_permission?(permission)
  api.post([id, 'grant', permission].uri_concat)
end
grant_to_multiple(id_list, permission) click to toggle source

@param id_list [Array] list of account IDs @param permission [String] permission group to grant to user. @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 273
def grant_to_multiple(id_list, permission)
  validate_account_list(id_list)
  wf_permission?(permission)
  api.post(['grant', permission].uri_concat, id_list, 'application/json')
end
revoke_from_id(id, permission) click to toggle source

@param id [String] ID of the user @param permission [String] permission group to revoke from user. @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 283
def revoke_from_id(id, permission)
  wf_account_id?(id)
  wf_permission?(permission)
  api.post([id, 'revoke', permission].uri_concat)
end
revoke_from_multiple(id_list, permission) click to toggle source

@param id_list [Array] list of account IDs @param permission [String] permission group to revoke from user. @return [Wavefront::Response]

# File lib/wavefront-sdk/account.rb, line 293
def revoke_from_multiple(id_list, permission)
  validate_account_list(id_list)
  wf_permission?(permission)
  api.post(['revoke', permission].uri_concat, id_list, 'application/json')
end
update_keys() click to toggle source
# File lib/wavefront-sdk/account.rb, line 299
def update_keys
  %i[identifier groups userGroups roles ingestionPolicyId]
end