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_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_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_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_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.
40 41 42 43 44 |
# File 'lib/stratus/aws/iam.rb', line 40 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
123 124 125 126 127 128 129 |
# File 'lib/stratus/aws/iam.rb', line 123 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
47 48 49 |
# File 'lib/stratus/aws/iam.rb', line 47 def api_version API_VERSION end |
#call_api(action, params) ⇒ Object
Returns RestClient::Response.
426 427 428 429 430 431 432 |
# File 'lib/stratus/aws/iam.rb', line 426 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
218 219 220 221 222 223 |
# File 'lib/stratus/aws/iam.rb', line 218 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
77 78 79 80 81 82 83 |
# File 'lib/stratus/aws/iam.rb', line 77 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_user(options = {}) ⇒ Hash
Calls CreateUser API
158 159 160 161 162 163 164 |
# File 'lib/stratus/aws/iam.rb', line 158 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
52 53 54 |
# File 'lib/stratus/aws/iam.rb', line 52 def default_host DEFAULT_HOST end |
#delete_access_key(options = {}) ⇒ Hash
Calls DeleteAccessKey API
229 230 231 232 233 234 235 |
# File 'lib/stratus/aws/iam.rb', line 229 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
89 90 91 92 93 94 |
# File 'lib/stratus/aws/iam.rb', line 89 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
298 299 300 301 302 303 304 |
# File 'lib/stratus/aws/iam.rb', line 298 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_signing_certificate(options = {}) ⇒ Hash
Calls DeleteSigningCertificate API
404 405 406 407 408 409 410 |
# File 'lib/stratus/aws/iam.rb', line 404 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
170 171 172 173 174 175 |
# File 'lib/stratus/aws/iam.rb', line 170 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
355 356 357 358 359 360 361 |
# File 'lib/stratus/aws/iam.rb', line 355 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
57 58 59 |
# File 'lib/stratus/aws/iam.rb', line 57 def endpoint @endpoint end |
#get_group(options = {}) ⇒ Hash
Calls GetGropup API
65 66 67 68 69 70 71 |
# File 'lib/stratus/aws/iam.rb', line 65 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
265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/stratus/aws/iam.rb', line 265 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_user(options = {}) ⇒ Hash
Calls GetUser API
147 148 149 150 151 152 |
# File 'lib/stratus/aws/iam.rb', line 147 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
322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/stratus/aws/iam.rb', line 322 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
254 255 256 257 258 259 |
# File 'lib/stratus/aws/iam.rb', line 254 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
310 311 312 313 314 315 316 |
# File 'lib/stratus/aws/iam.rb', line 310 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
99 100 101 102 103 104 |
# File 'lib/stratus/aws/iam.rb', line 99 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
192 193 194 195 196 197 198 |
# File 'lib/stratus/aws/iam.rb', line 192 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
416 417 418 419 420 421 |
# File 'lib/stratus/aws/iam.rb', line 416 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
367 368 369 370 371 372 373 |
# File 'lib/stratus/aws/iam.rb', line 367 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
181 182 183 184 185 186 |
# File 'lib/stratus/aws/iam.rb', line 181 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
281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/stratus/aws/iam.rb', line 281 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
338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/stratus/aws/iam.rb', line 338 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
135 136 137 138 139 140 141 |
# File 'lib/stratus/aws/iam.rb', line 135 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
241 242 243 244 245 246 247 248 |
# File 'lib/stratus/aws/iam.rb', line 241 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
110 111 112 113 114 115 116 117 |
# File 'lib/stratus/aws/iam.rb', line 110 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_signing_certificate(options = {}) ⇒ Hash
Calls UpdateSigningCertificate API
391 392 393 394 395 396 397 398 |
# File 'lib/stratus/aws/iam.rb', line 391 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
204 205 206 207 208 209 210 211 212 |
# File 'lib/stratus/aws/iam.rb', line 204 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
379 380 381 382 383 384 385 |
# File 'lib/stratus/aws/iam.rb', line 379 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 |