AWS services or capabilities described in AWS Documentation may vary by region/location. Click
Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Class: Aws::IAM::Resource
- Inherits:
-
Object
- Object
- Aws::IAM::Resource
show all
- 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)
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Resource
Returns a new instance of Resource.
27
28
29
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 27
def initialize(options = {})
@client = options[:client] || Client.new(options)
end
|
Instance Method Details
778
779
780
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 778
def account_password_policy
AccountPasswordPolicy.new(client: @client)
end
|
783
784
785
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 783
def account_summary
AccountSummary.new(client: @client)
end
|
#change_password(options = {}) ⇒ EmptyStructure
64
65
66
67
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 64
def change_password(options = {})
resp = @client.change_password(options)
resp.data
end
|
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
87
88
89
90
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 87
def create_account_alias(options = {})
resp = @client.create_account_alias(options)
resp.data
end
|
#create_account_password_policy(options = {}) ⇒ AccountPasswordPolicy
177
178
179
180
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 177
def create_account_password_policy(options = {})
@client.update_account_password_policy(options)
AccountPasswordPolicy.new(client: @client)
end
|
#create_group(options = {}) ⇒ Group
215
216
217
218
219
220
221
222
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 215
def create_group(options = {})
resp = @client.create_group(options)
Group.new(
name: options[:group_name],
data: resp.data.group,
client: @client
)
end
|
#create_instance_profile(options = {}) ⇒ InstanceProfile
261
262
263
264
265
266
267
268
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 261
def create_instance_profile(options = {})
resp = @client.create_instance_profile(options)
InstanceProfile.new(
name: options[:instance_profile_name],
data: resp.data.instance_profile,
client: @client
)
end
|
#create_policy(options = {}) ⇒ Policy
339
340
341
342
343
344
345
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 339
def create_policy(options = {})
resp = @client.create_policy(options)
Policy.new(
arn: resp.data.policy.arn,
client: @client
)
end
|
#create_role(options = {}) ⇒ Role
457
458
459
460
461
462
463
464
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 457
def create_role(options = {})
resp = @client.create_role(options)
Role.new(
name: options[:role_name],
data: resp.data.role,
client: @client
)
end
|
#create_saml_provider(options = {}) ⇒ SamlProvider
499
500
501
502
503
504
505
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 499
def create_saml_provider(options = {})
resp = @client.create_saml_provider(options)
SamlProvider.new(
arn: resp.data.saml_provider_arn,
client: @client
)
end
|
#create_server_certificate(options = {}) ⇒ ServerCertificate
608
609
610
611
612
613
614
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 608
def create_server_certificate(options = {})
@client.upload_server_certificate(options)
ServerCertificate.new(
name: options[:server_certificate_name],
client: @client
)
end
|
#create_signing_certificate(options = {}) ⇒ SigningCertificate
653
654
655
656
657
658
659
660
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 653
def create_signing_certificate(options = {})
resp = @client.upload_signing_certificate(options)
SigningCertificate.new(
id: resp.data.certificate.certificate_id,
data: resp.data.certificate,
client: @client
)
end
|
#create_user(options = {}) ⇒ User
719
720
721
722
723
724
725
726
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 719
def create_user(options = {})
resp = @client.create_user(options)
User.new(
name: options[:user_name],
data: resp.data.user,
client: @client
)
end
|
#create_virtual_mfa_device(options = {}) ⇒ VirtualMfaDevice
766
767
768
769
770
771
772
773
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 766
def create_virtual_mfa_device(options = {})
resp = @client.create_virtual_mfa_device(options)
VirtualMfaDevice.new(
serial_number: resp.data.virtual_mfa_device.serial_number,
data: resp.data.virtual_mfa_device,
client: @client
)
end
|
788
789
790
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 788
def current_user
CurrentUser.new(client: @client)
end
|
11
12
13
14
15
16
17
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/customizations/resource.rb', line 11
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
794
795
796
797
798
799
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 794
def group(name)
Group.new(
name: name,
client: @client
)
end
|
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 824
def groups(options = {})
batches = Enumerator.new do |y|
resp = @client.list_groups(options)
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
|
844
845
846
847
848
849
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 844
def instance_profile(name)
InstanceProfile.new(
name: name,
client: @client
)
end
|
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 875
def instance_profiles(options = {})
batches = Enumerator.new do |y|
resp = @client.list_instance_profiles(options)
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
|
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 942
def policies(options = {})
batches = Enumerator.new do |y|
resp = @client.list_policies(options)
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
962
963
964
965
966
967
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 962
def policy(arn)
Policy.new(
arn: arn,
client: @client
)
end
|
#role(name) ⇒ Role
971
972
973
974
975
976
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 971
def role(name)
Role.new(
name: name,
client: @client
)
end
|
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1001
def roles(options = {})
batches = Enumerator.new do |y|
resp = @client.list_roles(options)
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
|
1021
1022
1023
1024
1025
1026
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1021
def saml_provider(arn)
SamlProvider.new(
arn: arn,
client: @client
)
end
|
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1033
def saml_providers(options = {})
batches = Enumerator.new do |y|
batch = []
resp = @client.list_saml_providers(options)
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
|
1050
1051
1052
1053
1054
1055
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1050
def server_certificate(name)
ServerCertificate.new(
name: name,
client: @client
)
end
|
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1081
def server_certificates(options = {})
batches = Enumerator.new do |y|
resp = @client.list_server_certificates(options)
resp.each_page do |page|
batch = []
page.data.server_certificate_metadata_list.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
1100
1101
1102
1103
1104
1105
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1100
def user(name)
User.new(
name: name,
client: @client
)
end
|
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1130
def users(options = {})
batches = Enumerator.new do |y|
resp = @client.list_users(options)
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
1150
1151
1152
1153
1154
1155
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1150
def virtual_mfa_device(serial_number)
VirtualMfaDevice.new(
serial_number: serial_number,
client: @client
)
end
|
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
|
# File 'gems/aws-sdk-iam/lib/aws-sdk-iam/resource.rb', line 1168
def virtual_mfa_devices(options = {})
batches = Enumerator.new do |y|
resp = @client.list_virtual_mfa_devices(options)
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
|