Class: Wavefront::Account

Inherits:
CoreApi
  • Object
show all
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

#api, #creds, #logger, #opts, #update_keys

Instance Method Summary collapse

Methods included from Mixin::User

#validate_account_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_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_monitoredcluster_id?, #wf_ms_ts?, #wf_name?, #wf_notificant_id?, #wf_permission?, #wf_point?, #wf_point_tag?, #wf_point_tags?, #wf_proxy_id?, #wf_sampling_value?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_serviceaccount_id?, #wf_source_id?, #wf_string?, #wf_tag?, #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

Parameters:

  • policy_id (String)

    ID of the ingestion policy

  • id_list (Array[String])

    list of accounts to be put in policy

Returns:



125
126
127
128
129
130
131
132
# File 'lib/wavefront-sdk/account.rb', line 125

def add_ingestion_policy(policy_id, id_list)
  wf_ingestionpolicy_id?(policy_id)
  (id_list)
  api.post('addingestionpolicy',
           { ingestionPolicyId: policy_id,
             accounts: id_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)

Parameters:

  • id (String)

    ID of the account

  • group_list (Array[String])

    list of groups to add

Returns:



53
54
55
56
57
58
# File 'lib/wavefront-sdk/account.rb', line 53

def add_user_groups(id, group_list)
  (id)
  validate_usergroup_list(group_list)
  api.post([id, 'addUserGroups'].uri_concat, group_list,
           'application/json')
end

#business_functions(id) ⇒ Wavefront::Response

GET /api/v2/account/id/businessFunctions Returns business functions of a specific account (user or service account).

Parameters:

Returns:



66
67
68
69
# File 'lib/wavefront-sdk/account.rb', line 66

def business_functions(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

Parameters:

  • id (String)

    ID of the account

Returns:



32
33
34
35
# File 'lib/wavefront-sdk/account.rb', line 32

def delete(id)
  (id)
  api.delete(id)
end

#delete_accounts(id_list) ⇒ Wavefront::Response

POST /api/v2/account/deleteAccounts Deletes multiple accounts (users or service accounts)

Parameters:

  • id (String)

    ID of the account

  • group_list (Array[String])

    list of accounts to delete

Returns:



155
156
157
158
# File 'lib/wavefront-sdk/account.rb', line 155

def delete_accounts(id_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)

Parameters:

  • id (String)

    ID of the proxy

Returns:



42
43
44
45
# File 'lib/wavefront-sdk/account.rb', line 42

def describe(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)

Parameters:

  • id_list (Array[String], String)

    single account ID or list of account IDs

  • permission (String)

    permission group to grant to user.

Returns:



94
95
96
97
98
99
100
# File 'lib/wavefront-sdk/account.rb', line 94

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) ⇒ Wavefront::Response

GET /api/v2/account Get all accounts (users and service accounts) of a customer

Parameters:

  • offset (Int) (defaults to: 0)

    account at which the list begins

  • limit (Int) (defaults to: 100)

    the number of accounts to return

Returns:



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

Parameters:

  • policy_id (String)

    ID of the ingestion policy

  • id_list (Array[String])

    list of accounts to be put in policy

Returns:



140
141
142
143
144
145
146
147
# File 'lib/wavefront-sdk/account.rb', line 140

def remove_ingestion_policy(policy_id, id_list)
  wf_ingestionpolicy_id?(policy_id)
  (id_list)
  api.post('removeingestionpolicy',
           { ingestionPolicyId: policy_id,
             accounts: id_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)

Parameters:

  • id (String)

    ID of the account

  • group_list (Array[String])

    list of groups to add

Returns:



77
78
79
80
81
82
# File 'lib/wavefront-sdk/account.rb', line 77

def remove_user_groups(id, group_list)
  (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

Parameters:

  • id (String, Array[String])

    ID of the user, or list of user IDs

  • permission (String)

    permission group to revoke from user.

Returns:



111
112
113
114
115
116
117
# File 'lib/wavefront-sdk/account.rb', line 111

def revoke(id, permission)
  if id.is_a?(String)
    revoke_from_id(id, permission)
  else
    revoke_from_multiple(id, permission)
  end
end