diplomat-blsk 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +24 -0
- data/README.md +341 -0
- data/features/configuration.feature +9 -0
- data/features/step_definitions/setup_diplomat.rb +24 -0
- data/features/step_definitions/test_key_value.rb +9 -0
- data/lib/diplomat.rb +62 -0
- data/lib/diplomat/acl.rb +92 -0
- data/lib/diplomat/agent.rb +70 -0
- data/lib/diplomat/api_options.rb +46 -0
- data/lib/diplomat/check.rb +81 -0
- data/lib/diplomat/configuration.rb +28 -0
- data/lib/diplomat/datacenter.rb +22 -0
- data/lib/diplomat/error.rb +14 -0
- data/lib/diplomat/event.rb +177 -0
- data/lib/diplomat/health.rb +101 -0
- data/lib/diplomat/kv.rb +266 -0
- data/lib/diplomat/lock.rb +62 -0
- data/lib/diplomat/maintenance.rb +44 -0
- data/lib/diplomat/members.rb +13 -0
- data/lib/diplomat/node.rb +56 -0
- data/lib/diplomat/nodes.rb +25 -0
- data/lib/diplomat/query.rb +124 -0
- data/lib/diplomat/rest_client.rb +180 -0
- data/lib/diplomat/service.rb +118 -0
- data/lib/diplomat/session.rb +99 -0
- data/lib/diplomat/status.rb +22 -0
- data/lib/diplomat/version.rb +3 -0
- metadata +233 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
module Diplomat
|
2
|
+
# Methods for interacting with the Consul session API endpoint
|
3
|
+
class Session < Diplomat::RestClient
|
4
|
+
@access_methods = %i[create destroy list renew info node]
|
5
|
+
|
6
|
+
# Create a new session
|
7
|
+
# @param value [Object] hash or json representation of the session arguments
|
8
|
+
# @param options [Hash] session options
|
9
|
+
# @param options [String] :dc datacenter to create session for
|
10
|
+
# @return [String] The sesssion id
|
11
|
+
def create(value = nil, options = nil)
|
12
|
+
# TODO: only certain keys are recognised in a session create request,
|
13
|
+
# should raise an error on others.
|
14
|
+
raw = @conn.put do |req|
|
15
|
+
url = ['/v1/session/create']
|
16
|
+
url += use_named_parameter('dc', options[:dc]) if options && options[:dc]
|
17
|
+
|
18
|
+
req.url concat_url url
|
19
|
+
req.body = (value.is_a?(String) ? value : JSON.generate(value)) unless value.nil?
|
20
|
+
end
|
21
|
+
body = JSON.parse(raw.body)
|
22
|
+
body['ID']
|
23
|
+
end
|
24
|
+
|
25
|
+
# Destroy a session
|
26
|
+
# @param id [String] session id
|
27
|
+
# @param options [Hash] session options
|
28
|
+
# @param options [String] :dc datacenter to destroy session for
|
29
|
+
# @return [String] Success or failure of the session destruction
|
30
|
+
def destroy(id, options = nil)
|
31
|
+
raw = @conn.put do |req|
|
32
|
+
url = ["/v1/session/destroy/#{id}"]
|
33
|
+
url += use_named_parameter('dc', options[:dc]) if options && options[:dc]
|
34
|
+
|
35
|
+
req.url concat_url url
|
36
|
+
end
|
37
|
+
raw.body
|
38
|
+
end
|
39
|
+
|
40
|
+
# List sessions
|
41
|
+
# @param options [Hash] session options
|
42
|
+
# @param options [String] :dc datacenter to list sessions
|
43
|
+
# @return [OpenStruct]
|
44
|
+
def list(options = nil)
|
45
|
+
raw = @conn.get do |req|
|
46
|
+
url = ['/v1/session/list']
|
47
|
+
url += use_named_parameter('dc', options[:dc]) if options && options[:dc]
|
48
|
+
|
49
|
+
req.url concat_url url
|
50
|
+
end
|
51
|
+
JSON.parse(raw.body).map { |session| OpenStruct.new session }
|
52
|
+
end
|
53
|
+
|
54
|
+
# Renew session
|
55
|
+
# @param id [String] session id
|
56
|
+
# @param options [Hash] session options
|
57
|
+
# @param options [String] :dc datacenter to renew session for
|
58
|
+
# @return [OpenStruct]
|
59
|
+
def renew(id, options = nil)
|
60
|
+
raw = @conn.put do |req|
|
61
|
+
url = ["/v1/session/renew/#{id}"]
|
62
|
+
url += use_named_parameter('dc', options[:dc]) if options && options[:dc]
|
63
|
+
|
64
|
+
req.url concat_url url
|
65
|
+
end
|
66
|
+
JSON.parse(raw.body).map { |session| OpenStruct.new session }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Session information
|
70
|
+
# @param id [String] session id
|
71
|
+
# @param options [Hash] session options
|
72
|
+
# @param options [String] :dc datacenter to renew session for
|
73
|
+
# @return [OpenStruct]
|
74
|
+
def info(id, options = nil)
|
75
|
+
raw = @conn.get do |req|
|
76
|
+
url = ["/v1/session/info/#{id}"]
|
77
|
+
url += use_named_parameter('dc', options[:dc]) if options && options[:dc]
|
78
|
+
|
79
|
+
req.url concat_url url
|
80
|
+
end
|
81
|
+
JSON.parse(raw.body).map { |session| OpenStruct.new session }
|
82
|
+
end
|
83
|
+
|
84
|
+
# Session information for a given node
|
85
|
+
# @param name [String] node name
|
86
|
+
# @param options [Hash] session options
|
87
|
+
# @param options [String] :dc datacenter to renew session for
|
88
|
+
# @return [OpenStruct]
|
89
|
+
def node(name, options = nil)
|
90
|
+
raw = @conn.get do |req|
|
91
|
+
url = ["/v1/session/node/#{name}"]
|
92
|
+
url += use_named_parameter('dc', options[:dc]) if options && options[:dc]
|
93
|
+
|
94
|
+
req.url concat_url url
|
95
|
+
end
|
96
|
+
JSON.parse(raw.body).map { |session| OpenStruct.new session }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Diplomat
|
2
|
+
# Methods for interacting with the Consul status API endpoints, leader and peers
|
3
|
+
class Status < Diplomat::RestClient
|
4
|
+
@access_methods = %i[leader peers]
|
5
|
+
|
6
|
+
# Get the raft leader for the datacenter in which the local consul agent is running
|
7
|
+
# @return [OpenStruct] the address of the leader
|
8
|
+
def leader
|
9
|
+
url = ['/v1/status/leader']
|
10
|
+
ret = @conn.get concat_url url
|
11
|
+
JSON.parse(ret.body)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get an array of Raft peers for the datacenter in which the agent is running
|
15
|
+
# @return [OpenStruct] an array of peers
|
16
|
+
def peers
|
17
|
+
url = ['/v1/status/peers']
|
18
|
+
ret = @conn.get concat_url url
|
19
|
+
JSON.parse(ret.body)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: diplomat-blsk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Hamelink
|
8
|
+
- Trevor Wood
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: codeclimate-test-reporter
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.4.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.4.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: cucumber
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: fakes-rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.1'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: fivemat
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.3'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.3'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: gem-release
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0.7'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0.7'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: pry
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.9'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.9'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rake
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '12.0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '12.0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rspec
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '3.2'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '3.2'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0.47'
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.47.1
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - "~>"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0.47'
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.47.1
|
160
|
+
- !ruby/object:Gem::Dependency
|
161
|
+
name: faraday
|
162
|
+
requirement: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.9'
|
167
|
+
type: :runtime
|
168
|
+
prerelease: false
|
169
|
+
version_requirements: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.9'
|
174
|
+
description: Diplomat is a simple wrapper for Consul
|
175
|
+
email:
|
176
|
+
- john@johnhamelink.com
|
177
|
+
- trevor.g.wood@gmail.com
|
178
|
+
executables: []
|
179
|
+
extensions: []
|
180
|
+
extra_rdoc_files: []
|
181
|
+
files:
|
182
|
+
- LICENSE
|
183
|
+
- README.md
|
184
|
+
- features/configuration.feature
|
185
|
+
- features/step_definitions/setup_diplomat.rb
|
186
|
+
- features/step_definitions/test_key_value.rb
|
187
|
+
- lib/diplomat.rb
|
188
|
+
- lib/diplomat/acl.rb
|
189
|
+
- lib/diplomat/agent.rb
|
190
|
+
- lib/diplomat/api_options.rb
|
191
|
+
- lib/diplomat/check.rb
|
192
|
+
- lib/diplomat/configuration.rb
|
193
|
+
- lib/diplomat/datacenter.rb
|
194
|
+
- lib/diplomat/error.rb
|
195
|
+
- lib/diplomat/event.rb
|
196
|
+
- lib/diplomat/health.rb
|
197
|
+
- lib/diplomat/kv.rb
|
198
|
+
- lib/diplomat/lock.rb
|
199
|
+
- lib/diplomat/maintenance.rb
|
200
|
+
- lib/diplomat/members.rb
|
201
|
+
- lib/diplomat/node.rb
|
202
|
+
- lib/diplomat/nodes.rb
|
203
|
+
- lib/diplomat/query.rb
|
204
|
+
- lib/diplomat/rest_client.rb
|
205
|
+
- lib/diplomat/service.rb
|
206
|
+
- lib/diplomat/session.rb
|
207
|
+
- lib/diplomat/status.rb
|
208
|
+
- lib/diplomat/version.rb
|
209
|
+
homepage: https://github.com/WeAreFarmGeek/diplomat
|
210
|
+
licenses:
|
211
|
+
- BSD-3-Clause
|
212
|
+
metadata: {}
|
213
|
+
post_install_message:
|
214
|
+
rdoc_options: []
|
215
|
+
require_paths:
|
216
|
+
- lib
|
217
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
|
+
requirements:
|
224
|
+
- - ">="
|
225
|
+
- !ruby/object:Gem::Version
|
226
|
+
version: '0'
|
227
|
+
requirements: []
|
228
|
+
rubyforge_project:
|
229
|
+
rubygems_version: 2.7.7
|
230
|
+
signing_key:
|
231
|
+
specification_version: 4
|
232
|
+
summary: Diplomat is a simple wrapper for Consul
|
233
|
+
test_files: []
|