diplomat 0.8.0 → 0.8.1

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
  SHA1:
3
- metadata.gz: 8c4fdef4cc41c9b67236ee64307e8f156ffcc790
4
- data.tar.gz: 3506d1b24c567796d5fa397ae3055da5efbac41f
3
+ metadata.gz: 09450d2e223b6c427a4a9c08baf350f71942619f
4
+ data.tar.gz: ecdb5da0593f8c23cfe33243e73425955b5185e2
5
5
  SHA512:
6
- metadata.gz: 837c53a701c4a1d3d1c2d8972bde7895530319dd056dcb9d5d1d9567c0c59ea130e3dca260df277f3f145bec30d18891987a9519e74551e21682090e95fc237d
7
- data.tar.gz: 8a0d0aab7c784b5af4bb39a6d7aeb24b717d9c49134293542dc5ba5aa19a53f373bf067502ff0b30a8b7dff40951a49deb39c6cb935e56a1fedf33e4af380a84
6
+ metadata.gz: de68de63837165d8317e6549273bd2a563c5b16f7050785cc94ca25eef7580aff0054e0f5130c848e13b03df287bc8cd13e58484b0bab925a5c7242d83d10325
7
+ data.tar.gz: 4ddd450e82c8d0bab4381c62dff895931fa74baad7a5c7179995ceed4a31d5edaeed19e2c97aac59139be6d2b6e31e42b91a0c947125e71dd35cda9847017065
@@ -3,6 +3,8 @@ require 'faraday'
3
3
 
4
4
  module Diplomat
5
5
  class Service < Diplomat::RestClient
6
+ REGISTER_URL = '/v1/agent/service/register'
7
+ DEREGISTER_URL = '/v1/agent/service/deregister'
6
8
 
7
9
  # Get a service by it's key
8
10
  # @param key [String] the key
@@ -42,9 +44,36 @@ module Diplomat
42
44
  return OpenStruct.new JSON.parse(ret.body).first
43
45
  end
44
46
 
47
+ # Register a service
48
+ # @param definition [Hash] Hash containing definition of service
49
+ # @return [Boolean]
50
+ def register(definition)
51
+ json_definition = JSON.dump(definition)
52
+ register = @conn.put Service::REGISTER_URL, json_definition
53
+ return register.status == 200
54
+ end
55
+
56
+ # De-register a service
57
+ # @param service_name [String] Service name to de-register
58
+ # @return [Boolean]
59
+ def deregister(service_name)
60
+ deregister = @conn.get "#{Service::DEREGISTER_URL}/#{service_name}"
61
+ return deregister.status == 200
62
+ end
63
+
45
64
  # @note This is sugar, see (#get)
46
65
  def self.get *args
47
- new(*args).get
66
+ Diplomat::Service.new(*args).get
67
+ end
68
+
69
+ # @note This is sugar, see (#register)
70
+ def self.register definition
71
+ Diplomat::Service.new.register definition
72
+ end
73
+
74
+ # @note This is sugar, see (#deregister)
75
+ def self.deregister service_name
76
+ Diplomat::Service.new.deregister service_name
48
77
  end
49
78
 
50
79
  end
@@ -1,3 +1,3 @@
1
1
  module Diplomat
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
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: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hamelink