aws-sdk-iam 1.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,178 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module IAM
10
+ class GroupPolicy
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(group_name, name, options = {})
15
+ # @param [String] group_name
16
+ # @param [String] name
17
+ # @option options [Client] :client
18
+ # @overload def initialize(options = {})
19
+ # @option options [required, String] :group_name
20
+ # @option options [required, String] :name
21
+ # @option options [Client] :client
22
+ def initialize(*args)
23
+ options = Hash === args.last ? args.pop.dup : {}
24
+ @group_name = extract_group_name(args, options)
25
+ @name = extract_name(args, options)
26
+ @data = options.delete(:data)
27
+ @client = options.delete(:client) || Client.new(options)
28
+ end
29
+
30
+ # @!group Read-Only Attributes
31
+
32
+ # @return [String]
33
+ def group_name
34
+ @group_name
35
+ end
36
+
37
+ # @return [String]
38
+ def name
39
+ @name
40
+ end
41
+ alias :policy_name :name
42
+
43
+ # The policy document.
44
+ # @return [String]
45
+ def policy_document
46
+ data.policy_document
47
+ end
48
+
49
+ # @!endgroup
50
+
51
+ # @return [Client]
52
+ def client
53
+ @client
54
+ end
55
+
56
+ # Loads, or reloads {#data} for the current {GroupPolicy}.
57
+ # Returns `self` making it possible to chain methods.
58
+ #
59
+ # group_policy.reload.data
60
+ #
61
+ # @return [self]
62
+ def load
63
+ resp = @client.get_group_policy(
64
+ group_name: @group_name,
65
+ policy_name: @name
66
+ )
67
+ @data = resp.data
68
+ self
69
+ end
70
+ alias :reload :load
71
+
72
+ # @return [Types::GetGroupPolicyResponse]
73
+ # Returns the data for this {GroupPolicy}. Calls
74
+ # {Client#get_group_policy} if {#data_loaded?} is `false`.
75
+ def data
76
+ load unless @data
77
+ @data
78
+ end
79
+
80
+ # @return [Boolean]
81
+ # Returns `true` if this resource is loaded. Accessing attributes or
82
+ # {#data} on an unloaded resource will trigger a call to {#load}.
83
+ def data_loaded?
84
+ !!@data
85
+ end
86
+
87
+ # @!group Actions
88
+
89
+ # @example Request syntax with placeholder values
90
+ #
91
+ # group_policy.delete()
92
+ # @param [Hash] options ({})
93
+ # @return [EmptyStructure]
94
+ def delete(options = {})
95
+ options = options.merge(
96
+ group_name: @group_name,
97
+ policy_name: @name
98
+ )
99
+ resp = @client.delete_group_policy(options)
100
+ resp.data
101
+ end
102
+
103
+ # @example Request syntax with placeholder values
104
+ #
105
+ # group_policy.put({
106
+ # policy_document: "policyDocumentType", # required
107
+ # })
108
+ # @param [Hash] options ({})
109
+ # @option options [required, String] :policy_document
110
+ # The policy document.
111
+ #
112
+ # The [regex pattern][1] for this parameter is a string of characters
113
+ # consisting of any printable ASCII character ranging from the space
114
+ # character (\\u0020) through end of the ASCII character range
115
+ # (\\u00FF). It also includes the special characters tab (\\u0009), line
116
+ # feed (\\u000A), and carriage return (\\u000D).
117
+ #
118
+ #
119
+ #
120
+ # [1]: http://wikipedia.org/wiki/regex
121
+ # @return [EmptyStructure]
122
+ def put(options = {})
123
+ options = options.merge(
124
+ group_name: @group_name,
125
+ policy_name: @name
126
+ )
127
+ resp = @client.put_group_policy(options)
128
+ resp.data
129
+ end
130
+
131
+ # @!group Associations
132
+
133
+ # @return [Group]
134
+ def group
135
+ Group.new(
136
+ name: @group_name,
137
+ client: @client
138
+ )
139
+ end
140
+
141
+ # @deprecated
142
+ # @api private
143
+ def identifiers
144
+ {
145
+ group_name: @group_name,
146
+ name: @name
147
+ }
148
+ end
149
+ deprecated(:identifiers)
150
+
151
+ private
152
+
153
+ def extract_group_name(args, options)
154
+ value = args[0] || options.delete(:group_name)
155
+ case value
156
+ when String then value
157
+ when nil then raise ArgumentError, "missing required option :group_name"
158
+ else
159
+ msg = "expected :group_name to be a String, got #{value.class}"
160
+ raise ArgumentError, msg
161
+ end
162
+ end
163
+
164
+ def extract_name(args, options)
165
+ value = args[1] || options.delete(:name)
166
+ case value
167
+ when String then value
168
+ when nil then raise ArgumentError, "missing required option :name"
169
+ else
170
+ msg = "expected :name to be a String, got #{value.class}"
171
+ raise ArgumentError, msg
172
+ end
173
+ end
174
+
175
+ class Collection < Aws::Resources::Collection; end
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,264 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module IAM
10
+ class InstanceProfile
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(name, options = {})
15
+ # @param [String] name
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :name
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @name = extract_name(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def name
31
+ @name
32
+ end
33
+ alias :instance_profile_name :name
34
+
35
+ # The path to the instance profile. For more information about paths,
36
+ # see [IAM Identifiers][1] in the *Using IAM* guide.
37
+ #
38
+ #
39
+ #
40
+ # [1]: http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
41
+ # @return [String]
42
+ def path
43
+ data.path
44
+ end
45
+
46
+ # The stable and unique string identifying the instance profile. For
47
+ # more information about IDs, see [IAM Identifiers][1] in the *Using
48
+ # IAM* guide.
49
+ #
50
+ #
51
+ #
52
+ # [1]: http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
53
+ # @return [String]
54
+ def instance_profile_id
55
+ data.instance_profile_id
56
+ end
57
+
58
+ # The Amazon Resource Name (ARN) specifying the instance profile. For
59
+ # more information about ARNs and how to use them in policies, see [IAM
60
+ # Identifiers][1] in the *Using IAM* guide.
61
+ #
62
+ #
63
+ #
64
+ # [1]: http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
65
+ # @return [String]
66
+ def arn
67
+ data.arn
68
+ end
69
+
70
+ # The date when the instance profile was created.
71
+ # @return [Time]
72
+ def create_date
73
+ data.create_date
74
+ end
75
+
76
+ # @!endgroup
77
+
78
+ # @return [Client]
79
+ def client
80
+ @client
81
+ end
82
+
83
+ # Loads, or reloads {#data} for the current {InstanceProfile}.
84
+ # Returns `self` making it possible to chain methods.
85
+ #
86
+ # instance_profile.reload.data
87
+ #
88
+ # @return [self]
89
+ def load
90
+ resp = @client.get_instance_profile(instance_profile_name: @name)
91
+ @data = resp.instanceprofile
92
+ self
93
+ end
94
+ alias :reload :load
95
+
96
+ # @return [Types::InstanceProfile]
97
+ # Returns the data for this {InstanceProfile}. Calls
98
+ # {Client#get_instance_profile} if {#data_loaded?} is `false`.
99
+ def data
100
+ load unless @data
101
+ @data
102
+ end
103
+
104
+ # @return [Boolean]
105
+ # Returns `true` if this resource is loaded. Accessing attributes or
106
+ # {#data} on an unloaded resource will trigger a call to {#load}.
107
+ def data_loaded?
108
+ !!@data
109
+ end
110
+
111
+ # @param [Hash] options ({})
112
+ # @return [Boolean]
113
+ # Returns `true` if the InstanceProfile exists.
114
+ def exists?(options = {})
115
+ begin
116
+ wait_until_exists(options.merge(max_attempts: 1))
117
+ true
118
+ rescue Aws::Waiters::Errors::UnexpectedError => e
119
+ raise e.error
120
+ rescue Aws::Waiters::Errors::WaiterFailed
121
+ false
122
+ end
123
+ end
124
+
125
+ # @param [Hash] options ({})
126
+ # @option options [Integer] :max_attempts (40)
127
+ # @option options [Float] :delay (1)
128
+ # @option options [Proc] :before_attempt
129
+ # @option options [Proc] :before_wait
130
+ # @return [InstanceProfile]
131
+ def wait_until_exists(options = {})
132
+ options, params = separate_params_and_options(options)
133
+ waiter = Waiters::InstanceProfileExists.new(options)
134
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
135
+ waiter.wait(params.merge(instance_profile_name: @name))
136
+ InstanceProfile.new({
137
+ name: @name,
138
+ client: @client
139
+ })
140
+ end
141
+
142
+ # @!group Actions
143
+
144
+ # @example Request syntax with placeholder values
145
+ #
146
+ # instance_profile.add_role({
147
+ # role_name: "roleNameType", # required
148
+ # })
149
+ # @param [Hash] options ({})
150
+ # @option options [required, String] :role_name
151
+ # The name of the role to add.
152
+ #
153
+ # The [regex pattern][1] for this parameter is a string of characters
154
+ # consisting of upper and lowercase alphanumeric characters with no
155
+ # spaces. You can also include any of the following characters: =,.@-
156
+ #
157
+ #
158
+ #
159
+ # [1]: http://wikipedia.org/wiki/regex
160
+ # @return [EmptyStructure]
161
+ def add_role(options = {})
162
+ options = options.merge(instance_profile_name: @name)
163
+ resp = @client.add_role_to_instance_profile(options)
164
+ resp.data
165
+ end
166
+
167
+ # @example Request syntax with placeholder values
168
+ #
169
+ # instance_profile.delete()
170
+ # @param [Hash] options ({})
171
+ # @return [EmptyStructure]
172
+ def delete(options = {})
173
+ options = options.merge(instance_profile_name: @name)
174
+ resp = @client.delete_instance_profile(options)
175
+ resp.data
176
+ end
177
+
178
+ # @example Request syntax with placeholder values
179
+ #
180
+ # instance_profile.remove_role({
181
+ # role_name: "roleNameType", # required
182
+ # })
183
+ # @param [Hash] options ({})
184
+ # @option options [required, String] :role_name
185
+ # The name of the role to remove.
186
+ #
187
+ # The [regex pattern][1] for this parameter is a string of characters
188
+ # consisting of upper and lowercase alphanumeric characters with no
189
+ # spaces. You can also include any of the following characters: =,.@-
190
+ #
191
+ #
192
+ #
193
+ # [1]: http://wikipedia.org/wiki/regex
194
+ # @return [EmptyStructure]
195
+ def remove_role(options = {})
196
+ options = options.merge(instance_profile_name: @name)
197
+ resp = @client.remove_role_from_instance_profile(options)
198
+ resp.data
199
+ end
200
+
201
+ # @!group Associations
202
+
203
+ # @return [Role::Collection]
204
+ def roles
205
+ batch = []
206
+ data.roles.each do |r|
207
+ batch << Role.new(
208
+ name: r.role_name,
209
+ data: r,
210
+ client: @client
211
+ )
212
+ end
213
+ Role::Collection.new([batch], size: batch.size)
214
+ end
215
+
216
+ # @deprecated
217
+ # @api private
218
+ def identifiers
219
+ { name: @name }
220
+ end
221
+ deprecated(:identifiers)
222
+
223
+ private
224
+
225
+ def extract_name(args, options)
226
+ value = args[0] || options.delete(:name)
227
+ case value
228
+ when String then value
229
+ when nil then raise ArgumentError, "missing required option :name"
230
+ else
231
+ msg = "expected :name to be a String, got #{value.class}"
232
+ raise ArgumentError, msg
233
+ end
234
+ end
235
+
236
+ def yield_waiter_and_warn(waiter, &block)
237
+ if !@waiter_block_warned
238
+ msg = "pass options to configure the waiter; "
239
+ msg << "yielding the waiter is deprecated"
240
+ warn(msg)
241
+ @waiter_block_warned = true
242
+ end
243
+ yield(waiter.waiter)
244
+ end
245
+
246
+ def separate_params_and_options(options)
247
+ opts = Set.new([:client, :max_attempts, :delay, :before_attempt, :before_wait])
248
+ waiter_opts = {}
249
+ waiter_params = {}
250
+ options.each_pair do |key, value|
251
+ if opts.include?(key)
252
+ waiter_opts[key] = value
253
+ else
254
+ waiter_params[key] = value
255
+ end
256
+ end
257
+ waiter_opts[:client] ||= @client
258
+ [waiter_opts, waiter_params]
259
+ end
260
+
261
+ class Collection < Aws::Resources::Collection; end
262
+ end
263
+ end
264
+ end
@@ -0,0 +1,196 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module IAM
10
+ class LoginProfile
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(user_name, options = {})
15
+ # @param [String] user_name
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :user_name
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @user_name = extract_user_name(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def user_name
31
+ @user_name
32
+ end
33
+
34
+ # The date when the password for the user was created.
35
+ # @return [Time]
36
+ def create_date
37
+ data.create_date
38
+ end
39
+
40
+ # Specifies whether the user is required to set a new password on next
41
+ # sign-in.
42
+ # @return [Boolean]
43
+ def password_reset_required
44
+ data.password_reset_required
45
+ end
46
+
47
+ # @!endgroup
48
+
49
+ # @return [Client]
50
+ def client
51
+ @client
52
+ end
53
+
54
+ # Loads, or reloads {#data} for the current {LoginProfile}.
55
+ # Returns `self` making it possible to chain methods.
56
+ #
57
+ # login_profile.reload.data
58
+ #
59
+ # @return [self]
60
+ def load
61
+ resp = @client.get_login_profile(user_name: @user_name)
62
+ @data = resp.loginprofile
63
+ self
64
+ end
65
+ alias :reload :load
66
+
67
+ # @return [Types::LoginProfile]
68
+ # Returns the data for this {LoginProfile}. Calls
69
+ # {Client#get_login_profile} if {#data_loaded?} is `false`.
70
+ def data
71
+ load unless @data
72
+ @data
73
+ end
74
+
75
+ # @return [Boolean]
76
+ # Returns `true` if this resource is loaded. Accessing attributes or
77
+ # {#data} on an unloaded resource will trigger a call to {#load}.
78
+ def data_loaded?
79
+ !!@data
80
+ end
81
+
82
+ # @!group Actions
83
+
84
+ # @example Request syntax with placeholder values
85
+ #
86
+ # loginprofile = login_profile.create({
87
+ # password: "passwordType", # required
88
+ # password_reset_required: false,
89
+ # })
90
+ # @param [Hash] options ({})
91
+ # @option options [required, String] :password
92
+ # The new password for the user.
93
+ #
94
+ # The [regex pattern][1] for this parameter is a string of characters
95
+ # consisting of almost any printable ASCII character from the space
96
+ # (\\u0020) through the end of the ASCII character range (\\u00FF). You
97
+ # can also include the tab (\\u0009), line feed (\\u000A), and carriage
98
+ # return (\\u000D) characters. Although any of these characters are
99
+ # valid in a password, note that many tools, such as the AWS Management
100
+ # Console, might restrict the ability to enter certain characters
101
+ # because they have special meaning within that tool.
102
+ #
103
+ #
104
+ #
105
+ # [1]: http://wikipedia.org/wiki/regex
106
+ # @option options [Boolean] :password_reset_required
107
+ # Specifies whether the user is required to set a new password on next
108
+ # sign-in.
109
+ # @return [LoginProfile]
110
+ def create(options = {})
111
+ options = options.merge(user_name: @user_name)
112
+ resp = @client.create_login_profile(options)
113
+ LoginProfile.new(
114
+ user_name: resp.data.login_profile.user_name,
115
+ data: resp.data.login_profile,
116
+ client: @client
117
+ )
118
+ end
119
+
120
+ # @example Request syntax with placeholder values
121
+ #
122
+ # login_profile.delete()
123
+ # @param [Hash] options ({})
124
+ # @return [EmptyStructure]
125
+ def delete(options = {})
126
+ options = options.merge(user_name: @user_name)
127
+ resp = @client.delete_login_profile(options)
128
+ resp.data
129
+ end
130
+
131
+ # @example Request syntax with placeholder values
132
+ #
133
+ # login_profile.update({
134
+ # password: "passwordType",
135
+ # password_reset_required: false,
136
+ # })
137
+ # @param [Hash] options ({})
138
+ # @option options [String] :password
139
+ # The new password for the specified IAM user.
140
+ #
141
+ # The [regex pattern][1] for this parameter is a string of characters
142
+ # consisting of any printable ASCII character ranging from the space
143
+ # character (\\u0020) through end of the ASCII character range
144
+ # (\\u00FF). It also includes the special characters tab (\\u0009), line
145
+ # feed (\\u000A), and carriage return (\\u000D). However, the format can
146
+ # be further restricted by the account administrator by setting a
147
+ # password policy on the AWS account. For more information, see
148
+ # UpdateAccountPasswordPolicy.
149
+ #
150
+ #
151
+ #
152
+ # [1]: http://wikipedia.org/wiki/regex
153
+ # @option options [Boolean] :password_reset_required
154
+ # Allows this new password to be used only once by requiring the
155
+ # specified IAM user to set a new password on next sign-in.
156
+ # @return [EmptyStructure]
157
+ def update(options = {})
158
+ options = options.merge(user_name: @user_name)
159
+ resp = @client.update_login_profile(options)
160
+ resp.data
161
+ end
162
+
163
+ # @!group Associations
164
+
165
+ # @return [User]
166
+ def user
167
+ User.new(
168
+ name: @user_name,
169
+ client: @client
170
+ )
171
+ end
172
+
173
+ # @deprecated
174
+ # @api private
175
+ def identifiers
176
+ { user_name: @user_name }
177
+ end
178
+ deprecated(:identifiers)
179
+
180
+ private
181
+
182
+ def extract_user_name(args, options)
183
+ value = args[0] || options.delete(:user_name)
184
+ case value
185
+ when String then value
186
+ when nil then raise ArgumentError, "missing required option :user_name"
187
+ else
188
+ msg = "expected :user_name to be a String, got #{value.class}"
189
+ raise ArgumentError, msg
190
+ end
191
+ end
192
+
193
+ class Collection < Aws::Resources::Collection; end
194
+ end
195
+ end
196
+ end