Class: Gs2::Identifier::Client
- Inherits:
-
Core::AbstractClient
- Object
- Core::AbstractClient
- Gs2::Identifier::Client
- Defined in:
- lib/gs2/identifier/Client.rb
Overview
GS2-Identifier クライアント
Constant Summary
- @@ENDPOINT =
'identifier'
- @@VARIATION =
'a'
Class Method Summary collapse
-
.ENDPOINT(v = nil) ⇒ Object
デバッグ用。通常利用する必要はありません。.
-
.VARIATION(v = nil) ⇒ Object
デバッグ用。通常利用する必要はありません。.
Instance Method Summary collapse
-
#attach_security_policy(request) ⇒ Object
ユーザにセキュリティポリシーを割り当てる.
-
#create_identifier(request) ⇒ Array
GSIを作成
GSIはSDKなどでAPIを利用する際に必要となる クライアントID/シークレット です。
AWSでいうIAMのクレデンシャルに相当します。
. -
#create_security_policy(request) ⇒ Object
セキュリティポリシーを作成
セキュリティポリシーはユーザの権限を定義したものです。
AWSのIAMポリシーに似せて設計されていますが、いくつかAWSのIAMポリシーと比較して劣る点があります。
2016/9 時点では以下の様な点が IAMポリシー とは異なります。
. -
#create_user(request) ⇒ Array
ユーザを作成
GS2のサービスを利用するにはユーザを作成する必要があります。
ユーザを作成後、ユーザに対して権限設定を行い、ユーザに対応したGSI(クライアントID/シークレット)を発行することでAPIが利用できるようになります。
. -
#delete_identifier(request) ⇒ Object
GSIを削除.
-
#delete_security_policy(request) ⇒ Object
セキュリティポリシーを削除.
-
#delete_user(request) ⇒ Object
ユーザを削除.
-
#describe_common_security_policy(pageToken = nil, limit = nil) ⇒ Array
共用セキュリティポリシーリストを取得.
-
#describe_identifier(request, pageToken = nil, limit = nil) ⇒ Array
GSIリストを取得.
-
#describe_security_policy(pageToken = nil, limit = nil) ⇒ Array
セキュリティポリシーリストを取得.
-
#describe_user(pageToken = nil, limit = nil) ⇒ Array
ユーザリストを取得.
-
#detach_security_policy(request) ⇒ Object
ユーザに割り当てられたセキュリティポリシーを解除.
-
#get_has_security_policy(request) ⇒ Array
ユーザが保持しているセキュリティポリシー一覧を取得.
-
#get_security_policy(request) ⇒ Array
セキュリティポリシーを取得.
-
#get_user(request) ⇒ Array
ユーザを取得.
-
#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client
constructor
コンストラクタ.
-
#update_security_policy(request) ⇒ Array
セキュリティポリシーを更新.
Constructor Details
#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client
コンストラクタ
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
ユーザにセキュリティポリシーを割り当てる
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のクレデンシャルに相当します。
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箇所のみ利用できます。
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が利用できるようになります。
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を削除
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
セキュリティポリシーを削除
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
ユーザを削除
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
共用セキュリティポリシーリストを取得
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リストを取得
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
セキュリティポリシーリストを取得
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
ユーザリストを取得
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
ユーザに割り当てられたセキュリティポリシーを解除
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
ユーザが保持しているセキュリティポリシー一覧を取得
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
セキュリティポリシーを取得
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
ユーザを取得
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
セキュリティポリシーを更新
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 |