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,258 @@
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 ScalingPolicy
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 :policy_name :name
34
+
35
+ # The name of the Auto Scaling group associated with this scaling
36
+ # policy.
37
+ # @return [String]
38
+ def auto_scaling_group_name
39
+ data.auto_scaling_group_name
40
+ end
41
+
42
+ # The Amazon Resource Name (ARN) of the policy.
43
+ # @return [String]
44
+ def policy_arn
45
+ data.policy_arn
46
+ end
47
+
48
+ # The policy type. Valid values are `SimpleScaling` and `StepScaling`.
49
+ # @return [String]
50
+ def policy_type
51
+ data.policy_type
52
+ end
53
+
54
+ # The adjustment type, which specifies how `ScalingAdjustment` is
55
+ # interpreted. Valid values are `ChangeInCapacity`, `ExactCapacity`, and
56
+ # `PercentChangeInCapacity`.
57
+ # @return [String]
58
+ def adjustment_type
59
+ data.adjustment_type
60
+ end
61
+
62
+ # Available for backward compatibility. Use `MinAdjustmentMagnitude`
63
+ # instead.
64
+ # @return [Integer]
65
+ def min_adjustment_step
66
+ data.min_adjustment_step
67
+ end
68
+
69
+ # The minimum number of instances to scale. If the value of
70
+ # `AdjustmentType` is `PercentChangeInCapacity`, the scaling policy
71
+ # changes the `DesiredCapacity` of the Auto Scaling group by at least
72
+ # this many instances. Otherwise, the error is `ValidationError`.
73
+ # @return [Integer]
74
+ def min_adjustment_magnitude
75
+ data.min_adjustment_magnitude
76
+ end
77
+
78
+ # The amount by which to scale, based on the specified adjustment type.
79
+ # A positive value adds to the current capacity while a negative number
80
+ # removes from the current capacity.
81
+ # @return [Integer]
82
+ def scaling_adjustment
83
+ data.scaling_adjustment
84
+ end
85
+
86
+ # The amount of time, in seconds, after a scaling activity completes
87
+ # before any further trigger-related scaling activities can start.
88
+ # @return [Integer]
89
+ def cooldown
90
+ data.cooldown
91
+ end
92
+
93
+ # A set of adjustments that enable you to scale based on the size of the
94
+ # alarm breach.
95
+ # @return [Array<Types::StepAdjustment>]
96
+ def step_adjustments
97
+ data.step_adjustments
98
+ end
99
+
100
+ # The aggregation type for the CloudWatch metrics. Valid values are
101
+ # `Minimum`, `Maximum`, and `Average`.
102
+ # @return [String]
103
+ def metric_aggregation_type
104
+ data.metric_aggregation_type
105
+ end
106
+
107
+ # The estimated time, in seconds, until a newly launched instance can
108
+ # contribute to the CloudWatch metrics.
109
+ # @return [Integer]
110
+ def estimated_instance_warmup
111
+ data.estimated_instance_warmup
112
+ end
113
+
114
+ # The CloudWatch alarms related to the policy.
115
+ # @return [Array<Types::Alarm>]
116
+ def alarms
117
+ data.alarms
118
+ end
119
+
120
+ # @!endgroup
121
+
122
+ # @return [Client]
123
+ def client
124
+ @client
125
+ end
126
+
127
+ # Loads, or reloads {#data} for the current {ScalingPolicy}.
128
+ # Returns `self` making it possible to chain methods.
129
+ #
130
+ # scaling_policy.reload.data
131
+ #
132
+ # @return [self]
133
+ def load
134
+ resp = @client.describe_policies(policy_names: [@name])
135
+ @data = resp.scalingpolicies[0]
136
+ self
137
+ end
138
+ alias :reload :load
139
+
140
+ # @return [Types::ScalingPolicy]
141
+ # Returns the data for this {ScalingPolicy}. Calls
142
+ # {Client#describe_policies} 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
+ # scaling_policy.delete({
160
+ # auto_scaling_group_name: "ResourceName",
161
+ # })
162
+ # @param [Hash] options ({})
163
+ # @option options [String] :auto_scaling_group_name
164
+ # The name of the Auto Scaling group.
165
+ # @return [EmptyStructure]
166
+ def delete(options = {})
167
+ options = options.merge(policy_name: @name)
168
+ resp = @client.delete_policy(options)
169
+ resp.data
170
+ end
171
+
172
+ # @example Request syntax with placeholder values
173
+ #
174
+ # scaling_policy.execute({
175
+ # auto_scaling_group_name: "ResourceName",
176
+ # honor_cooldown: false,
177
+ # metric_value: 1.0,
178
+ # breach_threshold: 1.0,
179
+ # })
180
+ # @param [Hash] options ({})
181
+ # @option options [String] :auto_scaling_group_name
182
+ # The name or Amazon Resource Name (ARN) of the Auto Scaling group.
183
+ # @option options [Boolean] :honor_cooldown
184
+ # If this parameter is true, Auto Scaling waits for the cooldown period
185
+ # to complete before executing the policy. Otherwise, Auto Scaling
186
+ # executes the policy without waiting for the cooldown period to
187
+ # complete.
188
+ #
189
+ # This parameter is not supported if the policy type is `StepScaling`.
190
+ #
191
+ # For more information, see [Auto Scaling Cooldowns][1] in the *Auto
192
+ # Scaling User Guide*.
193
+ #
194
+ #
195
+ #
196
+ # [1]: http://docs.aws.amazon.com/autoscaling/latest/userguide/Cooldown.html
197
+ # @option options [Float] :metric_value
198
+ # The metric value to compare to `BreachThreshold`. This enables you to
199
+ # execute a policy of type `StepScaling` and determine which step
200
+ # adjustment to use. For example, if the breach threshold is 50 and you
201
+ # want to use a step adjustment with a lower bound of 0 and an upper
202
+ # bound of 10, you can set the metric value to 59.
203
+ #
204
+ # If you specify a metric value that doesn't correspond to a step
205
+ # adjustment for the policy, the call returns an error.
206
+ #
207
+ # This parameter is required if the policy type is `StepScaling` and not
208
+ # supported otherwise.
209
+ # @option options [Float] :breach_threshold
210
+ # The breach threshold for the alarm.
211
+ #
212
+ # This parameter is required if the policy type is `StepScaling` and not
213
+ # supported otherwise.
214
+ # @return [EmptyStructure]
215
+ def execute(options = {})
216
+ options = options.merge(policy_name: @name)
217
+ resp = @client.execute_policy(options)
218
+ resp.data
219
+ end
220
+
221
+ # @!group Associations
222
+
223
+ # @return [AutoScalingGroup, nil]
224
+ def group
225
+ if data.auto_scaling_group_name
226
+ AutoScalingGroup.new(
227
+ name: data.auto_scaling_group_name,
228
+ client: @client
229
+ )
230
+ else
231
+ nil
232
+ end
233
+ end
234
+
235
+ # @deprecated
236
+ # @api private
237
+ def identifiers
238
+ { name: @name }
239
+ end
240
+ deprecated(:identifiers)
241
+
242
+ private
243
+
244
+ def extract_name(args, options)
245
+ value = args[0] || options.delete(:name)
246
+ case value
247
+ when String then value
248
+ when nil then raise ArgumentError, "missing required option :name"
249
+ else
250
+ msg = "expected :name to be a String, got #{value.class}"
251
+ raise ArgumentError, msg
252
+ end
253
+ end
254
+
255
+ class Collection < Aws::Resources::Collection; end
256
+ end
257
+ end
258
+ end
@@ -0,0 +1,183 @@
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 ScheduledAction
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 :scheduled_action_name :name
34
+
35
+ # The name of the group.
36
+ # @return [String]
37
+ def auto_scaling_group_name
38
+ data.auto_scaling_group_name
39
+ end
40
+
41
+ # The Amazon Resource Name (ARN) of the scheduled action.
42
+ # @return [String]
43
+ def scheduled_action_arn
44
+ data.scheduled_action_arn
45
+ end
46
+
47
+ # This parameter is deprecated.
48
+ # @return [Time]
49
+ def time
50
+ data.time
51
+ end
52
+
53
+ # The date and time that the action is scheduled to begin. This date and
54
+ # time can be up to one month in the future.
55
+ #
56
+ # When `StartTime` and `EndTime` are specified with `Recurrence`, they
57
+ # form the boundaries of when the recurring action will start and stop.
58
+ # @return [Time]
59
+ def start_time
60
+ data.start_time
61
+ end
62
+
63
+ # The date and time that the action is scheduled to end. This date and
64
+ # time can be up to one month in the future.
65
+ # @return [Time]
66
+ def end_time
67
+ data.end_time
68
+ end
69
+
70
+ # The recurring schedule for the action.
71
+ # @return [String]
72
+ def recurrence
73
+ data.recurrence
74
+ end
75
+
76
+ # The minimum size of the group.
77
+ # @return [Integer]
78
+ def min_size
79
+ data.min_size
80
+ end
81
+
82
+ # The maximum size of the group.
83
+ # @return [Integer]
84
+ def max_size
85
+ data.max_size
86
+ end
87
+
88
+ # The number of instances you prefer to maintain in the group.
89
+ # @return [Integer]
90
+ def desired_capacity
91
+ data.desired_capacity
92
+ end
93
+
94
+ # @!endgroup
95
+
96
+ # @return [Client]
97
+ def client
98
+ @client
99
+ end
100
+
101
+ # Loads, or reloads {#data} for the current {ScheduledAction}.
102
+ # Returns `self` making it possible to chain methods.
103
+ #
104
+ # scheduled_action.reload.data
105
+ #
106
+ # @return [self]
107
+ def load
108
+ resp = @client.describe_scheduled_actions(scheduled_action_names: [@name])
109
+ @data = resp.scheduledupdategroupactions[0]
110
+ self
111
+ end
112
+ alias :reload :load
113
+
114
+ # @return [Types::ScheduledUpdateGroupAction]
115
+ # Returns the data for this {ScheduledAction}. Calls
116
+ # {Client#describe_scheduled_actions} if {#data_loaded?} is `false`.
117
+ def data
118
+ load unless @data
119
+ @data
120
+ end
121
+
122
+ # @return [Boolean]
123
+ # Returns `true` if this resource is loaded. Accessing attributes or
124
+ # {#data} on an unloaded resource will trigger a call to {#load}.
125
+ def data_loaded?
126
+ !!@data
127
+ end
128
+
129
+ # @!group Actions
130
+
131
+ # @example Request syntax with placeholder values
132
+ #
133
+ # scheduled_action.delete({
134
+ # auto_scaling_group_name: "ResourceName", # required
135
+ # })
136
+ # @param [Hash] options ({})
137
+ # @option options [required, String] :auto_scaling_group_name
138
+ # The name of the Auto Scaling group.
139
+ # @return [EmptyStructure]
140
+ def delete(options = {})
141
+ options = options.merge(scheduled_action_name: @name)
142
+ resp = @client.delete_scheduled_action(options)
143
+ resp.data
144
+ end
145
+
146
+ # @!group Associations
147
+
148
+ # @return [AutoScalingGroup, nil]
149
+ def group
150
+ if data.auto_scaling_group_name
151
+ AutoScalingGroup.new(
152
+ name: data.auto_scaling_group_name,
153
+ client: @client
154
+ )
155
+ else
156
+ nil
157
+ end
158
+ end
159
+
160
+ # @deprecated
161
+ # @api private
162
+ def identifiers
163
+ { name: @name }
164
+ end
165
+ deprecated(:identifiers)
166
+
167
+ private
168
+
169
+ def extract_name(args, options)
170
+ value = args[0] || options.delete(:name)
171
+ case value
172
+ when String then value
173
+ when nil then raise ArgumentError, "missing required option :name"
174
+ else
175
+ msg = "expected :name to be a String, got #{value.class}"
176
+ raise ArgumentError, msg
177
+ end
178
+ end
179
+
180
+ class Collection < Aws::Resources::Collection; end
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,260 @@
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 Tag
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(key, resource_id, resource_type, options = {})
15
+ # @param [String] key
16
+ # @param [String] resource_id
17
+ # @param [String] resource_type
18
+ # @option options [Client] :client
19
+ # @overload def initialize(options = {})
20
+ # @option options [required, String] :key
21
+ # @option options [required, String] :resource_id
22
+ # @option options [required, String] :resource_type
23
+ # @option options [Client] :client
24
+ def initialize(*args)
25
+ options = Hash === args.last ? args.pop.dup : {}
26
+ @key = extract_key(args, options)
27
+ @resource_id = extract_resource_id(args, options)
28
+ @resource_type = extract_resource_type(args, options)
29
+ @data = options.delete(:data)
30
+ @client = options.delete(:client) || Client.new(options)
31
+ end
32
+
33
+ # @!group Read-Only Attributes
34
+
35
+ # @return [String]
36
+ def key
37
+ @key
38
+ end
39
+
40
+ # @return [String]
41
+ def resource_id
42
+ @resource_id
43
+ end
44
+
45
+ # @return [String]
46
+ def resource_type
47
+ @resource_type
48
+ end
49
+
50
+ # The tag value.
51
+ # @return [String]
52
+ def value
53
+ data.value
54
+ end
55
+
56
+ # Determines whether the tag is added to new instances as they are
57
+ # launched in the group.
58
+ # @return [Boolean]
59
+ def propagate_at_launch
60
+ data.propagate_at_launch
61
+ end
62
+
63
+ # @!endgroup
64
+
65
+ # @return [Client]
66
+ def client
67
+ @client
68
+ end
69
+
70
+ # Loads, or reloads {#data} for the current {Tag}.
71
+ # Returns `self` making it possible to chain methods.
72
+ #
73
+ # tag.reload.data
74
+ #
75
+ # @return [self]
76
+ def load
77
+ resp = @client.describe_tags(filters: [
78
+ {
79
+ name: "key",
80
+ values: [@key]
81
+ },
82
+ {
83
+ name: @resource_type,
84
+ values: [@resource_id]
85
+ }
86
+ ])
87
+ @data = resp.tags[0]
88
+ self
89
+ end
90
+ alias :reload :load
91
+
92
+ # @return [Types::TagDescription]
93
+ # Returns the data for this {Tag}. Calls
94
+ # {Client#describe_tags} if {#data_loaded?} is `false`.
95
+ def data
96
+ load unless @data
97
+ @data
98
+ end
99
+
100
+ # @return [Boolean]
101
+ # Returns `true` if this resource is loaded. Accessing attributes or
102
+ # {#data} on an unloaded resource will trigger a call to {#load}.
103
+ def data_loaded?
104
+ !!@data
105
+ end
106
+
107
+ # @!group Actions
108
+
109
+ # @example Request syntax with placeholder values
110
+ #
111
+ # tag.create({
112
+ # tags: [ # required
113
+ # {
114
+ # resource_id: "XmlString",
115
+ # resource_type: "XmlString",
116
+ # key: "TagKey", # required
117
+ # value: "TagValue",
118
+ # propagate_at_launch: false,
119
+ # },
120
+ # ],
121
+ # })
122
+ # @param [Hash] options ({})
123
+ # @option options [required, Array<Types::Tag>] :tags
124
+ # One or more tags.
125
+ # @return [EmptyStructure]
126
+ def create(options = {})
127
+ options = Aws::Util.deep_merge(options, tags: [{
128
+ resource_type: @resource_type,
129
+ resource_id: @resource_id,
130
+ key: @key
131
+ }])
132
+ resp = @client.create_or_update_tags(options)
133
+ resp.data
134
+ end
135
+
136
+ # @example Request syntax with placeholder values
137
+ #
138
+ # tag.delete({
139
+ # tags: [ # required
140
+ # {
141
+ # resource_id: "XmlString",
142
+ # resource_type: "XmlString",
143
+ # key: "TagKey", # required
144
+ # value: "TagValue",
145
+ # propagate_at_launch: false,
146
+ # },
147
+ # ],
148
+ # })
149
+ # @param [Hash] options ({})
150
+ # @option options [required, Array<Types::Tag>] :tags
151
+ # One or more tags.
152
+ # @return [EmptyStructure]
153
+ def delete(options = {})
154
+ options = Aws::Util.deep_merge(options, tags: [{
155
+ resource_type: @resource_type,
156
+ resource_id: @resource_id,
157
+ key: @key
158
+ }])
159
+ resp = @client.delete_tags(options)
160
+ resp.data
161
+ end
162
+
163
+ # @deprecated
164
+ # @api private
165
+ def identifiers
166
+ {
167
+ key: @key,
168
+ resource_id: @resource_id,
169
+ resource_type: @resource_type
170
+ }
171
+ end
172
+ deprecated(:identifiers)
173
+
174
+ private
175
+
176
+ def extract_key(args, options)
177
+ value = args[0] || options.delete(:key)
178
+ case value
179
+ when String then value
180
+ when nil then raise ArgumentError, "missing required option :key"
181
+ else
182
+ msg = "expected :key to be a String, got #{value.class}"
183
+ raise ArgumentError, msg
184
+ end
185
+ end
186
+
187
+ def extract_resource_id(args, options)
188
+ value = args[1] || options.delete(:resource_id)
189
+ case value
190
+ when String then value
191
+ when nil then raise ArgumentError, "missing required option :resource_id"
192
+ else
193
+ msg = "expected :resource_id to be a String, got #{value.class}"
194
+ raise ArgumentError, msg
195
+ end
196
+ end
197
+
198
+ def extract_resource_type(args, options)
199
+ value = args[2] || options.delete(:resource_type)
200
+ case value
201
+ when String then value
202
+ when nil then raise ArgumentError, "missing required option :resource_type"
203
+ else
204
+ msg = "expected :resource_type to be a String, got #{value.class}"
205
+ raise ArgumentError, msg
206
+ end
207
+ end
208
+
209
+ class Collection < Aws::Resources::Collection
210
+
211
+ # @!group Batch Actions
212
+
213
+ # @example Request syntax with placeholder values
214
+ #
215
+ # tag.batch_create()
216
+ # @param options ({})
217
+ # @return [void]
218
+ def batch_create(options = {})
219
+ batch_enum.each do |batch|
220
+ params = Aws::Util.copy_hash(options)
221
+ params[:tags] ||= []
222
+ batch.each do |item|
223
+ params[:tags] << {
224
+ resource_type: item.resource_type,
225
+ resource_id: item.resource_id,
226
+ key: item.key
227
+ }
228
+ end
229
+ batch[0].client.create_or_update_tags(params)
230
+ end
231
+ nil
232
+ end
233
+
234
+ # @example Request syntax with placeholder values
235
+ #
236
+ # tag.batch_delete!()
237
+ # @param options ({})
238
+ # @return [void]
239
+ def batch_delete!(options = {})
240
+ batch_enum.each do |batch|
241
+ params = Aws::Util.copy_hash(options)
242
+ params[:tags] ||= []
243
+ batch.each do |item|
244
+ params[:tags] << {
245
+ resource_type: item.resource_type,
246
+ resource_id: item.resource_id,
247
+ key: item.key
248
+ }
249
+ end
250
+ batch[0].client.delete_tags(params)
251
+ end
252
+ nil
253
+ end
254
+
255
+ # @!endgroup
256
+
257
+ end
258
+ end
259
+ end
260
+ end