Class: Wavefront::ApiToken
- Defined in:
- lib/wavefront-sdk/apitoken.rb
Overview
View and manage API tokens for one’s own user, and for service accounts.
Instance Attribute Summary
Attributes inherited from CoreApi
#api, #creds, #logger, #opts, #update_keys
Instance Method Summary collapse
-
#create ⇒ Wavefront::Response
POST /api/v2/apitoken Create a new api token.
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/apitoken/id Delete the specified api token.
-
#describe_customer_token(id) ⇒ Wavefront::Response
GET /api/v2/apitoken/customertokens/id Get the specified api token for a customer.
-
#list ⇒ Wavefront::Response
GET /api/v2/apitoken Get all api tokens for a user.
-
#list_customer_tokens ⇒ Object
GET /api/v2/apitoken/customertokens Get all api tokens for a customer.
-
#rename(id, name) ⇒ Wavefront::Response
PUT /api/v2/apitoken/id Update the name of the specified api token.
-
#revoke_customer_token ⇒ Object
PUT /api/v2/apitoken/customertokens/revoke Delete the specified api token for a customer.
-
#sa_create(id, name = nil) ⇒ Wavefront::Response
POST /api/v2/apitoken/serviceaccount/id Create a new api token for the service account.
-
#sa_delete(id, token_id) ⇒ Wavefront::Response
DELETE /api/v2/apitoken/serviceaccount/id/token Delete the specified api token of the given service account.
-
#sa_list(id) ⇒ Wavefront::Response
GET /api/v2/apitoken/serviceaccount/id Get all api tokens for the given service account.
-
#sa_rename(id, token_id, name) ⇒ Wavefront::Response
PUT /api/v2/apitoken/serviceaccount/id/token Update the name of the specified api token for the given service account.
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
#create ⇒ Wavefront::Response
POST /api/v2/apitoken Create a new api token
24 25 26 |
# File 'lib/wavefront-sdk/apitoken.rb', line 24 def create api.post('', nil, 'application/json') end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/apitoken/id Delete the specified api token
52 53 54 55 |
# File 'lib/wavefront-sdk/apitoken.rb', line 52 def delete(id) wf_apitoken_id?(id) api.delete(id) end |
#describe_customer_token(id) ⇒ Wavefront::Response
GET /api/v2/apitoken/customertokens/id Get the specified api token for a customer
41 42 43 44 |
# File 'lib/wavefront-sdk/apitoken.rb', line 41 def describe_customer_token(id) wf_apitoken_id?(id) api.get(['customertokens', id].uri_concat) end |
#list ⇒ Wavefront::Response
GET /api/v2/apitoken Get all api tokens for a user
15 16 17 |
# File 'lib/wavefront-sdk/apitoken.rb', line 15 def list api.get('') end |
#list_customer_tokens ⇒ Object
GET /api/v2/apitoken/customertokens Get all api tokens for a customer
31 32 33 |
# File 'lib/wavefront-sdk/apitoken.rb', line 31 def list_customer_tokens api.get('customertokens') end |
#rename(id, name) ⇒ Wavefront::Response
PUT /api/v2/apitoken/id Update the name of the specified api token
64 65 66 67 |
# File 'lib/wavefront-sdk/apitoken.rb', line 64 def rename(id, name) wf_apitoken_id?(id) api.put(id, { tokenID: id, tokenName: name }, 'application/json') end |
#revoke_customer_token ⇒ Object
PUT /api/v2/apitoken/customertokens/revoke Delete the specified api token for a customer
This appears to be only for use by the web API.
126 127 128 |
# File 'lib/wavefront-sdk/apitoken.rb', line 126 def revoke_customer_token raise 'Unsupported API path' end |
#sa_create(id, name = nil) ⇒ Wavefront::Response
POST /api/v2/apitoken/serviceaccount/id Create a new api token for the service account
87 88 89 90 91 |
# File 'lib/wavefront-sdk/apitoken.rb', line 87 def sa_create(id, name = nil) wf_serviceaccount_id?(id) body = {}.tap { |b| b[:tokenName] = name if name } api.post(['serviceaccount', id].uri_concat, body, 'application/json') end |
#sa_delete(id, token_id) ⇒ Wavefront::Response
DELETE /api/v2/apitoken/serviceaccount/id/token Delete the specified api token of the given service account
100 101 102 103 104 |
# File 'lib/wavefront-sdk/apitoken.rb', line 100 def sa_delete(id, token_id) wf_serviceaccount_id?(id) wf_apitoken_id?(token_id) api.delete(['serviceaccount', id, token_id].uri_concat) end |
#sa_list(id) ⇒ Wavefront::Response
GET /api/v2/apitoken/serviceaccount/id Get all api tokens for the given service account
75 76 77 78 |
# File 'lib/wavefront-sdk/apitoken.rb', line 75 def sa_list(id) wf_serviceaccount_id?(id) api.get(['serviceaccount', id].uri_concat) end |
#sa_rename(id, token_id, name) ⇒ Wavefront::Response
PUT /api/v2/apitoken/serviceaccount/id/token Update the name of the specified api token for the given service account
114 115 116 117 118 119 |
# File 'lib/wavefront-sdk/apitoken.rb', line 114 def sa_rename(id, token_id, name) wf_serviceaccount_id?(id) wf_apitoken_id?(token_id) api.put(['serviceaccount', id, token_id].uri_concat, { tokenID: token_id, tokenName: name }, 'application/json') end |