Class: Wavefront::MonitoredCluster

Inherits:
CoreApi
  • Object
show all
Includes:
Wavefront::Mixin::Tag
Defined in:
lib/wavefront-sdk/monitoredcluster.rb

Overview

Manage and query Wavefront monitored clusters

Instance Attribute Summary

Attributes inherited from CoreApi

#api, #creds, #logger, #opts

Instance Method Summary collapse

Methods included from Wavefront::Mixin::Tag

#tag_add, #tag_delete, #tag_set, #tags

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

#create(body) ⇒ Wavefront::Response

POST /api/v2/monitoredcluster Create a specific cluster

Parameters:

  • body (Hash)

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

Returns:

Raises:

  • (ArgumentError)


34
35
36
37
38
# File 'lib/wavefront-sdk/monitoredcluster.rb', line 34

def create(body)
  raise ArgumentError unless body.is_a?(Hash)

  api.post('', body, 'application/json')
end

#delete(id) ⇒ Wavefront::Response

DELETE /api/v2/monitoredcluster/id Delete a specific cluster

Parameters:

  • id (String, Integer)

    ID of the maintenance cluster

Returns:



45
46
47
48
# File 'lib/wavefront-sdk/monitoredcluster.rb', line 45

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

#describe(id) ⇒ Wavefront::Response

GET /api/v2/monitoredcluster/id Get a specific cluster

Parameters:

  • id (String, Integer)

    ID of the cluster

Returns:



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

def describe(id)
  wf_monitoredcluster_id?(id)
  api.get(id)
end

#list(offset = 0, limit = 100) ⇒ Wavefront::Response

GET /api/v2/monitoredcluster Get all monitored clusters

Parameters:

  • offset (Integer) (defaults to: 0)

    cluster at which the list begins

  • limit (Integer) (defaults to: 100)

    the number of clusters to return

Returns:



23
24
25
# File 'lib/wavefront-sdk/monitoredcluster.rb', line 23

def list(offset = 0, limit = 100)
  api.get('', offset: offset, limit: limit)
end

#merge(id1, id2) ⇒ Wavefront::Response

PUT /api/v2/monitoredcluster/merge/id1/id2 Merge two monitored clusters. The first cluster will remain and the second cluster will be deleted, with its id added as an alias to the first cluster.

Parameters:

  • id1 (String, Integer)

    ID of the target cluster

  • id2 (String, Integer)

    ID of the other cluster

Returns:



82
83
84
85
86
87
# File 'lib/wavefront-sdk/monitoredcluster.rb', line 82

def merge(id1, id2)
  wf_monitoredcluster_id?(id1)
  wf_monitoredcluster_id?(id2)

  api.put(['merge', id1, id2].uri_concat, nil, 'application/json')
end

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

PUT /api/v2/monitoredcluster/id Update a specific cluster

Returns:

Raises:

  • (ArgumentError)


64
65
66
67
68
69
70
71
72
# File 'lib/wavefront-sdk/monitoredcluster.rb', line 64

def update(id, body, modify = true)
  wf_monitoredcluster_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



13
14
15
# File 'lib/wavefront-sdk/monitoredcluster.rb', line 13

def update_keys
  %i[id]
end

#valid_id?(id) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/wavefront-sdk/monitoredcluster.rb', line 89

def valid_id?(id)
  wf_monitoredcluster_id?(id)
end