Class: AWS::AutoScaling::ScheduledActionCollection

Inherits:
Object
  • Object
show all
Includes:
Core::Collection::Limitable
Defined in:
lib/aws/auto_scaling/scheduled_action_collection.rb

Instance Method Summary collapse

Methods included from Core::Collection::Limitable

#each_batch

Methods included from Core::Collection

#each, #each_batch, #enum, #first, #in_groups_of, #page

Instance Method Details

#[](name) ⇒ ScheduledAction

Parameters:

  • name (String)

    The name of the scheduled action.

Returns:



77
78
79
80
81
82
83
84
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 77

def [] name
  options = {}
  options[:config] = config
  if group = @filters[:auto_scaling_group_name]
    options[:auto_scaling_group_name] = group
  end
  ScheduledAction.new(name, options)
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')

Parameters:

  • name (String)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :group (Group, String)
  • :desired_capacity (Integer)
  • :max_size (Integer)
  • :min_size (Integer)
  • :recurrence (String)
  • :start_time (Time)
  • :end_time (Time)

Returns:



63
64
65
66
67
68
69
70
71
72
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 63

def create name, options = {}
  
  scheduled_action = ScheduledAction.new(name, 
    :auto_scaling_group_name => auto_scaling_group_name_opt(options),
    :config => config)

  scheduled_action.update(options)
  scheduled_action

end

#filter(options = {}) ⇒ 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| ... }

Parameters:

  • filters (Hash)
  • opitons (Hash)

    a customizable set of options

Returns:

  • (ScheduledActionCollection)

    Returns a scheduled action collection that will filter the actions returned by the given criteria.



125
126
127
128
129
130
131
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 125

def filter options = {}
  init_opts = {}
  init_opts[:config] = config
  init_opts[:filters] = @filters
  init_opts[:filters].merge!(filter_opts(options))
  ScheduledActionCollection.new(init_opts)
end