Class: AWS::AutoScaling::ScheduledActionCollection

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

Instance Method Summary collapse

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 explicitly
auto_scaling.scheduled_actions.create('action-name', :group => 'group-name')

# implied by the group
group = auto_scaling.groups.first
group.scheduled_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(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| ... }

Parameters:

  • filters (Hash) (defaults to: {})
  • options (Hash)

    a customizable set of options

Options Hash (filters):

  • :group (Group, String)
  • :scheduled_actions (Array<String>)

    A list of scheduled actions to be described. If this list is omitted, all scheduled actions are described. The list of requested scheduled actions cannot contain more than 50 items. If an Auto Scaling group name is provided, the results are limited to that group. If unknown scheduled actions are requested, they are ignored with no error.

  • :end_time (Time, String)

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 filters = {}
  init_opts = {}
  init_opts[:config] = config
  init_opts[:filters] = @filters
  init_opts[:filters].merge!(filter_opts(filters))
  ScheduledActionCollection.new(init_opts)
end