mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
make elb/policies collection standalone
* there is no need to inject data from the load balancer model when an index request exists that maps directly
This commit is contained in:
parent
f54f7fd95a
commit
cdd724dff6
3 changed files with 26 additions and 22 deletions
|
@ -143,23 +143,22 @@ module Fog
|
|||
end
|
||||
|
||||
def listeners
|
||||
Fog::AWS::ELB::Listeners.new({
|
||||
Fog::AWS::ELB::Listeners.new(
|
||||
:data => attributes['ListenerDescriptions'],
|
||||
:service => service,
|
||||
:load_balancer => self
|
||||
})
|
||||
)
|
||||
end
|
||||
|
||||
def policies
|
||||
Fog::AWS::ELB::Policies.new({
|
||||
:data => policy_descriptions,
|
||||
:service => service,
|
||||
:load_balancer => self
|
||||
})
|
||||
requires :id
|
||||
|
||||
service.policies(:load_balancer_id => self.identity)
|
||||
end
|
||||
|
||||
def policy_descriptions
|
||||
requires :id
|
||||
|
||||
@policy_descriptions ||= service.describe_load_balancer_policies(id).body["DescribeLoadBalancerPoliciesResult"]["PolicyDescriptions"]
|
||||
end
|
||||
|
||||
|
|
|
@ -1,23 +1,33 @@
|
|||
require 'fog/aws/models/elb/policy'
|
||||
|
||||
module Fog
|
||||
module AWS
|
||||
class ELB
|
||||
class Policies < Fog::Collection
|
||||
|
||||
attribute :load_balancer_id
|
||||
|
||||
model Fog::AWS::ELB::Policy
|
||||
|
||||
attr_accessor :data, :load_balancer
|
||||
def all(options={})
|
||||
merge_attributes(options)
|
||||
|
||||
def all
|
||||
load(munged_data)
|
||||
requires :load_balancer_id
|
||||
|
||||
data = service.describe_load_balancer_policies(self.load_balancer_id).
|
||||
body["DescribeLoadBalancerPoliciesResult"]["PolicyDescriptions"]
|
||||
|
||||
load(munge(data))
|
||||
end
|
||||
|
||||
def get(id)
|
||||
all.find{|policy| id == policy.id}
|
||||
all.find { |policy| id == policy.id }
|
||||
end
|
||||
|
||||
private
|
||||
def munged_data
|
||||
data.reduce([]){|m,e|
|
||||
|
||||
def munge(data)
|
||||
data.reduce([]) { |m,e|
|
||||
policy_attribute_descriptions = e["PolicyAttributeDescriptions"]
|
||||
|
||||
policy = {
|
||||
|
|
|
@ -13,7 +13,6 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :id, :load_balancer
|
||||
service_method = nil
|
||||
args = [load_balancer.id, id]
|
||||
|
||||
if cookie_stickiness
|
||||
|
@ -45,12 +44,8 @@ module Fog
|
|||
reload
|
||||
end
|
||||
|
||||
def reload
|
||||
load_balancer.reload
|
||||
end
|
||||
|
||||
def load_balancer
|
||||
collection.load_balancer
|
||||
service.load_balancers.new(identity: collection.load_balancer_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue