Class: Stratus::AWS::IAM::Base
- Inherits:
-
Object
- Object
- Stratus::AWS::IAM::Base
- Defined in:
- lib/stratus/aws/iam.rb
Constant Summary collapse
- VALID_ACCESS_KEY_STATUSES =
[:active, :inactive].freeze
- VALID_HTTP_METHODS =
[:get, :post].freeze
Instance Method Summary collapse
-
#add_user_to_group(options = {}) ⇒ Hash
Calls AddUserToGroup API.
- #api_version ⇒ String
-
#call_api(action, params) ⇒ Object
RestClient::Response.
-
#create_access_key(options = {}) ⇒ Hash
Calls CreateAccessKey API.
-
#create_group(options = {}) ⇒ Hash
Calls CreateGropup API.
-
#create_login_profile(options = {}) ⇒ Hash
Calls create_login_profile API.
-
#create_user(options = {}) ⇒ Hash
Calls CreateUser API.
- #default_host ⇒ String
-
#delete_access_key(options = {}) ⇒ Hash
Calls DeleteAccessKey API.
-
#delete_group(options = {}) ⇒ Hash
Calls DeleteGropup API.
-
#delete_group_policy(options = {}) ⇒ Hash
Calls DeleteGroupPolicy API.
-
#delete_login_profile(options = {}) ⇒ Hash
Calls delete_login_profile API.
-
#delete_signing_certificate(options = {}) ⇒ Hash
Calls DeleteSigningCertificate API.
-
#delete_user(options = {}) ⇒ Hash
Calls DeleteUser API.
-
#delete_user_policy(options = {}) ⇒ Hash
Calls DeleteUserPolicy API.
- #endpoint ⇒ String
-
#get_group(options = {}) ⇒ Hash
Calls GetGropup API.
-
#get_group_policy(options = {}) ⇒ Hash
Calls GetGroupPolicy API.
-
#get_login_profile(options = {}) ⇒ Hash
Calls get_login_profile API.
-
#get_user(options = {}) ⇒ Hash
Calls GetUser API.
-
#get_user_policy(options = {}) ⇒ Hash
Calls GetUserPolicy API.
-
#initialize(access_key_id, secret_access_key) ⇒ Base
constructor
A new instance of Base.
-
#list_access_keys(options = {}) ⇒ Hash
Calls ListAccessKeys API.
-
#list_group_policies(options = {}) ⇒ Hash
Calls ListGroupPolicies API.
-
#list_groups(options = {}) ⇒ Hash
Calls ListGroups API.
-
#list_groups_for_user(options = {}) ⇒ Hash
Calls ListGroupsForUser API.
-
#list_signing_certificates(options = {}) ⇒ Hash
Calls list_signing_certificates API.
-
#list_user_policies(options = {}) ⇒ Hash
Calls ListUserPolicies API.
-
#list_users(options = {}) ⇒ Hash
Calls ListUsers API.
-
#put_group_policy(options = {}) ⇒ Hash
Calls PutGroupPolicy API.
-
#put_user_policy(options = {}) ⇒ Hash
Calls PutUserPolicy API.
-
#remove_user_from_group(options = {}) ⇒ Hash
Calls RemoveUserFromGroup API.
-
#update_access_key(options = {}) ⇒ Hash
Calls UpdateAccessKey API.
-
#update_group(options = {}) ⇒ Hash
Calls UpdateGroup API.
-
#update_login_profile(options = {}) ⇒ Hash
Calls update_login_profile API.
-
#update_signing_certificate(options = {}) ⇒ Hash
Calls UpdateSigningCertificate API.
-
#update_user(options = {}) ⇒ Hash
Calls UpdateUser API.
-
#upload_signing_certificate(options = {}) ⇒ Hash
Calls UploadSigningCertificate API.
Constructor Details
#initialize(access_key_id, secret_access_key) ⇒ Base
Returns a new instance of Base.
42 43 44 45 46 |
# File 'lib/stratus/aws/iam.rb', line 42 def initialize(access_key_id, secret_access_key) @access_key_id = access_key_id @secret_access_key = secret_access_key @endpoint = "https://#{DEFAULT_HOST}/" end |
Instance Method Details
#add_user_to_group(options = {}) ⇒ Hash
Calls AddUserToGroup API
125 126 127 128 129 130 131 |
# File 'lib/stratus/aws/iam.rb', line 125 def add_user_to_group( = {}) check_group_name() check_user_name() params = { 'GroupName' => [:group_name], 'UserName' => [:user_name] } response = call_api('AddUserToGroup', params) Response.parse(:xml => response.to_str) end |
#api_version ⇒ String
49 50 51 |
# File 'lib/stratus/aws/iam.rb', line 49 def api_version API_VERSION end |
#call_api(action, params) ⇒ Object
Returns RestClient::Response.
474 475 476 477 478 479 480 |
# File 'lib/stratus/aws/iam.rb', line 474 def call_api(action, params) params['Action'] = action.to_s if params['Action'] == 'UploadSigningCertificate' return request(params, :method => :post) end request(params) end |
#create_access_key(options = {}) ⇒ Hash
Calls CreateAccessKey API
220 221 222 223 224 225 |
# File 'lib/stratus/aws/iam.rb', line 220 def create_access_key( = {}) params = {} params['UserName'] = [:user_name] if [:user_name] response = call_api('CreateAccessKey', params) Response.parse(:xml => response.to_str) end |
#create_group(options = {}) ⇒ Hash
Calls CreateGropup API
79 80 81 82 83 84 85 |
# File 'lib/stratus/aws/iam.rb', line 79 def create_group( = {}) check_group_name() params = { 'GroupName' => [:group_name] } params['Path'] = [:path] if [:path] response = call_api('CreateGroup', params) Response.parse(:xml => response.to_str) end |
#create_login_profile(options = {}) ⇒ Hash
Calls create_login_profile API
440 441 442 443 444 445 446 |
# File 'lib/stratus/aws/iam.rb', line 440 def create_login_profile( = {}) check_user_name() check_password() params = { 'UserName' => [:user_name], 'Password' => [:password] } response = call_api('CreateLoginProfile', params) Response.parse(:xml => response.to_str) end |
#create_user(options = {}) ⇒ Hash
Calls CreateUser API
160 161 162 163 164 165 166 |
# File 'lib/stratus/aws/iam.rb', line 160 def create_user( = {}) check_user_name() params = { 'UserName' => [:user_name] } params['Path'] = [:path] if [:path] response = call_api('CreateUser', params) Response.parse(:xml => response.to_str) end |
#default_host ⇒ String
54 55 56 |
# File 'lib/stratus/aws/iam.rb', line 54 def default_host DEFAULT_HOST end |
#delete_access_key(options = {}) ⇒ Hash
Calls DeleteAccessKey API
231 232 233 234 235 236 237 |
# File 'lib/stratus/aws/iam.rb', line 231 def delete_access_key( = {}) check_access_key_id() params = { 'AccessKeyId' => [:access_key_id] } params['UserName'] = [:user_name] if [:user_name] response = call_api('DeleteAccessKey', params) Response.parse(:xml => response.to_str) end |
#delete_group(options = {}) ⇒ Hash
Calls DeleteGropup API
91 92 93 94 95 96 |
# File 'lib/stratus/aws/iam.rb', line 91 def delete_group( = {}) check_group_name() params = { 'GroupName' => [:group_name] } response = call_api('DeleteGroup', params) Response.parse(:xml => response.to_str) end |
#delete_group_policy(options = {}) ⇒ Hash
Calls DeleteGroupPolicy API
300 301 302 303 304 305 306 |
# File 'lib/stratus/aws/iam.rb', line 300 def delete_group_policy( = {}) check_group_name() check_policy_name() params = { 'GroupName' => [:group_name], 'PolicyName' => [:policy_name] } response = call_api('DeleteGroupPolicy', params) Response.parse(:xml => response.to_str) end |
#delete_login_profile(options = {}) ⇒ Hash
Calls delete_login_profile API
464 465 466 467 468 469 |
# File 'lib/stratus/aws/iam.rb', line 464 def delete_login_profile( = {}) check_user_name() params = { 'UserName' => [:user_name] } response = call_api('DeleteLoginProfile', params) Response.parse(:xml => response.to_str) end |
#delete_signing_certificate(options = {}) ⇒ Hash
Calls DeleteSigningCertificate API
406 407 408 409 410 411 412 |
# File 'lib/stratus/aws/iam.rb', line 406 def delete_signing_certificate( = {}) check_certificate_id() params = { 'CertificateId' => [:certificate_id] } params['UserName'] = [:user_name] if [:user_name] response = call_api('DeleteSigningCertificate', params) Response.parse(:xml => response.to_str) end |
#delete_user(options = {}) ⇒ Hash
Calls DeleteUser API
172 173 174 175 176 177 |
# File 'lib/stratus/aws/iam.rb', line 172 def delete_user( = {}) check_user_name() params = { 'UserName' => [:user_name] } response = call_api('DeleteUser', params) Response.parse(:xml => response.to_str) end |
#delete_user_policy(options = {}) ⇒ Hash
Calls DeleteUserPolicy API
357 358 359 360 361 362 363 |
# File 'lib/stratus/aws/iam.rb', line 357 def delete_user_policy( = {}) check_user_name() check_policy_name() params = { 'UserName' => [:user_name], 'PolicyName' => [:policy_name] } response = call_api('DeleteUserPolicy', params) Response.parse(:xml => response.to_str) end |
#endpoint ⇒ String
59 60 61 |
# File 'lib/stratus/aws/iam.rb', line 59 def endpoint @endpoint end |
#get_group(options = {}) ⇒ Hash
Calls GetGropup API
67 68 69 70 71 72 73 |
# File 'lib/stratus/aws/iam.rb', line 67 def get_group( = {}) check_group_name() params = make_pagination_params() params['GroupName'] = [:group_name] response = call_api('GetGroup', params) Response.parse(:xml => response.to_str) end |
#get_group_policy(options = {}) ⇒ Hash
Calls GetGroupPolicy API
267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/stratus/aws/iam.rb', line 267 def get_group_policy( = {}) check_group_name() check_policy_name() params = { 'GroupName' => [:group_name], 'PolicyName' => [:policy_name] } response = call_api('GetGroupPolicy', params) result = Response.parse(:xml => response.to_str) if result && result['GetGroupPolicyResult'] && result['GetGroupPolicyResult']['PolicyDocument'] result['GetGroupPolicyResult']['PolicyDocument'] = decode_uri(result['GetGroupPolicyResult']['PolicyDocument']) end result end |
#get_login_profile(options = {}) ⇒ Hash
Calls get_login_profile API
429 430 431 432 433 434 |
# File 'lib/stratus/aws/iam.rb', line 429 def get_login_profile( = {}) check_user_name() params = { 'UserName' => [:user_name] } response = call_api('GetLoginProfile', params) Response.parse(:xml => response.to_str) end |
#get_user(options = {}) ⇒ Hash
Calls GetUser API
149 150 151 152 153 154 |
# File 'lib/stratus/aws/iam.rb', line 149 def get_user( = {}) params = {} params['UserName'] = [:user_name] if [:user_name] response = call_api('GetUser', params) Response.parse(:xml => response.to_str) end |
#get_user_policy(options = {}) ⇒ Hash
Calls GetUserPolicy API
324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/stratus/aws/iam.rb', line 324 def get_user_policy( = {}) check_user_name() check_policy_name() params = { 'UserName' => [:user_name], 'PolicyName' => [:policy_name] } response = call_api('GetUserPolicy', params) result = Response.parse(:xml => response.to_str) if result && result['GetUserPolicyResult'] && result['GetUserPolicyResult']['PolicyDocument'] result['GetUserPolicyResult']['PolicyDocument'] = decode_uri(result['GetUserPolicyResult']['PolicyDocument']) end result end |
#list_access_keys(options = {}) ⇒ Hash
Calls ListAccessKeys API
256 257 258 259 260 261 |
# File 'lib/stratus/aws/iam.rb', line 256 def list_access_keys( = {}) params = make_pagination_params() params['UserName'] = [:user_name] if [:user_name] response = call_api('ListAccessKeys', params) Response.parse(:xml => response.to_str) end |
#list_group_policies(options = {}) ⇒ Hash
Calls ListGroupPolicies API
312 313 314 315 316 317 318 |
# File 'lib/stratus/aws/iam.rb', line 312 def list_group_policies( = {}) check_group_name() params = make_pagination_params() params['GroupName'] = [:group_name] response = call_api('ListGroupPolicies', params) Response.parse(:xml => response.to_str) end |
#list_groups(options = {}) ⇒ Hash
Calls ListGroups API
101 102 103 104 105 106 |
# File 'lib/stratus/aws/iam.rb', line 101 def list_groups( = {}) params = make_pagination_params() params['PathPrefix'] = [:path_prefix] if [:path_prefix] response = call_api('ListGroups', params) Response.parse(:xml => response.to_str) end |
#list_groups_for_user(options = {}) ⇒ Hash
Calls ListGroupsForUser API
194 195 196 197 198 199 200 |
# File 'lib/stratus/aws/iam.rb', line 194 def list_groups_for_user( = {}) check_user_name() params = make_pagination_params() params['UserName'] = [:user_name] response = call_api('ListGroupsForUser', params) Response.parse(:xml => response.to_str) end |
#list_signing_certificates(options = {}) ⇒ Hash
Calls list_signing_certificates API
418 419 420 421 422 423 |
# File 'lib/stratus/aws/iam.rb', line 418 def list_signing_certificates( = {}) params = make_pagination_params() params['UserName'] = [:user_name] if [:user_name] response = call_api('ListSigningCertificates', params) Response.parse(:xml => response.to_str) end |
#list_user_policies(options = {}) ⇒ Hash
Calls ListUserPolicies API
369 370 371 372 373 374 375 |
# File 'lib/stratus/aws/iam.rb', line 369 def list_user_policies( = {}) check_user_name() params = make_pagination_params() params['UserName'] = [:user_name] response = call_api('ListUserPolicies', params) Response.parse(:xml => response.to_str) end |
#list_users(options = {}) ⇒ Hash
Calls ListUsers API
183 184 185 186 187 188 |
# File 'lib/stratus/aws/iam.rb', line 183 def list_users( = {}) params = make_pagination_params() params['PathPrefix'] = [:path_prefix] if [:path_prefix] response = call_api('ListUsers', params) Response.parse(:xml => response.to_str) end |
#put_group_policy(options = {}) ⇒ Hash
Calls PutGroupPolicy API
283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/stratus/aws/iam.rb', line 283 def put_group_policy( = {}) check_group_name() check_policy_name() check_policy_document() params = { 'GroupName' => [:group_name], 'PolicyName' => [:policy_name], 'PolicyDocument' => [:policy_document] } response = call_api('PutGroupPolicy', params) Response.parse(:xml => response.to_str) end |
#put_user_policy(options = {}) ⇒ Hash
Calls PutUserPolicy API
340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/stratus/aws/iam.rb', line 340 def put_user_policy( = {}) check_user_name() check_policy_name() check_policy_document() params = { 'UserName' => [:user_name], 'PolicyName' => [:policy_name], 'PolicyDocument' => [:policy_document] } response = call_api('PutUserPolicy', params) Response.parse(:xml => response.to_str) end |
#remove_user_from_group(options = {}) ⇒ Hash
Calls RemoveUserFromGroup API
137 138 139 140 141 142 143 |
# File 'lib/stratus/aws/iam.rb', line 137 def remove_user_from_group( = {}) check_group_name() check_user_name() params = { 'GroupName' => [:group_name], 'UserName' => [:user_name] } response = call_api('RemoveUserFromGroup', params) Response.parse(:xml => response.to_str) end |
#update_access_key(options = {}) ⇒ Hash
Calls UpdateAccessKey API
243 244 245 246 247 248 249 250 |
# File 'lib/stratus/aws/iam.rb', line 243 def update_access_key( = {}) check_access_key_id() check_activity_status() params = { 'AccessKeyId' => [:access_key_id], 'Status' => [:status].to_s.capitalize } params['UserName'] = [:user_name] if [:user_name] response = call_api('UpdateAccessKey', params) Response.parse(:xml => response.to_str) end |
#update_group(options = {}) ⇒ Hash
Calls UpdateGroup API
112 113 114 115 116 117 118 119 |
# File 'lib/stratus/aws/iam.rb', line 112 def update_group( = {}) check_group_name() params = { 'GroupName' => [:group_name] } params['NewGroupName'] = [:new_group_name] if [:new_group_name] params['NewPathName'] = [:new_path_name] if [:new_path_name] response = call_api('UpdateGroup', params) Response.parse(:xml => response.to_str) end |
#update_login_profile(options = {}) ⇒ Hash
Calls update_login_profile API
452 453 454 455 456 457 458 |
# File 'lib/stratus/aws/iam.rb', line 452 def update_login_profile( = {}) check_user_name() check_password() params = { 'UserName' => [:user_name], 'Password' => [:password] } response = call_api('UpdateLoginProfile', params) Response.parse(:xml => response.to_str) end |
#update_signing_certificate(options = {}) ⇒ Hash
Calls UpdateSigningCertificate API
393 394 395 396 397 398 399 400 |
# File 'lib/stratus/aws/iam.rb', line 393 def update_signing_certificate( = {}) check_certificate_id() check_activity_status() params = { 'CertificateId' => [:certificate_id], 'Status' => [:status].to_s.capitalize } params['UserName'] = [:user_name] if [:user_name] response = call_api('UpdateSigningCertificate', params) Response.parse(:xml => response.to_str) end |
#update_user(options = {}) ⇒ Hash
Calls UpdateUser API
206 207 208 209 210 211 212 213 214 |
# File 'lib/stratus/aws/iam.rb', line 206 def update_user( = {}) check_user_name() params = {} params['UserName'] = [:user_name] params['NewPath'] = [:new_path] if [:new_path] params['NewUserName'] = [:new_user_name] if [:new_user_name] response = call_api('UpdateUser', params) Response.parse(:xml => response.to_str) end |
#upload_signing_certificate(options = {}) ⇒ Hash
Calls UploadSigningCertificate API
381 382 383 384 385 386 387 |
# File 'lib/stratus/aws/iam.rb', line 381 def upload_signing_certificate( = {}) check_certificate_body() params = { 'CertificateBody' => [:certificate_body] } params['UserName'] = [:user_name] if [:user_name] response = call_api('UploadSigningCertificate', params) Response.parse(:xml => response.to_str) end |