Class: Wavefront::Webhook

Inherits:
Base
  • Object
show all
Defined in:
lib/wavefront-sdk/webhook.rb

Overview

Manage and query Wavefront webhooks

Instance Attribute Summary

Attributes inherited from Base

#api_base, #conn, #debug, #logger, #net, #noop, #opts, #verbose

Instance Method Summary collapse

Methods inherited from Base

#api_delete, #api_get, #api_post, #api_put, #hash_for_update, #initialize, #log, #mk_conn, #respond, #time_to_ms

Methods included from Mixins

#parse_time

Methods included from Validators

#wf_alert_id?, #wf_alert_severity?, #wf_cloudintegration_id?, #wf_dashboard_id?, #wf_epoch?, #wf_event_id?, #wf_granularity?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_ms_ts?, #wf_name?, #wf_point?, #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::Base

Instance Method Details

#create(body) ⇒ Wavefront::Response

POST /api/v2/webhook Create a specific webhook.

Parameters:

  • body (Hash)

    a hash of parameters describing the webhook. Please refer to the Wavefront Swagger docs for key:value information

Returns:

Raises:

  • (ArgumentError)


30
31
32
33
# File 'lib/wavefront-sdk/webhook.rb', line 30

def create(body)
  raise ArgumentError unless body.is_a?(Hash)
  api_post('', body, 'application/json')
end

#delete(id) ⇒ Wavefront::Response

DELETE /api/v2/webhook/id Delete a specific webhook.

Parameters:

  • id (String, Integer)

    ID of the webhook

Returns:



41
42
43
44
# File 'lib/wavefront-sdk/webhook.rb', line 41

def delete(id)
  wf_webhook_id?(id)
  api_delete(id)
end

#describe(id) ⇒ Wavefront::Response

GET /api/v2/webhook/id Get a specific webhook.

Parameters:

  • id (String, Integer)

    ID of the webhook

Returns:



52
53
54
55
# File 'lib/wavefront-sdk/webhook.rb', line 52

def describe(id)
  wf_webhook_id?(id)
  api_get(id)
end

#list(offset = 0, limit = 100) ⇒ Object

GET /api/v2/webhook Get all webhooks for a customer.

Parameters:

  • offset (Integer) (defaults to: 0)

    webhook at which the list begins

  • limit (Integer) (defaults to: 100)

    the number of webhooks to return



18
19
20
# File 'lib/wavefront-sdk/webhook.rb', line 18

def list(offset = 0, limit = 100)
  api_get('', { offset: offset, limit: limit })
end

#update(id, body, modify = true) ⇒ Wavefront::Response

PUT /api/v2/webhook/id Update a specific webhook.

Parameters:

  • id (String)

    a Wavefront webhook ID

  • body (Hash)

    key-value hash of the parameters you wish to change

  • modify (true, false) (defaults to: true)

    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.

Returns:

Raises:

  • (ArgumentError)


68
69
70
71
72
73
74
75
76
# File 'lib/wavefront-sdk/webhook.rb', line 68

def update(id, body, modify = true)
  wf_webhook_id?(id)
  raise ArgumentError unless body.is_a?(Hash)

  return api_put(id, body, 'application/json') unless modify

  api_put(id, hash_for_update(describe(id).response, body),
          'application/json')
end

#update_keysObject



8
9
10
# File 'lib/wavefront-sdk/webhook.rb', line 8

def update_keys
  %i(title description template title triggers recipient)
end