Class: Aws::IAM::Resource
- Inherits:
-
Object
- Object
- Aws::IAM::Resource
- Defined in:
- gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb,
gems/aws-sdk-iam/lib/aws-sdk-iam/customizations/resource.rb
Overview
This class provides a resource oriented interface for IAM. To create a resource object:
resource = Aws::IAM::Resource.new(region: 'us-west-2')
You can supply a client object with custom configuration that will be used for all resource operations.
If you do not pass :client
, a default client will be constructed.
client = Aws::IAM::Client.new(region: 'us-west-2')
resource = Aws::IAM::Resource.new(client: client)
Actions collapse
-
#change_password(options = {}) ⇒ EmptyStructure
-
#create_account_alias(options = {}) ⇒ EmptyStructure
-
#create_account_password_policy(options = {}) ⇒ AccountPasswordPolicy
-
#create_group(options = {}) ⇒ Group
-
#create_instance_profile(options = {}) ⇒ InstanceProfile
-
#create_policy(options = {}) ⇒ Policy
-
#create_role(options = {}) ⇒ Role
-
#create_saml_provider(options = {}) ⇒ SamlProvider
-
#create_server_certificate(options = {}) ⇒ ServerCertificate
-
#create_signing_certificate(options = {}) ⇒ SigningCertificate
-
#create_user(options = {}) ⇒ User
-
#create_virtual_mfa_device(options = {}) ⇒ VirtualMfaDevice
Associations collapse
-
#account_password_policy ⇒ AccountPasswordPolicy
-
#account_summary ⇒ AccountSummary
-
#current_user ⇒ CurrentUser
-
#group(name) ⇒ Group
-
#groups(options = {}) ⇒ Group::Collection
-
#instance_profile(name) ⇒ InstanceProfile
-
#instance_profiles(options = {}) ⇒ InstanceProfile::Collection
-
#policies(options = {}) ⇒ Policy::Collection
-
#policy(arn) ⇒ Policy
-
#role(name) ⇒ Role
-
#roles(options = {}) ⇒ Role::Collection
-
#saml_provider(arn) ⇒ SamlProvider
-
#saml_providers(options = {}) ⇒ SamlProvider::Collection
-
#server_certificate(name) ⇒ ServerCertificate
-
#server_certificates(options = {}) ⇒ ServerCertificate::Collection
-
#user(name) ⇒ User
-
#users(options = {}) ⇒ User::Collection
-
#virtual_mfa_device(serial_number) ⇒ VirtualMfaDevice
-
#virtual_mfa_devices(options = {}) ⇒ VirtualMfaDevice::Collection
Instance Method Summary collapse
-
#client ⇒ Client
-
#delete_account_alias ⇒ Seahorse::Client::Response, false
Returns the response from Client#delete_account_alias if an alias was deleted.
-
#initialize(options = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
Instance Method Details
#account_password_policy ⇒ AccountPasswordPolicy
971 972 973 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 971 def account_password_policy AccountPasswordPolicy.new(client: @client) end |
#account_summary ⇒ AccountSummary
976 977 978 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 976 def account_summary AccountSummary.new(client: @client) end |
#change_password(options = {}) ⇒ EmptyStructure
65 66 67 68 69 70 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 65 def change_password( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.change_password() end resp.data end |
#client ⇒ Client
32 33 34 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 32 def client @client end |
#create_account_alias(options = {}) ⇒ EmptyStructure
90 91 92 93 94 95 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 90 def create_account_alias( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_account_alias() end resp.data end |
#create_account_password_policy(options = {}) ⇒ AccountPasswordPolicy
195 196 197 198 199 200 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 195 def create_account_password_policy( = {}) Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.update_account_password_policy() end AccountPasswordPolicy.new(client: @client) end |
#create_group(options = {}) ⇒ Group
235 236 237 238 239 240 241 242 243 244 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 235 def create_group( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_group() end Group.new( name: [:group_name], data: resp.data.group, client: @client ) end |
#create_instance_profile(options = {}) ⇒ InstanceProfile
304 305 306 307 308 309 310 311 312 313 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 304 def create_instance_profile( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_instance_profile() end InstanceProfile.new( name: [:instance_profile_name], data: resp.data.instance_profile, client: @client ) end |
#create_policy(options = {}) ⇒ Policy
419 420 421 422 423 424 425 426 427 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 419 def create_policy( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_policy() end Policy.new( arn: resp.data.policy.arn, client: @client ) end |
#create_role(options = {}) ⇒ Role
561 562 563 564 565 566 567 568 569 570 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 561 def create_role( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_role() end Role.new( name: [:role_name], data: resp.data.role, client: @client ) end |
#create_saml_provider(options = {}) ⇒ SamlProvider
626 627 628 629 630 631 632 633 634 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 626 def create_saml_provider( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_saml_provider() end SamlProvider.new( arn: resp.data.saml_provider_arn, client: @client ) end |
#create_server_certificate(options = {}) ⇒ ServerCertificate
758 759 760 761 762 763 764 765 766 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 758 def create_server_certificate( = {}) Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.upload_server_certificate() end ServerCertificate.new( name: [:server_certificate_name], client: @client ) end |
#create_signing_certificate(options = {}) ⇒ SigningCertificate
805 806 807 808 809 810 811 812 813 814 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 805 def create_signing_certificate( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.upload_signing_certificate() end SigningCertificate.new( id: resp.data.certificate.certificate_id, data: resp.data.certificate, client: @client ) end |
#create_user(options = {}) ⇒ User
887 888 889 890 891 892 893 894 895 896 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 887 def create_user( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_user() end User.new( name: [:user_name], data: resp.data.user, client: @client ) end |
#create_virtual_mfa_device(options = {}) ⇒ VirtualMfaDevice
957 958 959 960 961 962 963 964 965 966 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 957 def create_virtual_mfa_device( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_virtual_mfa_device() end VirtualMfaDevice.new( serial_number: resp.data.virtual_mfa_device.serial_number, data: resp.data.virtual_mfa_device, client: @client ) end |
#current_user ⇒ CurrentUser
981 982 983 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 981 def current_user CurrentUser.new(client: @client) end |
#delete_account_alias ⇒ Seahorse::Client::Response, false
Returns the response
from Client#delete_account_alias if an alias was deleted.
Returns false
if this account had no alias to remove.
11 12 13 14 15 16 17 18 19 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/customizations/resource.rb', line 11 def delete_account_alias Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do if name = @client.list_account_aliases.account_aliases.first @client.delete_account_alias(account_alias: name) else false end end end |
#group(name) ⇒ Group
987 988 989 990 991 992 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 987 def group(name) Group.new( name: name, client: @client ) end |
#groups(options = {}) ⇒ Group::Collection
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1017 def groups( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_groups() end resp.each_page do |page| batch = [] page.data.groups.each do |g| batch << Group.new( name: g.group_name, data: g, client: @client ) end y.yield(batch) end end Group::Collection.new(batches) end |
#instance_profile(name) ⇒ InstanceProfile
1039 1040 1041 1042 1043 1044 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1039 def instance_profile(name) InstanceProfile.new( name: name, client: @client ) end |
#instance_profiles(options = {}) ⇒ InstanceProfile::Collection
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1070 def instance_profiles( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_instance_profiles() end resp.each_page do |page| batch = [] page.data.instance_profiles.each do |i| batch << InstanceProfile.new( name: i.instance_profile_name, data: i, client: @client ) end y.yield(batch) end end InstanceProfile::Collection.new(batches) end |
#policies(options = {}) ⇒ Policy::Collection
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1139 def policies( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_policies() end resp.each_page do |page| batch = [] page.data.policies.each do |p| batch << Policy.new( arn: p.arn, data: p, client: @client ) end y.yield(batch) end end Policy::Collection.new(batches) end |
#policy(arn) ⇒ Policy
1161 1162 1163 1164 1165 1166 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1161 def policy(arn) Policy.new( arn: arn, client: @client ) end |
#role(name) ⇒ Role
1170 1171 1172 1173 1174 1175 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1170 def role(name) Role.new( name: name, client: @client ) end |
#roles(options = {}) ⇒ Role::Collection
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1200 def roles( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_roles() end resp.each_page do |page| batch = [] page.data.roles.each do |r| batch << Role.new( name: r.role_name, data: r, client: @client ) end y.yield(batch) end end Role::Collection.new(batches) end |
#saml_provider(arn) ⇒ SamlProvider
1222 1223 1224 1225 1226 1227 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1222 def saml_provider(arn) SamlProvider.new( arn: arn, client: @client ) end |
#saml_providers(options = {}) ⇒ SamlProvider::Collection
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1234 def saml_providers( = {}) batches = Enumerator.new do |y| batch = [] resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_saml_providers() end resp.data.saml_provider_list.each do |s| batch << SamlProvider.new( arn: s.arn, client: @client ) end y.yield(batch) end SamlProvider::Collection.new(batches) end |
#server_certificate(name) ⇒ ServerCertificate
1253 1254 1255 1256 1257 1258 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1253 def server_certificate(name) ServerCertificate.new( name: name, client: @client ) end |
#server_certificates(options = {}) ⇒ ServerCertificate::Collection
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1284 def server_certificates( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_server_certificates() end resp.each_page do |page| batch = [] page.data..each do |s| batch << ServerCertificate.new( name: s.server_certificate_name, client: @client ) end y.yield(batch) end end ServerCertificate::Collection.new(batches) end |
#user(name) ⇒ User
1305 1306 1307 1308 1309 1310 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1305 def user(name) User.new( name: name, client: @client ) end |
#users(options = {}) ⇒ User::Collection
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1335 def users( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_users() end resp.each_page do |page| batch = [] page.data.users.each do |u| batch << User.new( name: u.user_name, data: u, client: @client ) end y.yield(batch) end end User::Collection.new(batches) end |
#virtual_mfa_device(serial_number) ⇒ VirtualMfaDevice
1357 1358 1359 1360 1361 1362 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1357 def virtual_mfa_device(serial_number) VirtualMfaDevice.new( serial_number: serial_number, client: @client ) end |
#virtual_mfa_devices(options = {}) ⇒ VirtualMfaDevice::Collection
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 |
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1375 def virtual_mfa_devices( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_virtual_mfa_devices() end resp.each_page do |page| batch = [] page.data.virtual_mfa_devices.each do |v| batch << VirtualMfaDevice.new( serial_number: v.serial_number, data: v, client: @client ) end y.yield(batch) end end VirtualMfaDevice::Collection.new(batches) end |