Class: Wavefront::IngestionPolicy

Inherits:
CoreApi
  • Object
show all
Defined in:
lib/wavefront-sdk/ingestionpolicy.rb

Overview

View and manage Wavefront ingestion policies.

These use the Usage API path.

Instance Attribute Summary

Attributes inherited from CoreApi

#api, #creds, #logger, #opts

Instance Method Summary collapse

Methods inherited from CoreApi

#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

#api_baseObject



12
13
14
# File 'lib/wavefront-sdk/ingestionpolicy.rb', line 12

def api_base
  '/usage/ingestionpolicy'
end

#create(body) ⇒ Wavefront::Response

POST /api/v2/usage/ingestionpolicy Create a specific ingestion policy

Parameters:

  • body (Hash)

    description of ingestion policy

Returns:

Raises:

  • (ArgumentError)


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

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

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

#delete(id) ⇒ Wavefront::Response

DELETE /api/v2/usage/ingestionpolicy/id Delete a specific ingestion policy

Parameters:

  • id (String)

    ID of the ingestion policy

Returns:



47
48
49
50
# File 'lib/wavefront-sdk/ingestionpolicy.rb', line 47

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

#describe(id, version = nil) ⇒ Wavefront::Response

GET /api/v2/usage/ingestionpolicy/id GET /api/v2/usage/ingestionpolicy/id/history/version Get a specific ingestion policy

Parameters:

  • id (String)

    ID of the ingestion policy

  • version (Integer) (defaults to: nil)

    version of ingestion policy

Returns:



61
62
63
64
65
66
67
# File 'lib/wavefront-sdk/ingestionpolicy.rb', line 61

def describe(id, version = nil)
  wf_ingestionpolicy_id?(id)
  wf_version?(version) if version
  fragments = [id]
  fragments += ['history', version] if version
  api.get(fragments.uri_concat)
end

#history(id) ⇒ Wavefront::Response

GET /api/v2/usage/ingestionpolicy/id/history Get the version history of ingestion policy

Parameters:

  • id (String)

    ID of the ingestion policy

Returns:



95
96
97
98
# File 'lib/wavefront-sdk/ingestionpolicy.rb', line 95

def history(id)
  wf_ingestionpolicy_id?(id)
  api.get([id, 'history'].uri_concat)
end

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

GET /api/v2/usage/ingestionpolicy Get all ingestion policies for a customer

Parameters:

  • offset (Int) (defaults to: 0)

    ingestion policy at which the list begins

  • limit (Int) (defaults to: 100)

    the number of ingestion policies to return

Returns:



25
26
27
# File 'lib/wavefront-sdk/ingestionpolicy.rb', line 25

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

#revert(id, version) ⇒ Wavefront::Response

POST /api/v2/usage/ingestionpolicy/id/revert/version Revert to a specific historical version of a ingestion policy

Parameters:

  • id (String)

    ID of the ingestion policy

  • version (Integer)

    version to revert to

Returns:



106
107
108
109
110
# File 'lib/wavefront-sdk/ingestionpolicy.rb', line 106

def revert(id, version)
  wf_ingestionpolicy_id?(id)
  wf_version?(version)
  api.post([id, 'revert', version].uri_concat, nil, 'application/json')
end

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

PUT /api/v2/usage/ingestionpolicy/id Update a specific ingestion policy

Parameters:

  • id (String)

    ID of the ingestion policy

  • 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)


80
81
82
83
84
85
86
87
88
# File 'lib/wavefront-sdk/ingestionpolicy.rb', line 80

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



112
113
114
# File 'lib/wavefront-sdk/ingestionpolicy.rb', line 112

def update_keys
  %i[name]
end