class Applb::ClientWrapper

Public Class Methods

new(options) click to toggle source
# File lib/applb/client_wrapper.rb, line 14
def initialize(options)
  @includes = options[:includes] || []
  @excludes = options[:excludes] || []
  @client = Aws::ElasticLoadBalancingV2::Client.new
end

Public Instance Methods

delete_load_balancer(arn) click to toggle source
# File lib/applb/client_wrapper.rb, line 33
def delete_load_balancer(arn)
  @client.delete_load_balancer(load_balancer_arn: arn)
end
listeners(*argv) click to toggle source
# File lib/applb/client_wrapper.rb, line 48
def listeners(*argv)
  results = []
  next_marker = nil
  begin
    resp = @client.describe_listeners(*argv)
    results.push(*resp.listeners)
    next_marker = resp.next_marker
  end while next_marker
  results
end
load_balancer_attributes(*argv) click to toggle source
# File lib/applb/client_wrapper.rb, line 70
def load_balancer_attributes(*argv)
  resp = @client.describe_load_balancer_attributes(*argv)
  resp.attributes
end
load_balancers() click to toggle source
# File lib/applb/client_wrapper.rb, line 20
def load_balancers
  results = []
  next_marker = nil
  begin
    resp = @client.describe_load_balancers(marker: next_marker)
    resp.load_balancers.each do |lb|
      results << lb if target?(lb)
    end
    next_marker = resp.next_marker
  end while next_marker
  results
end
rules(*argv) click to toggle source
# File lib/applb/client_wrapper.rb, line 59
def rules(*argv)
  results = []
  next_marker = nil
  begin
    resp = @client.describe_rules(*argv)
    results.push(*resp.rules)
    next_marker = resp.next_marker
  end while next_marker
  results
end
target_groups(*argv) click to toggle source
# File lib/applb/client_wrapper.rb, line 37
def target_groups(*argv)
  results = []
  next_marker = nil
  begin
    resp = @client.describe_target_groups(*argv)
    results.push(*resp.target_groups)
    next_marker = resp.next_marker
  end while next_marker
  results
end

Private Instance Methods

target?(lb) click to toggle source
# File lib/applb/client_wrapper.rb, line 77
def target?(lb)
  name = lb.load_balancer_name
  unless @includes.empty?
    return @includes.include?(name)
  end
  unless @excludes.empty?
    return !@excludes.any? { |regex| name =~ regex }
  end
  true
end