Class: Gs2::Identifier::Client

Inherits:
Core::AbstractClient
  • Object
show all
Defined in:
lib/gs2/identifier/Client.rb

Overview

GS2-Identifier クライアント

Author:

  • Game Server Services, Inc.

Constant Summary

@@ENDPOINT =
'identifier'
@@VARIATION =
'a'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client

コンストラクタ

Parameters:

  • region (String)

    リージョン名

  • gs2_client_id (String)

    GSIクライアントID

  • gs2_client_secret (String)

    GSIクライアントシークレット



18
19
20
# File 'lib/gs2/identifier/Client.rb', line 18

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

デバッグ用。通常利用する必要はありません。



23
24
25
26
27
28
29
# File 'lib/gs2/identifier/Client.rb', line 23

def self.ENDPOINT(v = nil)
  if v
    @@ENDPOINT = v
  else
    return @@ENDPOINT
  end
end

.VARIATION(v = nil) ⇒ Object

デバッグ用。通常利用する必要はありません。



32
33
34
35
36
37
38
# File 'lib/gs2/identifier/Client.rb', line 32

def self.VARIATION(v = nil)
  if v
    @@VARIATION = v
  else
    return @@VARIATION
  end
end

Instance Method Details

#attach_security_policy(request) ⇒ Object

ユーザにセキュリティポリシーを割り当てる

Parameters:

  • request (Array)
    • userName => ユーザ名

    • securityPolicyId => セキュリティポリシーID



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/gs2/identifier/Client.rb', line 245

def attach_security_policy(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('userName'); raise ArgumentError.new(); end
  if not request['userName']; raise ArgumentError.new(); end
  body = {}
  if request.has_key?('securityPolicyId'); body['securityPolicyId'] = request['securityPolicyId']; end
  query = {}
  return put(
      'Gs2Identifier',
      'AttachSecurityPolicy',
      @@ENDPOINT,
      @@VARIATION,
      '/user/' + request['userName'] + '/securityPolicy',
      body);
end

#create_identifier(request) ⇒ Array

GSIを作成

GSIはSDKなどでAPIを利用する際に必要となる クライアントID/シークレット です。
AWSでいうIAMのクレデンシャルに相当します。

Parameters:

  • request (Array)
    • userName => ユーザ名

Returns:

  • (Array)
    • item

      • identifierId => GSIID

      • ownerId => オーナーID

      • clientId => クライアントID

      • clientSecret => クライアントシークレット

      • createAt => 作成日時



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/gs2/identifier/Client.rb', line 178

def create_identifier(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('userName'); raise ArgumentError.new(); end
  if not request['userName']; raise ArgumentError.new(); end
  body = {}
  query = {}
  return post(
      'Gs2Identifier',
      'CreateIdentifier',
      @@ENDPOINT,
      @@VARIATION,
      '/user/' + request['userName'] + '/identifier',
      body,
      query);
end

#create_security_policy(request) ⇒ Object

セキュリティポリシーを作成

セキュリティポリシーはユーザの権限を定義したものです。
AWSのIAMポリシーに似せて設計されていますが、いくつかAWSのIAMポリシーと比較して劣る点があります。
2016/9 時点では以下の様な点が IAMポリシー とは異なります。

  • リソースに対するアクセス制御はできません。

  • アクションのワイルドカードは最後に1箇所のみ利用できます。

Parameters:

  • array

    request

    • name => セキュリティポリシー名

    • policy => ポリシー

Returns:

  • array

    • item

      • securityPolicyId => セキュリティポリシーID

      • ownerId => オーナーID

      • name => セキュリティポリシー名

      • policy => ポリシー

      • createAt => 作成日時

      • updateAt => 更新日時



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/gs2/identifier/Client.rb', line 356

def create_security_policy(request)
  if not request; raise ArgumentError.new(); end
  body = {}
  if request.has_key?('name'); body['name'] = request['name']; end
  if request.has_key?('policy'); body['policy'] = request['policy']; end
  query = {}
  return post(
      'Gs2Identifier',
      'CreateSecurityPolicy',
      ENDPOINT,
      VARIATION,
      '/securityPolicy',
      body,
      query);
end

#create_user(request) ⇒ Array

ユーザを作成

GS2のサービスを利用するにはユーザを作成する必要があります。
ユーザを作成後、ユーザに対して権限設定を行い、ユーザに対応したGSI(クライアントID/シークレット)を発行することでAPIが利用できるようになります。

Parameters:

  • request (Array)
    • name => ユーザ名

Returns:

  • (Array)
    • item

      • userId => ユーザID

      • ownerId => オーナーID

      • name => ユーザ名

      • createAt => 作成日時



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/gs2/identifier/Client.rb', line 78

def create_user(request)
  if not request; raise ArgumentError.new(); end
  body = {}
  if request.has_key?('name'); body['name'] = request['name']; end
  query = {}
  return post(
        'Gs2Identifier', 
        'CreateUser', 
        @@ENDPOINT, 
        @@VARIATION,
        '/user',
        body,
        query);
end

#delete_identifier(request) ⇒ Object

GSIを削除

Parameters:

  • request (Array)
    • userName => ユーザ名

    • identifierId => GSI ID



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/gs2/identifier/Client.rb', line 199

def delete_identifier(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('userName'); raise ArgumentError.new(); end
  if not request['userName']; raise ArgumentError.new(); end
  if not request.has_key?('identifierId'); raise ArgumentError.new(); end
  if not request['identifierId']; raise ArgumentError.new(); end
  query = {}
  return delete(
      'Gs2Identifier',
      'DeleteIdentifier',
      @@ENDPOINT,
      @@VARIATION,
      '/user/' + request['userName'] + '/identifier/' + request['identifierId'],
      query);
end

#delete_security_policy(request) ⇒ Object

セキュリティポリシーを削除

Parameters:

  • request (Array)
    • securityPolicyName => セキュリティポリシー名



430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/gs2/identifier/Client.rb', line 430

def delete_security_policy(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('securityPolicyName'); raise ArgumentError.new(); end
  if request['securityPolicyName']; raise ArgumentError.new(); end
  query = {}
  return delete(
      'Gs2Identifier',
      'DeleteSecurityPolicy',
      @@ENDPOINT,
      @@VARIATION,
      '/securityPolicy/' + request['securityPolicyName'],
      query);
end

#delete_user(request) ⇒ Object

ユーザを削除

Parameters:

  • request (Array)
    • userName => ユーザ名



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/gs2/identifier/Client.rb', line 120

def delete_user(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('userName'); raise ArgumentError.new(); end
  if not request['userName']; raise ArgumentError.new(); end
  query = {}
  return delete(
        'Gs2Identifier', 
        'DeleteUser', 
        @@ENDPOINT, 
        @@VARIATION,
        '/user/' + request['userName'],
        query);
end

#describe_common_security_policy(pageToken = nil, limit = nil) ⇒ Array

共用セキュリティポリシーリストを取得

Parameters:

  • pageToken (String) (defaults to: nil)

    ページトークン

  • limit (Integer) (defaults to: nil)

    取得件数

Returns:

  • (Array)
    • items

      Array
      • securityPolicyId => セキュリティポリシーID

      • ownerId => オーナーID

      • name => セキュリティポリシー名

      • policy => ポリシー

      • createAt => 作成日時

      • updateAt => 更新日時

    • nextPageToken => 次ページトークン



323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/gs2/identifier/Client.rb', line 323

def describe_common_security_policy(pageToken = nil, limit = nil)
  query = {}
  if pageToken; query['pageToken'] = pageToken; end
  if limit; query['limit'] = limit; end
  return get(
      'Gs2Identifier',
      'DescribeSecurityPolicy',
      @@ENDPOINT,
      @@VARIATION,
      '/securityPolicy/common',
      query);
end

#describe_identifier(request, pageToken = nil, limit = nil) ⇒ Array

GSIリストを取得

Parameters:

  • request (Array)
    • userName => ユーザ名

  • pageToken (String) (defaults to: nil)

    ページトークン

  • limit (Integer) (defaults to: nil)

    取得件数

Returns:

  • (Array)
    • items

      Array
      • identifierId => GSIID

      • ownerId => オーナーID

      • clientId => クライアントID

      • createAt => 作成日時

    • nextPageToken => 次ページトークン



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/gs2/identifier/Client.rb', line 148

def describe_identifier(request, pageToken = nil, limit = nil)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('userName'); raise ArgumentError.new(); end
  if not request['userName']; raise ArgumentError.new(); end
  query = {}
  if pageToken; query['pageToken'] = pageToken; end
  if limit; query['limit'] = limit; end
  return get(
      'Gs2Identifier',
      'DescribeIdentifier',
      @@ENDPOINT,
      @@VARIATION,
      '/user/' + request['userName'] + '/identifier',
      query);
end

#describe_security_policy(pageToken = nil, limit = nil) ⇒ Array

セキュリティポリシーリストを取得

Parameters:

  • pageToken (String) (defaults to: nil)

    ページトークン

  • limit (Integer) (defaults to: nil)

    取得件数

Returns:

  • (Array)
    • items

      Array
      • securityPolicyId => セキュリティポリシーID

      • ownerId => オーナーID

      • name => セキュリティポリシー名

      • policy => ポリシー

      • createAt => 作成日時

      • updateAt => 更新日時

    • nextPageToken => 次ページトークン



296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/gs2/identifier/Client.rb', line 296

def describe_security_policy(pageToken = nil, limit = nil)
  query = {}
  if pageToken; query['pageToken'] = pageToken; end
  if limit; query['limit'] = limit; end
  return get(
      'Gs2Identifier',
      'DescribeSecurityPolicy',
      @@ENDPOINT,
      @@VARIATION,
      '/securityPolicy',
      query);
end

#describe_user(pageToken = nil, limit = nil) ⇒ Array

ユーザリストを取得

Parameters:

  • pageToken (String) (defaults to: nil)

    ページトークン

  • limit (Integer) (defaults to: nil)

    取得件数

Returns:

  • (Array)
    • items

      Array
      • userId => ユーザID

      • ownerId => オーナーID

      • name => ユーザ名

      • createAt => 作成日時

    • nextPageToken => 次ページトークン



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/gs2/identifier/Client.rb', line 52

def describe_user(pageToken = nil, limit = nil)
  query = {}
  if pageToken; query['pageToken'] = pageToken; end
  if limit; query['limit'] = limit; end
  return get(
        'Gs2Identifier', 
        'DescribeUser', 
        @@ENDPOINT, 
        @@VARIATION,
        '/user',
        query);
end

#detach_security_policy(request) ⇒ Object

ユーザに割り当てられたセキュリティポリシーを解除

Parameters:

  • request (Array)
    • userName => ユーザ名

    • securityPolicyId => セキュリティポリシーID



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/gs2/identifier/Client.rb', line 266

def detach_security_policy(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('userName'); raise ArgumentError.new(); end
  if not request['userName']; raise ArgumentError.new(); end
  if not request.has_key?('securityPolicyId'); raise ArgumentError.new(); end
  if not request['securityPolicyId']; raise ArgumentError.new(); end
  query = {}
  return delete(
      'Gs2Identifier',
      'DetachSecurityPolicy',
      @@ENDPOINT,
      @@VARIATION,
      '/user/' + request['userName'] + '/securityPolicy/' + request['securityPolicyId'],
      query);
end

#get_has_security_policy(request) ⇒ Array

ユーザが保持しているセキュリティポリシー一覧を取得

Parameters:

  • request (Array)
    • userName => ユーザ名

Returns:

  • (Array)
    • items

      Array
      • identifierId => GSIID

      • ownerId => オーナーID

      • clientId => クライアントID

      • createAt => 作成日時



226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/gs2/identifier/Client.rb', line 226

def get_has_security_policy(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('userName'); raise ArgumentError.new(); end
  if not request['userName']; raise ArgumentError.new(); end
  query = {}
  return get(
      'Gs2Identifier',
      'HasSecurityPolicy',
      @@ENDPOINT,
      @@VARIATION,
      '/user/' + request['userName'] + '/securityPolicy',
      query);
end

#get_security_policy(request) ⇒ Array

セキュリティポリシーを取得

Parameters:

  • request (Array)
    • securityPolicyName => セキュリティポリシー名

Returns:

  • (Array)
    • item

      • securityPolicyId => セキュリティポリシーID

      • ownerId => オーナーID

      • name => セキュリティポリシー名

      • policy => ポリシー

      • createAt => 作成日時

      • updateAt => 更新日時



384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/gs2/identifier/Client.rb', line 384

def get_security_policy(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('securityPolicyName'); raise ArgumentError.new(); end
  query = {}
  return get(
      'Gs2Identifier',
      'GetSecurityPolicy',
      @@ENDPOINT,
      @@VARIATION,
      '/securityPolicy/' + request['securityPolicyName'],
      query);
end

#get_user(request) ⇒ Array

ユーザを取得

Parameters:

  • request (Array)
    • userName => ユーザ名

Returns:

  • (Array)
    • item

      • userId => ユーザID

      • ownerId => オーナーID

      • name => ユーザ名

      • createAt => 作成日時



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/gs2/identifier/Client.rb', line 103

def get_user(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('userName'); raise ArgumentError.new(); end
  query = {}
  return get(
      'Gs2Identifier',
      'GetUser',
      @@ENDPOINT,
      @@VARIATION,
      '/user/' + request['userName'],
      query);
end

#update_security_policy(request) ⇒ Array

セキュリティポリシーを更新

Parameters:

  • request (Array)
    • securityPolicyName => セキュリティポリシー名

Returns:

  • (Array)
    • item

      • securityPolicyId => セキュリティポリシーID

      • ownerId => オーナーID

      • name => セキュリティポリシー名

      • policy => ポリシー

      • createAt => 作成日時

      • updateAt => 更新日時



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# File 'lib/gs2/identifier/Client.rb', line 409

def update_security_policy(request)
  if not request; raise ArgumentError.new(); end
  if not request.has_key?('securityPolicyName'); raise ArgumentError.new(); end
  if request['securityPolicyName']; raise ArgumentError.new(); end
  body = {}
  if request.has_key?('policy'); body['policy'] = request['policy']; end
  query = {}
  return put(
      'Gs2Identifier',
      'UpdateSecurityPolicy',
      @@ENDPOINT,
      @@VARIATION,
      '/securityPolicy/' + request['securityPolicyName'],
      body,
      query);
end