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 collapse
- @@ENDPOINT =
'identifier'
Class Method Summary collapse
-
.ENDPOINT(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
コンストラクタ
17 18 19 |
# File 'lib/gs2/identifier/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/identifier/Client.rb', line 22 def self.ENDPOINT(v = nil) if v @@ENDPOINT = v else return @@ENDPOINT end end |
Instance Method Details
#attach_security_policy(request) ⇒ Object
ユーザにセキュリティポリシーを割り当てる
227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/gs2/identifier/Client.rb', line 227 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, '/user/' + request['userName'] + '/securityPolicy', body); end |
#create_identifier(request) ⇒ Array
GSIを作成
GSIはSDKなどでAPIを利用する際に必要となる クライアントID/シークレット です。
AWSでいうIAMのクレデンシャルに相当します。
163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/gs2/identifier/Client.rb', line 163 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, '/user/' + request['userName'] + '/identifier', body, query); end |
#create_security_policy(request) ⇒ Object
セキュリティポリシーを作成
セキュリティポリシーはユーザの権限を定義したものです。
AWSのIAMポリシーに似せて設計されていますが、いくつかAWSのIAMポリシーと比較して劣る点があります。
2016/9 時点では以下の様な点が IAMポリシー とは異なります。
-
リソースに対するアクセス制御はできません。
-
アクションのワイルドカードは最後に1箇所のみ利用できます。
334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/gs2/identifier/Client.rb', line 334 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, '/securityPolicy', body, query); end |
#create_user(request) ⇒ Array
ユーザを作成
GS2のサービスを利用するにはユーザを作成する必要があります。
ユーザを作成後、ユーザに対して権限設定を行い、ユーザに対応したGSI(クライアントID/シークレット)を発行することでAPIが利用できるようになります。
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/gs2/identifier/Client.rb', line 67 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, '/user', body, query); end |
#delete_identifier(request) ⇒ Object
GSIを削除
183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/gs2/identifier/Client.rb', line 183 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, '/user/' + request['userName'] + '/identifier/' + request['identifierId'], query); end |
#delete_security_policy(request) ⇒ Object
セキュリティポリシーを削除
405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/gs2/identifier/Client.rb', line 405 def delete_security_policy(request) if not request; raise ArgumentError.new(); end if not request.has_key?('securityPolicyName'); raise ArgumentError.new(); end if not request['securityPolicyName']; raise ArgumentError.new(); end query = {} return delete( 'Gs2Identifier', 'DeleteSecurityPolicy', @@ENDPOINT, '/securityPolicy/' + request['securityPolicyName'], query); end |
#delete_user(request) ⇒ Object
ユーザを削除
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/gs2/identifier/Client.rb', line 107 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, '/user/' + request['userName'], query); end |
#describe_common_security_policy(pageToken = nil, limit = nil) ⇒ Array
共用セキュリティポリシーリストを取得
302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/gs2/identifier/Client.rb', line 302 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, '/securityPolicy/common', query); end |
#describe_identifier(request, pageToken = nil, limit = nil) ⇒ Array
GSIリストを取得
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/gs2/identifier/Client.rb', line 134 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, '/user/' + request['userName'] + '/identifier', query); end |
#describe_security_policy(pageToken = nil, limit = nil) ⇒ Array
セキュリティポリシーリストを取得
276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/gs2/identifier/Client.rb', line 276 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, '/securityPolicy', query); end |
#describe_user(pageToken = nil, limit = nil) ⇒ Array
ユーザリストを取得
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gs2/identifier/Client.rb', line 42 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, '/user', query); end |
#detach_security_policy(request) ⇒ Object
ユーザに割り当てられたセキュリティポリシーを解除
247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/gs2/identifier/Client.rb', line 247 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, '/user/' + request['userName'] + '/securityPolicy/' + request['securityPolicyId'], query); end |
#get_has_security_policy(request) ⇒ Array
ユーザが保持しているセキュリティポリシー一覧を取得
209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/gs2/identifier/Client.rb', line 209 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, '/user/' + request['userName'] + '/securityPolicy', query); end |
#get_security_policy(request) ⇒ Array
セキュリティポリシーを取得
361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/gs2/identifier/Client.rb', line 361 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, '/securityPolicy/' + request['securityPolicyName'], query); end |
#get_user(request) ⇒ Array
ユーザを取得
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/gs2/identifier/Client.rb', line 91 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, '/user/' + request['userName'], query); end |
#update_security_policy(request) ⇒ Array
セキュリティポリシーを更新
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/gs2/identifier/Client.rb', line 385 def update_security_policy(request) if not request; raise ArgumentError.new(); end if not request.has_key?('securityPolicyName'); raise ArgumentError.new(); end if not request['securityPolicyName']; raise ArgumentError.new(); end body = {} if request.has_key?('policy'); body['policy'] = request['policy']; end query = {} return put( 'Gs2Identifier', 'UpdateSecurityPolicy', @@ENDPOINT, '/securityPolicy/' + request['securityPolicyName'], body, query); end |