aws-sdk-autoscaling 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,329 @@
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 AutoScaling
10
+ class LifecycleHook
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
+ alias :auto_scaling_group_name :group_name
37
+
38
+ # @return [String]
39
+ def name
40
+ @name
41
+ end
42
+ alias :lifecycle_hook_name :name
43
+
44
+ # The state of the EC2 instance to which you want to attach the
45
+ # lifecycle hook. For a list of lifecycle hook types, see
46
+ # DescribeLifecycleHookTypes.
47
+ # @return [String]
48
+ def lifecycle_transition
49
+ data.lifecycle_transition
50
+ end
51
+
52
+ # The ARN of the notification target that Auto Scaling uses to notify
53
+ # you when an instance is in the transition state for the lifecycle
54
+ # hook. This ARN target can be either an SQS queue or an SNS topic. The
55
+ # notification message sent to the target includes the following:
56
+ #
57
+ # * Lifecycle action token
58
+ #
59
+ # * User account ID
60
+ #
61
+ # * Name of the Auto Scaling group
62
+ #
63
+ # * Lifecycle hook name
64
+ #
65
+ # * EC2 instance ID
66
+ #
67
+ # * Lifecycle transition
68
+ #
69
+ # * Notification metadata
70
+ # @return [String]
71
+ def notification_target_arn
72
+ data.notification_target_arn
73
+ end
74
+
75
+ # The ARN of the IAM role that allows the Auto Scaling group to publish
76
+ # to the specified notification target.
77
+ # @return [String]
78
+ def role_arn
79
+ data.role_arn
80
+ end
81
+
82
+ # Additional information that you want to include any time Auto Scaling
83
+ # sends a message to the notification target.
84
+ # @return [String]
85
+ def notification_metadata
86
+ data.notification_metadata
87
+ end
88
+
89
+ # The maximum time, in seconds, that can elapse before the lifecycle
90
+ # hook times out. The default is 3600 seconds (1 hour). When the
91
+ # lifecycle hook times out, Auto Scaling performs the default action.
92
+ # You can prevent the lifecycle hook from timing out by calling
93
+ # RecordLifecycleActionHeartbeat.
94
+ # @return [Integer]
95
+ def heartbeat_timeout
96
+ data.heartbeat_timeout
97
+ end
98
+
99
+ # The maximum time, in seconds, that an instance can remain in a
100
+ # `Pending:Wait` or `Terminating:Wait` state. The maximum is 172800
101
+ # seconds (48 hours) or 100 times `HeartbeatTimeout`, whichever is
102
+ # smaller.
103
+ # @return [Integer]
104
+ def global_timeout
105
+ data.global_timeout
106
+ end
107
+
108
+ # Defines the action the Auto Scaling group should take when the
109
+ # lifecycle hook timeout elapses or if an unexpected failure occurs. The
110
+ # valid values are `CONTINUE` and `ABANDON`. The default value is
111
+ # `CONTINUE`.
112
+ # @return [String]
113
+ def default_result
114
+ data.default_result
115
+ end
116
+
117
+ # @!endgroup
118
+
119
+ # @return [Client]
120
+ def client
121
+ @client
122
+ end
123
+
124
+ # Loads, or reloads {#data} for the current {LifecycleHook}.
125
+ # Returns `self` making it possible to chain methods.
126
+ #
127
+ # lifecycle_hook.reload.data
128
+ #
129
+ # @return [self]
130
+ def load
131
+ resp = @client.describe_lifecycle_hooks(
132
+ auto_scaling_group_name: @group_name,
133
+ lifecycle_hook_names: [@name]
134
+ )
135
+ @data = resp.lifecyclehooks[0]
136
+ self
137
+ end
138
+ alias :reload :load
139
+
140
+ # @return [Types::LifecycleHook]
141
+ # Returns the data for this {LifecycleHook}. Calls
142
+ # {Client#describe_lifecycle_hooks} if {#data_loaded?} is `false`.
143
+ def data
144
+ load unless @data
145
+ @data
146
+ end
147
+
148
+ # @return [Boolean]
149
+ # Returns `true` if this resource is loaded. Accessing attributes or
150
+ # {#data} on an unloaded resource will trigger a call to {#load}.
151
+ def data_loaded?
152
+ !!@data
153
+ end
154
+
155
+ # @!group Actions
156
+
157
+ # @example Request syntax with placeholder values
158
+ #
159
+ # lifecycle_hook.complete({
160
+ # lifecycle_action_token: "LifecycleActionToken",
161
+ # lifecycle_action_result: "LifecycleActionResult", # required
162
+ # instance_id: "XmlStringMaxLen19",
163
+ # })
164
+ # @param [Hash] options ({})
165
+ # @option options [String] :lifecycle_action_token
166
+ # A universally unique identifier (UUID) that identifies a specific
167
+ # lifecycle action associated with an instance. Auto Scaling sends this
168
+ # token to the notification target you specified when you created the
169
+ # lifecycle hook.
170
+ # @option options [required, String] :lifecycle_action_result
171
+ # The action for the group to take. This parameter can be either
172
+ # `CONTINUE` or `ABANDON`.
173
+ # @option options [String] :instance_id
174
+ # The ID of the instance.
175
+ # @return [Types::CompleteLifecycleActionAnswer]
176
+ def complete(options = {})
177
+ options = options.merge(
178
+ auto_scaling_group_name: @group_name,
179
+ lifecycle_hook_name: @name
180
+ )
181
+ resp = @client.complete_lifecycle_action(options)
182
+ resp.data
183
+ end
184
+
185
+ # @example Request syntax with placeholder values
186
+ #
187
+ # lifecycle_hook.delete()
188
+ # @param [Hash] options ({})
189
+ # @return [Types::DeleteLifecycleHookAnswer]
190
+ def delete(options = {})
191
+ options = options.merge(
192
+ auto_scaling_group_name: @group_name,
193
+ lifecycle_hook_name: @name
194
+ )
195
+ resp = @client.delete_lifecycle_hook(options)
196
+ resp.data
197
+ end
198
+
199
+ # @example Request syntax with placeholder values
200
+ #
201
+ # lifecycle_hook.put({
202
+ # lifecycle_transition: "LifecycleTransition",
203
+ # role_arn: "ResourceName",
204
+ # notification_target_arn: "NotificationTargetResourceName",
205
+ # notification_metadata: "XmlStringMaxLen1023",
206
+ # heartbeat_timeout: 1,
207
+ # default_result: "LifecycleActionResult",
208
+ # })
209
+ # @param [Hash] options ({})
210
+ # @option options [String] :lifecycle_transition
211
+ # The instance state to which you want to attach the lifecycle hook. For
212
+ # a list of lifecycle hook types, see DescribeLifecycleHookTypes.
213
+ #
214
+ # This parameter is required for new lifecycle hooks, but optional when
215
+ # updating existing hooks.
216
+ # @option options [String] :role_arn
217
+ # The ARN of the IAM role that allows the Auto Scaling group to publish
218
+ # to the specified notification target.
219
+ #
220
+ # This parameter is required for new lifecycle hooks, but optional when
221
+ # updating existing hooks.
222
+ # @option options [String] :notification_target_arn
223
+ # The ARN of the notification target that Auto Scaling will use to
224
+ # notify you when an instance is in the transition state for the
225
+ # lifecycle hook. This target can be either an SQS queue or an SNS
226
+ # topic. If you specify an empty string, this overrides the current ARN.
227
+ #
228
+ # This operation uses the JSON format when sending notifications to an
229
+ # Amazon SQS queue, and an email key/value pair format when sending
230
+ # notifications to an Amazon SNS topic.
231
+ #
232
+ # When you specify a notification target, Auto Scaling sends it a test
233
+ # message. Test messages contains the following additional key/value
234
+ # pair: `"Event": "autoscaling:TEST_NOTIFICATION"`.
235
+ # @option options [String] :notification_metadata
236
+ # Contains additional information that you want to include any time Auto
237
+ # Scaling sends a message to the notification target.
238
+ # @option options [Integer] :heartbeat_timeout
239
+ # The amount of time, in seconds, that can elapse before the lifecycle
240
+ # hook times out. When the lifecycle hook times out, Auto Scaling
241
+ # performs the default action. You can prevent the lifecycle hook from
242
+ # timing out by calling RecordLifecycleActionHeartbeat. The default is
243
+ # 3600 seconds (1 hour).
244
+ # @option options [String] :default_result
245
+ # Defines the action the Auto Scaling group should take when the
246
+ # lifecycle hook timeout elapses or if an unexpected failure occurs.
247
+ # This parameter can be either `CONTINUE` or `ABANDON`. The default
248
+ # value is `ABANDON`.
249
+ # @return [Types::PutLifecycleHookAnswer]
250
+ def put(options = {})
251
+ options = options.merge(
252
+ auto_scaling_group_name: @group_name,
253
+ lifecycle_hook_name: @name
254
+ )
255
+ resp = @client.put_lifecycle_hook(options)
256
+ resp.data
257
+ end
258
+
259
+ # @example Request syntax with placeholder values
260
+ #
261
+ # lifecycle_hook.record_heartbeat({
262
+ # lifecycle_action_token: "LifecycleActionToken",
263
+ # instance_id: "XmlStringMaxLen19",
264
+ # })
265
+ # @param [Hash] options ({})
266
+ # @option options [String] :lifecycle_action_token
267
+ # A token that uniquely identifies a specific lifecycle action
268
+ # associated with an instance. Auto Scaling sends this token to the
269
+ # notification target you specified when you created the lifecycle hook.
270
+ # @option options [String] :instance_id
271
+ # The ID of the instance.
272
+ # @return [Types::RecordLifecycleActionHeartbeatAnswer]
273
+ def record_heartbeat(options = {})
274
+ options = options.merge(
275
+ auto_scaling_group_name: @group_name,
276
+ lifecycle_hook_name: @name
277
+ )
278
+ resp = @client.record_lifecycle_action_heartbeat(options)
279
+ resp.data
280
+ end
281
+
282
+ # @!group Associations
283
+
284
+ # @return [AutoScalingGroup]
285
+ def group
286
+ AutoScalingGroup.new(
287
+ name: @group_name,
288
+ client: @client
289
+ )
290
+ end
291
+
292
+ # @deprecated
293
+ # @api private
294
+ def identifiers
295
+ {
296
+ group_name: @group_name,
297
+ name: @name
298
+ }
299
+ end
300
+ deprecated(:identifiers)
301
+
302
+ private
303
+
304
+ def extract_group_name(args, options)
305
+ value = args[0] || options.delete(:group_name)
306
+ case value
307
+ when String then value
308
+ when nil then raise ArgumentError, "missing required option :group_name"
309
+ else
310
+ msg = "expected :group_name to be a String, got #{value.class}"
311
+ raise ArgumentError, msg
312
+ end
313
+ end
314
+
315
+ def extract_name(args, options)
316
+ value = args[1] || options.delete(:name)
317
+ case value
318
+ when String then value
319
+ when nil then raise ArgumentError, "missing required option :name"
320
+ else
321
+ msg = "expected :name to be a String, got #{value.class}"
322
+ raise ArgumentError, msg
323
+ end
324
+ end
325
+
326
+ class Collection < Aws::Resources::Collection; end
327
+ end
328
+ end
329
+ end
@@ -0,0 +1,219 @@
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 AutoScaling
10
+ class LoadBalancer
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 :load_balancer_name :name
42
+
43
+ # One of the following load balancer states:
44
+ #
45
+ # * `Adding` - The instances in the group are being registered with the
46
+ # load balancer.
47
+ #
48
+ # * `Added` - All instances in the group are registered with the load
49
+ # balancer.
50
+ #
51
+ # * `InService` - At least one instance in the group passed an ELB
52
+ # health check.
53
+ #
54
+ # * `Removing` - The instances in the group are being deregistered from
55
+ # the load balancer. If connection draining is enabled, Elastic Load
56
+ # Balancing waits for in-flight requests to complete before
57
+ # deregistering the instances.
58
+ #
59
+ # * `Removed` - All instances in the group are deregistered from the
60
+ # load balancer.
61
+ # @return [String]
62
+ def state
63
+ data.state
64
+ end
65
+
66
+ # @!endgroup
67
+
68
+ # @return [Client]
69
+ def client
70
+ @client
71
+ end
72
+
73
+ # @raise [Errors::ResourceNotLoadable]
74
+ # @api private
75
+ def load
76
+ msg = "#load is not implemented, data only available via enumeration"
77
+ raise Errors::ResourceNotLoadable, msg
78
+ end
79
+ alias :reload :load
80
+
81
+ # @raise [Errors::ResourceNotLoadableError] Raises when {#data_loaded?} is `false`.
82
+ # @return [Types::LoadBalancerState]
83
+ # Returns the data for this {LoadBalancer}.
84
+ def data
85
+ load unless @data
86
+ @data
87
+ end
88
+
89
+ # @return [Boolean]
90
+ # Returns `true` if this resource is loaded. Accessing attributes or
91
+ # {#data} on an unloaded resource will trigger a call to {#load}.
92
+ def data_loaded?
93
+ !!@data
94
+ end
95
+
96
+ # @!group Actions
97
+
98
+ # @example Request syntax with placeholder values
99
+ #
100
+ # load_balancer.attach()
101
+ # @param [Hash] options ({})
102
+ # @return [Types::AttachLoadBalancersResultType]
103
+ def attach(options = {})
104
+ options = Aws::Util.deep_merge(options,
105
+ auto_scaling_group_name: @group_name,
106
+ load_balancer_names: [@name]
107
+ )
108
+ resp = @client.attach_load_balancers(options)
109
+ resp.data
110
+ end
111
+
112
+ # @example Request syntax with placeholder values
113
+ #
114
+ # load_balancer.detach()
115
+ # @param [Hash] options ({})
116
+ # @return [Types::DetachLoadBalancersResultType]
117
+ def detach(options = {})
118
+ options = Aws::Util.deep_merge(options,
119
+ auto_scaling_group_name: @group_name,
120
+ load_balancer_names: [@name]
121
+ )
122
+ resp = @client.detach_load_balancers(options)
123
+ resp.data
124
+ end
125
+
126
+ # @!group Associations
127
+
128
+ # @return [AutoScalingGroup]
129
+ def group
130
+ AutoScalingGroup.new(
131
+ name: @group_name,
132
+ client: @client
133
+ )
134
+ end
135
+
136
+ # @deprecated
137
+ # @api private
138
+ def identifiers
139
+ {
140
+ group_name: @group_name,
141
+ name: @name
142
+ }
143
+ end
144
+ deprecated(:identifiers)
145
+
146
+ private
147
+
148
+ def extract_group_name(args, options)
149
+ value = args[0] || options.delete(:group_name)
150
+ case value
151
+ when String then value
152
+ when nil then raise ArgumentError, "missing required option :group_name"
153
+ else
154
+ msg = "expected :group_name to be a String, got #{value.class}"
155
+ raise ArgumentError, msg
156
+ end
157
+ end
158
+
159
+ def extract_name(args, options)
160
+ value = args[1] || options.delete(:name)
161
+ case value
162
+ when String then value
163
+ when nil then raise ArgumentError, "missing required option :name"
164
+ else
165
+ msg = "expected :name to be a String, got #{value.class}"
166
+ raise ArgumentError, msg
167
+ end
168
+ end
169
+
170
+ class Collection < Aws::Resources::Collection
171
+
172
+ # @!group Batch Actions
173
+
174
+ # @example Request syntax with placeholder values
175
+ #
176
+ # load_balancer.batch_attach()
177
+ # @param options ({})
178
+ # @return [void]
179
+ def batch_attach(options = {})
180
+ batch_enum.each do |batch|
181
+ params = Aws::Util.copy_hash(options)
182
+ params[:auto_scaling_group_name] = batch[0].group_name
183
+ params[:load_balancer_names] ||= []
184
+ batch.each do |item|
185
+ params[:load_balancer_names] << {
186
+ name: item.name
187
+ }
188
+ end
189
+ batch[0].client.attach_load_balancers(params)
190
+ end
191
+ nil
192
+ end
193
+
194
+ # @example Request syntax with placeholder values
195
+ #
196
+ # load_balancer.batch_detach()
197
+ # @param options ({})
198
+ # @return [void]
199
+ def batch_detach(options = {})
200
+ batch_enum.each do |batch|
201
+ params = Aws::Util.copy_hash(options)
202
+ params[:auto_scaling_group_name] = batch[0].group_name
203
+ params[:load_balancer_names] ||= []
204
+ batch.each do |item|
205
+ params[:load_balancer_names] << {
206
+ name: item.name
207
+ }
208
+ end
209
+ batch[0].client.detach_load_balancers(params)
210
+ end
211
+ nil
212
+ end
213
+
214
+ # @!endgroup
215
+
216
+ end
217
+ end
218
+ end
219
+ end