gs2-ruby-sdk-watch 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.buildpath +5 -0
- data/.gitignore +10 -0
- data/.project +17 -0
- data/Gemfile +5 -0
- data/README.md +2 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gs2-ruby-sdk-watch.gemspec +25 -0
- data/lib/gs2/watch/Client.rb +310 -0
- data/lib/gs2/watch/version.rb +5 -0
- data/lib/gs2-watch.rb +1 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 44e125588facd495cd3bfdc7d4411139110c91f3
|
4
|
+
data.tar.gz: 9b3d6865a9a2512d3805580f681eaa4f0c2ec222
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eef684d281562f63d9d093cf605ef435226e598332612dfbf5e39543cb3b6c4bd8c0cd8164dedb2b97642c82f121d351fde018f98718bd8d37110c61fda3334d
|
7
|
+
data.tar.gz: 17211d2f7ed472eb288cb694c6304e3eb712a7714cb9464acd154b721f679a51d05d26695eeffd8b987f952543197cb8cea9a16ce05d98a32c291753b638ae52
|
data/.buildpath
ADDED
data/.gitignore
ADDED
data/.project
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<projectDescription>
|
3
|
+
<name>gs2-ruby-sdk-watch</name>
|
4
|
+
<comment></comment>
|
5
|
+
<projects>
|
6
|
+
</projects>
|
7
|
+
<buildSpec>
|
8
|
+
<buildCommand>
|
9
|
+
<name>org.eclipse.dltk.core.scriptbuilder</name>
|
10
|
+
<arguments>
|
11
|
+
</arguments>
|
12
|
+
</buildCommand>
|
13
|
+
</buildSpec>
|
14
|
+
<natures>
|
15
|
+
<nature>org.eclipse.dltk.ruby.core.nature</nature>
|
16
|
+
</natures>
|
17
|
+
</projectDescription>
|
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gs2/sdk/for/ruby/watch"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gs2/watch/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gs2-ruby-sdk-watch"
|
8
|
+
spec.version = Gs2::Watch::VERSION
|
9
|
+
spec.authors = ["Game Server Services, Inc."]
|
10
|
+
spec.email = ["contact@gs2.io"]
|
11
|
+
spec.licenses = "Apache-2.0"
|
12
|
+
|
13
|
+
spec.summary = %q{Game Server Services GS2-Watch Client Library}
|
14
|
+
spec.homepage = "https://gs2.io/"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "gs2-ruby-sdk-core", "~> 0.0.1"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,310 @@
|
|
1
|
+
require 'gs2/core/AbstractClient.rb'
|
2
|
+
|
3
|
+
module Gs2 module Watch
|
4
|
+
|
5
|
+
# GS2-Watch クライアント
|
6
|
+
#
|
7
|
+
# @author Game Server Services, Inc.
|
8
|
+
class Client < Gs2::Core::AbstractClient
|
9
|
+
|
10
|
+
@@ENDPOINT = 'watch'
|
11
|
+
|
12
|
+
# コンストラクタ
|
13
|
+
#
|
14
|
+
# @param region [String] リージョン名
|
15
|
+
# @param gs2_client_id [String] GSIクライアントID
|
16
|
+
# @param gs2_client_secret [String] GSIクライアントシークレット
|
17
|
+
def initialize(region, gs2_client_id, gs2_client_secret)
|
18
|
+
super(region, gs2_client_id, gs2_client_secret)
|
19
|
+
end
|
20
|
+
|
21
|
+
# デバッグ用。通常利用する必要はありません。
|
22
|
+
def self.ENDPOINT(v = nil)
|
23
|
+
if v
|
24
|
+
@@ENDPOINT = v
|
25
|
+
else
|
26
|
+
return @@ENDPOINT
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# アラームリストを取得
|
31
|
+
#
|
32
|
+
# @param pageToken [String] ページトークン
|
33
|
+
# @param limit [Integer] 取得件数
|
34
|
+
# @return [Array]
|
35
|
+
# * items
|
36
|
+
# [Array]
|
37
|
+
# * alermId => アラームID
|
38
|
+
# * ownerId => オーナーID
|
39
|
+
# * name => アラーム名
|
40
|
+
# * description => 説明文
|
41
|
+
# * service => 監視対象サービス
|
42
|
+
# * serviceId => 監視対象サービスID
|
43
|
+
# * operation => 監視対象オペレーション
|
44
|
+
# * expression => 演算子
|
45
|
+
# * threshold => 閾値
|
46
|
+
# * notificationId => 通知ID
|
47
|
+
# * createAt => 作成日時
|
48
|
+
# * updateAt => 更新日時
|
49
|
+
# * status => ステータス
|
50
|
+
# * lastStatusChangeAt => 最終ステータス更新日時
|
51
|
+
# * nextPageToken => 次ページトークン
|
52
|
+
def describe_alerm(pageToken = nil, limit = nil)
|
53
|
+
query = {}
|
54
|
+
if pageToken; query['pageToken'] = pageToken; end
|
55
|
+
if limit; query['limit'] = limit; end
|
56
|
+
return get(
|
57
|
+
'Gs2Watch',
|
58
|
+
'DescribeAlerm',
|
59
|
+
@@ENDPOINT,
|
60
|
+
'/alerm',
|
61
|
+
query);
|
62
|
+
end
|
63
|
+
|
64
|
+
# アラームを作成<br>
|
65
|
+
# <br>
|
66
|
+
# GS2 内のスタティスティックスに対して監視を行うことができます。<br>
|
67
|
+
# クオータの消費量に対して閾値を設定し、閾値を超えた際に通知を出すことができます。<br>
|
68
|
+
#
|
69
|
+
# @param request [Array]
|
70
|
+
# * name => アラーム名
|
71
|
+
# * description => 説明文
|
72
|
+
# * service => 監視対象サービス
|
73
|
+
# * serviceId => 監視対象サービスID
|
74
|
+
# * operation => 監視対象オペレーション
|
75
|
+
# * expression => 演算子(>=, >, <, <=)
|
76
|
+
# * threshold => 閾値
|
77
|
+
# * notificationId => 通知ID
|
78
|
+
# @return [Array]
|
79
|
+
# * item
|
80
|
+
# * alermId => アラームID
|
81
|
+
# * ownerId => オーナーID
|
82
|
+
# * name => アラーム名
|
83
|
+
# * description => 説明文
|
84
|
+
# * service => 監視対象サービス
|
85
|
+
# * serviceId => 監視対象サービスID
|
86
|
+
# * operation => 監視対象オペレーション
|
87
|
+
# * expression => 演算子
|
88
|
+
# * threshold => 閾値
|
89
|
+
# * notificationId => 通知ID
|
90
|
+
# * createAt => 作成日時
|
91
|
+
# * updateAt => 更新日時
|
92
|
+
# * status => ステータス
|
93
|
+
# * lastStatusChangeAt => 最終ステータス更新日時
|
94
|
+
def create_alerm(request)
|
95
|
+
if not request; raise ArgumentError.new(); end
|
96
|
+
body = {}
|
97
|
+
if request.has_key?('name'); body['name'] = request['name']; end
|
98
|
+
if request.has_key?('description'); body['description'] = request['description']; end
|
99
|
+
if request.has_key?('service'); body['service'] = request['service']; end
|
100
|
+
if request.has_key?('serviceId'); body['serviceId'] = request['serviceId']; end
|
101
|
+
if request.has_key?('operation'); body['operation'] = request['operation']; end
|
102
|
+
if request.has_key?('expression'); body['expression'] = request['expression']; end
|
103
|
+
if request.has_key?('threshold'); body['threshold'] = request['threshold']; end
|
104
|
+
if request.has_key?('notificationId'); body['notificationId'] = request['notificationId']; end
|
105
|
+
query = {}
|
106
|
+
return post(
|
107
|
+
'Gs2Watch',
|
108
|
+
'CreateAlerm',
|
109
|
+
@@ENDPOINT,
|
110
|
+
'/alerm',
|
111
|
+
body,
|
112
|
+
query);
|
113
|
+
end
|
114
|
+
|
115
|
+
# アラームを取得
|
116
|
+
#
|
117
|
+
# @param request [Array]
|
118
|
+
# * alermName => アラーム名
|
119
|
+
# @return [Array]
|
120
|
+
# * item
|
121
|
+
# * alermId => アラームID
|
122
|
+
# * ownerId => オーナーID
|
123
|
+
# * name => アラーム名
|
124
|
+
# * description => 説明文
|
125
|
+
# * service => 監視対象サービス
|
126
|
+
# * serviceId => 監視対象サービスID
|
127
|
+
# * operation => 監視対象オペレーション
|
128
|
+
# * expression => 演算子
|
129
|
+
# * threshold => 閾値
|
130
|
+
# * notificationId => 通知ID
|
131
|
+
# * createAt => 作成日時
|
132
|
+
# * updateAt => 更新日時
|
133
|
+
# * status => ステータス
|
134
|
+
# * lastStatusChangeAt => 最終ステータス更新日時
|
135
|
+
def get_alerm(request)
|
136
|
+
if not request; raise ArgumentError.new(); end
|
137
|
+
if not request.has_key?('alermName'); raise ArgumentError.new(); end
|
138
|
+
if not request['alermName']; raise ArgumentError.new(); end
|
139
|
+
query = {}
|
140
|
+
return get(
|
141
|
+
'Gs2Watch',
|
142
|
+
'GetAlerm',
|
143
|
+
@@ENDPOINT,
|
144
|
+
'/alerm/' + request['alermName'],
|
145
|
+
query);
|
146
|
+
end
|
147
|
+
|
148
|
+
# アラームを更新
|
149
|
+
#
|
150
|
+
# @param request [Array]
|
151
|
+
# * alermName => アラーム名
|
152
|
+
# * description => 説明文
|
153
|
+
# * expression => 演算子(>=, >, <, <=)
|
154
|
+
# * threshold => 閾値
|
155
|
+
# * notificationId => 通知ID
|
156
|
+
# @return [Array]
|
157
|
+
# * item
|
158
|
+
# * alermId => アラームID
|
159
|
+
# * ownerId => オーナーID
|
160
|
+
# * name => アラーム名
|
161
|
+
# * description => 説明文
|
162
|
+
# * service => 監視対象サービス
|
163
|
+
# * serviceId => 監視対象サービスID
|
164
|
+
# * operation => 監視対象オペレーション
|
165
|
+
# * expression => 演算子
|
166
|
+
# * threshold => 閾値
|
167
|
+
# * notificationId => 通知ID
|
168
|
+
# * createAt => 作成日時
|
169
|
+
# * updateAt => 更新日時
|
170
|
+
# * status => ステータス
|
171
|
+
# * lastStatusChangeAt => 最終ステータス更新日時
|
172
|
+
def update_alerm(request)
|
173
|
+
if not request; raise ArgumentError.new(); end
|
174
|
+
if not request.has_key?('alermName'); raise ArgumentError.new(); end
|
175
|
+
if not request['alermName']; raise ArgumentError.new(); end
|
176
|
+
body = {}
|
177
|
+
if request.has_key?('description'); body['description'] = request['description']; end
|
178
|
+
if request.has_key?('expression'); body['expression'] = request['expression']; end
|
179
|
+
if request.has_key?('threshold'); body['threshold'] = request['threshold']; end
|
180
|
+
if request.has_key?('notificationId'); body['notificationId'] = request['notificationId']; end
|
181
|
+
query = {}
|
182
|
+
return put(
|
183
|
+
'Gs2Watch',
|
184
|
+
'UpdateAlerm',
|
185
|
+
@@ENDPOINT,
|
186
|
+
'/alerm/' + request['alermName'],
|
187
|
+
body,
|
188
|
+
query);
|
189
|
+
end
|
190
|
+
|
191
|
+
# アラームを削除
|
192
|
+
#
|
193
|
+
# @param request [Array]
|
194
|
+
# * alermName => アラーム名
|
195
|
+
def delete_alerm(request)
|
196
|
+
if not request; raise ArgumentError.new(); end
|
197
|
+
if not request.has_key?('alermName'); raise ArgumentError.new(); end
|
198
|
+
if not request['alermName']; raise ArgumentError.new(); end
|
199
|
+
query = {}
|
200
|
+
return delete(
|
201
|
+
'Gs2Watch',
|
202
|
+
'DeleteAlerm',
|
203
|
+
@@ENDPOINT,
|
204
|
+
'/alerm/' + request['alermName'],
|
205
|
+
query);
|
206
|
+
end
|
207
|
+
|
208
|
+
# アラームイベントリストを取得<br>
|
209
|
+
# <br>
|
210
|
+
# 過去にアラームが発生した履歴などを確認できます。<br>
|
211
|
+
#
|
212
|
+
# @param request [Array]
|
213
|
+
# * alermName => アラーム名
|
214
|
+
# @param pageToken [String] ページトークン
|
215
|
+
# @param limit [Integer] 取得件数
|
216
|
+
# @return [Array]
|
217
|
+
# * items
|
218
|
+
# [Array]
|
219
|
+
# * eventId => アラームイベントID
|
220
|
+
# * alermId => アラームID
|
221
|
+
# * type => イベントの種類
|
222
|
+
# * eventAt => イベント発生日時
|
223
|
+
# * nextPageToken => 次ページトークン
|
224
|
+
def describe_alerm_event(request, pageToken = nil, limit = nil)
|
225
|
+
if not request; raise ArgumentError.new(); end
|
226
|
+
if not request.has_key?('alermName'); raise ArgumentError.new(); end
|
227
|
+
if not request['alermName']; raise ArgumentError.new(); end
|
228
|
+
query = {}
|
229
|
+
if pageToken; query['pageToken'] = pageToken; end
|
230
|
+
if limit; query['limit'] = limit; end
|
231
|
+
return get(
|
232
|
+
'Gs2Watch',
|
233
|
+
'DescribeAlermEvent',
|
234
|
+
@@ENDPOINT,
|
235
|
+
'/alerm/' + request['alermName'] + '/event',
|
236
|
+
query);
|
237
|
+
end
|
238
|
+
|
239
|
+
# サービス名リストを取得<br>
|
240
|
+
# <br>
|
241
|
+
# アラームを設定する際に指定できるサービスの一覧を取得できます。<br>
|
242
|
+
#
|
243
|
+
# @return [Array] サービス名リスト
|
244
|
+
def describe_service()
|
245
|
+
query = {}
|
246
|
+
result = get(
|
247
|
+
'Gs2Watch',
|
248
|
+
'DescribeService',
|
249
|
+
@@ENDPOINT,
|
250
|
+
'/service',
|
251
|
+
query);
|
252
|
+
return result['items'];
|
253
|
+
end
|
254
|
+
|
255
|
+
# オペレーション名リストを取得<br>
|
256
|
+
# <br>
|
257
|
+
# アラームを設定する際に指定できるオペレーションの一覧を取得できます。<br>
|
258
|
+
#
|
259
|
+
# @param request [Array]
|
260
|
+
# * serviceName => サービス名
|
261
|
+
# @return [Array] オペレーション名リスト
|
262
|
+
def describe_operation(request)
|
263
|
+
if not request; raise ArgumentError.new(); end
|
264
|
+
if not request.has_key?('serviceName'); raise ArgumentError.new(); end
|
265
|
+
if not request['serviceName']; raise ArgumentError.new(); end
|
266
|
+
query = {}
|
267
|
+
result = get(
|
268
|
+
'Gs2Watch',
|
269
|
+
'DescribeOperation',
|
270
|
+
@@ENDPOINT,
|
271
|
+
'/service/' + request['serviceName'] + '/operation',
|
272
|
+
query);
|
273
|
+
return result['items'];
|
274
|
+
end
|
275
|
+
|
276
|
+
# メトリクスを取得<br>
|
277
|
+
# <br>
|
278
|
+
# 過去のサービスの利用状況を取得します。<br>
|
279
|
+
#
|
280
|
+
# @param request [Array]
|
281
|
+
# * serviceId => サービスID
|
282
|
+
# * operation => オペレーション名
|
283
|
+
# * begin => メトリクス取得開始日時(unixepoch)
|
284
|
+
# * end => メトリクス取得終了日時(unixepoch)
|
285
|
+
# * allowLongTerm => 7日以上の期間のデータを取得することを許可するか(OPTIONAL)
|
286
|
+
# * serviceId => サービスID
|
287
|
+
# @return [Array]
|
288
|
+
# * items
|
289
|
+
# [Array]
|
290
|
+
# * timestamp => タイムスタンプ(YYYY-MM-DD HH:mm:SS)
|
291
|
+
# * value => 値
|
292
|
+
def get_metric(request)
|
293
|
+
if not request; raise ArgumentError.new(); end
|
294
|
+
if not request.has_key?('serviceId'); raise ArgumentError.new(); end
|
295
|
+
if not request['serviceId']; raise ArgumentError.new(); end
|
296
|
+
if not request.has_key?('operation'); raise ArgumentError.new(); end
|
297
|
+
if not request['operation']; raise ArgumentError.new(); end
|
298
|
+
query = {}
|
299
|
+
if request.has_key?('begin'); query['begin'] = request['begin']; end
|
300
|
+
if request.has_key?('end'); query['end'] = request['end']; end
|
301
|
+
if request.has_key?('allowLongTerm'); query['allowLongTerm'] = request['allowLongTerm']; end
|
302
|
+
return get(
|
303
|
+
'Gs2Watch',
|
304
|
+
'GetMetric',
|
305
|
+
@@ENDPOINT,
|
306
|
+
'/metric/' + request['serviceId'] + '/' + request['operation'],
|
307
|
+
query);
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end end
|
data/lib/gs2-watch.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'gs2/watch/Client.rb'
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gs2-ruby-sdk-watch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Game Server Services, Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gs2-ruby-sdk-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- contact@gs2.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".buildpath"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".project"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- gs2-ruby-sdk-watch.gemspec
|
71
|
+
- lib/gs2-watch.rb
|
72
|
+
- lib/gs2/watch/Client.rb
|
73
|
+
- lib/gs2/watch/version.rb
|
74
|
+
homepage: https://gs2.io/
|
75
|
+
licenses:
|
76
|
+
- Apache-2.0
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.5.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Game Server Services GS2-Watch Client Library
|
98
|
+
test_files: []
|