mackerel-client 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/CHANGELOG.md +10 -0
- data/RELEASE.md +3 -3
- data/VERSION +1 -1
- data/lib/mackerel/alert.rb +10 -1
- data/lib/mackerel/version.rb +1 -1
- data/mackerel-client.gemspec +1 -1
- data/spec/mackerel/alert_spec.rb +85 -12
- metadata +13 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c256ae64c9db044569a48a32de536f25bf194d41def84e7e2f862f9730c7973
|
|
4
|
+
data.tar.gz: 87b3521e311375f682a001dd7cbf9d5864095a9fd376e60ca15b7bcb21bed7f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83bd86498f4e491ea2dc54a4e4c3bd4f2c4583b2c25d6138af217a74280db52b7f93278ae3f055f2e5f1fd20c075e7e890df3c2e5aec709f2140b8ff1dbc7424
|
|
7
|
+
data.tar.gz: b9755848c7670e397133c3ffd7519459b673f699a3e3adf95c4ae8f2b029a63acab58908a0ade1f905244816a37f208ea9d10bd7c77b2c28f76c5bd764bf0c28
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -9,9 +9,9 @@ jobs:
|
|
|
9
9
|
strategy:
|
|
10
10
|
fail-fast: false
|
|
11
11
|
matrix:
|
|
12
|
-
os: ['ubuntu-
|
|
12
|
+
os: ['ubuntu-latest', 'macOS-latest']
|
|
13
13
|
# See https://github.com/actions/runner/issues/849 for quoting '3.0'
|
|
14
|
-
ruby: [2.6, 2.7, '3.0']
|
|
14
|
+
ruby: [2.6, 2.7, '3.0', 3.1]
|
|
15
15
|
runs-on: ${{ matrix.os }}
|
|
16
16
|
steps:
|
|
17
17
|
- uses: actions/checkout@v2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.12.1 (2023-10-20)
|
|
4
|
+
|
|
5
|
+
* Update faraday requirement from ~> 1.0 to >= 1, < 3 #67 (dependabot[bot])
|
|
6
|
+
* added ruby 3.1 on ci #68 (yset)
|
|
7
|
+
|
|
8
|
+
## v0.12.0 (2021-12-15)
|
|
9
|
+
|
|
10
|
+
* Add get_alert to Alert API #65 (inommm, pyto86)
|
|
11
|
+
* Send query parameters to alerts api #64 (kenchan)
|
|
12
|
+
|
|
3
13
|
## v0.11.0 (2021-03-24)
|
|
4
14
|
|
|
5
15
|
* Implements downtime API #61 (myoan)
|
data/RELEASE.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
RELEASE
|
|
2
2
|
=======
|
|
3
3
|
|
|
4
|
-
1. Create release branch. (`git
|
|
4
|
+
1. Create release branch. (`git switch -c version-<VERSION>`)
|
|
5
5
|
1. Bump version `VERSION` and `lib/mackerel/version.rb` files.
|
|
6
6
|
1. Write changes in CHANGELOG.md
|
|
7
7
|
1. Push release branch to upstream(GitHub). (`git push -u origin version-<VERSION>`)
|
|
8
|
-
1. Create Pull-Request on
|
|
9
|
-
1. Merge Pull-Request to master branch on
|
|
8
|
+
1. Create Pull-Request on GitHub.
|
|
9
|
+
1. Merge Pull-Request to master branch on GitHub.
|
|
10
10
|
1. Tagging and Release. (`rake release`)
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.12.1
|
data/lib/mackerel/alert.rb
CHANGED
|
@@ -31,12 +31,21 @@ module Mackerel
|
|
|
31
31
|
|
|
32
32
|
module REST
|
|
33
33
|
module Alert
|
|
34
|
-
def get_alerts()
|
|
34
|
+
def get_alerts(opts = {})
|
|
35
35
|
command = ApiCommand.new(:get, "/api/v0/alerts", @api_key)
|
|
36
|
+
command.params['withClosed'] = opts[:with_closed] if opts[:with_closed]
|
|
37
|
+
command.params['nextId'] = opts[:next_id] if opts[:next_id]
|
|
38
|
+
command.params['limit'] = opts[:limit] if opts[:limit]
|
|
36
39
|
data = command.execute(client)
|
|
37
40
|
data["alerts"].map { |a| Mackerel::Alert.new(a) }
|
|
38
41
|
end
|
|
39
42
|
|
|
43
|
+
def get_alert(alert_id)
|
|
44
|
+
command = ApiCommand.new(:get, "/api/v0/alerts/#{alert_id}", @api_key)
|
|
45
|
+
data = command.execute(client)
|
|
46
|
+
Mackerel::Alert.new(data)
|
|
47
|
+
end
|
|
48
|
+
|
|
40
49
|
def close_alert(alertId, reason)
|
|
41
50
|
command = ApiCommand.new(:post, "/api/v0/alerts/#{alertId}/close", @api_key)
|
|
42
51
|
command.body = { reason: reason.to_s }.to_json
|
data/lib/mackerel/version.rb
CHANGED
data/mackerel-client.gemspec
CHANGED
|
@@ -16,7 +16,7 @@ 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', '
|
|
19
|
+
spec.add_dependency 'faraday', '>= 1', '< 3'
|
|
20
20
|
|
|
21
21
|
spec.add_development_dependency "rake"
|
|
22
22
|
spec.add_development_dependency "bundler"
|
data/spec/mackerel/alert_spec.rb
CHANGED
|
@@ -11,15 +11,6 @@ RSpec.describe Mackerel::Client do
|
|
|
11
11
|
]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
let(:test_client) {
|
|
15
|
-
Faraday.new do |builder|
|
|
16
|
-
builder.response :raise_error
|
|
17
|
-
builder.adapter :test do |stubs|
|
|
18
|
-
stubs.get(api_path) { stubbed_response }
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
let(:api_path) { '/api/v0/alerts' }
|
|
24
15
|
|
|
25
16
|
let(:alertId) { 'abcdefg' }
|
|
@@ -42,16 +33,98 @@ RSpec.describe Mackerel::Client do
|
|
|
42
33
|
{ 'alerts' => alerts }
|
|
43
34
|
}
|
|
44
35
|
|
|
36
|
+
context 'no parameters' do
|
|
37
|
+
let(:test_client) {
|
|
38
|
+
Faraday.new do |builder|
|
|
39
|
+
builder.response :raise_error
|
|
40
|
+
builder.adapter :test do |stubs|
|
|
41
|
+
stubs.get(api_path) { stubbed_response }
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
before do
|
|
47
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "successfully get alerts" do
|
|
51
|
+
expect(client.get_alerts().map(&:to_h)).to eq(alerts)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context 'with parameters' do
|
|
56
|
+
let(:with_closed) { true }
|
|
57
|
+
let(:next_id) { alertId }
|
|
58
|
+
let(:limit) { 100 }
|
|
59
|
+
|
|
60
|
+
let(:test_client) {
|
|
61
|
+
Faraday.new do |builder|
|
|
62
|
+
builder.response :raise_error
|
|
63
|
+
builder.adapter :test do |stubs|
|
|
64
|
+
stubs.get("#{api_path}?limit=#{limit}&nextId=#{next_id}&withClosed=#{with_closed}") { stubbed_response }
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
before do
|
|
70
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "successfully get alerts" do
|
|
74
|
+
expect(
|
|
75
|
+
client.get_alerts(with_closed: with_closed, next_id: next_id, limit: limit).map(&:to_h)
|
|
76
|
+
).to eq(alerts)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe '#get_alert' do
|
|
82
|
+
let(:stubbed_response) {
|
|
83
|
+
[
|
|
84
|
+
200,
|
|
85
|
+
{},
|
|
86
|
+
JSON.dump(response_object)
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let(:test_client) {
|
|
91
|
+
Faraday.new do |builder|
|
|
92
|
+
builder.response :raise_error
|
|
93
|
+
builder.adapter :test do |stubs|
|
|
94
|
+
stubs.get(api_path) { stubbed_response }
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let(:api_path) { "/api/v0/alerts/#{alert_id}" }
|
|
100
|
+
let(:alert_id) { 'abcdefg' }
|
|
101
|
+
let(:monitor_id) { 'hijklmnopqr' }
|
|
102
|
+
let(:reason) { 'Nantonaku' }
|
|
103
|
+
|
|
104
|
+
let(:alert) {
|
|
105
|
+
{
|
|
106
|
+
'id' => alert_id,
|
|
107
|
+
'status' => 'OK',
|
|
108
|
+
'reason' => reason,
|
|
109
|
+
'monitorId' => monitor_id,
|
|
110
|
+
'type' => 'check',
|
|
111
|
+
'openedAt' => 1234567890
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let(:response_object) {
|
|
116
|
+
alert
|
|
117
|
+
}
|
|
118
|
+
|
|
45
119
|
before do
|
|
46
120
|
allow(client).to receive(:http_client).and_return(test_client)
|
|
47
121
|
end
|
|
48
122
|
|
|
49
|
-
it "successfully get
|
|
50
|
-
expect(client.
|
|
123
|
+
it "successfully get alert" do
|
|
124
|
+
expect(client.get_alert(alert_id).to_h).to eq(response_object)
|
|
51
125
|
end
|
|
52
126
|
end
|
|
53
127
|
|
|
54
|
-
|
|
55
128
|
describe '#close_alert' do
|
|
56
129
|
let(:stubbed_response) {
|
|
57
130
|
[
|
metadata
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mackerel-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mackerel developer team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-10-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1'
|
|
20
|
+
- - "<"
|
|
18
21
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
22
|
+
version: '3'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '1'
|
|
30
|
+
- - "<"
|
|
25
31
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
32
|
+
version: '3'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: rake
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -153,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
153
159
|
- !ruby/object:Gem::Version
|
|
154
160
|
version: '0'
|
|
155
161
|
requirements: []
|
|
156
|
-
rubygems_version: 3.
|
|
162
|
+
rubygems_version: 3.2.3
|
|
157
163
|
signing_key:
|
|
158
164
|
specification_version: 4
|
|
159
165
|
summary: Mackerel client implemented by Ruby.
|