Class: AWS::AutoScaling::ScheduledActionCollection
- Inherits:
-
Object
- Object
- AWS::AutoScaling::ScheduledActionCollection
- Includes:
- Core::Collection::Limitable
- Defined in:
- lib/aws/auto_scaling/scheduled_action_collection.rb
Instance Attribute Summary
Attributes included from Core::Model
Instance Method Summary collapse
- #[](name) ⇒ ScheduledAction
-
#create(name, options = {}) ⇒ ScheduledAction
(also: #put)
Creates a scheduled scaling action for an Auto Scaling group.
-
#filter(filters = {}) ⇒ ScheduledActionCollection
Returns a new ScheduledActionCollection filtered by the given options.
-
#initialize(options = {}) ⇒ ScheduledActionCollection
constructor
A new instance of ScheduledActionCollection.
Methods included from Core::Collection::Limitable
Methods included from Core::Collection
#each, #each_batch, #enum, #first, #in_groups_of, #page
Methods included from Core::Model
#client, #config_prefix, #inspect
Constructor Details
#initialize(options = {}) ⇒ ScheduledActionCollection
Returns a new instance of ScheduledActionCollection.
24 25 26 27 |
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 24 def initialize = {} @filters = [:filters] || {} super end |
Instance Method Details
#[](name) ⇒ ScheduledAction
77 78 79 80 81 82 83 84 |
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 77 def [] name = {} [:config] = config if group = @filters[:auto_scaling_group_name] [:auto_scaling_group_name] = group end ScheduledAction.new(name, ) end |
#create(name, options = {}) ⇒ ScheduledAction Also known as: put
Creates a scheduled scaling action for an Auto Scaling group. If you leave a parameter unspecified, the corresponding attribute remains unchanged in the group.
You must specify an Auto Scaling group. This can be implicit or explicit:
# given explicity
auto_scaling.secheduled_actions.create('action-name', :group => 'group-name')
# implied by the group
group = auto_scaling.groups.first
group.secheduled_actions.create('action-name')
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 63 def create name, = {} scheduled_action = ScheduledAction.new(name, :auto_scaling_group_name => auto_scaling_group_name_opt(), :config => config) scheduled_action.update() scheduled_action end |
#filter(filters = {}) ⇒ ScheduledActionCollection
Returns a new AWS::AutoScaling::ScheduledActionCollection filtered by the given options.
auto_scaling.scheduled_actions.filter(:end_time => Time.now).each do |a|
# ...
end
You can chain filter calls:
actions = auto_scaling.scheduled_actions.
filter(:group => 'auto-scaling-group-name').
filter(:start_time => Time.now - 3600).
filter(:end_time => Time.now)
actions.each {|scheduled_action| ... }
125 126 127 128 129 130 131 |
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 125 def filter filters = {} init_opts = {} init_opts[:config] = config init_opts[:filters] = @filters init_opts[:filters].merge!(filter_opts(filters)) ScheduledActionCollection.new(init_opts) end |