Sha256: 67e820ac37bfb8627a156b9c5eca4a9174b1fe88af4c58dbf762e3049a83d684

Contents?: true

Size: 1.54 KB

Versions: 12

Compression:

Stored size: 1.54 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? }

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

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

Version data entries

12 entries across 12 versions & 7 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/aws/models/auto_scaling/policy.rb
fog-nirvanix-1.8.1 lib/fog/aws/models/auto_scaling/policy.rb
fog-parser-fix-1.6.1 lib/fog/aws/models/auto_scaling/policy.rb
fog-test-again-1.6.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-parser-fix-1.6.0 lib/fog/aws/models/auto_scaling/policy.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/aws/models/auto_scaling/policy.rb
fog-sgonyea-1.8.1 lib/fog/aws/models/auto_scaling/policy.rb
fog-1.8.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/aws/models/auto_scaling/policy.rb
fog-1.7.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-1.6.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-1.5.0 lib/fog/aws/models/auto_scaling/policy.rb