2012-06-15 14:10:04 -04:00
|
|
|
require 'fog/aws/models/auto_scaling/policy'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class AutoScaling
|
|
|
|
class Policies < Fog::Collection
|
|
|
|
model Fog::AWS::AutoScaling::Policy
|
|
|
|
|
|
|
|
# Creates a new scaling policy.
|
|
|
|
def initialize(attributes={})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def all
|
|
|
|
data = []
|
|
|
|
next_token = nil
|
|
|
|
loop do
|
2012-12-22 18:32:30 -05:00
|
|
|
result = service.describe_policies('NextToken' => next_token).body['DescribePoliciesResult']
|
2012-06-15 14:10:04 -04:00
|
|
|
data += result['ScalingPolicies']
|
|
|
|
next_token = result['NextToken']
|
|
|
|
break if next_token.nil?
|
|
|
|
end
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(identity, auto_scaling_group = nil)
|
2012-12-22 18:32:30 -05:00
|
|
|
data = service.describe_policies('PolicyNames' => identity, 'AutoScalingGroupName' => auto_scaling_group).body['DescribePoliciesResult']['ScalingPolicies'].first
|
2012-06-15 14:10:04 -04:00
|
|
|
new(data) unless data.nil?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|