Class: Otc::ASGroup

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/otc/asgroup.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.query_all(name: nil) ⇒ Object



6
7
8
9
10
11
# File 'lib/otc/asgroup.rb', line 6

def query_all(name: nil)
  response = Request.get service: "as", path: "/autoscaling-api/v1/#{Configuration.project!}/scaling_group?scaling_group_name=#{name}"
  JSON.parse(response.body)["scaling_groups"].map do |group|
    ASGroup.new(group)
  end
end

.query_one(name: nil) ⇒ Object



13
14
15
# File 'lib/otc/asgroup.rb', line 13

def query_one(name: nil)
  query_all(name: name).first
end

Instance Method Details

#instancesObject



18
19
20
21
22
23
24
25
# File 'lib/otc/asgroup.rb', line 18

def instances
  @_instances ||= begin
    response = Request.get service: "as", path: "/autoscaling-api/v1/#{Configuration.project!}/scaling_group_instance/#{self.scaling_group_id}/list"
    JSON.parse(response.body)["scaling_group_instances"].map do |group|
      ASGroupInstance.new(group)
    end
  end
end