You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

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:



79
80
81
82
83
84
85
86
87
88
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 79

def [] name
  if group_name = @filters[:auto_scaling_group_name]
    group = Group.new(group_name, :config => config)
    ScheduledAction.new(group, name)
  else
    msg = 'uou must filter this collection by a group to get a ' +
      'scheduled action by name'
    raise msg
  end
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
73
74
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 63

def create name, options = {}

  group = auto_scaling_group(options)

  scheduled_action = ScheduledAction.new(group, name,
    :auto_scaling_group_name => group.name,
    :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.



129
130
131
132
133
134
135
# File 'lib/aws/auto_scaling/scheduled_action_collection.rb', line 129

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