pixela 1.4.1 → 2.2.0
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/test.yml +2 -4
- data/CHANGELOG.md +44 -1
- data/lib/pixela.rb +0 -2
- data/lib/pixela/client.rb +6 -27
- data/lib/pixela/client/graph_methods.rb +68 -3
- data/lib/pixela/client/pixel_methods.rb +2 -2
- data/lib/pixela/client/profile_methods.rb +40 -0
- data/lib/pixela/client/user_methods.rb +1 -1
- data/lib/pixela/client/webhook_methods.rb +1 -1
- data/lib/pixela/graph.rb +50 -7
- data/lib/pixela/version.rb +1 -1
- data/pixela.gemspec +2 -2
- metadata +6 -10
- data/gemfiles/faraday_0.gemfile +0 -8
- data/lib/pixela/channel.rb +0 -106
- data/lib/pixela/client/channel_methods.rb +0 -148
- data/lib/pixela/client/notificaton_methods.rb +0 -103
- data/lib/pixela/notification.rb +0 -80
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9c101809b9328378863924ee2adc9aef94dd543cf93db7dc4f21e4916a02f5af
|
|
4
|
+
data.tar.gz: 89f280b63c454a27d90ef20762c3f6ccd0c7b2b724097bb9bdd762268e08b257
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfb71e70e9d65a5da0c60104dfbab46dbface426054adaf93cebb6e74104091c67994afe7268b2ad03c39fa0ba3218be758f8e6152bea468d81af0be29d4531b
|
|
7
|
+
data.tar.gz: 82845eee4380ffc77297f441a6acd5c37604a24d7f9522a52abb3b5d22e4b4cb847f2bad4429159c8768344878e31d443e0d5429b8cebc192d114319c8b24444
|
data/.github/workflows/test.yml
CHANGED
|
@@ -29,14 +29,12 @@ jobs:
|
|
|
29
29
|
|
|
30
30
|
matrix:
|
|
31
31
|
ruby:
|
|
32
|
-
- ruby:2.3
|
|
33
32
|
- ruby:2.4
|
|
34
33
|
- ruby:2.5
|
|
35
34
|
- ruby:2.6
|
|
36
35
|
- ruby:2.7
|
|
37
36
|
- rubylang/ruby:master-nightly-bionic
|
|
38
37
|
gemfile:
|
|
39
|
-
- faraday_0.gemfile
|
|
40
38
|
- faraday_1.gemfile
|
|
41
39
|
include:
|
|
42
40
|
- ruby: rubylang/ruby:master-nightly-bionic
|
|
@@ -94,7 +92,7 @@ jobs:
|
|
|
94
92
|
continue-on-error: true
|
|
95
93
|
|
|
96
94
|
- name: Slack Notification (not success)
|
|
97
|
-
uses:
|
|
95
|
+
uses: lazy-actions/slatify@master
|
|
98
96
|
if: "! success()"
|
|
99
97
|
continue-on-error: true
|
|
100
98
|
with:
|
|
@@ -112,7 +110,7 @@ jobs:
|
|
|
112
110
|
|
|
113
111
|
steps:
|
|
114
112
|
- name: Slack Notification (success)
|
|
115
|
-
uses:
|
|
113
|
+
uses: lazy-actions/slatify@master
|
|
116
114
|
if: always()
|
|
117
115
|
continue-on-error: true
|
|
118
116
|
with:
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
## Unreleased
|
|
2
|
-
[full changelog](http://github.com/sue445/pixela/compare/
|
|
2
|
+
[full changelog](http://github.com/sue445/pixela/compare/v2.2.0...master)
|
|
3
|
+
|
|
4
|
+
## v2.2.0
|
|
5
|
+
[full changelog](http://github.com/sue445/pixela/compare/v2.1.0...v2.2.0)
|
|
6
|
+
|
|
7
|
+
* Add `Pixela::Client#get_graph_def` and `Pixela::Graph#def`
|
|
8
|
+
* https://github.com/sue445/pixela/pull/83
|
|
9
|
+
* https://github.com/a-know/Pixela/releases/tag/v1.21.0
|
|
10
|
+
* Add `Pixela::Client#get_pixels` and `Pixela::Graph#pixels`
|
|
11
|
+
* https://github.com/sue445/pixela/pull/84
|
|
12
|
+
* https://github.com/a-know/Pixela/releases/tag/v1.21.0
|
|
13
|
+
|
|
14
|
+
## v2.1.0
|
|
15
|
+
[full changelog](http://github.com/sue445/pixela/compare/v2.0.0...v2.1.0)
|
|
16
|
+
|
|
17
|
+
* Add `Pixela::Client#update_profile`
|
|
18
|
+
* https://github.com/sue445/pixela/pull/81
|
|
19
|
+
* https://github.com/a-know/Pixela/releases/tag/v1.20.0
|
|
20
|
+
|
|
21
|
+
## v2.0.0
|
|
22
|
+
[full changelog](http://github.com/sue445/pixela/compare/v1.5.0...v2.0.0)
|
|
23
|
+
|
|
24
|
+
### :warning: Breaking changes :warning:
|
|
25
|
+
* Remove Channel and Notification
|
|
26
|
+
* https://github.com/sue445/pixela/pull/75
|
|
27
|
+
* https://github.com/a-know/Pixela/releases/tag/v1.19.0
|
|
28
|
+
* Drop support for faraday v0.x
|
|
29
|
+
* https://github.com/sue445/pixela/pull/77
|
|
30
|
+
* Drop support for ruby 2.3
|
|
31
|
+
* https://github.com/sue445/pixela/pull/78
|
|
32
|
+
|
|
33
|
+
## v1.5.0
|
|
34
|
+
[full changelog](http://github.com/sue445/pixela/compare/v1.4.2...v1.5.0)
|
|
35
|
+
|
|
36
|
+
* Add `Pixela::Client#run_stopwatch` and `Pixela::Graph#run_stopwatch`
|
|
37
|
+
* https://github.com/sue445/pixela/pull/74
|
|
38
|
+
* https://github.com/a-know/Pixela/releases/tag/v1.18.0
|
|
39
|
+
|
|
40
|
+
## v1.4.2
|
|
41
|
+
[full changelog](http://github.com/sue445/pixela/compare/v1.4.1...v1.4.2)
|
|
42
|
+
|
|
43
|
+
* Support `remind_by` of Notification
|
|
44
|
+
* https://github.com/sue445/pixela/pull/72
|
|
45
|
+
* https://github.com/a-know/Pixela/releases/tag/v1.17.0
|
|
3
46
|
|
|
4
47
|
## v1.4.1
|
|
5
48
|
[full changelog](http://github.com/sue445/pixela/compare/v1.4.0...v1.4.1)
|
data/lib/pixela.rb
CHANGED
|
@@ -5,11 +5,9 @@ require "faraday_curl"
|
|
|
5
5
|
require "date"
|
|
6
6
|
|
|
7
7
|
module Pixela
|
|
8
|
-
autoload :Channel, "pixela/channel"
|
|
9
8
|
autoload :Client, "pixela/client"
|
|
10
9
|
autoload :Configuration, "pixela/configuration"
|
|
11
10
|
autoload :Graph, "pixela/graph"
|
|
12
|
-
autoload :Notification, "pixela/notification"
|
|
13
11
|
autoload :Pixel, "pixela/pixel"
|
|
14
12
|
autoload :Response, "pixela/response"
|
|
15
13
|
autoload :Webhook, "pixela/webhook"
|
data/lib/pixela/client.rb
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
module Pixela
|
|
2
2
|
class Client
|
|
3
|
-
autoload :ChannelMethods, "pixela/client/channel_methods"
|
|
4
3
|
autoload :GraphMethods, "pixela/client/graph_methods"
|
|
5
|
-
autoload :NotificationMethods, "pixela/client/notificaton_methods"
|
|
6
4
|
autoload :PixelMethods, "pixela/client/pixel_methods"
|
|
5
|
+
autoload :ProfileMethods, "pixela/client/profile_methods"
|
|
7
6
|
autoload :UserMethods, "pixela/client/user_methods"
|
|
8
7
|
autoload :WebhookMethods, "pixela/client/webhook_methods"
|
|
9
8
|
|
|
10
|
-
include ChannelMethods
|
|
11
9
|
include GraphMethods
|
|
12
|
-
include NotificationMethods
|
|
13
10
|
include PixelMethods
|
|
11
|
+
include ProfileMethods
|
|
14
12
|
include UserMethods
|
|
15
13
|
include WebhookMethods
|
|
16
14
|
|
|
17
15
|
API_ENDPOINT = "https://pixe.la/v1"
|
|
16
|
+
TOP_ENDPOINT = "https://pixe.la"
|
|
18
17
|
|
|
19
18
|
# @!attribute [r] username
|
|
20
19
|
# @return [String]
|
|
@@ -47,13 +46,6 @@ module Pixela
|
|
|
47
46
|
Webhook.new(client: self, webhook_hash: webhook_hash)
|
|
48
47
|
end
|
|
49
48
|
|
|
50
|
-
# @param channel_id [String]
|
|
51
|
-
#
|
|
52
|
-
# @return [Pixela::Channel]
|
|
53
|
-
def channel(channel_id)
|
|
54
|
-
Channel.new(client: self, channel_id: channel_id)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
49
|
private
|
|
58
50
|
|
|
59
51
|
# @!attribute [r] token
|
|
@@ -63,8 +55,8 @@ module Pixela
|
|
|
63
55
|
# @param request_headers [Hash]
|
|
64
56
|
#
|
|
65
57
|
# @return [Faraday::Connection]
|
|
66
|
-
def connection(request_headers
|
|
67
|
-
Faraday.new(url:
|
|
58
|
+
def connection(request_headers: user_token_headers, endpoint: API_ENDPOINT)
|
|
59
|
+
Faraday.new(url: endpoint, headers: request_headers) do |conn|
|
|
68
60
|
conn.request :json
|
|
69
61
|
conn.response :mashify, mash_class: Pixela::Response
|
|
70
62
|
conn.response :json
|
|
@@ -81,7 +73,7 @@ module Pixela
|
|
|
81
73
|
|
|
82
74
|
def with_error_handling
|
|
83
75
|
yield
|
|
84
|
-
rescue
|
|
76
|
+
rescue Faraday::ClientError, Faraday::ServerError => error
|
|
85
77
|
begin
|
|
86
78
|
body = JSON.parse(error.response[:body])
|
|
87
79
|
raise PixelaError, body["message"]
|
|
@@ -90,14 +82,6 @@ module Pixela
|
|
|
90
82
|
end
|
|
91
83
|
end
|
|
92
84
|
|
|
93
|
-
def faraday_errors
|
|
94
|
-
if Gem::Version.create(Faraday::VERSION) >= Gem::Version.create("1.0.0")
|
|
95
|
-
return [Faraday::ClientError, Faraday::ServerError]
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
[Faraday::Error::ClientError]
|
|
99
|
-
end
|
|
100
|
-
|
|
101
85
|
def default_headers
|
|
102
86
|
{
|
|
103
87
|
"User-Agent" => "Pixela v#{Pixela::VERSION} (https://github.com/sue445/pixela)",
|
|
@@ -118,10 +102,5 @@ module Pixela
|
|
|
118
102
|
|
|
119
103
|
date.strftime("%Y%m%d")
|
|
120
104
|
end
|
|
121
|
-
|
|
122
|
-
def compact_hash(hash)
|
|
123
|
-
# NOTE: Hash#compact is available since MRI 2.4+
|
|
124
|
-
hash.reject { |_, v| v.nil? }
|
|
125
|
-
end
|
|
126
105
|
end
|
|
127
106
|
end
|
|
@@ -33,7 +33,7 @@ module Pixela::Client::GraphMethods
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
with_error_handling do
|
|
36
|
-
connection.post("users/#{username}/graphs",
|
|
36
|
+
connection.post("users/#{username}/graphs", params.compact).body
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -126,7 +126,7 @@ module Pixela::Client::GraphMethods
|
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
with_error_handling do
|
|
129
|
-
connection.put("users/#{username}/graphs/#{graph_id}",
|
|
129
|
+
connection.put("users/#{username}/graphs/#{graph_id}", params.compact).body
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
|
|
@@ -170,12 +170,38 @@ module Pixela::Client::GraphMethods
|
|
|
170
170
|
|
|
171
171
|
res =
|
|
172
172
|
with_error_handling do
|
|
173
|
-
connection.get("users/#{username}/graphs/#{graph_id}/pixels",
|
|
173
|
+
connection.get("users/#{username}/graphs/#{graph_id}/pixels", params.compact).body
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
res.pixels.map { |ymd| Date.parse(ymd) }
|
|
177
177
|
end
|
|
178
178
|
|
|
179
|
+
# Get a Date list of Pixel registered in the graph specified by graphID.
|
|
180
|
+
#
|
|
181
|
+
# @param graph_id [String]
|
|
182
|
+
# @param from [Date] Specify the start position of the period.
|
|
183
|
+
# @param to [Date] Specify the end position of the period.
|
|
184
|
+
#
|
|
185
|
+
# @return [Array<Hashie::Mash>]
|
|
186
|
+
#
|
|
187
|
+
# @raise [Pixela::PixelaError] API is failed
|
|
188
|
+
#
|
|
189
|
+
# @see https://docs.pixe.la/entry/get-graph-pixels
|
|
190
|
+
#
|
|
191
|
+
# @example
|
|
192
|
+
# client.get_pixels(graph_id: "test-graph", from: Date.new(2018, 1, 1), to: Date.new(2018, 12, 31))
|
|
193
|
+
def get_pixels(graph_id:, from: nil, to: nil)
|
|
194
|
+
params = {
|
|
195
|
+
from: to_ymd(from),
|
|
196
|
+
to: to_ymd(to),
|
|
197
|
+
withBody: true,
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
with_error_handling do
|
|
201
|
+
connection.get("users/#{username}/graphs/#{graph_id}/pixels", params.compact).body.pixels
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
179
205
|
# Based on the registered information, get various statistics.
|
|
180
206
|
#
|
|
181
207
|
# @param graph_id [String]
|
|
@@ -193,4 +219,43 @@ module Pixela::Client::GraphMethods
|
|
|
193
219
|
connection.get("users/#{username}/graphs/#{graph_id}/stats").body
|
|
194
220
|
end
|
|
195
221
|
end
|
|
222
|
+
|
|
223
|
+
# This will start and end the measurement of the time.
|
|
224
|
+
#
|
|
225
|
+
# @param graph_id [String]
|
|
226
|
+
#
|
|
227
|
+
# @return [Pixela::Response]
|
|
228
|
+
#
|
|
229
|
+
# @raise [Pixela::PixelaError] API is failed
|
|
230
|
+
#
|
|
231
|
+
# @see https://docs.pixe.la/entry/post-stopwatch
|
|
232
|
+
#
|
|
233
|
+
# @example
|
|
234
|
+
# client.run_stopwatch(graph_id: "test-graph")
|
|
235
|
+
def run_stopwatch(graph_id:)
|
|
236
|
+
with_error_handling do
|
|
237
|
+
connection.post("users/#{username}/graphs/#{graph_id}/stopwatch").body
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
alias_method :start_stopwatch, :run_stopwatch
|
|
242
|
+
alias_method :end_stopwatch, :run_stopwatch
|
|
243
|
+
|
|
244
|
+
# Get a predefined pixelation graph definition.
|
|
245
|
+
#
|
|
246
|
+
# @param graph_id [String]
|
|
247
|
+
#
|
|
248
|
+
# @return [Pixela::Response]
|
|
249
|
+
#
|
|
250
|
+
# @raise [Pixela::PixelaError] API is failed
|
|
251
|
+
#
|
|
252
|
+
# @see https://docs.pixe.la/entry/get-a-graph-def
|
|
253
|
+
#
|
|
254
|
+
# @example
|
|
255
|
+
# client.get_graph_def(graph_id: "test-graph")
|
|
256
|
+
def get_graph_def(graph_id:)
|
|
257
|
+
with_error_handling do
|
|
258
|
+
connection.get("users/#{username}/graphs/#{graph_id}/graph-def").body
|
|
259
|
+
end
|
|
260
|
+
end
|
|
196
261
|
end
|
|
@@ -22,7 +22,7 @@ module Pixela::Client::PixelMethods
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
with_error_handling do
|
|
25
|
-
connection.post("users/#{username}/graphs/#{graph_id}",
|
|
25
|
+
connection.post("users/#{username}/graphs/#{graph_id}", params.compact).body
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -80,7 +80,7 @@ module Pixela::Client::PixelMethods
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
with_error_handling do
|
|
83
|
-
connection.put("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}",
|
|
83
|
+
connection.put("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", params.compact).body
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Pixela::Client::ProfileMethods
|
|
2
|
+
# Updates the profile information for the user corresponding to username
|
|
3
|
+
#
|
|
4
|
+
# @param display_name [String]
|
|
5
|
+
# @param gravatar_icon_email [String]
|
|
6
|
+
# @param title [String]
|
|
7
|
+
# @param timezone [String]
|
|
8
|
+
# @param about_url [String]
|
|
9
|
+
# @param contribute_urls [Array<String>]
|
|
10
|
+
# @param pinned_graph_id [String]
|
|
11
|
+
#
|
|
12
|
+
# @return [Pixela::Response]
|
|
13
|
+
#
|
|
14
|
+
# @raise [Pixela::PixelaError] API is failed
|
|
15
|
+
#
|
|
16
|
+
# @see https://docs.pixe.la/entry/put-profile
|
|
17
|
+
#
|
|
18
|
+
# @example
|
|
19
|
+
# client.update_profile(display_name: "a-know", gravatar_icon_email: "user@example.com", title: "my title", timezone: "Asia/Tokyo", about_url: "https://home.a-know.me", contribute_urls: ["https://pixe.la/","https://github.com/a-know/pi","https://blog.a-know.me/archive/category/Pixela"])
|
|
20
|
+
def update_profile(display_name: nil, gravatar_icon_email: nil, title: nil, timezone: nil,
|
|
21
|
+
about_url: nil, contribute_urls: [], pinned_graph_id: nil)
|
|
22
|
+
|
|
23
|
+
params = {
|
|
24
|
+
displayName: display_name,
|
|
25
|
+
gravatarIconEmail: gravatar_icon_email,
|
|
26
|
+
title: title,
|
|
27
|
+
timezone: timezone,
|
|
28
|
+
aboutURL: about_url,
|
|
29
|
+
pinnedGraphID: pinned_graph_id
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
unless contribute_urls.empty?
|
|
33
|
+
params[:contributeURLs] = contribute_urls
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
with_error_handling do
|
|
37
|
+
connection(endpoint: Pixela::Client::TOP_ENDPOINT).put("@#{username}", params.compact).body
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -53,7 +53,7 @@ module Pixela::Client::WebhookMethods
|
|
|
53
53
|
# client.invoke_webhook(webhook_hash: "<webhookHash>")
|
|
54
54
|
def invoke_webhook(webhook_hash:)
|
|
55
55
|
with_error_handling do
|
|
56
|
-
connection(default_headers).post("users/#{username}/webhooks/#{webhook_hash}").body
|
|
56
|
+
connection(request_headers: default_headers).post("users/#{username}/webhooks/#{webhook_hash}").body
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
data/lib/pixela/graph.rb
CHANGED
|
@@ -22,13 +22,6 @@ module Pixela
|
|
|
22
22
|
Pixel.new(client: client, graph_id: graph_id, date: date)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# @param notification_id [String]
|
|
26
|
-
#
|
|
27
|
-
# @return [Pixela::Notification]
|
|
28
|
-
def notification(notification_id)
|
|
29
|
-
Notification.new(client: client, graph_id: graph_id, notification_id: notification_id)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
25
|
# Create a new pixelation graph definition.
|
|
33
26
|
#
|
|
34
27
|
# @param name [String]
|
|
@@ -156,6 +149,23 @@ module Pixela
|
|
|
156
149
|
client.get_pixel_dates(graph_id: graph_id, from: from, to: to)
|
|
157
150
|
end
|
|
158
151
|
|
|
152
|
+
# Get a Date list of Pixel registered in the graph specified by graphID.
|
|
153
|
+
#
|
|
154
|
+
# @param from [Date] Specify the start position of the period.
|
|
155
|
+
# @param to [Date] Specify the end position of the period.
|
|
156
|
+
#
|
|
157
|
+
# @return [Array<Hashie::Mash>]
|
|
158
|
+
#
|
|
159
|
+
# @raise [Pixela::PixelaError] API is failed
|
|
160
|
+
#
|
|
161
|
+
# @see https://docs.pixe.la/entry/get-graph-pixels
|
|
162
|
+
#
|
|
163
|
+
# @example
|
|
164
|
+
# client.graph("test-graph").pixels(from: Date.new(2018, 1, 1), to: Date.new(2018, 12, 31))
|
|
165
|
+
def pixels(from: nil, to: nil)
|
|
166
|
+
client.get_pixels(graph_id: graph_id, from: from, to: to)
|
|
167
|
+
end
|
|
168
|
+
|
|
159
169
|
# Based on the registered information, get various statistics.
|
|
160
170
|
#
|
|
161
171
|
# @return [Pixela::Response]
|
|
@@ -169,5 +179,38 @@ module Pixela
|
|
|
169
179
|
def stats
|
|
170
180
|
client.get_graph_stats(graph_id: graph_id)
|
|
171
181
|
end
|
|
182
|
+
|
|
183
|
+
# This will start and end the measurement of the time.
|
|
184
|
+
#
|
|
185
|
+
# @return [Pixela::Response]
|
|
186
|
+
#
|
|
187
|
+
# @raise [Pixela::PixelaError] API is failed
|
|
188
|
+
#
|
|
189
|
+
# @see https://docs.pixe.la/entry/post-stopwatch
|
|
190
|
+
#
|
|
191
|
+
# @example
|
|
192
|
+
# client.graph("test-graph").run_stopwatch
|
|
193
|
+
def run_stopwatch
|
|
194
|
+
client.run_stopwatch(graph_id: graph_id)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
alias_method :start_stopwatch, :run_stopwatch
|
|
198
|
+
alias_method :end_stopwatch, :run_stopwatch
|
|
199
|
+
|
|
200
|
+
# Get a predefined pixelation graph definition.
|
|
201
|
+
#
|
|
202
|
+
# @return [Pixela::Response]
|
|
203
|
+
#
|
|
204
|
+
# @raise [Pixela::PixelaError] API is failed
|
|
205
|
+
#
|
|
206
|
+
# @see https://docs.pixe.la/entry/get-a-graph-def
|
|
207
|
+
#
|
|
208
|
+
# @example
|
|
209
|
+
# client.graph("test-graph").def
|
|
210
|
+
def def
|
|
211
|
+
client.get_graph_def(graph_id: graph_id)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
alias_method :definition, :def
|
|
172
215
|
end
|
|
173
216
|
end
|
data/lib/pixela/version.rb
CHANGED
data/pixela.gemspec
CHANGED
|
@@ -34,9 +34,9 @@ Gem::Specification.new do |spec|
|
|
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
35
35
|
spec.require_paths = ["lib"]
|
|
36
36
|
|
|
37
|
-
spec.required_ruby_version = ">= 2.
|
|
37
|
+
spec.required_ruby_version = ">= 2.4.0"
|
|
38
38
|
|
|
39
|
-
spec.add_dependency "faraday"
|
|
39
|
+
spec.add_dependency "faraday", ">= 1.0.0"
|
|
40
40
|
spec.add_dependency "faraday_curl"
|
|
41
41
|
spec.add_dependency "faraday_middleware"
|
|
42
42
|
spec.add_dependency "hashie"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pixela
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- sue445
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-11-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 1.0.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:
|
|
26
|
+
version: 1.0.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: faraday_curl
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -240,20 +240,16 @@ files:
|
|
|
240
240
|
- Rakefile
|
|
241
241
|
- bin/console
|
|
242
242
|
- bin/setup
|
|
243
|
-
- gemfiles/faraday_0.gemfile
|
|
244
243
|
- gemfiles/faraday_1.gemfile
|
|
245
244
|
- lib/pixela.rb
|
|
246
|
-
- lib/pixela/channel.rb
|
|
247
245
|
- lib/pixela/client.rb
|
|
248
|
-
- lib/pixela/client/channel_methods.rb
|
|
249
246
|
- lib/pixela/client/graph_methods.rb
|
|
250
|
-
- lib/pixela/client/notificaton_methods.rb
|
|
251
247
|
- lib/pixela/client/pixel_methods.rb
|
|
248
|
+
- lib/pixela/client/profile_methods.rb
|
|
252
249
|
- lib/pixela/client/user_methods.rb
|
|
253
250
|
- lib/pixela/client/webhook_methods.rb
|
|
254
251
|
- lib/pixela/configuration.rb
|
|
255
252
|
- lib/pixela/graph.rb
|
|
256
|
-
- lib/pixela/notification.rb
|
|
257
253
|
- lib/pixela/pixel.rb
|
|
258
254
|
- lib/pixela/response.rb
|
|
259
255
|
- lib/pixela/version.rb
|
|
@@ -274,7 +270,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
274
270
|
requirements:
|
|
275
271
|
- - ">="
|
|
276
272
|
- !ruby/object:Gem::Version
|
|
277
|
-
version: 2.
|
|
273
|
+
version: 2.4.0
|
|
278
274
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
275
|
requirements:
|
|
280
276
|
- - ">="
|
data/gemfiles/faraday_0.gemfile
DELETED
data/lib/pixela/channel.rb
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
module Pixela
|
|
2
|
-
class Channel
|
|
3
|
-
# @!attribute [r] client
|
|
4
|
-
# @return [Pixela::Client]
|
|
5
|
-
attr_reader :client
|
|
6
|
-
|
|
7
|
-
# @!attribute [r] id
|
|
8
|
-
# @return [String]
|
|
9
|
-
attr_reader :channel_id
|
|
10
|
-
|
|
11
|
-
# @param client [Pixela::Client]
|
|
12
|
-
# @param graph_id [String]
|
|
13
|
-
def initialize(client:, channel_id:)
|
|
14
|
-
@client = client
|
|
15
|
-
@channel_id = channel_id
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Create a new channel settings for notification.
|
|
19
|
-
#
|
|
20
|
-
# @param name [String]
|
|
21
|
-
# @param type [String]
|
|
22
|
-
# @param detail [Hash]
|
|
23
|
-
#
|
|
24
|
-
# @return [Pixela::Response]
|
|
25
|
-
#
|
|
26
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
27
|
-
#
|
|
28
|
-
# @see https://docs.pixe.la/entry/post-channel
|
|
29
|
-
#
|
|
30
|
-
# @example
|
|
31
|
-
# client.channel("my-channel").create(name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
|
|
32
|
-
def create(name:, type:, detail:)
|
|
33
|
-
client.create_channel(channel_id: channel_id, name: name, type: type, detail: detail)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Create a new channel settings for slack notification.
|
|
37
|
-
#
|
|
38
|
-
# @param name [String]
|
|
39
|
-
# @param url [String]
|
|
40
|
-
# @param user_name [String]
|
|
41
|
-
# @param channel_name [String]
|
|
42
|
-
#
|
|
43
|
-
# @return [Pixela::Response]
|
|
44
|
-
#
|
|
45
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
46
|
-
#
|
|
47
|
-
# @see https://docs.pixe.la/entry/post-channel
|
|
48
|
-
#
|
|
49
|
-
# @example
|
|
50
|
-
# client.channel("my-channel").create_with_slack(name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
|
|
51
|
-
def create_with_slack(name:, url:, user_name:, channel_name:)
|
|
52
|
-
client.create_slack_channel(channel_id: channel_id, name: name, url: url, user_name: user_name, channel_name: channel_name)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Update predefined channel settings.
|
|
56
|
-
#
|
|
57
|
-
# @param name [String]
|
|
58
|
-
# @param type [String]
|
|
59
|
-
# @param detail [Hash]
|
|
60
|
-
#
|
|
61
|
-
# @return [Pixela::Response]
|
|
62
|
-
#
|
|
63
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
64
|
-
#
|
|
65
|
-
# @see https://docs.pixe.la/entry/put-channel
|
|
66
|
-
#
|
|
67
|
-
# @example
|
|
68
|
-
# client.channel("my-channel").update(name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
|
|
69
|
-
def update(name:, type:, detail:)
|
|
70
|
-
client.update_channel(channel_id: channel_id, name: name, type: type, detail: detail)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Update predefined slack channel settings.
|
|
74
|
-
#
|
|
75
|
-
# @param name [String]
|
|
76
|
-
# @param url [String]
|
|
77
|
-
# @param user_name [String]
|
|
78
|
-
# @param channel_name [String]
|
|
79
|
-
#
|
|
80
|
-
# @return [Pixela::Response]
|
|
81
|
-
#
|
|
82
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
83
|
-
#
|
|
84
|
-
# @see https://docs.pixe.la/entry/post-channel
|
|
85
|
-
#
|
|
86
|
-
# @example
|
|
87
|
-
# client.channel("my-channel").update_with_slack(name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
|
|
88
|
-
def update_with_slack(name:, url:, user_name:, channel_name:)
|
|
89
|
-
client.update_slack_channel(channel_id: channel_id, name: name, url: url, user_name: user_name, channel_name: channel_name)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Delete predefined channel settings.
|
|
93
|
-
#
|
|
94
|
-
# @see https://docs.pixe.la/entry/delete-channel
|
|
95
|
-
#
|
|
96
|
-
# @return [Pixela::Response]
|
|
97
|
-
#
|
|
98
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
99
|
-
#
|
|
100
|
-
# @example
|
|
101
|
-
# client.channel("my-channel").delete
|
|
102
|
-
def delete
|
|
103
|
-
client.delete_channel(channel_id: channel_id)
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
module Pixela::Client::ChannelMethods
|
|
2
|
-
# Create a new channel settings for notification.
|
|
3
|
-
#
|
|
4
|
-
# @param channel_id [String]
|
|
5
|
-
# @param name [String]
|
|
6
|
-
# @param type [String]
|
|
7
|
-
# @param detail [Hash]
|
|
8
|
-
#
|
|
9
|
-
# @return [Pixela::Response]
|
|
10
|
-
#
|
|
11
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
12
|
-
#
|
|
13
|
-
# @see https://docs.pixe.la/entry/post-channel
|
|
14
|
-
#
|
|
15
|
-
# @example
|
|
16
|
-
# client.create_channel(channel_id: "my-channel", name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
|
|
17
|
-
def create_channel(channel_id:, name:, type:, detail:)
|
|
18
|
-
params = {
|
|
19
|
-
id: channel_id,
|
|
20
|
-
name: name,
|
|
21
|
-
type: type,
|
|
22
|
-
detail: detail,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
with_error_handling do
|
|
26
|
-
connection.post("users/#{username}/channels", compact_hash(params)).body
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Create a new channel settings for slack notification.
|
|
31
|
-
#
|
|
32
|
-
# @param channel_id [String]
|
|
33
|
-
# @param name [String]
|
|
34
|
-
# @param url [String]
|
|
35
|
-
# @param user_name [String]
|
|
36
|
-
# @param channel_name [String]
|
|
37
|
-
#
|
|
38
|
-
# @return [Pixela::Response]
|
|
39
|
-
#
|
|
40
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
41
|
-
#
|
|
42
|
-
# @see https://docs.pixe.la/entry/post-channel
|
|
43
|
-
#
|
|
44
|
-
# @example
|
|
45
|
-
# client.create_slack_channel(channel_id: "my-channel", name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
|
|
46
|
-
def create_slack_channel(channel_id:, name:, url:, user_name:, channel_name:)
|
|
47
|
-
create_channel(
|
|
48
|
-
channel_id: channel_id,
|
|
49
|
-
name: name,
|
|
50
|
-
type: "slack",
|
|
51
|
-
detail: {
|
|
52
|
-
url: url,
|
|
53
|
-
userName: user_name,
|
|
54
|
-
channelName: channel_name,
|
|
55
|
-
},
|
|
56
|
-
)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# Get all predefined channels.
|
|
60
|
-
#
|
|
61
|
-
# @see https://docs.pixe.la/entry/get-channels
|
|
62
|
-
#
|
|
63
|
-
# @return [Array<Pixela::Response>]
|
|
64
|
-
#
|
|
65
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
66
|
-
#
|
|
67
|
-
# @example
|
|
68
|
-
# client.get_channels
|
|
69
|
-
def get_channels
|
|
70
|
-
with_error_handling do
|
|
71
|
-
connection.get("users/#{username}/channels").body.channels
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Update predefined channel settings.
|
|
76
|
-
#
|
|
77
|
-
# @param channel_id [String]
|
|
78
|
-
# @param name [String]
|
|
79
|
-
# @param type [String]
|
|
80
|
-
# @param detail [Hash]
|
|
81
|
-
#
|
|
82
|
-
# @return [Pixela::Response]
|
|
83
|
-
#
|
|
84
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
85
|
-
#
|
|
86
|
-
# @see https://docs.pixe.la/entry/put-channel
|
|
87
|
-
#
|
|
88
|
-
# @example
|
|
89
|
-
# client.update_channel(channel_id: "my-channel", name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
|
|
90
|
-
def update_channel(channel_id:, name:, type:, detail:)
|
|
91
|
-
params = {
|
|
92
|
-
name: name,
|
|
93
|
-
type: type,
|
|
94
|
-
detail: detail,
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
with_error_handling do
|
|
98
|
-
connection.put("users/#{username}/channels/#{channel_id}", compact_hash(params)).body
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# Update predefined slack channel settings.
|
|
103
|
-
#
|
|
104
|
-
# @param channel_id [String]
|
|
105
|
-
# @param name [String]
|
|
106
|
-
# @param url [String]
|
|
107
|
-
# @param user_name [String]
|
|
108
|
-
# @param channel_name [String]
|
|
109
|
-
#
|
|
110
|
-
# @return [Pixela::Response]
|
|
111
|
-
#
|
|
112
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
113
|
-
#
|
|
114
|
-
# @see https://docs.pixe.la/entry/post-channel
|
|
115
|
-
#
|
|
116
|
-
# @example
|
|
117
|
-
# client.update_slack_channel(channel_id: "my-channel", name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
|
|
118
|
-
def update_slack_channel(channel_id:, name:, url:, user_name:, channel_name:)
|
|
119
|
-
update_channel(
|
|
120
|
-
channel_id: channel_id,
|
|
121
|
-
name: name,
|
|
122
|
-
type: "slack",
|
|
123
|
-
detail: {
|
|
124
|
-
url: url,
|
|
125
|
-
userName: user_name,
|
|
126
|
-
channelName: channel_name,
|
|
127
|
-
},
|
|
128
|
-
)
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
# Delete predefined channel settings.
|
|
132
|
-
#
|
|
133
|
-
# @param channel_id [String]
|
|
134
|
-
#
|
|
135
|
-
# @see https://docs.pixe.la/entry/delete-channel
|
|
136
|
-
#
|
|
137
|
-
# @return [Pixela::Response]
|
|
138
|
-
#
|
|
139
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
140
|
-
#
|
|
141
|
-
# @example
|
|
142
|
-
# client.delete_channel(channel_id: "my-channel")
|
|
143
|
-
def delete_channel(channel_id:)
|
|
144
|
-
with_error_handling do
|
|
145
|
-
connection.delete("users/#{username}/channels/#{channel_id}").body
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
module Pixela::Client::NotificationMethods
|
|
2
|
-
# Create a notification rule.
|
|
3
|
-
#
|
|
4
|
-
# @param graph_id [String]
|
|
5
|
-
# @param notification_id [String]
|
|
6
|
-
# @param name [String]
|
|
7
|
-
# @param target [String]
|
|
8
|
-
# @param condition [String]
|
|
9
|
-
# @param threshold [String]
|
|
10
|
-
# @param channel_id [String]
|
|
11
|
-
#
|
|
12
|
-
# @return [Pixela::Response]
|
|
13
|
-
#
|
|
14
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
15
|
-
#
|
|
16
|
-
# @see https://docs.pixe.la/entry/post-notification
|
|
17
|
-
#
|
|
18
|
-
# @example
|
|
19
|
-
# client.create_notification(graph_id: "test-graph", notification_id: "my-notification-rule", name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
|
|
20
|
-
def create_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:)
|
|
21
|
-
params = {
|
|
22
|
-
id: notification_id,
|
|
23
|
-
name: name,
|
|
24
|
-
target: target,
|
|
25
|
-
condition: condition,
|
|
26
|
-
threshold: threshold,
|
|
27
|
-
channelID: channel_id,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
with_error_handling do
|
|
31
|
-
connection.post("users/#{username}/graphs/#{graph_id}/notifications", compact_hash(params)).body
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Get all predefined notifications.
|
|
36
|
-
#
|
|
37
|
-
# @param graph_id [String]
|
|
38
|
-
#
|
|
39
|
-
# @return [Array<Pixela::Response>]
|
|
40
|
-
#
|
|
41
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
42
|
-
#
|
|
43
|
-
# @see https://docs.pixe.la/entry/get-notifications
|
|
44
|
-
#
|
|
45
|
-
# @example
|
|
46
|
-
# client.get_notifications(graph_id: "test-graph")
|
|
47
|
-
def get_notifications(graph_id:)
|
|
48
|
-
with_error_handling do
|
|
49
|
-
connection.get("users/#{username}/graphs/#{graph_id}/notifications").body.notifications
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# Update predefined notification rule.
|
|
54
|
-
#
|
|
55
|
-
# @param graph_id [String]
|
|
56
|
-
# @param notification_id [String]
|
|
57
|
-
# @param name [String]
|
|
58
|
-
# @param target [String]
|
|
59
|
-
# @param condition [String]
|
|
60
|
-
# @param threshold [String]
|
|
61
|
-
# @param channel_id [String]
|
|
62
|
-
#
|
|
63
|
-
# @return [Pixela::Response]
|
|
64
|
-
#
|
|
65
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
66
|
-
#
|
|
67
|
-
# @see https://docs.pixe.la/entry/put-notification
|
|
68
|
-
#
|
|
69
|
-
# @example
|
|
70
|
-
# client.update_notification(graph_id: "test-graph", notification_id: "my-notification-rule", name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
|
|
71
|
-
def update_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:)
|
|
72
|
-
params = {
|
|
73
|
-
name: name,
|
|
74
|
-
target: target,
|
|
75
|
-
condition: condition,
|
|
76
|
-
threshold: threshold,
|
|
77
|
-
channelID: channel_id,
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
with_error_handling do
|
|
81
|
-
connection.put("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}", compact_hash(params)).body
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Delete predefined notification settings.
|
|
86
|
-
#
|
|
87
|
-
# @param graph_id [String]
|
|
88
|
-
# @param notification_id [String]
|
|
89
|
-
#
|
|
90
|
-
# @return [Pixela::Response]
|
|
91
|
-
#
|
|
92
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
93
|
-
#
|
|
94
|
-
# @see https://docs.pixe.la/entry/delete-notification
|
|
95
|
-
#
|
|
96
|
-
# @example
|
|
97
|
-
# client.delete_notification(graph_id: "test-graph", notification_id: "my-notification-rule")
|
|
98
|
-
def delete_notification(graph_id:, notification_id:)
|
|
99
|
-
with_error_handling do
|
|
100
|
-
connection.delete("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}").body
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
data/lib/pixela/notification.rb
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
module Pixela
|
|
2
|
-
class Notification
|
|
3
|
-
# @!attribute [r] client
|
|
4
|
-
# @return [Pixela::Client]
|
|
5
|
-
attr_reader :client
|
|
6
|
-
|
|
7
|
-
# @!attribute [r] graph_id
|
|
8
|
-
# @return [String]
|
|
9
|
-
attr_reader :graph_id
|
|
10
|
-
|
|
11
|
-
# @!attribute [r] notification_id
|
|
12
|
-
# @return [String]
|
|
13
|
-
attr_reader :notification_id
|
|
14
|
-
|
|
15
|
-
# @param client [Pixela::Client]
|
|
16
|
-
# @param graph_id [String]
|
|
17
|
-
# @param notification_id [String]
|
|
18
|
-
def initialize(client:, graph_id:, notification_id:)
|
|
19
|
-
@client = client
|
|
20
|
-
@graph_id = graph_id
|
|
21
|
-
@notification_id = notification_id
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Create a notification rule.
|
|
25
|
-
#
|
|
26
|
-
# @param name [String]
|
|
27
|
-
# @param target [String]
|
|
28
|
-
# @param condition [String]
|
|
29
|
-
# @param threshold [String]
|
|
30
|
-
# @param channel_id [String]
|
|
31
|
-
#
|
|
32
|
-
# @return [Pixela::Response]
|
|
33
|
-
#
|
|
34
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
35
|
-
#
|
|
36
|
-
# @see https://docs.pixe.la/entry/post-notification
|
|
37
|
-
#
|
|
38
|
-
# @example
|
|
39
|
-
# client.graph("test-graph").notification("my-notification-rule").create(name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
|
|
40
|
-
def create(name:, target:, condition:, threshold:, channel_id:)
|
|
41
|
-
client.create_notification(graph_id: graph_id, notification_id: notification_id, name: name, target: target, condition: condition, threshold: threshold, channel_id: channel_id)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Update predefined notification rule.
|
|
45
|
-
#
|
|
46
|
-
# @param graph_id [String]
|
|
47
|
-
# @param notification_id [String]
|
|
48
|
-
# @param name [String]
|
|
49
|
-
# @param target [String]
|
|
50
|
-
# @param condition [String]
|
|
51
|
-
# @param threshold [String]
|
|
52
|
-
# @param channel_id [String]
|
|
53
|
-
#
|
|
54
|
-
# @return [Pixela::Response]
|
|
55
|
-
#
|
|
56
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
57
|
-
#
|
|
58
|
-
# @see https://docs.pixe.la/entry/put-notification
|
|
59
|
-
#
|
|
60
|
-
# @example
|
|
61
|
-
# client.graph("test-graph").notification("my-notification-rule").update(name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
|
|
62
|
-
def update(name:, target:, condition:, threshold:, channel_id:)
|
|
63
|
-
client.update_notification(graph_id: graph_id, notification_id: notification_id, name: name, target: target, condition: condition, threshold: threshold, channel_id: channel_id)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Delete predefined notification settings.
|
|
67
|
-
#
|
|
68
|
-
# @return [Pixela::Response]
|
|
69
|
-
#
|
|
70
|
-
# @raise [Pixela::PixelaError] API is failed
|
|
71
|
-
#
|
|
72
|
-
# @see https://docs.pixe.la/entry/delete-notification
|
|
73
|
-
#
|
|
74
|
-
# @example
|
|
75
|
-
# client.graph("test-graph").notification("my-notification-rule").delete
|
|
76
|
-
def delete
|
|
77
|
-
client.delete_notification(graph_id: graph_id, notification_id: notification_id)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|