Class: AwsRo::ElasticLoadBalancing::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_ro/elastic_load_balancing/repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_or_options)
  @client = if client_or_options.is_a? Aws::ElasticLoadBalancing::Client
              client_or_options
            else
              Aws::ElasticLoadBalancing::Client.new(client_or_options)
            end
end

Instance Attribute Details

#clientObject (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

#allObject



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_repositoryObject



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