Class: Fog::Compute::Ecloud::Environments

Inherits:
Ecloud::Collection show all
Defined in:
lib/fog/compute/ecloud/models/environments.rb

Constant Summary collapse

Vdcs =
Environments

Instance Method Summary collapse

Methods inherited from Ecloud::Collection

#check_href!, #load

Instance Method Details

#allObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/ecloud/models/environments.rb', line 13

def all
  data = []
  raw_location = service.get_organization(href).body[:Locations][:Location]
  if raw_location.is_a?(Array)
    # If there's more than one location, the XML parser returns an
    # array.
    location = raw_location
  else
    # Otherwise it returns a hash.
    location = [raw_location]
  end

  location.each do |l|
    environments = l[:Environments]
    next unless environments
    if environments[:Environment].is_a?(Array)
      environments[:Environment].each { |e| data << e }
    else
      data << environments[:Environment]
    end
  end
  load(data)
end

#get(uri) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/fog/compute/ecloud/models/environments.rb', line 37

def get(uri)
  if data = service.get_environment(uri)
    new(data.body)
  end
rescue Fog::Errors::NotFound
  nil
end