mackerel-client 0.5.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/ci.yml +22 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +31 -0
- data/README.md +1 -1
- data/RELEASE.md +7 -4
- data/VERSION +1 -1
- data/example/03_host.rb +0 -15
- data/lib/mackerel/api_command.rb +10 -22
- data/lib/mackerel/client.rb +2 -0
- data/lib/mackerel/error.rb +4 -0
- data/lib/mackerel/host.rb +2 -2
- data/lib/mackerel/version.rb +1 -1
- data/mackerel-client.gemspec +4 -4
- data/spec/mackerel/alert_spec.rb +3 -5
- data/spec/mackerel/annotation_spec.rb +5 -5
- data/spec/mackerel/api_commend_spec.rb +82 -0
- data/spec/mackerel/channel_spec.rb +2 -5
- data/spec/mackerel/client/helper_spec.rb +1 -1
- data/spec/mackerel/client_spec.rb +16 -7
- data/spec/mackerel/dashboard_spec.rb +6 -5
- data/spec/mackerel/invitation_spec.rb +3 -5
- data/spec/mackerel/metric_spec.rb +7 -5
- data/spec/mackerel/monitor_spec.rb +5 -5
- data/spec/mackerel/monitoring_spec.rb +2 -5
- data/spec/mackerel/notification_group_spec.rb +5 -5
- data/spec/mackerel/organization_spec.rb +2 -5
- data/spec/mackerel/service_spec.rb +4 -5
- data/spec/mackerel/user_spec.rb +3 -5
- data/spec/spec_helper.rb +8 -0
- metadata +24 -20
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: defff3c3d0b9980e41b4fc6d9cc38c89a28f0093617a3f9bc32b5dc02307b7c3
|
4
|
+
data.tar.gz: 8d72678528c3f43c2c9772b7583fccc40abbe021afb67a89d14214f895542a40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08d0ea5a016ae5cdda43fddfbf57fa9868f05fb42b1ab8cd0f3f630fd4b2eb80e94d19856b4746c215b26784e95e90fcca320fcae7a092b625534319c781f8a0'
|
7
|
+
data.tar.gz: b2e3ca3de0d0e95dfc302a808d4648ed0ded2ebe2445980b4aa6f20007bcb359e6d8d0fcc372e403471892d9ae9481a2448e9ada6e97c8a2da3a3b600db0cd5d
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
pull_request:
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
os: ['ubuntu-20.04', 'macOS-10.15']
|
13
|
+
# See https://github.com/actions/runner/issues/849 for quoting '3.0'
|
14
|
+
ruby: [2.6, 2.7, '3.0']
|
15
|
+
runs-on: ${{ matrix.os }}
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
22
|
+
- run: bundle exec rake
|
data/.rspec
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v0.10.0 (2021-03-15)
|
4
|
+
|
5
|
+
## Breaking change
|
6
|
+
|
7
|
+
Previously `Host` has `type` attribute, but it is removed.
|
8
|
+
|
9
|
+
* Drop `type` attribute from `Host` and introduce `size` instead #58 (astj)
|
10
|
+
|
11
|
+
## v0.9.0 (2020-01-23)
|
12
|
+
|
13
|
+
* Use Faraday v1.0 #54 (onk)
|
14
|
+
|
15
|
+
## v0.8.0 (2019-06-26)
|
16
|
+
|
17
|
+
### Breaking change
|
18
|
+
|
19
|
+
Now mackerel-client raises `Mackerel::Error` when HTTP requests failed.
|
20
|
+
Previously various exceptions (mainly `RuntimeError` or `NoMethodError`) happened in such cases.
|
21
|
+
|
22
|
+
* Use Faraday::Response::RaiseError middleware #49 (onk)
|
23
|
+
|
24
|
+
## v0.7.0 (2018-10-22)
|
25
|
+
|
26
|
+
* fix unintended initializing http headers #47 (y_uuki)
|
27
|
+
|
28
|
+
## v0.6.0 (2018-07-04)
|
29
|
+
|
30
|
+
* Use Rspec v3.x #43 (onk)
|
31
|
+
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# mackerel-client [![
|
1
|
+
# mackerel-client [![CI](https://github.com/mackerelio/mackerel-client-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/mackerelio/mackerel-client-ruby/actions/workflows/ci.yml) [![Gem Version](https://badge.fury.io/rb/mackerel-client.svg)](https://badge.fury.io/rb/mackerel-client)
|
2
2
|
|
3
3
|
mackerel-client is a ruby library to access Mackerel (https://mackerel.io/).
|
4
4
|
|
data/RELEASE.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
RELEASE
|
2
2
|
=======
|
3
3
|
|
4
|
-
1.
|
5
|
-
1.
|
6
|
-
1.
|
7
|
-
1. `
|
4
|
+
1. Create release branch. (`git checkout -b version-<VERSION>`)
|
5
|
+
1. Bump version `VERSION` and `lib/mackerel/version.rb` files.
|
6
|
+
1. Write changes in CHANGELOG.md
|
7
|
+
1. Push release branch to upstream(GitHub). (`git push -u origin version-<VERSION>`)
|
8
|
+
1. Create Pull-Request on Github.
|
9
|
+
1. Merge Pull-Request to master branch on Github.
|
10
|
+
1. Tagging and Release. (`rake release`)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.10.0
|
data/example/03_host.rb
CHANGED
@@ -14,11 +14,7 @@ pp mc.post_host({
|
|
14
14
|
'agent-revision' => 'bc2f9f6',
|
15
15
|
'agent-version' => '0.6.1',
|
16
16
|
},
|
17
|
-
'type' => 'unknown',
|
18
|
-
'status' => 'working',
|
19
17
|
'memo' => 'test web host',
|
20
|
-
'isRetired' => false,
|
21
|
-
'createdAt' => '1401291970',
|
22
18
|
'roleFullnames' => [
|
23
19
|
'mackerel:web'
|
24
20
|
],
|
@@ -35,11 +31,7 @@ pp mc.post_host({
|
|
35
31
|
'agent-revision' => 'bc2f9f6',
|
36
32
|
'agent-version' => '0.6.1',
|
37
33
|
},
|
38
|
-
'type' => 'unknown',
|
39
|
-
'status' => 'working',
|
40
34
|
'memo' => 'test db host',
|
41
|
-
'isRetired' => false,
|
42
|
-
'createdAt' => '1401291976',
|
43
35
|
'roleFullnames' => [
|
44
36
|
'mackerel:db'
|
45
37
|
],
|
@@ -75,12 +67,7 @@ pp mc.update_host(target_host.id,{
|
|
75
67
|
'agent-revision' => 'bc2f9f6',
|
76
68
|
'agent-version' => '0.6.1',
|
77
69
|
},
|
78
|
-
'type' => 'unknown',
|
79
|
-
'status' => 'working',
|
80
70
|
'memo' => 'test host',
|
81
|
-
'isRetired' => false,
|
82
|
-
'createdAt' => '1401291976',
|
83
|
-
'id' => target_host.id,
|
84
71
|
'roleFullnames' => [
|
85
72
|
'mackerel:db'
|
86
73
|
],
|
@@ -93,5 +80,3 @@ pp mc.update_host(target_host.id,{
|
|
93
80
|
|
94
81
|
# retire the host
|
95
82
|
pp mc.retire_host(target_host.id)
|
96
|
-
|
97
|
-
|
data/lib/mackerel/api_command.rb
CHANGED
@@ -27,38 +27,26 @@ module Mackerel
|
|
27
27
|
|
28
28
|
client_method = client.method(@method)
|
29
29
|
response = client_method.call(request_path) do |req|
|
30
|
-
req.headers
|
30
|
+
req.headers.update @headers
|
31
31
|
req.headers['x-api-key'] = @api_key
|
32
32
|
req.headers['Content-Type'] ||= JSON_CONTENT_TYPE
|
33
33
|
req.params = @params
|
34
34
|
req.body = @body
|
35
35
|
end
|
36
|
-
check_status(response.status)
|
37
|
-
|
38
36
|
JSON.parse(response.body)
|
37
|
+
rescue Faraday::ClientError, Faraday::ServerError => e
|
38
|
+
begin
|
39
|
+
body = JSON.parse(e.response[:body])
|
40
|
+
message = body["error"].is_a?(Hash) ? body["error"]["message"] : body["error"]
|
41
|
+
raise Mackerel::Error, "#{@method.upcase} #{@path} failed: #{e.response[:status]} #{message}"
|
42
|
+
rescue JSON::ParserError
|
43
|
+
# raise Mackerel::Error with original response body
|
44
|
+
raise Mackerel::Error, "#{@method.upcase} #{@path} failed: #{e.response[:status]} #{e.response[:body]}"
|
45
|
+
end
|
39
46
|
end
|
40
47
|
|
41
48
|
private
|
42
49
|
|
43
|
-
def check_status(status)
|
44
|
-
case status
|
45
|
-
when 200...300
|
46
|
-
nil
|
47
|
-
when 400
|
48
|
-
message ="Invalid parameter"
|
49
|
-
raise "#{@method.upcase} #{@path} failed: #{status} #{message}"
|
50
|
-
when 403
|
51
|
-
message ="Not authorized"
|
52
|
-
raise "#{@method.upcase} #{@path} failed: #{status} #{message}"
|
53
|
-
when 404
|
54
|
-
message ="Resource not found"
|
55
|
-
raise "#{@method.upcase} #{@path} failed: #{status} #{message}"
|
56
|
-
when 409
|
57
|
-
message ="Already exists"
|
58
|
-
raise "#{@method.upcase} #{@path} failed: #{status} #{message}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
50
|
def make_escaped_query
|
63
51
|
@query.map{|k,v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join("&")
|
64
52
|
end
|
data/lib/mackerel/client.rb
CHANGED
@@ -4,6 +4,7 @@ require 'uri'
|
|
4
4
|
require 'json' unless defined? ::JSON
|
5
5
|
|
6
6
|
require 'mackerel/api_command'
|
7
|
+
require 'mackerel/error'
|
7
8
|
|
8
9
|
require 'mackerel/role'
|
9
10
|
require 'mackerel/host'
|
@@ -54,6 +55,7 @@ module Mackerel
|
|
54
55
|
|
55
56
|
def http_client
|
56
57
|
Faraday.new(:url => @origin) do |faraday|
|
58
|
+
faraday.response :raise_error
|
57
59
|
faraday.response :logger if ENV['DEBUG']
|
58
60
|
faraday.adapter Faraday.default_adapter
|
59
61
|
faraday.options.params_encoder = Faraday::FlatParamsEncoder
|
data/lib/mackerel/host.rb
CHANGED
@@ -3,13 +3,13 @@ module Mackerel
|
|
3
3
|
class Host
|
4
4
|
|
5
5
|
MACKEREL_INTERFACE_NAME_PATTERN = /^eth\d/
|
6
|
-
attr_accessor :name, :
|
6
|
+
attr_accessor :name, :size, :status, :memo, :isRetired, :id, :createdAt, :roles, :interfaces, :customIdentifier
|
7
7
|
|
8
8
|
def initialize(args = {})
|
9
9
|
@hash = args
|
10
10
|
@name = args["name"]
|
11
11
|
@meta = args["meta"]
|
12
|
-
@
|
12
|
+
@size = args["size"]
|
13
13
|
@status = args["status"]
|
14
14
|
@memo = args["memo"]
|
15
15
|
@isRetired = args["isRetired"]
|
data/lib/mackerel/version.rb
CHANGED
data/mackerel-client.gemspec
CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency 'faraday', '~> 0
|
19
|
+
spec.add_dependency 'faraday', '~> 1.0'
|
20
20
|
|
21
|
-
spec.add_development_dependency "rake"
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rspec"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
24
|
end
|
data/spec/mackerel/alert_spec.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -17,6 +13,7 @@ describe Mackerel::Client do
|
|
17
13
|
|
18
14
|
let(:test_client) {
|
19
15
|
Faraday.new do |builder|
|
16
|
+
builder.response :raise_error
|
20
17
|
builder.adapter :test do |stubs|
|
21
18
|
stubs.get(api_path) { stubbed_response }
|
22
19
|
end
|
@@ -66,6 +63,7 @@ describe Mackerel::Client do
|
|
66
63
|
|
67
64
|
let(:test_client) {
|
68
65
|
Faraday.new do |builder|
|
66
|
+
builder.response :raise_error
|
69
67
|
builder.adapter :test do |stubs|
|
70
68
|
stubs.post(api_path) { stubbed_response }
|
71
69
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -17,6 +13,7 @@ describe Mackerel::Client do
|
|
17
13
|
|
18
14
|
let(:test_client) {
|
19
15
|
Faraday.new do |builder|
|
16
|
+
builder.response :raise_error
|
20
17
|
builder.adapter :test do |stubs|
|
21
18
|
stubs.post(api_path) { stubbed_response }
|
22
19
|
end
|
@@ -62,6 +59,7 @@ describe Mackerel::Client do
|
|
62
59
|
|
63
60
|
let(:test_client) {
|
64
61
|
Faraday.new do |builder|
|
62
|
+
builder.response :raise_error
|
65
63
|
builder.adapter :test do |stubs|
|
66
64
|
stubs.get(api_path) { stubbed_response }
|
67
65
|
end
|
@@ -122,6 +120,7 @@ describe Mackerel::Client do
|
|
122
120
|
|
123
121
|
let(:test_client) {
|
124
122
|
Faraday.new do |builder|
|
123
|
+
builder.response :raise_error
|
125
124
|
builder.adapter :test do |stubs|
|
126
125
|
stubs.put(api_path) { stubbed_response }
|
127
126
|
end
|
@@ -169,6 +168,7 @@ describe Mackerel::Client do
|
|
169
168
|
|
170
169
|
let(:test_client) {
|
171
170
|
Faraday.new do |builder|
|
171
|
+
builder.response :raise_error
|
172
172
|
builder.adapter :test do |stubs|
|
173
173
|
stubs.delete(api_path) { stubbed_response }
|
174
174
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
RSpec.describe Mackerel::ApiCommand do
|
2
|
+
let(:api_key) { "xxxxxxxx" }
|
3
|
+
let(:command) { Mackerel::ApiCommand.new(:get, "/api/v0/services", api_key) }
|
4
|
+
|
5
|
+
describe "#execute" do
|
6
|
+
let(:api_path) { "/api/v0/services" }
|
7
|
+
|
8
|
+
let(:test_client) {
|
9
|
+
Faraday.new do |builder|
|
10
|
+
builder.response :raise_error
|
11
|
+
builder.adapter :test do |stubs|
|
12
|
+
stubs.get(api_path) { stubbed_response }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
}
|
16
|
+
|
17
|
+
let(:services) {
|
18
|
+
{
|
19
|
+
"services" => [
|
20
|
+
{
|
21
|
+
"name" => "Web",
|
22
|
+
"memo" => "store",
|
23
|
+
"roles" => [
|
24
|
+
"normal role",
|
25
|
+
"special role"
|
26
|
+
]
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"name" => "Web",
|
30
|
+
"memo" => "store",
|
31
|
+
"roles" => [
|
32
|
+
"a role",
|
33
|
+
"the role"
|
34
|
+
]
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
context "when success" do
|
41
|
+
let(:stubbed_response) {
|
42
|
+
[
|
43
|
+
200,
|
44
|
+
{},
|
45
|
+
JSON.dump(services)
|
46
|
+
]
|
47
|
+
}
|
48
|
+
|
49
|
+
it {
|
50
|
+
expect(command.execute(test_client)).to eq(services)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when 404 Not Found" do
|
55
|
+
let(:stubbed_response) {
|
56
|
+
[
|
57
|
+
404,
|
58
|
+
{},
|
59
|
+
JSON.dump({"error" => { "message" => "Host Not Found."} })
|
60
|
+
]
|
61
|
+
}
|
62
|
+
|
63
|
+
it {
|
64
|
+
expect { command.execute(test_client) }.to raise_error Mackerel::Error, "GET /api/v0/services failed: 404 Host Not Found."
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when 401 Unauthorized" do
|
69
|
+
let(:stubbed_response) {
|
70
|
+
[
|
71
|
+
401,
|
72
|
+
{},
|
73
|
+
JSON.dump({ "error" => "Authentication failed. Please try with valid Api Key." })
|
74
|
+
]
|
75
|
+
}
|
76
|
+
|
77
|
+
it {
|
78
|
+
expect { command.execute(test_client) }.to raise_error Mackerel::Error, "GET /api/v0/services failed: 401 Authentication failed. Please try with valid Api Key."
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -19,6 +15,7 @@ describe Mackerel::Client do
|
|
19
15
|
|
20
16
|
let(:test_client) {
|
21
17
|
Faraday.new do |builder|
|
18
|
+
builder.response :raise_error
|
22
19
|
builder.adapter :test do |stubs|
|
23
20
|
stubs.get(api_path) { stubbed_response }
|
24
21
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -24,6 +20,7 @@ describe Mackerel::Client do
|
|
24
20
|
|
25
21
|
let(:test_client) {
|
26
22
|
Faraday.new do |builder|
|
23
|
+
builder.response :raise_error
|
27
24
|
builder.adapter :test do |stubs|
|
28
25
|
stubs.post(api_path) { stubbed_response }
|
29
26
|
end
|
@@ -66,6 +63,7 @@ describe Mackerel::Client do
|
|
66
63
|
|
67
64
|
let(:test_client) {
|
68
65
|
Faraday.new do |builder|
|
66
|
+
builder.response :raise_error
|
69
67
|
builder.adapter :test do |stubs|
|
70
68
|
stubs.put(api_path) { stubbed_response }
|
71
69
|
end
|
@@ -108,6 +106,7 @@ describe Mackerel::Client do
|
|
108
106
|
|
109
107
|
let(:test_client) {
|
110
108
|
Faraday.new do |builder|
|
109
|
+
builder.response :raise_error
|
111
110
|
builder.adapter :test do |stubs|
|
112
111
|
stubs.get(api_path) { stubbed_response }
|
113
112
|
end
|
@@ -126,7 +125,7 @@ describe Mackerel::Client do
|
|
126
125
|
'agent-revision' => 'bc2f9f6',
|
127
126
|
'agent-version' => '0.6.1',
|
128
127
|
},
|
129
|
-
'
|
128
|
+
'size' => 'standard',
|
130
129
|
'status' => 'working',
|
131
130
|
'memo' => 'test host',
|
132
131
|
'isRetired' => false,
|
@@ -163,6 +162,7 @@ describe Mackerel::Client do
|
|
163
162
|
|
164
163
|
let(:test_client) {
|
165
164
|
Faraday.new do |builder|
|
165
|
+
builder.response :raise_error
|
166
166
|
builder.adapter :test do |stubs|
|
167
167
|
stubs.post(api_path) { stubbed_response }
|
168
168
|
end
|
@@ -198,6 +198,7 @@ describe Mackerel::Client do
|
|
198
198
|
|
199
199
|
let(:test_client) {
|
200
200
|
Faraday.new do |builder|
|
201
|
+
builder.response :raise_error
|
201
202
|
builder.adapter :test do |stubs|
|
202
203
|
stubs.put(api_path) { stubbed_response }
|
203
204
|
end
|
@@ -240,6 +241,7 @@ describe Mackerel::Client do
|
|
240
241
|
|
241
242
|
let(:test_client) {
|
242
243
|
Faraday.new do |builder|
|
244
|
+
builder.response :raise_error
|
243
245
|
builder.adapter :test do |stubs|
|
244
246
|
stubs.post(api_path) { stubbed_response }
|
245
247
|
end
|
@@ -274,6 +276,7 @@ describe Mackerel::Client do
|
|
274
276
|
|
275
277
|
let(:test_client) {
|
276
278
|
Faraday.new do |builder|
|
279
|
+
builder.response :raise_error
|
277
280
|
builder.adapter :test do |stubs|
|
278
281
|
stubs.post(api_path) { stubbed_response }
|
279
282
|
end
|
@@ -331,6 +334,7 @@ describe Mackerel::Client do
|
|
331
334
|
|
332
335
|
let(:test_client) {
|
333
336
|
Faraday.new do |builder|
|
337
|
+
builder.response :raise_error
|
334
338
|
builder.adapter :test do |stubs|
|
335
339
|
stubs.get(api_path) { stubbed_response }
|
336
340
|
end
|
@@ -350,7 +354,7 @@ describe Mackerel::Client do
|
|
350
354
|
'agent-revision' => 'bc2f9f6',
|
351
355
|
'agent-version' => '0.6.1',
|
352
356
|
},
|
353
|
-
'
|
357
|
+
'size' => 'standard',
|
354
358
|
'status' => 'working',
|
355
359
|
'memo' => 'test host',
|
356
360
|
'isRetired' => false,
|
@@ -392,6 +396,7 @@ describe Mackerel::Client do
|
|
392
396
|
|
393
397
|
let(:test_client) {
|
394
398
|
Faraday.new do |builder|
|
399
|
+
builder.response :raise_error
|
395
400
|
builder.adapter :test do |stubs|
|
396
401
|
stubs.post(api_path) { stubbed_response }
|
397
402
|
end
|
@@ -437,6 +442,7 @@ describe Mackerel::Client do
|
|
437
442
|
|
438
443
|
let(:test_client) {
|
439
444
|
Faraday.new do |builder|
|
445
|
+
builder.response :raise_error
|
440
446
|
builder.adapter :test do |stubs|
|
441
447
|
stubs.get(api_path) { stubbed_response }
|
442
448
|
end
|
@@ -470,6 +476,7 @@ describe Mackerel::Client do
|
|
470
476
|
|
471
477
|
let(:test_client) {
|
472
478
|
Faraday.new do |builder|
|
479
|
+
builder.response :raise_error
|
473
480
|
builder.adapter :test do |stubs|
|
474
481
|
stubs.get(api_path) { stubbed_response }
|
475
482
|
end
|
@@ -505,6 +512,7 @@ describe Mackerel::Client do
|
|
505
512
|
|
506
513
|
let(:test_client) {
|
507
514
|
Faraday.new do |builder|
|
515
|
+
builder.response :raise_error
|
508
516
|
builder.adapter :test do |stubs|
|
509
517
|
stubs.put(api_path) { stubbed_response }
|
510
518
|
end
|
@@ -544,6 +552,7 @@ describe Mackerel::Client do
|
|
544
552
|
|
545
553
|
let(:test_client) {
|
546
554
|
Faraday.new do |builder|
|
555
|
+
builder.response :raise_error
|
547
556
|
builder.adapter :test do |stubs|
|
548
557
|
stubs.delete(api_path) { stubbed_response }
|
549
558
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -17,6 +13,7 @@ describe Mackerel::Client do
|
|
17
13
|
|
18
14
|
let(:test_client) {
|
19
15
|
Faraday.new do |builder|
|
16
|
+
builder.response :raise_error
|
20
17
|
builder.adapter :test do |stubs|
|
21
18
|
stubs.post(api_path) { stubbed_response }
|
22
19
|
end
|
@@ -65,6 +62,7 @@ describe Mackerel::Client do
|
|
65
62
|
|
66
63
|
let(:test_client) {
|
67
64
|
Faraday.new do |builder|
|
65
|
+
builder.response :raise_error
|
68
66
|
builder.adapter :test do |stubs|
|
69
67
|
stubs.put(api_path) { stubbed_response }
|
70
68
|
end
|
@@ -114,6 +112,7 @@ describe Mackerel::Client do
|
|
114
112
|
|
115
113
|
let(:test_client) {
|
116
114
|
Faraday.new do |builder|
|
115
|
+
builder.response :raise_error
|
117
116
|
builder.adapter :test do |stubs|
|
118
117
|
stubs.get(api_path) { stubbed_response }
|
119
118
|
end
|
@@ -164,6 +163,7 @@ describe Mackerel::Client do
|
|
164
163
|
|
165
164
|
let(:test_client) {
|
166
165
|
Faraday.new do |builder|
|
166
|
+
builder.response :raise_error
|
167
167
|
builder.adapter :test do |stubs|
|
168
168
|
stubs.get(api_path) { stubbed_response }
|
169
169
|
end
|
@@ -212,6 +212,7 @@ describe Mackerel::Client do
|
|
212
212
|
|
213
213
|
let(:test_client) {
|
214
214
|
Faraday.new do |builder|
|
215
|
+
builder.response :raise_error
|
215
216
|
builder.adapter :test do |stubs|
|
216
217
|
stubs.delete(api_path) { stubbed_response }
|
217
218
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -19,6 +15,7 @@ describe Mackerel::Client do
|
|
19
15
|
|
20
16
|
let(:test_client) {
|
21
17
|
Faraday.new do |builder|
|
18
|
+
builder.response :raise_error
|
22
19
|
builder.adapter :test do |stubs|
|
23
20
|
stubs.post(api_path) { stubbed_response }
|
24
21
|
end
|
@@ -60,6 +57,7 @@ describe Mackerel::Client do
|
|
60
57
|
|
61
58
|
let(:test_client) {
|
62
59
|
Faraday.new do |builder|
|
60
|
+
builder.response :raise_error
|
63
61
|
builder.adapter :test do |stubs|
|
64
62
|
stubs.post(api_path) { stubbed_response }
|
65
63
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -17,6 +13,7 @@ describe Mackerel::Client do
|
|
17
13
|
|
18
14
|
let(:test_client) {
|
19
15
|
Faraday.new do |builder|
|
16
|
+
builder.response :raise_error
|
20
17
|
builder.adapter :test do |stubs|
|
21
18
|
stubs.post(api_path) { stubbed_response }
|
22
19
|
end
|
@@ -56,6 +53,7 @@ describe Mackerel::Client do
|
|
56
53
|
|
57
54
|
let(:test_client) {
|
58
55
|
Faraday.new do |builder|
|
56
|
+
builder.response :raise_error
|
59
57
|
builder.adapter :test do |stubs|
|
60
58
|
stubs.get(api_path) { stubbed_response }
|
61
59
|
end
|
@@ -102,6 +100,7 @@ describe Mackerel::Client do
|
|
102
100
|
|
103
101
|
let(:test_client) {
|
104
102
|
Faraday.new do |builder|
|
103
|
+
builder.response :raise_error
|
105
104
|
builder.adapter :test do |stubs|
|
106
105
|
stubs.get(api_path) { stubbed_response }
|
107
106
|
end
|
@@ -145,6 +144,7 @@ describe Mackerel::Client do
|
|
145
144
|
|
146
145
|
let(:test_client) {
|
147
146
|
Faraday.new do |builder|
|
147
|
+
builder.response :raise_error
|
148
148
|
builder.adapter :test do |stubs|
|
149
149
|
stubs.post(api_path) { stubbed_response }
|
150
150
|
end
|
@@ -185,6 +185,7 @@ describe Mackerel::Client do
|
|
185
185
|
|
186
186
|
let(:test_client) {
|
187
187
|
Faraday.new do |builder|
|
188
|
+
builder.response :raise_error
|
188
189
|
builder.adapter :test do |stubs|
|
189
190
|
stubs.get(api_path) { stubbed_response }
|
190
191
|
end
|
@@ -226,6 +227,7 @@ describe Mackerel::Client do
|
|
226
227
|
|
227
228
|
let(:test_client) {
|
228
229
|
Faraday.new do |builder|
|
230
|
+
builder.response :raise_error
|
229
231
|
builder.adapter :test do |stubs|
|
230
232
|
stubs.post(api_path) { stubbed_response }
|
231
233
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -17,6 +13,7 @@ describe Mackerel::Client do
|
|
17
13
|
|
18
14
|
let(:test_client) {
|
19
15
|
Faraday.new do |builder|
|
16
|
+
builder.response :raise_error
|
20
17
|
builder.adapter :test do |stubs|
|
21
18
|
stubs.post(api_path) { stubbed_response }
|
22
19
|
end
|
@@ -63,6 +60,7 @@ describe Mackerel::Client do
|
|
63
60
|
|
64
61
|
let(:test_client) {
|
65
62
|
Faraday.new do |builder|
|
63
|
+
builder.response :raise_error
|
66
64
|
builder.adapter :test do |stubs|
|
67
65
|
stubs.get(api_path) { stubbed_response }
|
68
66
|
end
|
@@ -129,6 +127,7 @@ describe Mackerel::Client do
|
|
129
127
|
|
130
128
|
let(:test_client) {
|
131
129
|
Faraday.new do |builder|
|
130
|
+
builder.response :raise_error
|
132
131
|
builder.adapter :test do |stubs|
|
133
132
|
stubs.put(api_path) { stubbed_response }
|
134
133
|
end
|
@@ -177,6 +176,7 @@ describe Mackerel::Client do
|
|
177
176
|
|
178
177
|
let(:test_client) {
|
179
178
|
Faraday.new do |builder|
|
179
|
+
builder.response :raise_error
|
180
180
|
builder.adapter :test do |stubs|
|
181
181
|
stubs.delete(api_path) { stubbed_response }
|
182
182
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -17,6 +13,7 @@ describe Mackerel::Client do
|
|
17
13
|
|
18
14
|
let(:test_client) {
|
19
15
|
Faraday.new do |builder|
|
16
|
+
builder.response :raise_error
|
20
17
|
builder.adapter :test do |stubs|
|
21
18
|
stubs.post(api_path) { stubbed_response }
|
22
19
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -17,6 +13,7 @@ describe Mackerel::Client do
|
|
17
13
|
|
18
14
|
let(:test_client) {
|
19
15
|
Faraday.new do |builder|
|
16
|
+
builder.response :raise_error
|
20
17
|
builder.adapter :test do |stubs|
|
21
18
|
stubs.post(api_path) { stubbed_response }
|
22
19
|
end
|
@@ -80,6 +77,7 @@ describe Mackerel::Client do
|
|
80
77
|
|
81
78
|
let(:test_client) {
|
82
79
|
Faraday.new do |builder|
|
80
|
+
builder.response :raise_error
|
83
81
|
builder.adapter :test do |stubs|
|
84
82
|
stubs.get(api_path) { stubbed_response }
|
85
83
|
end
|
@@ -163,6 +161,7 @@ describe Mackerel::Client do
|
|
163
161
|
|
164
162
|
let(:test_client) {
|
165
163
|
Faraday.new do |builder|
|
164
|
+
builder.response :raise_error
|
166
165
|
builder.adapter :test do |stubs|
|
167
166
|
stubs.put(api_path) { stubbed_response }
|
168
167
|
end
|
@@ -223,6 +222,7 @@ describe Mackerel::Client do
|
|
223
222
|
|
224
223
|
let(:test_client) {
|
225
224
|
Faraday.new do |builder|
|
225
|
+
builder.response :raise_error
|
226
226
|
builder.adapter :test do |stubs|
|
227
227
|
stubs.delete(api_path) { stubbed_response }
|
228
228
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -19,6 +15,7 @@ describe Mackerel::Client do
|
|
19
15
|
|
20
16
|
let(:test_client) {
|
21
17
|
Faraday.new do |builder|
|
18
|
+
builder.response :raise_error
|
22
19
|
builder.adapter :test do |stubs|
|
23
20
|
stubs.get(api_path) { stubbed_response }
|
24
21
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -19,6 +15,7 @@ describe Mackerel::Client do
|
|
19
15
|
|
20
16
|
let(:test_client) {
|
21
17
|
Faraday.new do |builder|
|
18
|
+
builder.response :raise_error
|
22
19
|
builder.adapter :test do |stubs|
|
23
20
|
stubs.get(api_path) { stubbed_response }
|
24
21
|
end
|
@@ -75,6 +72,7 @@ describe Mackerel::Client do
|
|
75
72
|
|
76
73
|
let(:test_client) {
|
77
74
|
Faraday.new do |builder|
|
75
|
+
builder.response :raise_error
|
78
76
|
builder.adapter :test do |stubs|
|
79
77
|
stubs.get(api_path) { stubbed_response }
|
80
78
|
end
|
@@ -124,6 +122,7 @@ describe Mackerel::Client do
|
|
124
122
|
|
125
123
|
let(:test_client) {
|
126
124
|
Faraday.new do |builder|
|
125
|
+
builder.response :raise_error
|
127
126
|
builder.adapter :test do |stubs|
|
128
127
|
stubs.get(api_path) { stubbed_response }
|
129
128
|
end
|
data/spec/mackerel/user_spec.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mackerel/host'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe Mackerel::Client do
|
1
|
+
RSpec.describe Mackerel::Client do
|
6
2
|
let(:api_key) { 'xxxxxxxx' }
|
7
3
|
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
4
|
|
@@ -19,6 +15,7 @@ describe Mackerel::Client do
|
|
19
15
|
|
20
16
|
let(:test_client) {
|
21
17
|
Faraday.new do |builder|
|
18
|
+
builder.response :raise_error
|
22
19
|
builder.adapter :test do |stubs|
|
23
20
|
stubs.get(api_path) { stubbed_response }
|
24
21
|
end
|
@@ -68,6 +65,7 @@ describe Mackerel::Client do
|
|
68
65
|
|
69
66
|
let(:test_client) {
|
70
67
|
Faraday.new do |builder|
|
68
|
+
builder.response :raise_error
|
71
69
|
builder.adapter :test do |stubs|
|
72
70
|
stubs.delete(api_path) { stubbed_response }
|
73
71
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mackerel-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mackerel developer team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
description: Mackerel client is a library to access Mackerel (https://mackerel.io/).
|
70
70
|
email:
|
71
71
|
- developers@mackerel.io
|
@@ -73,9 +73,11 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".github/dependabot.yml"
|
77
|
+
- ".github/workflows/ci.yml"
|
76
78
|
- ".gitignore"
|
77
79
|
- ".rspec"
|
78
|
-
-
|
80
|
+
- CHANGELOG.md
|
79
81
|
- Gemfile
|
80
82
|
- LICENSE.txt
|
81
83
|
- README.md
|
@@ -100,6 +102,7 @@ files:
|
|
100
102
|
- lib/mackerel/client.rb
|
101
103
|
- lib/mackerel/client/helper.rb
|
102
104
|
- lib/mackerel/dashboard.rb
|
105
|
+
- lib/mackerel/error.rb
|
103
106
|
- lib/mackerel/host.rb
|
104
107
|
- lib/mackerel/invitation.rb
|
105
108
|
- lib/mackerel/metadata.rb
|
@@ -115,6 +118,7 @@ files:
|
|
115
118
|
- mackerel-client.gemspec
|
116
119
|
- spec/mackerel/alert_spec.rb
|
117
120
|
- spec/mackerel/annotation_spec.rb
|
121
|
+
- spec/mackerel/api_commend_spec.rb
|
118
122
|
- spec/mackerel/channel_spec.rb
|
119
123
|
- spec/mackerel/client/helper_spec.rb
|
120
124
|
- spec/mackerel/client_spec.rb
|
@@ -132,7 +136,7 @@ homepage: https://mackerel.io/
|
|
132
136
|
licenses:
|
133
137
|
- Apache 2
|
134
138
|
metadata: {}
|
135
|
-
post_install_message:
|
139
|
+
post_install_message:
|
136
140
|
rdoc_options: []
|
137
141
|
require_paths:
|
138
142
|
- lib
|
@@ -147,14 +151,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
151
|
- !ruby/object:Gem::Version
|
148
152
|
version: '0'
|
149
153
|
requirements: []
|
150
|
-
|
151
|
-
|
152
|
-
signing_key:
|
154
|
+
rubygems_version: 3.2.10
|
155
|
+
signing_key:
|
153
156
|
specification_version: 4
|
154
157
|
summary: Mackerel client implemented by Ruby.
|
155
158
|
test_files:
|
156
159
|
- spec/mackerel/alert_spec.rb
|
157
160
|
- spec/mackerel/annotation_spec.rb
|
161
|
+
- spec/mackerel/api_commend_spec.rb
|
158
162
|
- spec/mackerel/channel_spec.rb
|
159
163
|
- spec/mackerel/client/helper_spec.rb
|
160
164
|
- spec/mackerel/client_spec.rb
|