Class: Wavefront::User
Overview
Manage and query Wavefront users
Instance Attribute Summary
Attributes inherited from CoreApi
#api, #creds, #logger, #opts, #update_keys
Instance Method Summary collapse
-
#create(body, send_email = false) ⇒ Wavefront::Response
POST /api/v2/user Creates or updates a user.
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/user/id Delete a specific user.
-
#describe(id) ⇒ Wavefront::Response
GET /api/v2/user/id Retrieves a user by identifier (email addr).
-
#everything ⇒ Object
the user API class does not support pagination.
-
#grant(id, group) ⇒ Wavefront::Response
PUT /api/v2/user/id/grant Grants a specific user permission.
-
#list ⇒ Object
GET /api/v2/user Get all users.
-
#response_shim(body, status) ⇒ Object
Fake a response which looks like we get from all the other paths.
-
#revoke(id, group) ⇒ Wavefront::Response
PUT /api/v2/user/id/revoke Revokes a specific user permission.
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
#wf_alert_id?, #wf_alert_severity?, #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_integration_id?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_ms_ts?, #wf_name?, #wf_notificant_id?, #wf_point?, #wf_point_tag?, #wf_point_tags?, #wf_proxy_id?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_source_id?, #wf_string?, #wf_tag?, #wf_ts?, #wf_user_id?, #wf_value?, #wf_version?, #wf_webhook_id?
Constructor Details
This class inherits a constructor from Wavefront::CoreApi
Instance Method Details
#create(body, send_email = false) ⇒ Wavefront::Response
POST /api/v2/user Creates or updates a user
23 24 25 26 |
# File 'lib/wavefront-sdk/user.rb', line 23 def create(body, send_email = false) raise ArgumentError unless body.is_a?(Hash) api.post("?sendEmail=#{send_email}", body, 'application/json') end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/user/id Delete a specific user.
34 35 36 37 |
# File 'lib/wavefront-sdk/user.rb', line 34 def delete(id) wf_user_id?(id) api.delete(id) end |
#describe(id) ⇒ Wavefront::Response
GET /api/v2/user/id Retrieves a user by identifier (email addr).
45 46 47 48 |
# File 'lib/wavefront-sdk/user.rb', line 45 def describe(id) wf_user_id?(id) api.get(id) end |
#everything ⇒ Object
the user API class does not support pagination. Be up-front about that.
106 107 108 |
# File 'lib/wavefront-sdk/user.rb', line 106 def everything raise NoMethodError end |
#grant(id, group) ⇒ Wavefront::Response
PUT /api/v2/user/id/grant Grants a specific user permission.
63 64 65 66 67 68 |
# File 'lib/wavefront-sdk/user.rb', line 63 def grant(id, group) wf_user_id?(id) raise ArgumentError unless group.is_a?(String) api.post([id, 'grant'].uri_concat, "group=#{group}", 'application/x-www-form-urlencoded') end |
#list ⇒ Object
GET /api/v2/user Get all users.
11 12 13 |
# File 'lib/wavefront-sdk/user.rb', line 11 def list api.get('') end |
#response_shim(body, status) ⇒ Object
Fake a response which looks like we get from all the other paths. I’m expecting the user response model to be made consistent with others in the future.
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/wavefront-sdk/user.rb', line 90 def response_shim(body, status) items = JSON.parse(body) { response: { items: items, offset: 0, limit: items.size, totalItems: items.size, modeItems: false }, status: { result: status == 200 ? 'OK' : 'ERROR', message: '', code: status } }.to_json end |
#revoke(id, group) ⇒ Wavefront::Response
PUT /api/v2/user/id/revoke Revokes a specific user permission.
79 80 81 82 83 84 |
# File 'lib/wavefront-sdk/user.rb', line 79 def revoke(id, group) wf_user_id?(id) raise ArgumentError unless group.is_a?(String) api.post([id, 'revoke'].uri_concat, "group=#{group}", 'application/x-www-form-urlencoded') end |