Class: Aws::IAM::Resource
- Inherits:
-
Object
- Object
- Aws::IAM::Resource
- Defined in:
- lib/aws-sdk-iam/resource.rb,
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
776 777 778 |
# File 'lib/aws-sdk-iam/resource.rb', line 776 def account_password_policy AccountPasswordPolicy.new(client: @client) end |
#account_summary ⇒ AccountSummary
781 782 783 |
# File 'lib/aws-sdk-iam/resource.rb', line 781 def account_summary AccountSummary.new(client: @client) end |
#change_password(options = {}) ⇒ EmptyStructure
62 63 64 65 |
# File 'lib/aws-sdk-iam/resource.rb', line 62 def change_password( = {}) resp = @client.change_password() resp.data end |
#create_account_alias(options = {}) ⇒ EmptyStructure
85 86 87 88 |
# File 'lib/aws-sdk-iam/resource.rb', line 85 def create_account_alias( = {}) resp = @client.create_account_alias() resp.data end |
#create_account_password_policy(options = {}) ⇒ AccountPasswordPolicy
175 176 177 178 |
# File 'lib/aws-sdk-iam/resource.rb', line 175 def create_account_password_policy( = {}) resp = @client.update_account_password_policy() AccountPasswordPolicy.new(client: @client) end |
#create_group(options = {}) ⇒ Group
213 214 215 216 217 218 219 220 |
# File 'lib/aws-sdk-iam/resource.rb', line 213 def create_group( = {}) resp = @client.create_group() Group.new( name: [:group_name], data: resp.data.group, client: @client ) end |
#create_instance_profile(options = {}) ⇒ InstanceProfile
259 260 261 262 263 264 265 266 |
# File 'lib/aws-sdk-iam/resource.rb', line 259 def create_instance_profile( = {}) resp = @client.create_instance_profile() InstanceProfile.new( name: [:instance_profile_name], data: resp.data.instance_profile, client: @client ) end |
#create_policy(options = {}) ⇒ Policy
337 338 339 340 341 342 343 |
# File 'lib/aws-sdk-iam/resource.rb', line 337 def create_policy( = {}) resp = @client.create_policy() Policy.new( arn: resp.data.policy.arn, client: @client ) end |
#create_role(options = {}) ⇒ Role
455 456 457 458 459 460 461 462 |
# File 'lib/aws-sdk-iam/resource.rb', line 455 def create_role( = {}) resp = @client.create_role() Role.new( name: [:role_name], data: resp.data.role, client: @client ) end |
#create_saml_provider(options = {}) ⇒ SamlProvider
497 498 499 500 501 502 503 |
# File 'lib/aws-sdk-iam/resource.rb', line 497 def create_saml_provider( = {}) resp = @client.create_saml_provider() SamlProvider.new( arn: resp.data.saml_provider_arn, client: @client ) end |
#create_server_certificate(options = {}) ⇒ ServerCertificate
606 607 608 609 610 611 612 |
# File 'lib/aws-sdk-iam/resource.rb', line 606 def create_server_certificate( = {}) resp = @client.upload_server_certificate() ServerCertificate.new( name: [:server_certificate_name], client: @client ) end |
#create_signing_certificate(options = {}) ⇒ SigningCertificate
651 652 653 654 655 656 657 658 |
# File 'lib/aws-sdk-iam/resource.rb', line 651 def create_signing_certificate( = {}) resp = @client.upload_signing_certificate() SigningCertificate.new( id: resp.data.certificate.certificate_id, data: resp.data.certificate, client: @client ) end |
#create_user(options = {}) ⇒ User
717 718 719 720 721 722 723 724 |
# File 'lib/aws-sdk-iam/resource.rb', line 717 def create_user( = {}) resp = @client.create_user() User.new( name: [:user_name], data: resp.data.user, client: @client ) end |
#create_virtual_mfa_device(options = {}) ⇒ VirtualMfaDevice
764 765 766 767 768 769 770 771 |
# File 'lib/aws-sdk-iam/resource.rb', line 764 def create_virtual_mfa_device( = {}) resp = @client.create_virtual_mfa_device() VirtualMfaDevice.new( serial_number: resp.data.virtual_mfa_device.serial_number, data: resp.data.virtual_mfa_device, client: @client ) end |
#current_user ⇒ CurrentUser
786 787 788 |
# File 'lib/aws-sdk-iam/resource.rb', line 786 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.
9 10 11 12 13 14 15 |
# File 'lib/aws-sdk-iam/customizations/resource.rb', line 9 def delete_account_alias if name = @client.list_account_aliases.account_aliases.first @client.delete_account_alias(account_alias: name) else false end end |
#group(name) ⇒ Group
792 793 794 795 796 797 |
# File 'lib/aws-sdk-iam/resource.rb', line 792 def group(name) Group.new( name: name, client: @client ) end |
#groups(options = {}) ⇒ Group::Collection
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
# File 'lib/aws-sdk-iam/resource.rb', line 822 def groups( = {}) batches = Enumerator.new do |y| resp = @client.list_groups() 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
842 843 844 845 846 847 |
# File 'lib/aws-sdk-iam/resource.rb', line 842 def instance_profile(name) InstanceProfile.new( name: name, client: @client ) end |
#instance_profiles(options = {}) ⇒ InstanceProfile::Collection
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 |
# File 'lib/aws-sdk-iam/resource.rb', line 873 def instance_profiles( = {}) batches = Enumerator.new do |y| resp = @client.list_instance_profiles() 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
940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
# File 'lib/aws-sdk-iam/resource.rb', line 940 def policies( = {}) batches = Enumerator.new do |y| resp = @client.list_policies() 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
960 961 962 963 964 965 |
# File 'lib/aws-sdk-iam/resource.rb', line 960 def policy(arn) Policy.new( arn: arn, client: @client ) end |
#role(name) ⇒ Role
969 970 971 972 973 974 |
# File 'lib/aws-sdk-iam/resource.rb', line 969 def role(name) Role.new( name: name, client: @client ) end |
#roles(options = {}) ⇒ Role::Collection
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
# File 'lib/aws-sdk-iam/resource.rb', line 999 def roles( = {}) batches = Enumerator.new do |y| resp = @client.list_roles() 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
1019 1020 1021 1022 1023 1024 |
# File 'lib/aws-sdk-iam/resource.rb', line 1019 def saml_provider(arn) SamlProvider.new( arn: arn, client: @client ) end |
#saml_providers(options = {}) ⇒ SamlProvider::Collection
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
# File 'lib/aws-sdk-iam/resource.rb', line 1031 def saml_providers( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.list_saml_providers() 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
1048 1049 1050 1051 1052 1053 |
# File 'lib/aws-sdk-iam/resource.rb', line 1048 def server_certificate(name) ServerCertificate.new( name: name, client: @client ) end |
#server_certificates(options = {}) ⇒ ServerCertificate::Collection
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 |
# File 'lib/aws-sdk-iam/resource.rb', line 1079 def server_certificates( = {}) batches = Enumerator.new do |y| resp = @client.list_server_certificates() 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
1098 1099 1100 1101 1102 1103 |
# File 'lib/aws-sdk-iam/resource.rb', line 1098 def user(name) User.new( name: name, client: @client ) end |
#users(options = {}) ⇒ User::Collection
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 |
# File 'lib/aws-sdk-iam/resource.rb', line 1128 def users( = {}) batches = Enumerator.new do |y| resp = @client.list_users() 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
1148 1149 1150 1151 1152 1153 |
# File 'lib/aws-sdk-iam/resource.rb', line 1148 def virtual_mfa_device(serial_number) VirtualMfaDevice.new( serial_number: serial_number, client: @client ) end |
#virtual_mfa_devices(options = {}) ⇒ VirtualMfaDevice::Collection
1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 |
# File 'lib/aws-sdk-iam/resource.rb', line 1166 def virtual_mfa_devices( = {}) batches = Enumerator.new do |y| resp = @client.list_virtual_mfa_devices() 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 |