pixela 1.3.1 → 1.4.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/.travis.yml +3 -3
- data/CHANGELOG.md +8 -1
- data/lib/pixela.rb +2 -0
- data/lib/pixela/channel.rb +106 -0
- data/lib/pixela/client.rb +16 -5
- data/lib/pixela/client/channel_methods.rb +148 -0
- data/lib/pixela/client/notificaton_methods.rb +103 -0
- data/lib/pixela/graph.rb +7 -0
- data/lib/pixela/notification.rb +80 -0
- data/lib/pixela/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 375d6ec8ab2c9c4be2747ba45a7c820ced86af17de33af609d9dd1113838b029
|
4
|
+
data.tar.gz: daf59f70e4899e6bb62dd3ea3f2f1e8406d9de8172b47e22b90a462d1cceee2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44f9c7ff48301f987d0978320fe637b4881680f9c18afecd5034ca475c1207fd23a11113f21588ad596f0e6018f213bfc70902b4d91043c144ba87bb07f367ad
|
7
|
+
data.tar.gz: ac91d230a786cba5a1a3599fa9cb4ade64a2965dd1c3086be6a57ea9997c02af8937363e246da7d14e9518fa5ead6591767f533ed23f6b32da56562145801349
|
data/.travis.yml
CHANGED
@@ -15,7 +15,7 @@ before_script:
|
|
15
15
|
- chmod +x ./cc-test-reporter
|
16
16
|
- ./cc-test-reporter before-build
|
17
17
|
script:
|
18
|
-
- bundle exec rspec
|
18
|
+
- RUBYOPT=$RSPEC_RUBYOPT bundle exec rspec
|
19
19
|
after_script:
|
20
20
|
- if [ "$PIXELA_WEBHOOK_URL" != "" ]; then curl -X POST $PIXELA_WEBHOOK_URL -H 'Content-Length:0'; fi
|
21
21
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
@@ -31,9 +31,9 @@ matrix:
|
|
31
31
|
- rvm: ruby-head
|
32
32
|
include:
|
33
33
|
- rvm: 2.6
|
34
|
-
env:
|
34
|
+
env: RSPEC_RUBYOPT="--jit"
|
35
35
|
- rvm: ruby-head
|
36
|
-
env:
|
36
|
+
env: RSPEC_RUBYOPT="--jit"
|
37
37
|
sudo: false
|
38
38
|
env:
|
39
39
|
global:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](http://github.com/sue445/pixela/compare/v1.
|
2
|
+
[full changelog](http://github.com/sue445/pixela/compare/v1.4.0...master)
|
3
|
+
|
4
|
+
## v1.4.0
|
5
|
+
[full changelog](http://github.com/sue445/pixela/compare/v1.3.1...v1.4.0)
|
6
|
+
|
7
|
+
* Support Channel and Notification API
|
8
|
+
* https://github.com/sue445/pixela/pull/59
|
9
|
+
* https://github.com/a-know/Pixela/releases/tag/v1.13.0
|
3
10
|
|
4
11
|
## v1.3.1
|
5
12
|
[full changelog](http://github.com/sue445/pixela/compare/v1.3.0...v1.3.1)
|
data/lib/pixela.rb
CHANGED
@@ -5,9 +5,11 @@ require "faraday_curl"
|
|
5
5
|
require "date"
|
6
6
|
|
7
7
|
module Pixela
|
8
|
+
autoload :Channel, "pixela/channel"
|
8
9
|
autoload :Client, "pixela/client"
|
9
10
|
autoload :Configuration, "pixela/configuration"
|
10
11
|
autoload :Graph, "pixela/graph"
|
12
|
+
autoload :Notification, "pixela/notification"
|
11
13
|
autoload :Pixel, "pixela/pixel"
|
12
14
|
autoload :Response, "pixela/response"
|
13
15
|
autoload :Webhook, "pixela/webhook"
|
@@ -0,0 +1,106 @@
|
|
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
|
data/lib/pixela/client.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
module Pixela
|
2
2
|
class Client
|
3
|
-
autoload :
|
4
|
-
autoload :
|
5
|
-
autoload :
|
6
|
-
autoload :
|
7
|
-
|
3
|
+
autoload :ChannelMethods, "pixela/client/channel_methods"
|
4
|
+
autoload :GraphMethods, "pixela/client/graph_methods"
|
5
|
+
autoload :NotificationMethods, "pixela/client/notificaton_methods"
|
6
|
+
autoload :PixelMethods, "pixela/client/pixel_methods"
|
7
|
+
autoload :UserMethods, "pixela/client/user_methods"
|
8
|
+
autoload :WebhookMethods, "pixela/client/webhook_methods"
|
9
|
+
|
10
|
+
include ChannelMethods
|
8
11
|
include GraphMethods
|
12
|
+
include NotificationMethods
|
9
13
|
include PixelMethods
|
10
14
|
include UserMethods
|
11
15
|
include WebhookMethods
|
@@ -43,6 +47,13 @@ module Pixela
|
|
43
47
|
Webhook.new(client: self, webhook_hash: webhook_hash)
|
44
48
|
end
|
45
49
|
|
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
|
+
|
46
57
|
private
|
47
58
|
|
48
59
|
# @!attribute [r] token
|
@@ -0,0 +1,148 @@
|
|
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
|
@@ -0,0 +1,103 @@
|
|
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/graph.rb
CHANGED
@@ -22,6 +22,13 @@ 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
|
+
|
25
32
|
# Create a new pixelation graph definition.
|
26
33
|
#
|
27
34
|
# @param name [String]
|
@@ -0,0 +1,80 @@
|
|
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
|
data/lib/pixela/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -241,13 +241,17 @@ files:
|
|
241
241
|
- bin/console
|
242
242
|
- bin/setup
|
243
243
|
- lib/pixela.rb
|
244
|
+
- lib/pixela/channel.rb
|
244
245
|
- lib/pixela/client.rb
|
246
|
+
- lib/pixela/client/channel_methods.rb
|
245
247
|
- lib/pixela/client/graph_methods.rb
|
248
|
+
- lib/pixela/client/notificaton_methods.rb
|
246
249
|
- lib/pixela/client/pixel_methods.rb
|
247
250
|
- lib/pixela/client/user_methods.rb
|
248
251
|
- lib/pixela/client/webhook_methods.rb
|
249
252
|
- lib/pixela/configuration.rb
|
250
253
|
- lib/pixela/graph.rb
|
254
|
+
- lib/pixela/notification.rb
|
251
255
|
- lib/pixela/pixel.rb
|
252
256
|
- lib/pixela/response.rb
|
253
257
|
- lib/pixela/version.rb
|
@@ -275,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
279
|
- !ruby/object:Gem::Version
|
276
280
|
version: '0'
|
277
281
|
requirements: []
|
278
|
-
rubygems_version: 3.0.
|
282
|
+
rubygems_version: 3.0.6
|
279
283
|
signing_key:
|
280
284
|
specification_version: 4
|
281
285
|
summary: Pixela API client for Ruby
|