Class: OpsWorker::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ops_worker/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/ops_worker/client.rb', line 5

def initialize(options = {})
  @opsworks_client = AWS::OpsWorks.new(options).client
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



36
37
38
# File 'lib/ops_worker/client.rb', line 36

def method_missing(method_name, *args, &block)
  @opsworks_client.__send__(method_name, *args, &block)
end

Instance Method Details

#find_app_by_name(name) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ops_worker/client.rb', line 9

def find_app_by_name(name)
  stacks().each do |stack|
    app = stack.apps.detect {|a| a.name == name}

    if app
      return app
    end
  end

  return nil
end

#reloadObject



32
33
34
# File 'lib/ops_worker/client.rb', line 32

def reload
  @stacks = nil
end

#stacksObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/ops_worker/client.rb', line 21

def stacks
  if @stacks
    return @stacks
  end

  stacks = @opsworks_client.describe_stacks()[:stacks]
  @stacks = stacks.map do |stack_hash|
    Stack.new(stack_hash[:stack_id], stack_hash[:name], stack_hash[:region], @opsworks_client)
  end
end