Class: AwsRo::ElasticLoadBalancingV2::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_ro/elastic_load_balancing_v2/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_v2/repository.rb', line 10

def initialize(client_or_options)
  @client = if client_or_options.is_a? Aws::ElasticLoadBalancingV2::Client
              client_or_options
            else
              Aws::ElasticLoadBalancingV2::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_v2/repository.rb', line 8

def client
  @client
end

Instance Method Details

#allObject



25
26
27
28
29
30
31
# File 'lib/aws_ro/elastic_load_balancing_v2/repository.rb', line 25

def all
  client.describe_load_balancers.each_with_object([]) do |page, arr|
    page.load_balancers.each do |alb|
      arr << LoadBalancer.new(alb, client)
    end
  end
end

#ec2_repositoryObject



18
19
20
21
22
23
# File 'lib/aws_ro/elastic_load_balancing_v2/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



33
34
35
36
# File 'lib/aws_ro/elastic_load_balancing_v2/repository.rb', line 33

def find_by_name(name)
  alb = client.describe_load_balancers(names: [name]).load_balancers.first
  LoadBalancer.new(alb, client) if alb
end