Class: ActiveAws::ElasticLoadBalancingV2

Inherits:
Base
  • Object
show all
Defined in:
lib/active_aws/elastic_load_balancing_v2.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

configure, inherited, #initialize, load_config!, #to_h

Constructor Details

This class inherits a constructor from ActiveAws::Base

Class Method Details

.clientObject



15
16
17
# File 'lib/active_aws/elastic_load_balancing_v2.rb', line 15

def client
  Aws::ElasticLoadBalancingV2::Client.new( **configure.default_client_params )
end

.find(load_balancer_arn) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/active_aws/elastic_load_balancing_v2.rb', line 19

def find( load_balancer_arn )
  response = client.describe_load_balancers({
    load_balancer_arns: [load_balancer_arn], 
  })
  return nil unless response
  new( **response.load_balancers[0].to_h )
end

.find_by_name(name) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/active_aws/elastic_load_balancing_v2.rb', line 27

def find_by_name( name )
  response = client.describe_load_balancers({
    names: [name], 
  })
  return nil unless response
  new( **response.load_balancers[0].to_h )
end

Instance Method Details

#nameObject



36
37
38
# File 'lib/active_aws/elastic_load_balancing_v2.rb', line 36

def name
  load_balancer_name
end

#reloadObject



40
41
42
# File 'lib/active_aws/elastic_load_balancing_v2.rb', line 40

def reload
  self.class.find( load_balancer_arn )
end

#target_groupsObject



44
45
46
# File 'lib/active_aws/elastic_load_balancing_v2.rb', line 44

def target_groups
  TargetGroup.where( load_balancer_arn: load_balancer_arn )
end

#wait_until(waiter_name = :load_balancer_available, &block) ⇒ Object

‘waiter_name` can be checked with the command below. ActiveAws::ElasticLoadBalancingV2.client.waiter_names

Usage: alb.wait_until :load_balancer_available do |i|

i.max_attempts = 5
i.delay = 5

end



56
57
58
# File 'lib/active_aws/elastic_load_balancing_v2.rb', line 56

def wait_until( waiter_name=:load_balancer_available, &block )
  self.class.client.wait_until(waiter_name, load_balancer_arns: [load_balancer_arn], &block)
end