Class: Gs2::Notification::Client
- Inherits:
-
Core::AbstractClient
- Object
- Core::AbstractClient
- Gs2::Notification::Client
- Defined in:
- lib/gs2/notification/Client.rb
Overview
GS2-Notification クライアント
Constant Summary collapse
- @@ENDPOINT =
'notification'
Class Method Summary collapse
-
.ENDPOINT(v = nil) ⇒ Object
デバッグ用。通常利用する必要はありません。.
Instance Method Summary collapse
-
#create_notification(request) ⇒ Array
通知を作成
通知はGS2内で発生したイベントを受け取る手段を提供します。
例えば、GS2-Watch の監視データが一定の閾値を超えた時に通知する。といった用途に利用できます。
GS2 のサービスの多くはクオータを買い、その範囲内でサービスを利用する形式が多く取られていますが、
現在の消費クオータが GS2-Watch で取れますので、クオータの消費量が予約量の80%を超えたら通知をだす。というような使い方ができます。
. -
#create_subscribe(request) ⇒ Array
通知先を作成
E-Mail, HTTP/HTTPS 通信を指定して通知先を登録できます。
通知先は1つの通知に対して複数登録することもできます。
そのため、メールとSlackに通知する。といった利用ができます。
type に指定できるパラメータ
. -
#delete_notification(request) ⇒ Object
通知を削除.
-
#delete_subscribe(request) ⇒ Object
通知先を削除.
-
#describe_notification(pageToken = nil, limit = nil) ⇒ Array
通知リストを取得.
-
#describe_subscribe(request, pageToken = nil, limit = nil) ⇒ Array
通知先リストを取得.
-
#get_notification(request) ⇒ Array
通知を取得.
-
#get_subscribe(request) ⇒ Array
通知先を取得.
-
#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client
constructor
コンストラクタ.
-
#update_notification(request) ⇒ Array
通知を更新.
Constructor Details
#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client
コンストラクタ
17 18 19 |
# File 'lib/gs2/notification/Client.rb', line 17 def initialize(region, gs2_client_id, gs2_client_secret) super(region, gs2_client_id, gs2_client_secret) end |
Class Method Details
.ENDPOINT(v = nil) ⇒ Object
デバッグ用。通常利用する必要はありません。
22 23 24 25 26 27 28 |
# File 'lib/gs2/notification/Client.rb', line 22 def self.ENDPOINT(v = nil) if v @@ENDPOINT = v else return @@ENDPOINT end end |
Instance Method Details
#create_notification(request) ⇒ Array
通知を作成
通知はGS2内で発生したイベントを受け取る手段を提供します。
例えば、GS2-Watch の監視データが一定の閾値を超えた時に通知する。といった用途に利用できます。
GS2 のサービスの多くはクオータを買い、その範囲内でサービスを利用する形式が多く取られていますが、
現在の消費クオータが GS2-Watch で取れますので、クオータの消費量が予約量の80%を超えたら通知をだす。というような使い方ができます。
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/gs2/notification/Client.rb', line 75 def create_notification(request) if not request; raise ArgumentError.new(); end body = {} if request.has_key?('name'); body['name'] = request['name']; end if request.has_key?('description'); body['description'] = request['description']; end query = {} return post( 'Gs2Notification', 'CreateNotification', @@ENDPOINT, '/notification', body, query); end |
#create_subscribe(request) ⇒ Array
通知先を作成
E-Mail, HTTP/HTTPS 通信を指定して通知先を登録できます。
通知先は1つの通知に対して複数登録することもできます。
そのため、メールとSlackに通知する。といった利用ができます。
type に指定できるパラメータ
-
email
-
http/https
endpoint には type に指定したプロトコルによって指定する内容が変わります。
email を選択した場合には メールアドレスを、
http/https を選択した場合には URL を指定してください。
http/https を選択した場合には登録時に疎通確認を行います。
指定したURLでPOSTリクエストを受け付けられる状態で登録してください。
疎通確認の通信は通常の通知とは異なり、body パラメータがからの通信が発生します。ご注意ください。
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/gs2/notification/Client.rb', line 224 def create_subscribe(request) if not request; raise ArgumentError.new(); end if not request.has_key?('notificationName'); raise ArgumentError.new(); end if not request['notificationName']; raise ArgumentError.new(); end body = {} if request.has_key?('name'); body['name'] = request['name']; end if request.has_key?('type'); body['type'] = request['type']; end if request.has_key?('endpoint'); body['endpoint'] = request['endpoint']; end query = {} return post( 'Gs2Notification', 'CreateSubscribe', @@ENDPOINT, '/notification/' + request['notificationName'] + '/subscribe', body, query); end |
#delete_notification(request) ⇒ Object
通知を削除
148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/gs2/notification/Client.rb', line 148 def delete_notification(request) if not request; raise ArgumentError.new(); end if not request.has_key?('notificationName'); raise ArgumentError.new(); end if not request['notificationName']; raise ArgumentError.new(); end query = {} return delete( 'Gs2Notification', 'DeleteNotification', @@ENDPOINT, '/notification/' + request['notificationName'], query); end |
#delete_subscribe(request) ⇒ Object
通知先を削除
274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/gs2/notification/Client.rb', line 274 def delete_subscribe(request) if not request; raise ArgumentError.new(); end if not request.has_key?('notificationName'); raise ArgumentError.new(); end if not request['notificationName']; raise ArgumentError.new(); end if not request.has_key?('subscribeId'); raise ArgumentError.new(); end if not request['subscribeId']; raise ArgumentError.new(); end query = {} return delete( 'Gs2Notification', 'DeleteSubscribe', @@ENDPOINT, '/notification/' + request['notificationName'] + '/subscribe/' + request['subscribeId'], query); end |
#describe_notification(pageToken = nil, limit = nil) ⇒ Array
通知リストを取得
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gs2/notification/Client.rb', line 44 def describe_notification(pageToken = nil, limit = nil) query = {} if pageToken; query['pageToken'] = pageToken; end if limit; query['limit'] = limit; end return get( 'Gs2Notification', 'DescribeNotification', @@ENDPOINT, '/notification', query); end |
#describe_subscribe(request, pageToken = nil, limit = nil) ⇒ Array
通知先リストを取得
176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/gs2/notification/Client.rb', line 176 def describe_subscribe(request, pageToken = nil, limit = nil) if not request; raise ArgumentError.new(); end if not request.has_key?('notificationName'); raise ArgumentError.new(); end if not request['notificationName']; raise ArgumentError.new(); end query = {} if pageToken; query['pageToken'] = pageToken; end if limit; query['limit'] = limit; end return get( 'Gs2Notification', 'DescribeSubscribe', @@ENDPOINT, '/notification/' + request['notificationName'] + '/subscribe', query); end |
#get_notification(request) ⇒ Array
通知を取得
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/gs2/notification/Client.rb', line 102 def get_notification(request) if not request; raise ArgumentError.new(); end if not request.has_key?('notificationName'); raise ArgumentError.new(); end if not request['notificationName']; raise ArgumentError.new(); end query = {} return get( 'Gs2Notification', 'GetNotification', @@ENDPOINT, '/notification/' + request['notificationName'], query); end |
#get_subscribe(request) ⇒ Array
通知先を取得
254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/gs2/notification/Client.rb', line 254 def get_subscribe(request) if not request; raise ArgumentError.new(); end if not request.has_key?('notificationName'); raise ArgumentError.new(); end if not request['notificationName']; raise ArgumentError.new(); end if not request.has_key?('subscribeId'); raise ArgumentError.new(); end if not request['subscribeId']; raise ArgumentError.new(); end query = {} return get( 'Gs2Notification', 'GetSubscribe', @@ENDPOINT, '/notification/' + request['notificationName'] + '/subscribe/' + request['subscribeId'], query); end |
#update_notification(request) ⇒ Array
通知を更新
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/gs2/notification/Client.rb', line 128 def update_notification(request) if not request; raise ArgumentError.new(); end if not request.has_key?('notificationName'); raise ArgumentError.new(); end if not request['notificationName']; raise ArgumentError.new(); end body = {} if request.has_key?('description'); body['description'] = request['description']; end query = {} return put( 'Gs2Notification', 'UpdateNotification', @@ENDPOINT, '/notification/' + request['notificationName'], body, query); end |