Class: Fog::Compute::Google::Operations

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/google/models/compute/operations.rb

Instance Method Summary collapse

Instance Method Details

#all(filters = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/google/models/compute/operations.rb', line 10

def all(filters = {})
  if filters['zone']
    data = service.list_zone_operations(filters['zone']).body
  elsif filters['region']
    data = service.list_region_operations(filters['region']).body
  else
    data = service.list_global_operations.body
  end
  load(data['items'] || [])
end

#get(identity, zone = nil, region = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/google/models/compute/operations.rb', line 21

def get(identity, zone=nil, region=nil)
  if not zone.nil?
    response = service.get_zone_operation(zone, identity)
  elsif not region.nil?
    response = service.get_region_operation(region, identity)
  else
    response = service.get_global_operation(identity)
  end
  return nil if response.nil?
  new(response.body)
rescue Fog::Errors::NotFound
  nil
end