Class: Fog::Compute::Google::Operation

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/google/models/compute/operation.rb

Constant Summary collapse

PENDING_STATE =
"PENDING"
RUNNING_STATE =
"RUNNING"
DONE_STATE =
"DONE"

Instance Method Summary collapse

Instance Method Details

#destroyObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/google/models/compute/operation.rb', line 47

def destroy
  requires :identity

  if zone
    service.delete_zone_operation(zone, identity)
  elsif region
    service.delete_region_operation(region, identity)
  else
    service.delete_global_operation(identity)
  end
  true
end

#pending?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fog/google/models/compute/operation.rb', line 35

def pending?
  self.status == PENDING_STATE
end

#ready?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/fog/google/models/compute/operation.rb', line 31

def ready?
  self.status == DONE_STATE
end

#region_nameObject



39
40
41
# File 'lib/fog/google/models/compute/operation.rb', line 39

def region_name
  region.nil? ? nil : region.split('/')[-1]
end

#reloadObject



60
61
62
63
64
65
66
67
# File 'lib/fog/google/models/compute/operation.rb', line 60

def reload
  requires :identity

  data = collection.get(identity, zone, region)
  new_attributes = data.attributes
  merge_attributes(new_attributes)
  self
end

#zone_nameObject



43
44
45
# File 'lib/fog/google/models/compute/operation.rb', line 43

def zone_name
  zone.nil? ? nil : zone.split('/')[-1]
end