mortar-api-ruby 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -0
- data/lib/mortar/api/errors.rb +2 -0
- data/lib/mortar/api/jobs.rb +9 -0
- data/lib/mortar/api/version.rb +1 -1
- data/lib/mortar/api.rb +2 -0
- data/spec/mortar/api/jobs_spec.rb +8 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/mortar/api/errors.rb
CHANGED
@@ -32,11 +32,13 @@ module Mortar
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
class BadRequest < ErrorWithResponse; end
|
35
36
|
class Unauthorized < ErrorWithResponse; end
|
36
37
|
class VerificationRequired < ErrorWithResponse; end
|
37
38
|
class Forbidden < ErrorWithResponse; end
|
38
39
|
class NotFound < ErrorWithResponse; end
|
39
40
|
class Timeout < ErrorWithResponse; end
|
41
|
+
class Conflict < ErrorWithResponse; end
|
40
42
|
class Locked < ErrorWithResponse; end
|
41
43
|
class RequestFailed < ErrorWithResponse; end
|
42
44
|
end
|
data/lib/mortar/api/jobs.rb
CHANGED
@@ -99,5 +99,14 @@ module Mortar
|
|
99
99
|
:path => versioned_path("/jobs/#{job_id}")
|
100
100
|
)
|
101
101
|
end
|
102
|
+
|
103
|
+
# DELETE /v2/jobs/:job_id
|
104
|
+
def stop_job(job_id)
|
105
|
+
request(
|
106
|
+
:expects => 200,
|
107
|
+
:method => :delete,
|
108
|
+
:path => versioned_path("/jobs/#{job_id}")
|
109
|
+
)
|
110
|
+
end
|
102
111
|
end
|
103
112
|
end
|
data/lib/mortar/api/version.rb
CHANGED
data/lib/mortar/api.rb
CHANGED
@@ -80,11 +80,13 @@ module Mortar
|
|
80
80
|
response = @connection.request(params, &block)
|
81
81
|
rescue Excon::Errors::HTTPStatusError => error
|
82
82
|
klass = case error.response.status
|
83
|
+
when 400 then Mortar::API::Errors::BadRequest
|
83
84
|
when 401 then Mortar::API::Errors::Unauthorized
|
84
85
|
when 402 then Mortar::API::Errors::VerificationRequired
|
85
86
|
when 403 then Mortar::API::Errors::Forbidden
|
86
87
|
when 404 then Mortar::API::Errors::NotFound
|
87
88
|
when 408 then Mortar::API::Errors::Timeout
|
89
|
+
when 409 then Mortar::API::Errors::Conflict
|
88
90
|
when 422 then Mortar::API::Errors::RequestFailed
|
89
91
|
when 423 then Mortar::API::Errors::Locked
|
90
92
|
when /50./ then Mortar::API::Errors::RequestFailed
|
@@ -108,5 +108,13 @@ describe Mortar::API do
|
|
108
108
|
jobs.length.should == 2
|
109
109
|
end
|
110
110
|
|
111
|
+
it "stops a running job" do
|
112
|
+
job_id = "1234abc342221abc"
|
113
|
+
Excon.stub({:method => :delete, :path => "/v2/jobs/#{job_id}"}) do |params|
|
114
|
+
{:body => Mortar::API::OkJson.encode({"success" => true}), :status => 200}
|
115
|
+
end
|
116
|
+
response = @api.stop_job(job_id)
|
117
|
+
response.body["success"].should be_true
|
118
|
+
end
|
111
119
|
end
|
112
120
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortar-api-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mortar Data
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-08-
|
18
|
+
date: 2012-08-31 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: excon
|