Sha256: 825dd773ed31a99b192ee9275f8178b9275c740e2f5b87c831c7da6d4fa45635

Contents?: true

Size: 1.51 KB

Versions: 76

Compression:

Stored size: 1.51 KB

Contents

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

76 entries across 74 versions & 3 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.29.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.28.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.27.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.26.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.25.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.24.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.23.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.22.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.21.1 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.21.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.20.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.19.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.18.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.17.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.16.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.15.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.14.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.13.0 lib/fog/aws/models/auto_scaling/policy.rb
fog-aws-3.12.0 lib/fog/aws/models/auto_scaling/policy.rb