diplomat 2.6.0 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25c0b2769edc31ef7e21ce9a27bb80640ad924e8c7e5d3941ad85a7cf94605da
4
- data.tar.gz: b42997b367d7a4f17358823e773c5ade86789677c273d02f02ca799baba8c79f
3
+ metadata.gz: 5d140133bd3a6e625d15be77e1c851348e71c3a2ebf573d64d7542f1b68e8745
4
+ data.tar.gz: cb73d392f2a10f9999b43000c52a2064a892c83ba1ed802fc07597ab102bc496
5
5
  SHA512:
6
- metadata.gz: cd6483e59dd18715f52bb783d4cdfaaa4ba3f0b16e5f045c3a7bfea6cfea5f002bda8f3ca85fe33854be9e69e1ae523ba3277699204bcf07c07a8476c84af980
7
- data.tar.gz: 0c92e00358566383f63105d6c656db1b641199fefe03aefdabed592dd4efdf6eceeaa5e7e1a5a1c8ad8538bdf6ed5fdbc48ecd4400a9b556d40a5ab42b1bbeaf
6
+ metadata.gz: f223217f2580e3264164c61e9cfe42284714d853a5d111b330b46891cc3ea3348ccf455dd84446e87b67c92043ae0aef9733803be6a9e1446d8412fea4f41eef
7
+ data.tar.gz: 0d4e0f56a7bc839d1b284a76af995f1a698d092549672ec40c56fd37983d711652c9f4ca671c7d12772d1906147848f272e29cac02cd7c317b4a473c741a2046
data/README.md CHANGED
@@ -331,6 +331,40 @@ Get the health status from autopilot
331
331
  Diplomat::Autopilot.get_health()
332
332
  ```
333
333
 
334
+ ### Health
335
+
336
+ Retrieve health of a node
337
+
338
+ ```ruby
339
+ Diplomat::Health.node('fooNode', :dc => 'abc')
340
+ ```
341
+
342
+ Retrieve health of a given check
343
+
344
+ ```ruby
345
+ Diplomat::Health.checks('fooCheck', :dc => 'abc')
346
+ ```
347
+
348
+ Retrieve health of a given service
349
+
350
+ ```ruby
351
+ Diplomat::Health.service('fooService', :dc => 'abc')
352
+ ```
353
+
354
+ Retrieve a list of anything that correspond to the state ("any", "passing", "warning", or "critical")
355
+ You can use filters too !
356
+
357
+ ```ruby
358
+ Diplomat::Health.state("critical", {:dc => 'abc', :filter => 'Node==foo'})
359
+ ```
360
+
361
+ You also have some convenience method (`any`, `passing`, `warning`, `critical`)
362
+ That can be filtered
363
+
364
+ ```ruby
365
+ Diplomat::Health.critical({:dc => 'abc', :filter => 'ServiceName==foo'})
366
+ ```
367
+
334
368
  ### Maintenance mode
335
369
 
336
370
  Enable maintenance mode on a host, with optional reason and DC (requires access to local agent)
@@ -8,11 +8,12 @@ module Diplomat
8
8
 
9
9
  # Get node health
10
10
  # @param n [String] the node
11
- # @param options [Hash] :dc string for dc specific query
11
+ # @param options [Hash] :dc, :filter string for specific query
12
12
  # @return [OpenStruct] all data associated with the node
13
13
  def node(n, options = {})
14
14
  custom_params = []
15
15
  custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
16
+ custom_params << use_named_parameter('filter', options[:filter]) if options[:filter]
16
17
 
17
18
  ret = send_get_request(@conn, ["/v1/health/node/#{n}"], options, custom_params)
18
19
  JSON.parse(ret.body).map { |node| OpenStruct.new node }
@@ -20,11 +21,12 @@ module Diplomat
20
21
 
21
22
  # Get service checks
22
23
  # @param s [String] the service
23
- # @param options [Hash] :dc string for dc specific query
24
+ # @param options [Hash] :dc, :filter string for specific query
24
25
  # @return [OpenStruct] all data associated with the node
25
26
  def checks(s, options = {})
26
27
  custom_params = []
27
28
  custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
29
+ custom_params << use_named_parameter('filter', options[:filter]) if options[:filter]
28
30
 
29
31
  ret = send_get_request(@conn, ["/v1/health/checks/#{s}"], options, custom_params)
30
32
  JSON.parse(ret.body).map { |check| OpenStruct.new check }
@@ -44,6 +46,7 @@ module Diplomat
44
46
  custom_params << use_named_parameter('near', options[:near]) if options[:near]
45
47
  custom_params << use_named_parameter('node-meta', options[:node_meta]) if options[:node_meta]
46
48
  custom_params << use_named_parameter('index', options[:index]) if options[:index]
49
+ custom_params << use_named_parameter('filter', options[:filter]) if options[:filter]
47
50
 
48
51
  ret = send_get_request(@conn, ["/v1/health/service/#{s}"], options, custom_params)
49
52
  if meta && ret.headers
@@ -59,35 +62,44 @@ module Diplomat
59
62
 
60
63
  # Get service health
61
64
  # @param s [String] the state ("any", "passing", "warning", or "critical")
62
- # @param options [Hash] :dc string for dc specific query
65
+ # @param options [Hash] :dc, :near, :filter string for specific query
63
66
  # @return [OpenStruct] all data associated with the node
64
67
  def state(s, options = {})
65
68
  custom_params = []
66
69
  custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
67
70
  custom_params << use_named_parameter('near', options[:near]) if options[:near]
71
+ custom_params << use_named_parameter('filter', options[:filter]) if options[:filter]
68
72
 
69
73
  ret = send_get_request(@conn, ["/v1/health/state/#{s}"], options, custom_params)
70
74
  JSON.parse(ret.body).map { |status| OpenStruct.new status }
71
75
  end
72
76
 
73
77
  # Convenience method to get services in any state
74
- def any
75
- state('any')
78
+ # @param options [Hash] :dc, :near, :filter string for specific query
79
+ # @return [OpenStruct] all data associated with the node
80
+ def any(options = {})
81
+ state('any', options)
76
82
  end
77
83
 
78
84
  # Convenience method to get services in passing state
79
- def passing
80
- state('passing')
85
+ # @param options [Hash] :dc, :near, :filter string for specific query
86
+ # @return [OpenStruct] all data associated with the node
87
+ def passing(options = {})
88
+ state('passing', options)
81
89
  end
82
90
 
83
91
  # Convenience method to get services in warning state
84
- def warning
85
- state('warning')
92
+ # @param options [Hash] :dc, :near, :filter string for specific query
93
+ # @return [OpenStruct] all data associated with the node
94
+ def warning(options = {})
95
+ state('warning', options)
86
96
  end
87
97
 
88
98
  # Convenience method to get services in critical state
89
- def critical
90
- state('critical')
99
+ # @param options [Hash] :dc, :near, :filter string for specific query
100
+ # @return [OpenStruct] all data associated with the node
101
+ def critical(options = {})
102
+ state('critical', options)
91
103
  end
92
104
  end
93
105
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Diplomat
4
- VERSION = '2.6.0'
4
+ VERSION = '2.6.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diplomat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hamelink
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-09-26 00:00:00.000000000 Z
13
+ date: 2022-07-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -187,6 +187,9 @@ dependencies:
187
187
  - - ">="
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0.9'
190
+ - - "<"
191
+ - !ruby/object:Gem::Version
192
+ version: '2.0'
190
193
  type: :runtime
191
194
  prerelease: false
192
195
  version_requirements: !ruby/object:Gem::Requirement
@@ -194,6 +197,9 @@ dependencies:
194
197
  - - ">="
195
198
  - !ruby/object:Gem::Version
196
199
  version: '0.9'
200
+ - - "<"
201
+ - !ruby/object:Gem::Version
202
+ version: '2.0'
197
203
  description: Diplomat is a simple wrapper for Consul
198
204
  email:
199
205
  - john@johnhamelink.com