diplomat 2.0.4 → 2.0.5

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: 7f1bbdd8214c80fe6eb9251117c8b1d84126094556b000e71b09ef23858c5ed4
4
- data.tar.gz: 903ca1a188272e833f8c7b8b16c40b9657ddf106ee6106870f6f07258aed1778
3
+ metadata.gz: c67b8ac370c8b73bd37fea1bcdcca6f88cf75e789f58a2ebb7abe0b1a1da83c1
4
+ data.tar.gz: ec8ff0e996067dab3580d874961d30588b8015f6efdb0d133f0699a2501fd4ab
5
5
  SHA512:
6
- metadata.gz: 64707810314abf1181fb023c06a7163ab016569457d191f6486a6e3c57a51cb4b563563acdb915afc9bfee7d6806cc7c3998f7960ce2460a3121bf3fe72bb74d
7
- data.tar.gz: 4c374ced96963ee4a4fea2e4b7ab5d2a9e20a1036f5bdb80746a1ad94ffdc82db98653ddf1707d72158630efc8d8405e4b96ab0f527ebb28212cf34d12f35dbe
6
+ metadata.gz: fa2eca5776b8652c1032e5d67348086e48a8f3f05adf1b18a1457754a460f8bcbfda561108124962e7da059155c60df19860dfae1baf24b559ecfd258bcdcd41
7
+ data.tar.gz: b429f5262c799f09f735d6821a772429c2a66e829b08facd55b9fbb1938f768545fae8b2eda2a222dedcf9f560e3c3b4be5e7c46afb1e35ccc8e0412e933902e
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Diplomat
2
- [![Gem Version](https://badge.fury.io/rb/diplomat.svg)](http://badge.fury.io/rb/diplomat) [![Gem](https://img.shields.io/gem/dt/diplomat.svg)](https://rubygems.org/gems/diplomat/versions/2.0.0) [![Build Status](https://travis-ci.org/WeAreFarmGeek/diplomat.svg?branch=master)](https://travis-ci.org/WeAreFarmGeek/diplomat) [![Code Climate](https://codeclimate.com/github/johnhamelink/diplomat.svg)](https://codeclimate.com/github/WeAreFarmGeek/diplomat) [![Inline docs](http://inch-ci.org/github/wearefarmgeek/diplomat.svg?branch=master)](http://inch-ci.org/github/wearefarmgeek/diplomat)
2
+ [![Gem Version](https://badge.fury.io/rb/diplomat.svg)](https://rubygems.org/gems/diplomat) [![Gem](https://img.shields.io/gem/dt/diplomat.svg)](https://rubygems.org/gems/diplomat/versions/2.0.0) [![Build Status](https://travis-ci.org/WeAreFarmGeek/diplomat.svg?branch=master)](https://travis-ci.org/WeAreFarmGeek/diplomat) [![Code Climate](https://codeclimate.com/github/johnhamelink/diplomat.svg)](https://codeclimate.com/github/WeAreFarmGeek/diplomat) [![Inline docs](http://inch-ci.org/github/wearefarmgeek/diplomat.svg?branch=master)](http://inch-ci.org/github/wearefarmgeek/diplomat)
3
3
  ### A HTTP Ruby API for [Consul](http://www.consul.io/)
4
4
 
5
5
  ![Diplomacy Boad Game](http://i.imgur.com/Nkuy4b7.jpg)
@@ -50,32 +50,45 @@ module Diplomat
50
50
  # @param check_id [String] the unique id of the check
51
51
  # @return [Integer] Status code
52
52
  def deregister(check_id)
53
- ret = @conn.get "/v1/agent/check/deregister/#{check_id}"
53
+ ret = @conn.put "/v1/agent/check/deregister/#{check_id}"
54
54
  ret.status == 200
55
55
  end
56
56
 
57
- # Pass a check
57
+ # Update a TTL check
58
58
  # @param check_id [String] the unique id of the check
59
+ # @param status [String] status of the check. Valid values are "passing", "warning", and "critical"
60
+ # @param output [String] human-readable message will be passed through to the check's Output field
59
61
  # @return [Integer] Status code
60
- def pass(check_id)
61
- ret = @conn.get "/v1/agent/check/pass/#{check_id}"
62
+ def update_ttl(check_id, status, output = nil)
63
+ ret = @conn.put do |req|
64
+ req.url "/v1/agent/check/update/#{check_id}"
65
+ req.body = JSON.generate('Status' => status, 'Output' => output)
66
+ end
62
67
  ret.status == 200
63
68
  end
64
69
 
65
- # Warn a check
70
+ # Pass a check
66
71
  # @param check_id [String] the unique id of the check
72
+ # @param output [String] human-readable message will be passed through to the check's Output field
67
73
  # @return [Integer] Status code
68
- def warn(check_id)
69
- ret = @conn.get "/v1/agent/check/warn/#{check_id}"
70
- ret.status == 200
74
+ def pass(check_id, output = nil)
75
+ update_ttl(check_id, 'passing', output)
71
76
  end
72
77
 
73
78
  # Warn a check
74
79
  # @param check_id [String] the unique id of the check
80
+ # @param output [String] human-readable message will be passed through to the check's Output field
75
81
  # @return [Integer] Status code
76
- def fail(check_id)
77
- ret = @conn.get "/v1/agent/check/fail/#{check_id}"
78
- ret.status == 200
82
+ def warn(check_id, output = nil)
83
+ update_ttl(check_id, 'warning', output)
84
+ end
85
+
86
+ # Fail a check
87
+ # @param check_id [String] the unique id of the check
88
+ # @param output [String] human-readable message will be passed through to the check's Output field
89
+ # @return [Integer] Status code
90
+ def fail(check_id, output = nil)
91
+ update_ttl(check_id, 'critical', output)
79
92
  end
80
93
  end
81
94
  end
@@ -1,3 +1,3 @@
1
1
  module Diplomat
2
- VERSION = '2.0.4'.freeze
2
+ VERSION = '2.0.5'.freeze
3
3
  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.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hamelink
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-25 00:00:00.000000000 Z
12
+ date: 2019-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -224,7 +224,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  - !ruby/object:Gem::Version
225
225
  version: '0'
226
226
  requirements: []
227
- rubygems_version: 3.0.2
227
+ rubyforge_project:
228
+ rubygems_version: 2.7.7
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: Diplomat is a simple wrapper for Consul