orchestrate 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/orchestrate/api/response.rb +8 -1
- data/lib/orchestrate/client.rb +20 -3
- data/lib/orchestrate/version.rb +1 -1
- data/test/orchestrate/api/key_value_test.rb +31 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 155ad76859df4168e1f6c4bccb31aa3653c8d818
|
4
|
+
data.tar.gz: ff250dcd5c8fee7d94517aee3cc4ca3779111b08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29dc0b21580643d4dc2f064a0db2794be8d2d91abadb1ebc7f81c40359801aafe7fd6991de2c0739bd4b7a19449038c747940b4a3f1e419b7c2104c4ce386fb3
|
7
|
+
data.tar.gz: 6bdadb28536cefb2b8969e4e98f7ea2c8da1f13b1344395fb7407508c51ee863d70bc2cecf3129897942ab5fdf51be0324f3a743e9f3ebfe65770ae2e928705b
|
data/README.md
CHANGED
@@ -104,6 +104,12 @@ end
|
|
104
104
|
|
105
105
|
## Release Notes
|
106
106
|
|
107
|
+
- June 24, 2014: release 0.6.2
|
108
|
+
- Fix #48 to remove trailing -gzip from Etag header for ref value.
|
109
|
+
- Custom #to_s and #inspect methods for Client, Response classes.
|
110
|
+
- Implement `If-Match` header for Client#purge
|
111
|
+
- Implement Client#post for auto-generated keys endpoint
|
112
|
+
|
107
113
|
- June 17, 2014: release 0.6.1
|
108
114
|
- Fix #43 for If-None-Match on Client#put
|
109
115
|
- Fix #46 for Client#ping
|
@@ -40,6 +40,12 @@ module Orchestrate::API
|
|
40
40
|
@request_time = Time.parse(headers['Date'])
|
41
41
|
end
|
42
42
|
|
43
|
+
# @!visibility private
|
44
|
+
def to_s
|
45
|
+
"#<#{self.class.name} status=#{status} request_id=#{request_id}>"
|
46
|
+
end
|
47
|
+
alias :inspect :to_s
|
48
|
+
|
43
49
|
end
|
44
50
|
|
45
51
|
# A generic response for a single entity (K/V, Ref, Event)
|
@@ -55,8 +61,9 @@ module Orchestrate::API
|
|
55
61
|
def initialize(faraday_response, client)
|
56
62
|
super(faraday_response, client)
|
57
63
|
@location = headers['Content-Location'] || headers['Location']
|
58
|
-
@ref = headers.fetch('Etag','').gsub('"','')
|
64
|
+
@ref = headers.fetch('Etag','').gsub('"','').sub(/-gzip$/,'')
|
59
65
|
end
|
66
|
+
|
60
67
|
end
|
61
68
|
|
62
69
|
# A generic response for a collection of entities (K/V, Refs, Events, Search)
|
data/lib/orchestrate/client.rb
CHANGED
@@ -35,6 +35,12 @@ module Orchestrate
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
# @!visibility private
|
39
|
+
def to_s
|
40
|
+
"#<Orchestrate::Client api_key=#{api_key[0..7]}... >"
|
41
|
+
end
|
42
|
+
alias :inspect :to_s
|
43
|
+
|
38
44
|
# Tests authentication with Orchestrate.
|
39
45
|
# @return Orchestrate::API::Response
|
40
46
|
# @raise Orchestrate::API::Unauthorized if the client could not authenticate.
|
@@ -105,6 +111,15 @@ module Orchestrate
|
|
105
111
|
send_request :get, [collection, key, :refs], { query: options, response: API::CollectionResponse }
|
106
112
|
end
|
107
113
|
|
114
|
+
# [Creates a value at an auto-generated
|
115
|
+
# key](https://orchestrate.io/docs/api/?shell#key/value/post-\(create-&-generate-key\)).
|
116
|
+
# @param collection [#to_s] The name of the collection.
|
117
|
+
# @param body [#to_json] The value to store.
|
118
|
+
# @return Orchestrate::API::ItemResponse
|
119
|
+
def post(collection, body)
|
120
|
+
send_request :post, [collection], { body: body, response: API::ItemResponse }
|
121
|
+
end
|
122
|
+
|
108
123
|
# [Updates the value associated with
|
109
124
|
# a key](http://orchestrate.io/docs/api/#key/value/put-\(create/update\)).
|
110
125
|
# If the key does not currently have a value, will create the value.
|
@@ -159,10 +174,12 @@ module Orchestrate
|
|
159
174
|
# key](http://orchestrate.io/docs/api/#key/value/delete11).
|
160
175
|
# @param collection [#to_s] The name of the collection.
|
161
176
|
# @param key [#to_s] The name of the key.
|
177
|
+
# @param ref [#to_s] If specified, purges the ref only if the current value's ref matches.
|
162
178
|
# @return Orchestrate::API::Response
|
163
|
-
|
164
|
-
|
165
|
-
|
179
|
+
def purge(collection, key, ref=nil)
|
180
|
+
headers = {}
|
181
|
+
headers['If-Match'] = API::Helpers.format_ref(ref) if ref
|
182
|
+
send_request :delete, [collection, key], { query: { purge: true }, headers: headers }
|
166
183
|
end
|
167
184
|
|
168
185
|
# [List the KeyValue items in a collection](http://orchestrate.io/docs/api/#key/value/list).
|
data/lib/orchestrate/version.rb
CHANGED
@@ -16,7 +16,7 @@ class KeyValueTest < MiniTest::Unit::TestCase
|
|
16
16
|
assert_accepts_json env
|
17
17
|
headers = {
|
18
18
|
'Content-Location' => ref_url,
|
19
|
-
'ETag' => "\"#{ref}\"",
|
19
|
+
'ETag' => "\"#{ref}-gzip\"",
|
20
20
|
}.merge(chunked_encoding_header)
|
21
21
|
[ 200, response_headers(headers), body.to_json]
|
22
22
|
end
|
@@ -25,7 +25,7 @@ class KeyValueTest < MiniTest::Unit::TestCase
|
|
25
25
|
assert_equal 200, response.status
|
26
26
|
assert_equal body, response.body
|
27
27
|
|
28
|
-
assert_equal "\"#{ref}\"", response.headers['Etag']
|
28
|
+
assert_equal "\"#{ref}-gzip\"", response.headers['Etag']
|
29
29
|
assert_equal ref_url, response.headers['Content-Location']
|
30
30
|
|
31
31
|
assert_equal ref_url, response.location
|
@@ -46,6 +46,23 @@ class KeyValueTest < MiniTest::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def test_posts_key_value
|
50
|
+
body = {"foo" => "bar"}
|
51
|
+
ref = "12345"
|
52
|
+
key = "567890ac"
|
53
|
+
@stubs.post("/v0/#{@collection}") do |env|
|
54
|
+
assert_authorization @basic_auth, env
|
55
|
+
assert_header 'Content-Type', 'application/json', env
|
56
|
+
assert_equal body.to_json, env.body
|
57
|
+
headers = { "Location" => "/v0/#{@collection}/#{key}/refs/#{ref}", "Etag" => "\"#{ref}\"" }
|
58
|
+
[ 201, response_headers(headers), '' ]
|
59
|
+
end
|
60
|
+
response = @client.post(@collection, body)
|
61
|
+
assert_equal 201, response.status
|
62
|
+
assert_equal ref, response.ref
|
63
|
+
assert_equal "/v0/#{@collection}/#{key}/refs/#{ref}", response.location
|
64
|
+
end
|
65
|
+
|
49
66
|
def test_puts_key_value_without_ref
|
50
67
|
body={"foo" => "bar"}
|
51
68
|
ref = "12345"
|
@@ -169,6 +186,18 @@ class KeyValueTest < MiniTest::Unit::TestCase
|
|
169
186
|
assert_equal response.headers['X-Orchestrate-Req-Id'], response.request_id
|
170
187
|
end
|
171
188
|
|
189
|
+
def test_delete_key_value_with_purge_and_condition
|
190
|
+
ref = "12345"
|
191
|
+
@stubs.delete("/v0/#{@collection}/#{@key}") do |env|
|
192
|
+
assert_authorization @basic_auth, env
|
193
|
+
assert_equal "true", env.params["purge"]
|
194
|
+
assert_header 'If-Match', "\"#{ref}\"", env
|
195
|
+
[ 204, response_headers, '' ]
|
196
|
+
end
|
197
|
+
response = @client.purge(@collection, @key, ref)
|
198
|
+
assert_equal 204, response.status
|
199
|
+
end
|
200
|
+
|
172
201
|
def test_gets_ref
|
173
202
|
body = {"key" => "value"}
|
174
203
|
ref = '123456'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orchestrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Lyon
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-06-
|
13
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|