2011-05-11 15:27:27 -04:00
|
|
|
require 'fog/aws/models/elb/policy'
|
2011-05-02 18:17:19 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class ELB
|
|
|
|
class Policies < Fog::Collection
|
2011-05-04 18:29:07 -04:00
|
|
|
|
2011-05-02 18:17:19 -04:00
|
|
|
model Fog::AWS::ELB::Policy
|
|
|
|
|
|
|
|
attr_accessor :data, :load_balancer
|
|
|
|
|
|
|
|
def all
|
|
|
|
load(munged_data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(id)
|
|
|
|
all.detect{|policy| id == policy.id}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
# Munge a hash like:
|
|
|
|
# {'LBCookieStickinessPolicies' => [policies...],
|
2013-08-01 16:36:11 -04:00
|
|
|
# 'AppCookieStickinessPolicies' => [policies...],
|
|
|
|
# 'OtherPolicies' => [policies...]}
|
|
|
|
# to a single array of policies with an optional cookie_stickiness value
|
2011-05-02 18:17:19 -04:00
|
|
|
def munged_data
|
|
|
|
munged_data = []
|
|
|
|
data['LBCookieStickinessPolicies'].each do |policy|
|
|
|
|
munged_data << policy.merge(:cookie_stickiness => :lb)
|
|
|
|
end
|
2013-08-01 16:36:11 -04:00
|
|
|
data['AppCookieStickinessPolicies'].each do |policy|
|
2011-05-02 18:17:19 -04:00
|
|
|
munged_data << policy.merge(:cookie_stickiness => :app)
|
|
|
|
end
|
2013-08-01 16:36:11 -04:00
|
|
|
data['OtherPolicies'].each do |policy|
|
|
|
|
munged_data << {'PolicyName' => policy}
|
|
|
|
end
|
|
|
|
munged_data
|
2011-05-02 18:17:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|