Class: AWS::ELB::LoadBalancerPolicy
- Inherits:
-
Core::Resource
- Object
- Core::Resource
- AWS::ELB::LoadBalancerPolicy
- Defined in:
- lib/aws/elb/load_balancer_policy.rb
Instance Attribute Summary collapse
-
#load_balancer ⇒ LoadBalancer
readonly
Returns the load balancer this policy belongs to.
Attributes included from Core::Model
Instance Method Summary collapse
-
#attributes ⇒ Hash
Returns a hash of policy attributes.
-
#delete ⇒ nil
Deletes this load balancer policy.
-
#exists? ⇒ Boolean
Useful for determining if a policy with the given name exists:.
-
#initialize(load_balancer, name, options = {}) ⇒ LoadBalancerPolicy
constructor
A new instance of LoadBalancerPolicy.
Methods inherited from Core::Resource
attribute_providers, attribute_providers_for, attributes, #attributes_from_response, define_attribute_type, #eql?, #inspect, new_from
Methods included from Core::Cacheable
Methods included from Core::Model
#client, #config_prefix, #inspect
Constructor Details
#initialize(load_balancer, name, options = {}) ⇒ LoadBalancerPolicy
Returns a new instance of LoadBalancerPolicy.
19 20 21 22 |
# File 'lib/aws/elb/load_balancer_policy.rb', line 19 def initialize load_balancer, name, = {} @load_balancer = load_balancer super(load_balancer, .merge(:name => name.to_s)) end |
Instance Attribute Details
#load_balancer ⇒ LoadBalancer (readonly)
Returns the load balancer this policy belongs to.
25 26 27 |
# File 'lib/aws/elb/load_balancer_policy.rb', line 25 def load_balancer @load_balancer end |
Instance Method Details
#attributes ⇒ Hash
Returns a hash of policy attributes. Keys are policy attribute names, and values are arrays one or more policy attribute values.
46 47 48 49 50 51 52 53 |
# File 'lib/aws/elb/load_balancer_policy.rb', line 46 def attributes attributes = {} policy_attribute_descriptions.each do |desc| attributes[desc.attribute_name] ||= [] attributes[desc.attribute_name] << desc.attribute_value end attributes end |
#delete ⇒ nil
Deletes this load balancer policy.
57 58 59 60 61 62 63 64 65 |
# File 'lib/aws/elb/load_balancer_policy.rb', line 57 def delete client.delete_load_balancer_policy( :load_balancer_name => load_balancer.name, :policy_name => name) nil end |
#exists? ⇒ Boolean
Useful for determining if a policy with the given name exists:
load_balancer.policies['my-policy-name'].exists? # => true/false
73 74 75 76 77 78 |
# File 'lib/aws/elb/load_balancer_policy.rb', line 73 def exists? r = get_resource r.policy_descriptions.find{|d| d.policy_name == name } ? true : false rescue AWS::ELB::Errors::LoadBalancerNotFound false end |