wavefront-sdk 6.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +4 -4
  3. data/.github/workflows/test.yml +2 -2
  4. data/.rubocop.yml +1 -3
  5. data/Gemfile +11 -0
  6. data/HISTORY.md +32 -4
  7. data/README.md +3 -3
  8. data/lib/wavefront-sdk/accesspolicy.rb +37 -0
  9. data/lib/wavefront-sdk/account.rb +28 -0
  10. data/lib/wavefront-sdk/alert.rb +29 -10
  11. data/lib/wavefront-sdk/api_mixins/tag.rb +12 -12
  12. data/lib/wavefront-sdk/apitoken.rb +29 -2
  13. data/lib/wavefront-sdk/cloudintegration.rb +10 -8
  14. data/lib/wavefront-sdk/cluster.rb +18 -0
  15. data/lib/wavefront-sdk/core/api_caller.rb +3 -9
  16. data/lib/wavefront-sdk/core/exception.rb +4 -0
  17. data/lib/wavefront-sdk/core/response.rb +1 -1
  18. data/lib/wavefront-sdk/credentials.rb +2 -2
  19. data/lib/wavefront-sdk/dashboard.rb +7 -6
  20. data/lib/wavefront-sdk/defs/version.rb +1 -1
  21. data/lib/wavefront-sdk/derivedmetric.rb +7 -6
  22. data/lib/wavefront-sdk/event.rb +5 -5
  23. data/lib/wavefront-sdk/externallink.rb +3 -3
  24. data/lib/wavefront-sdk/ingestionpolicy.rb +32 -5
  25. data/lib/wavefront-sdk/integration.rb +14 -4
  26. data/lib/wavefront-sdk/internals.rb +93 -0
  27. data/lib/wavefront-sdk/maintenancewindow.rb +4 -4
  28. data/lib/wavefront-sdk/message.rb +1 -1
  29. data/lib/wavefront-sdk/metric.rb +2 -2
  30. data/lib/wavefront-sdk/metric_helper.rb +1 -1
  31. data/lib/wavefront-sdk/metricspolicy.rb +3 -3
  32. data/lib/wavefront-sdk/monitoredapplication.rb +55 -0
  33. data/lib/wavefront-sdk/notificant.rb +4 -4
  34. data/lib/wavefront-sdk/paginator/base.rb +1 -1
  35. data/lib/wavefront-sdk/proxy.rb +26 -4
  36. data/lib/wavefront-sdk/role.rb +2 -2
  37. data/lib/wavefront-sdk/savedsearch.rb +4 -4
  38. data/lib/wavefront-sdk/search.rb +9 -7
  39. data/lib/wavefront-sdk/source.rb +6 -6
  40. data/lib/wavefront-sdk/spansamplingpolicy.rb +126 -0
  41. data/lib/wavefront-sdk/stdlib/string.rb +1 -1
  42. data/lib/wavefront-sdk/support/mixins.rb +1 -1
  43. data/lib/wavefront-sdk/support/parse_time.rb +1 -1
  44. data/lib/wavefront-sdk/user.rb +5 -5
  45. data/lib/wavefront-sdk/usergroup.rb +2 -2
  46. data/lib/wavefront-sdk/validators.rb +31 -8
  47. data/lib/wavefront-sdk/webhook.rb +3 -3
  48. data/lib/wavefront-sdk/write.rb +1 -0
  49. data/lib/wavefront-sdk/writers/api.rb +31 -8
  50. data/lib/wavefront-sdk/writers/core.rb +1 -1
  51. data/lib/wavefront_sdk.rb +1 -1
  52. data/spec/constants.rb +2 -2
  53. data/spec/spec_helper.rb +1 -1
  54. data/spec/wavefront-sdk/accesspolicy_spec.rb +53 -0
  55. data/spec/wavefront-sdk/account_spec.rb +32 -1
  56. data/spec/wavefront-sdk/alert_spec.rb +17 -0
  57. data/spec/wavefront-sdk/api_mixins/user_mixins_spec.rb +1 -1
  58. data/spec/wavefront-sdk/apitoken_spec.rb +12 -0
  59. data/spec/wavefront-sdk/cluster_spec.rb +13 -0
  60. data/spec/wavefront-sdk/core/api_caller_spec.rb +1 -1
  61. data/spec/wavefront-sdk/core/api_spec.rb +2 -2
  62. data/spec/wavefront-sdk/core/logger_spec.rb +1 -1
  63. data/spec/wavefront-sdk/core/response_spec.rb +1 -1
  64. data/spec/wavefront-sdk/credentials_spec.rb +11 -15
  65. data/spec/wavefront-sdk/distribution_spec.rb +1 -1
  66. data/spec/wavefront-sdk/ingestionpolicy_spec.rb +11 -0
  67. data/spec/wavefront-sdk/integration_spec.rb +4 -0
  68. data/spec/wavefront-sdk/internals_spec.rb +62 -0
  69. data/spec/wavefront-sdk/metric_helper_spec.rb +1 -1
  70. data/spec/wavefront-sdk/metricspolicy_spec.rb +3 -3
  71. data/spec/wavefront-sdk/misc_spec.rb +3 -3
  72. data/spec/wavefront-sdk/monitoredapplication_spec.rb +35 -0
  73. data/spec/wavefront-sdk/paginator/base_spec.rb +1 -1
  74. data/spec/wavefront-sdk/paginator/post_spec.rb +1 -1
  75. data/spec/wavefront-sdk/proxy_spec.rb +14 -0
  76. data/spec/wavefront-sdk/resources/swagger.spec.gz +0 -0
  77. data/spec/wavefront-sdk/savedsearch_spec.rb +2 -2
  78. data/spec/wavefront-sdk/spansamplingpolicy_spec.rb +47 -0
  79. data/spec/wavefront-sdk/spy_spec.rb +1 -1
  80. data/spec/wavefront-sdk/stdlib/array_spec.rb +1 -1
  81. data/spec/wavefront-sdk/stdlib/hash_spec.rb +1 -1
  82. data/spec/wavefront-sdk/stdlib/string_spec.rb +1 -1
  83. data/spec/wavefront-sdk/support/mixins_spec.rb +1 -1
  84. data/spec/wavefront-sdk/support/parse_time_spec.rb +1 -1
  85. data/spec/wavefront-sdk/unstable/chart_spec.rb +1 -1
  86. data/spec/wavefront-sdk/usage_spec.rb +0 -1
  87. data/spec/wavefront-sdk/user_spec.rb +2 -2
  88. data/spec/wavefront-sdk/validators_spec.rb +17 -1
  89. data/spec/wavefront-sdk/write_spec.rb +1 -1
  90. data/spec/wavefront-sdk/writers/api_spec.rb +1 -1
  91. data/spec/wavefront-sdk/writers/core_spec.rb +1 -1
  92. data/spec/wavefront-sdk/writers/http_spec.rb +1 -1
  93. data/spec/wavefront-sdk/writers/proxy_spec.rb +1 -1
  94. data/spec/wavefront-sdk/writers/socket_spec.rb +1 -1
  95. data/spec/wavefront-sdk/writers/summary_spec.rb +1 -1
  96. data/wavefront-sdk.gemspec +4 -15
  97. metadata +22 -224
@@ -34,7 +34,7 @@ module Wavefront
34
34
  api.post('', body, 'application/json')
35
35
  end
36
36
 
37
- # DELETE /api/v2/derivedmetric/id
37
+ # DELETE /api/v2/derivedmetric/{id}
38
38
  # Delete a specific derived metric definition.
39
39
  # Deleting an active derived metric moves it to 'trash', from
40
40
  # where it can be restored with an #undelete operation. Deleting
@@ -48,7 +48,8 @@ module Wavefront
48
48
  api.delete(id)
49
49
  end
50
50
 
51
- # GET /api/v2/derivedmetric/id
51
+ # GET /api/v2/derivedmetric/{id}
52
+ # GET /api/v2/derivedmetric/{id}/history/{version}
52
53
  # Get a specific derived metric definition / Get a specific
53
54
  # historical version of a specific derived metric definition.
54
55
  #
@@ -64,10 +65,10 @@ module Wavefront
64
65
  api.get(fragments.uri_concat)
65
66
  end
66
67
 
67
- # PUT /api/v2/derivedmetric/id
68
+ # PUT /api/v2/derivedmetric/{id}
68
69
  # Update a specific derived metric definition.
69
70
  #
70
- # @param id [String] a Wavefront alert ID
71
+ # @param id [String] a Wavefront derived metric ID
71
72
  # @param body [Hash] key-value hash of the parameters you wish
72
73
  # to change
73
74
  # @param modify [true, false] if true, use {#describe()} to get
@@ -85,7 +86,7 @@ module Wavefront
85
86
  'application/json')
86
87
  end
87
88
 
88
- # GET /api/v2/derivedmetric/id/history
89
+ # GET /api/v2/derivedmetric/{id}/history
89
90
  # Get the version history of a derived metric definition.
90
91
  #
91
92
  # @param id [String] ID of the derived metric
@@ -96,7 +97,7 @@ module Wavefront
96
97
  api.get([id, 'history'].uri_concat)
97
98
  end
98
99
 
99
- # POST /api/v2/derivedmetric/id/undelete
100
+ # POST /api/v2/derivedmetric/{id}/undelete
100
101
  # Move a derived metric definition from 'trash' back into active
101
102
  # service.
102
103
  #
@@ -56,10 +56,10 @@ module Wavefront
56
56
  api.post('', body, 'application/json')
57
57
  end
58
58
 
59
- # DELETE /api/v2/event/id
59
+ # DELETE /api/v2/event/{id}
60
60
  # Delete a specific event.
61
61
  #
62
- # @param id [String] ID of the alert
62
+ # @param id [String] ID of the event
63
63
  # @return [Wavefront::Response]
64
64
  #
65
65
  def delete(id)
@@ -67,7 +67,7 @@ module Wavefront
67
67
  api.delete(id)
68
68
  end
69
69
 
70
- # GET /api/v2/event/id
70
+ # GET /api/v2/event/{id}
71
71
  # Get a specific event / Get a specific historical version of a
72
72
  # specific event.
73
73
  #
@@ -83,7 +83,7 @@ module Wavefront
83
83
  api.get(fragments.uri_concat)
84
84
  end
85
85
 
86
- # PUT /api/v2/event/id
86
+ # PUT /api/v2/event/{id}
87
87
  # Update a specific event
88
88
  #
89
89
  # This method helps you update one or more properties of an event.
@@ -107,7 +107,7 @@ module Wavefront
107
107
  'application/json')
108
108
  end
109
109
 
110
- # POST /api/v2/event/id/close
110
+ # POST /api/v2/event/{id}/close
111
111
  # Close a specific event.
112
112
  #
113
113
  # @param id [String] the ID of the event
@@ -38,7 +38,7 @@ module Wavefront
38
38
  api.post('', body, 'application/json')
39
39
  end
40
40
 
41
- # DELETE /api/v2/extlink/id
41
+ # DELETE /api/v2/extlink/{id}
42
42
  # Delete a specific external link.
43
43
  #
44
44
  # @param id [String] ID of the link
@@ -49,7 +49,7 @@ module Wavefront
49
49
  api.delete(id)
50
50
  end
51
51
 
52
- # GET /api/v2/extlink/id
52
+ # GET /api/v2/extlink/{id}
53
53
  # Get a specific external link.
54
54
  #
55
55
  # @param id [String] ID of the limnk
@@ -60,7 +60,7 @@ module Wavefront
60
60
  api.get(id)
61
61
  end
62
62
 
63
- # PUT /api/v2/extlink/id
63
+ # PUT /api/v2/extlink/{id}
64
64
  # Update a specific external link.
65
65
  #
66
66
  # @param id [String] a Wavefront external link ID
@@ -41,7 +41,7 @@ module Wavefront
41
41
  # DELETE /api/v2/usage/ingestionpolicy/{id}
42
42
  # Delete a specific ingestion policy
43
43
  #
44
- # @param id [String] ID of the alert
44
+ # @param id [String] ID of the ingestion policy
45
45
  # @return [Wavefront::Response]
46
46
  #
47
47
  def delete(id)
@@ -50,21 +50,26 @@ module Wavefront
50
50
  end
51
51
 
52
52
  # GET /api/v2/usage/ingestionpolicy/{id}
53
+ # GET /api/v2/usage/ingestionpolicy/{id}/history/{version}
53
54
  # Get a specific ingestion policy
54
55
  #
55
56
  # @return [Wavefront::Response]
56
- # @param id [String] ID of the proxy
57
+ # @param id [String] ID of the ingestion policy
58
+ # @param version [Integer] version of ingestion policy
57
59
  # @return [Wavefront::Response]
58
60
  #
59
- def describe(id)
61
+ def describe(id, version = nil)
60
62
  wf_ingestionpolicy_id?(id)
61
- api.get(id)
63
+ wf_version?(version) if version
64
+ fragments = [id]
65
+ fragments += ['history', version] if version
66
+ api.get(fragments.uri_concat)
62
67
  end
63
68
 
64
69
  # PUT /api/v2/usage/ingestionpolicy/{id}
65
70
  # Update a specific ingestion policy
66
71
  #
67
- # @param id [String] a Wavefront alert ID
72
+ # @param id [String] ID of the ingestion policy
68
73
  # @param body [Hash] key-value hash of the parameters you wish
69
74
  # to change
70
75
  # @param modify [true, false] if true, use {#describe()} to get
@@ -82,6 +87,28 @@ module Wavefront
82
87
  'application/json')
83
88
  end
84
89
 
90
+ # GET /api/v2/usage/ingestionpolicy/{id}/history
91
+ # Get the version history of ingestion policy
92
+ # @param id [String] ID of the ingestion policy
93
+ # @return [Wavefront::Response]
94
+ #
95
+ def history(id)
96
+ wf_ingestionpolicy_id?(id)
97
+ api.get([id, 'history'].uri_concat)
98
+ end
99
+
100
+ # POST /api/v2/usage/ingestionpolicy/{id}/revert/{version}
101
+ # Revert to a specific historical version of a ingestion policy
102
+ # @param id [String] ID of the ingestion policy
103
+ # @param version [Integer] version to revert to
104
+ # @return [Wavefront::Response]
105
+ #
106
+ def revert(id, version)
107
+ wf_ingestionpolicy_id?(id)
108
+ wf_version?(version)
109
+ api.post([id, 'revert', version].uri_concat, nil, 'application/json')
110
+ end
111
+
85
112
  def update_keys
86
113
  %i[name]
87
114
  end
@@ -19,7 +19,7 @@ module Wavefront
19
19
  api.get('', offset: offset, limit: limit)
20
20
  end
21
21
 
22
- # GET /api/v2/integration/id
22
+ # GET /api/v2/integration/{id}
23
23
  # Gets a single Wavefront integration by its id, along with its
24
24
  # status
25
25
  #
@@ -31,7 +31,7 @@ module Wavefront
31
31
  api.get(id)
32
32
  end
33
33
 
34
- # POST /api/v2/integration/id/install
34
+ # POST /api/v2/integration/{id}/install
35
35
  # Installs a Wavefront integration
36
36
  #
37
37
  # @param id [String] ID of the integration
@@ -53,7 +53,7 @@ module Wavefront
53
53
  api.post([id, 'install-all-alerts'].uri_concat, nil)
54
54
  end
55
55
 
56
- # GET /api/v2/integration/id/status
56
+ # GET /api/v2/integration/{id}/status
57
57
  # Gets the status of a single Wavefront integration
58
58
  #
59
59
  # @param id [String] ID of the integration
@@ -64,7 +64,7 @@ module Wavefront
64
64
  api.get([id, 'status'].uri_concat)
65
65
  end
66
66
 
67
- # POST /api/v2/integration/id/uninstall
67
+ # POST /api/v2/integration/{id}/uninstall
68
68
  # Uninstalls a Wavefront integration
69
69
  #
70
70
  # @param id [String] ID of the integration
@@ -114,5 +114,15 @@ module Wavefront
114
114
  def statuses
115
115
  api.get('status')
116
116
  end
117
+
118
+ # GET /api/v2/integration/manifests/min
119
+ # Gets all Wavefront integrations as structured in their integration
120
+ # manifests.
121
+ #
122
+ # @return [Wavefront::Response]
123
+ #
124
+ def manifests_min
125
+ api.get('manifests/min')
126
+ end
117
127
  end
118
128
  end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'pathname'
5
+
6
+ module Wavefront
7
+ #
8
+ # Methods to inspect the SDK itselr.
9
+ #
10
+ class Internals
11
+ API_REGEX = %r{^\s+ # (GET|POST|PUT|DELETE|PATCH) /}
12
+
13
+ # @return [Array[Pathname]] SDK API files
14
+ #
15
+ def sdk_files
16
+ Pathname.glob("#{__dir__}/**/*")
17
+ .select { |f| f.file? && f.extname == '.rb' }
18
+ .reject { |f| f == Pathname.new(__FILE__) }
19
+ end
20
+
21
+ # @return [Array[String]] list of all the remote API paths the SDK covers.
22
+ # Depends on the code being commented correctly, so not 100% bulletproof.
23
+ #
24
+ # rubocop:disable Metrics/AbcSize
25
+ def supported_api_paths
26
+ mix = { acl: [], tag: [], user: [] }
27
+ searches = []
28
+
29
+ paths = sdk_files.map do |f|
30
+ lines = File.readlines(f)
31
+ searches << f if lines.grep('CoreApi')
32
+ mix.each_key { |m| mix[m] << f if lines.grep(%r{"api_mixins/#{m}"}) }
33
+ lines.grep(API_REGEX)
34
+ end
35
+
36
+ clean = paths_struct(clean_paths(paths))
37
+ clean + mixin_paths(clean, mix) + search_paths(clean, searches)
38
+ end
39
+ # rubocop:enable Metrics/AbcSize
40
+
41
+ def clean_paths(paths)
42
+ paths.flatten.compact.map { |s| s.strip.sub(/^# /, '') }
43
+ end
44
+
45
+ def search_paths(paths, files)
46
+ search_paths = paths.select { |_v, x| x.include?('/search/') }
47
+
48
+ search_paths.each_with_object([]) do |(verb, path), ret|
49
+ files.each { |f| ret << [verb, path.sub('{entity}', api_word(f))] }
50
+ end
51
+ end
52
+
53
+ def remote_api_paths(spec = swagger_spec)
54
+ paths = JSON.parse(spec)['paths'].map do |path, data|
55
+ data.keys.map { |verb| [verb.upcase, path].join(' ') }
56
+ end
57
+
58
+ paths_struct(paths.flatten)
59
+ end
60
+
61
+ def missing_api_paths
62
+ # We don't have an explicit method for the many search paths: they're
63
+ # all bundled together under a generic Wavefront::Search.
64
+ (remote_api_paths - supported_api_paths).reject do |_method, path|
65
+ path.start_with?('/api/v2/search/')
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ def mixin_paths(paths, mixins)
72
+ mixins.each_with_object([]) do |(mixin, files), ret|
73
+ files.each do |file|
74
+ paths.select { |_v, x| x.include?(mixin.to_s) }.each do |verb, path|
75
+ ret << [verb, path.sub('{entity}', api_word(file))]
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ def api_word(file)
82
+ file.basename.to_s.sub(/\.rb$/, '')
83
+ end
84
+
85
+ def swagger_spec
86
+ Faraday.get('https://metrics.wavefront.com/api/v2/swagger.json').body
87
+ end
88
+
89
+ def paths_struct(paths)
90
+ paths.map(&:split).sort_by { |_k, v| v }
91
+ end
92
+ end
93
+ end
@@ -38,7 +38,7 @@ module Wavefront
38
38
  api.post('', body, 'application/json')
39
39
  end
40
40
 
41
- # DELETE /api/v2/maintenancewindow/id
41
+ # DELETE /api/v2/maintenancewindow/{id}
42
42
  # Delete a specific maintenance window.
43
43
  #
44
44
  # @param id [String, Integer] ID of the maintenance window
@@ -49,7 +49,7 @@ module Wavefront
49
49
  api.delete(id)
50
50
  end
51
51
 
52
- # GET /api/v2/maintenancewindow/id
52
+ # GET /api/v2/maintenancewindow/{id}
53
53
  # Get a specific maintenance window.
54
54
  #
55
55
  # @param id [String, Integer] ID of the maintenance window
@@ -60,7 +60,7 @@ module Wavefront
60
60
  api.get(id)
61
61
  end
62
62
 
63
- # PUT /api/v2/maintenancewindow/id
63
+ # PUT /api/v2/maintenancewindow/{id}
64
64
  # Update a specific maintenance window.
65
65
  #
66
66
  # @param id [String] a Wavefront maintenance window ID
@@ -93,7 +93,7 @@ module Wavefront
93
93
  # @return [Wavefront::Response]
94
94
  #
95
95
  def pending(hours = 24)
96
- cutoff = Time.now.to_i + hours * 3600
96
+ cutoff = Time.now.to_i + (hours * 3600)
97
97
 
98
98
  ret = windows_in_state(:pending)
99
99
 
@@ -18,7 +18,7 @@ module Wavefront
18
18
  api.get('', offset: offset, limit: limit, unreadOnly: unread_only)
19
19
  end
20
20
 
21
- # POST /api/v2/message/id/read
21
+ # POST /api/v2/message/{id}/read
22
22
  # Mark a specific message as read
23
23
  #
24
24
  # @param id [String] message ID to mark as read
@@ -27,10 +27,10 @@ module Wavefront
27
27
  if cursor
28
28
  raise ArgumentError unless cursor.is_a?(String)
29
29
 
30
- query.<< [:c, cursor]
30
+ query << [:c, cursor]
31
31
  end
32
32
 
33
- sources.each { |source| query.<< [:h, source] }
33
+ sources.each { |source| query << [:h, source] }
34
34
 
35
35
  api.get('detail', query)
36
36
  end
@@ -37,7 +37,7 @@ module Wavefront
37
37
  def gauge(path, value, tags = nil)
38
38
  gauge = { path: path, ts: Time.now.to_i, value: value }
39
39
  gauge[:tags] = tags if tags
40
- @buf[:gauges].<< gauge
40
+ @buf[:gauges] << gauge
41
41
  end
42
42
 
43
43
  # These counters are internal, and specific to the SDK. When
@@ -30,17 +30,17 @@ module Wavefront
30
30
  # @param limit [Integer] the number of versions to return
31
31
  #
32
32
  def history(offset = 0, limit = 100)
33
- api.get('', offset: offset, limit: limit)
33
+ api.get('history', offset: offset, limit: limit)
34
34
  end
35
35
 
36
36
  # POST /api/v2/metricspolicy/revert/{version}
37
37
  # Revert to a specific historical version of a metrics policy
38
- # @param version [Integer] specify version to describe
38
+ # @param version [Integer] version to revert to
39
39
  # @return [Wavefront::Response]
40
40
  #
41
41
  def revert(version)
42
42
  wf_version?(version)
43
- api.post(['revert', version].uri_concat)
43
+ api.post(['revert', version].uri_concat, nil, 'application/json')
44
44
  end
45
45
 
46
46
  # PUT /api/v2/metricspolicy
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'core/api'
4
+
5
+ module Wavefront
6
+ #
7
+ # Manage and query Wavefront monitored applications
8
+ #
9
+ class MonitoredApplication < CoreApi
10
+ def update_keys
11
+ %i[hidden application satisfiedLatencyMillis]
12
+ end
13
+
14
+ # GET /api/v2/monitoredapplication
15
+ # Get all monitored services
16
+ #
17
+ # @param offset [Integer] application at which the list begins
18
+ # @param limit [Integer] the number of application to return
19
+ #
20
+ def list(offset = 0, limit = 100)
21
+ api.get('', offset: offset, limit: limit)
22
+ end
23
+
24
+ # GET /api/v2/monitoredapplication/{application}
25
+ # Get a specific application
26
+ #
27
+ # @param id [String, Integer] ID of the application
28
+ # @return [Wavefront::Response]
29
+ #
30
+ def describe(id)
31
+ wf_monitoredapplication_id?(id)
32
+ api.get(id)
33
+ end
34
+
35
+ # PUT /api/v2/monitoredapplication/{application}
36
+ # Update a specific service
37
+ #
38
+ # @param id [String] a Wavefront monitored application ID
39
+ # @param body [Hash] key-value hash of the parameters you wish to change
40
+ # @param modify [true, false] if true, use {#describe()} to get a hash
41
+ # describing the existing object, and modify that with the new body. If
42
+ # false, pass the new body straight through.
43
+ # @return [Wavefront::Response]
44
+
45
+ def update(id, body, modify = true)
46
+ wf_monitoredapplication_id?(id)
47
+ raise ArgumentError unless body.is_a?(Hash)
48
+
49
+ return api.put(id, body, 'application/json') unless modify
50
+
51
+ api.put(id, hash_for_update(describe(id).response, body),
52
+ 'application/json')
53
+ end
54
+ end
55
+ end
@@ -29,7 +29,7 @@ module Wavefront
29
29
  api.post('', body, 'application/json')
30
30
  end
31
31
 
32
- # DELETE /api/v2/notificant/id
32
+ # DELETE /api/v2/notificant/{id}
33
33
  # Delete a specific notificant
34
34
  #
35
35
  # @param id [String] ID of the notification target
@@ -40,7 +40,7 @@ module Wavefront
40
40
  api.delete(id)
41
41
  end
42
42
 
43
- # GET /api/v2/notificant/id
43
+ # GET /api/v2/notificant/{id}
44
44
  # Get a specific notification target
45
45
  #
46
46
  # @param id [String] ID of the notification target
@@ -51,7 +51,7 @@ module Wavefront
51
51
  api.get(id)
52
52
  end
53
53
 
54
- # PUT /api/v2/notificant/id
54
+ # PUT /api/v2/notificant/{id}
55
55
  # Update a specific notification target
56
56
  #
57
57
  # @param id [String] a Wavefront notification target ID
@@ -72,7 +72,7 @@ module Wavefront
72
72
  'application/json')
73
73
  end
74
74
 
75
- # POST /api/v2/notificant/test/id
75
+ # POST /api/v2/notificant/test/{id}
76
76
  # Create a notification target.
77
77
  #
78
78
  # @param body [Hash] description of notification target
@@ -166,7 +166,7 @@ module Wavefront
166
166
  end
167
167
 
168
168
  p_args = set_pagination(offset, page_size, p_args)
169
- resp.response.items.map { |i| y.<< i }
169
+ resp.response.items.map { |i| y << i }
170
170
  raise StopIteration unless resp.more_items?
171
171
  end
172
172
  end.lazy
@@ -17,7 +17,7 @@ module Wavefront
17
17
  api.get('', offset: offset, limit: limit)
18
18
  end
19
19
 
20
- # DELETE /api/v2/proxy/id
20
+ # DELETE /api/v2/proxy/{id}
21
21
  # Delete a specific proxy
22
22
  #
23
23
  # Deleting an active proxy moves it to 'trash', from where it
@@ -32,7 +32,7 @@ module Wavefront
32
32
  api.delete(id)
33
33
  end
34
34
 
35
- # GET /api/v2/proxy/id
35
+ # GET /api/v2/proxy/{id}
36
36
  # Get a specific proxy
37
37
  #
38
38
  # @param id [String] ID of the proxy
@@ -43,7 +43,7 @@ module Wavefront
43
43
  api.get(id)
44
44
  end
45
45
 
46
- # POST /api/v2/proxy/id/undelete
46
+ # POST /api/v2/proxy/{id}/undelete
47
47
  # Undelete a specific proxy
48
48
  #
49
49
  # Move a proxy from 'trash' back into active service.
@@ -56,7 +56,7 @@ module Wavefront
56
56
  api.post([id, 'undelete'].uri_concat)
57
57
  end
58
58
 
59
- # PUT /api/v2/proxy/id
59
+ # PUT /api/v2/proxy/{id}
60
60
  # Update the name of a specific proxy
61
61
  #
62
62
  # Rename a proxy. This changes the human-readable name, not the
@@ -96,5 +96,27 @@ module Wavefront
96
96
  wf_proxy_id?(id)
97
97
  api.put(id, { shutdown: true }, 'application/json')
98
98
  end
99
+
100
+ # GET /api/v2/proxy/{id}/config
101
+ # Get a specific proxy config
102
+ #
103
+ # @param id [String] ID of the proxy
104
+ # @return [Wavefront::Response]
105
+ #
106
+ def config(id)
107
+ wf_proxy_id?(id)
108
+ api.get([id, 'config'].uri_concat)
109
+ end
110
+
111
+ # GET /api/v2/proxy/{id}/preprocessorRules
112
+ # Get a specific proxy preprocessor rules
113
+ #
114
+ # @param id [String] ID of the proxy
115
+ # @return [Wavefront::Response]
116
+ #
117
+ def preprocessor_rules(id)
118
+ wf_proxy_id?(id)
119
+ api.get([id, 'preprocessorRules'].uri_concat)
120
+ end
99
121
  end
100
122
  end
@@ -16,8 +16,8 @@ module Wavefront
16
16
 
17
17
  # GET /api/v2/role
18
18
  # Get all roles for a customer
19
- # @param offset [Int] alert at which the list begins
20
- # @param limit [Int] the number of alerts to return
19
+ # @param offset [Int] item at which the list begins
20
+ # @param limit [Int] the number of items to return
21
21
  # @return [Wavefront::Response]
22
22
  #
23
23
  def list(offset = 0, limit = 100)
@@ -32,7 +32,7 @@ module Wavefront
32
32
  api.post('', body, 'application/json')
33
33
  end
34
34
 
35
- # DELETE /api/v2/savedsearch/id
35
+ # DELETE /api/v2/savedsearch/{id}
36
36
  # Delete a specific saved search.
37
37
  #
38
38
  # @param id [String] ID of the saved search
@@ -43,7 +43,7 @@ module Wavefront
43
43
  api.delete(id)
44
44
  end
45
45
 
46
- # GET /api/v2/savedsearch/id
46
+ # GET /api/v2/savedsearch/{id}
47
47
  # Get a specific saved search.
48
48
  #
49
49
  # @param id [String] ID of the saved search
@@ -54,7 +54,7 @@ module Wavefront
54
54
  api.get(id)
55
55
  end
56
56
 
57
- # PUT /api/v2/savedsearch/id
57
+ # PUT /api/v2/savedsearch/{id}
58
58
  # Update a specific saved search.
59
59
  #
60
60
  # @param id [String] ID of the saved search
@@ -67,7 +67,7 @@ module Wavefront
67
67
  api.put(id, body)
68
68
  end
69
69
 
70
- # GET /api/v2/savedsearch/type/entitytype
70
+ # GET /api/v2/savedsearch/type/{entitytype}
71
71
  # Get all saved searches for a specific entity type for a user.
72
72
  #
73
73
  # @param entitytype [String] type of entity to retrieve
@@ -10,8 +10,8 @@ module Wavefront
10
10
  # lot up to the user. It may grow, with convenience methods.
11
11
  #
12
12
  class Search < CoreApi
13
- # POST /api/v2/search/entity
14
- # POST /api/v2/search/entity/deleted
13
+ # POST /api/v2/search/{entity}
14
+ # POST /api/v2/search/{entity}/deleted
15
15
  # Run a search query. This single method maps to many API paths.
16
16
  # It is a wrapper around #raw_search() for common, single
17
17
  # key-value searches. If you need to do more complicated things,
@@ -78,8 +78,8 @@ module Wavefront
78
78
  ascending: !options[:desc] || true }
79
79
  end
80
80
 
81
- # POST /api/v2/search/entity
82
- # POST /api/v2/search/entity/deleted
81
+ # POST /api/v2/search/{entity}
82
+ # POST /api/v2/search/{entity}/deleted
83
83
  # Run a search query. This single method maps to many API paths.
84
84
  #
85
85
  # @param entity [String] the type of Wavefront object you wish
@@ -98,10 +98,12 @@ module Wavefront
98
98
  end
99
99
 
100
100
  path = [entity]
101
- path.<< 'deleted' if deleted
101
+ path << 'deleted' if deleted
102
102
  api.post(path, body, 'application/json')
103
103
  end
104
104
 
105
+ # POST /api/v2/search/{entity}/facets
106
+ # POST /api/v2/search/{entity}/{facet}
105
107
  # @param entity [String] the type of Wavefront object you wish
106
108
  # to search
107
109
  # @param body [Hash] the query to use for searching. Refer to
@@ -119,8 +121,8 @@ module Wavefront
119
121
  raise ArgumentError unless entity.is_a?(String) && body.is_a?(Hash)
120
122
 
121
123
  path = [entity]
122
- path.<< 'deleted' if deleted
123
- path.<< facet || 'facets'
124
+ path << 'deleted' if deleted
125
+ path << (facet || 'facets')
124
126
  api.post(path, body, 'application/json')
125
127
  end
126
128
  # rubocop:enable Metrics/ParameterLists