Sha256: 3f023054ff3eeb62e5811c0d8710d6c97b0f98ae019b64a0c8fd194e6cae51f0

Contents?: true

Size: 1.53 KB

Versions: 87

Compression:

Stored size: 1.53 KB

Contents

require 'fog/core/model'

module Fog
  module AWS
    class AutoScaling
      class Policy < Fog::Model
        identity :id,                       :aliases => 'PolicyName'
        attribute :arn,                     :aliases => 'PolicyARN'
        attribute :adjustment_type,         :aliases => 'AdjustmentType'
        attribute :alarms,                  :aliases => 'Alarms'
        attribute :auto_scaling_group_name, :aliases => 'AutoScalingGroupName'
        attribute :cooldown,                :aliases => 'Cooldown'
        attribute :min_adjustment_step,     :aliases => 'MinAdjustmentStep'
        attribute :scaling_adjustment,      :aliases => 'ScalingAdjustment'

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

        # TODO: implement #alarms
        # TODO: implement #auto_scaling_group

        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? }

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

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

Version data entries

87 entries across 87 versions & 10 rubygems

Version Path
fog-maestrodev-1.18.0.20131218202447 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131126122111 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131125111730 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131125083406 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131123105121 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131122203507 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131121075022 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131118164830 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131115184302 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131114200144 lib/fog/aws/models/auto_scaling/policy.rb
gapinc-fog-1.12.1.2.1 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131112185232 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.18.0.20131111203459 lib/fog/aws/models/auto_scaling/policy.rb
fog-1.18.0 lib/fog/aws/models/auto_scaling/policy.rb