Class: AwsRo::ElasticLoadBalancing::Repository
- Inherits:
-
Object
- Object
- AwsRo::ElasticLoadBalancing::Repository
- Defined in:
- lib/aws_ro/elastic_load_balancing/repository.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #all ⇒ Object
- #ec2_repository ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize(client_or_options) ⇒ Repository
constructor
A new instance of Repository.
Constructor Details
#initialize(client_or_options) ⇒ Repository
Returns a new instance of Repository.
10 11 12 13 14 15 16 |
# File 'lib/aws_ro/elastic_load_balancing/repository.rb', line 10 def initialize() @client = if .is_a? Aws::ElasticLoadBalancing::Client else Aws::ElasticLoadBalancing::Client.new() end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/aws_ro/elastic_load_balancing/repository.rb', line 8 def client @client end |
Instance Method Details
#all ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/aws_ro/elastic_load_balancing/repository.rb', line 25 def all client.describe_load_balancers.each_with_object([]) do |page, arr| page.load_balancer_descriptions.each do |elb| lb = LoadBalancer.new(elb, ec2_repository) lb.store_instance_states(client.describe_instance_health(load_balancer_name: lb.name).instance_states) arr << lb end end end |
#ec2_repository ⇒ Object
18 19 20 21 22 23 |
# File 'lib/aws_ro/elastic_load_balancing/repository.rb', line 18 def ec2_repository @ec2_repository ||= AwsRo::EC2::Repository.new( region: client.config.region, credentials: client.config.credentials ) end |
#find_by_name(name) ⇒ Object
35 36 37 |
# File 'lib/aws_ro/elastic_load_balancing/repository.rb', line 35 def find_by_name(name) client.describe_load_balancers(load_balancer_names: [name]).first end |