Class: Gs2::Timer::Client
- Inherits:
-
Core::AbstractClient
- Object
- Core::AbstractClient
- Gs2::Timer::Client
- Defined in:
- lib/gs2/timer/Client.rb
Overview
GS2-Timer クライアント
Constant Summary collapse
- @@ENDPOINT =
'timer'
Class Method Summary collapse
-
.ENDPOINT(v = nil) ⇒ Object
デバッグ用。通常利用する必要はありません。.
Instance Method Summary collapse
-
#create_timer(request) ⇒ Array
タイマーを作成
タイマーを作成すると、指定した時刻に指定したURLに指定したパラメータを持ったアクセスを発生させます。
基本的には指定した時刻以降に60秒以内に呼び出し処理が開始されます。
混雑時には60秒以上かかることがありますので、タイミングがシビアな処理には向きません。
アカウントBANを指定した時刻付近で解除する。など、タイミングがシビアでない処理で利用することをおすすめします。
. -
#create_timer_pool(request) ⇒ Array
タイマープールを作成。
GS2-Timer を利用するには、まずタイマープールを作成する必要があります。
タイマープールには複数のタイマーを格納することができます。
. -
#delete_timer(request) ⇒ Object
タイマーを削除.
-
#delete_timer_pool(request) ⇒ Object
タイマープールを削除.
-
#describe_timer(request, pageToken = nil, limit = nil) ⇒ Array
タイマーリストを取得.
-
#describe_timer_pool(pageToken = nil, limit = nil) ⇒ Array
タイマープールリストを取得。.
-
#get_timer(request) ⇒ Array
タイマーを取得.
-
#get_timer_pool(request) ⇒ Array
タイマープールを取得.
-
#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client
constructor
コンストラクタ.
-
#update_timer_pool(request) ⇒ Array
タイマープールを更新。
.
Constructor Details
#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client
コンストラクタ
17 18 19 |
# File 'lib/gs2/timer/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/timer/Client.rb', line 22 def self.ENDPOINT(v = nil) if v @@ENDPOINT = v else return @@ENDPOINT end end |
Instance Method Details
#create_timer(request) ⇒ Array
タイマーを作成
タイマーを作成すると、指定した時刻に指定したURLに指定したパラメータを持ったアクセスを発生させます。
基本的には指定した時刻以降に60秒以内に呼び出し処理が開始されます。
混雑時には60秒以上かかることがありますので、タイミングがシビアな処理には向きません。
アカウントBANを指定した時刻付近で解除する。など、タイミングがシビアでない処理で利用することをおすすめします。
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/gs2/timer/Client.rb', line 204 def create_timer(request) if not request; raise ArgumentError.new(); end if not request.has_key?('timerPoolName'); raise ArgumentError.new(); end if request['timerPoolName'] == nil; raise ArgumentError.new(); end body = {}; if request.has_key?('callbackMethod'); body['callbackMethod'] = request['callbackMethod']; end if request.has_key?('callbackUrl'); body['callbackUrl'] = request['callbackUrl']; end if request.has_key?('executeTime'); body['executeTime'] = request['executeTime']; end if request.has_key?('retryMax'); body['retryMax'] = request['retryMax']; end query = {} return post( 'Gs2Timer', 'CreateTimer', @@ENDPOINT, '/timerPool/' + request['timerPoolName'] + '/timer', body, query) end |
#create_timer_pool(request) ⇒ Array
タイマープールを作成。
GS2-Timer を利用するには、まずタイマープールを作成する必要があります。
タイマープールには複数のタイマーを格納することができます。
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gs2/timer/Client.rb', line 70 def create_timer_pool(request) body = {} if not request; raise ArgumentError.new() end if request.has_key?('name'); body['name'] = request['name'] end if request.has_key?('description'); body['description'] = request['description'] end return post( 'Gs2Timer', 'CreateTimerPool', @@ENDPOINT, '/timerPool', body) end |
#delete_timer(request) ⇒ Object
タイマーを削除
259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/gs2/timer/Client.rb', line 259 def delete_timer(request) if not request; raise ArgumentError.new(); end if not request.has_key?('timerPoolName'); raise ArgumentError.new(); end if request['timerPoolName'] == nil; raise ArgumentError.new(); end if not request.has_key?('timerId'); raise ArgumentError.new(); end if request['timerId'] == nil; raise ArgumentError.new(); end query = {} return delete( 'Gs2Timer', 'DeleteTimer', @@ENDPOINT, '/timerPool/' + request['timerPoolName'] + '/timer/' + request['timerId'], query) end |
#delete_timer_pool(request) ⇒ Object
タイマープールを削除
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/gs2/timer/Client.rb', line 134 def delete_timer_pool(request) if not request; raise ArgumentError.new() end if not request.has_key?('timerPoolName'); raise ArgumentError.new() end if request['timerPoolName'] == nil; raise ArgumentError.new() end return delete( 'Gs2Timer', 'DeleteTimerPool', @@ENDPOINT, '/timerPool/' + request['timerPoolName']) end |
#describe_timer(request, pageToken = nil, limit = nil) ⇒ Array
タイマーリストを取得
-
timerPoolName => タイマープール名
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/gs2/timer/Client.rb', line 164 def describe_timer(request, pageToken = nil, limit = nil) if not request; raise ArgumentError.new(); end if not request.has_key?('timerPoolName'); raise ArgumentError.new(); end if request['timerPoolName'] == nil; raise ArgumentError.new(); end query = {} if pageToken; query['pageToken'] = pageToken; end if limit; query['limit'] = limit; end return get( 'Gs2Timer', 'DescribeTimer', @@ENDPOINT, '/timerPool/' + request['timerPoolName'] + '/timer', query) end |
#describe_timer_pool(pageToken = nil, limit = nil) ⇒ Array
タイマープールリストを取得。
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gs2/timer/Client.rb', line 43 def describe_timer_pool(pageToken = nil, limit = nil) query = {} if pageToken; query['pageToken'] = pageToken end if limit; query['limit'] = limit end return get( 'Gs2Timer', 'DescribeTimerPool', @@ENDPOINT, '/timerPool', query) end |
#get_timer(request) ⇒ Array
タイマーを取得
-
timerPoolName => タイマープール名
-
timerId => タイマーID
239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/gs2/timer/Client.rb', line 239 def get_timer(request) if not request; raise ArgumentError.new(); end if not request.has_key?('timerPoolName'); raise ArgumentError.new(); end if request['timerPoolName'] == nil; raise ArgumentError.new(); end if not request.has_key?('timerId'); raise ArgumentError.new(); end if request['timerId'] == nil; raise ArgumentError.new(); end query = {} return get( 'Gs2Timer', 'GetTimer', @@ENDPOINT, '/timerPool/' + request['timerPoolName'] + '/timer/' + request['timerId'], query) end |
#get_timer_pool(request) ⇒ Array
タイマープールを取得
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/gs2/timer/Client.rb', line 119 def get_timer_pool(request) if not request; raise ArgumentError.new() end if not request.has_key?('timerPoolName'); raise ArgumentError.new() end if request['timerPoolName'] == nil; raise ArgumentError.new() end return get( 'Gs2Timer', 'GetTimerPool', @@ENDPOINT, '/timerPool/' + request['timerPoolName']) end |
#update_timer_pool(request) ⇒ Array
タイマープールを更新。
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/gs2/timer/Client.rb', line 95 def update_timer_pool(request) body = {} if not request; raise ArgumentError.new() end if not request.has_key?('timerPoolName'); raise ArgumentError.new() end if request.has_key?('description'); body['description'] = request['description'] end return put( 'Gs2Timer', 'UpdateTimerPool', @@ENDPOINT, '/timerPool/' + request['timerPoolName'], body) end |