Class: Fog::AWS::AutoScaling::Policy

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/auto_scaling/policy.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

#initialize(attributes) ⇒ Policy

Returns a new instance of Policy.



16
17
18
19
20
# File 'lib/fog/aws/models/auto_scaling/policy.rb', line 16

def initialize(attributes)
  attributes['AdjustmentType']    ||= 'ChangeInCapacity'
  attributes['ScalingAdjustment'] ||= 1
  super
end

Instance Method Details

#destroyObject



38
39
40
41
42
# File 'lib/fog/aws/models/auto_scaling/policy.rb', line 38

def destroy
  requires :id
  requires :auto_scaling_group_name
  connection.delete_policy(auto_scaling_group_name, id)
end

#saveObject

TODO: implement #alarms TODO: implement #auto_scaling_group



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/aws/models/auto_scaling/policy.rb', line 25

def save
  requires :id
  requires :adjustment_type
  requires :auto_scaling_group_name
  requires :scaling_adjustment

  options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
  options.delete_if { |key, value| value.nil? }

  connection.put_scaling_policy(adjustment_type, auto_scaling_group_name, id, scaling_adjustment, options)
  reload
end