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



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

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



37
38
39
# File 'lib/fog/google/models/compute/operation.rb', line 37

def pending?
  self.status == PENDING_STATE
end

#ready?Boolean



33
34
35
# File 'lib/fog/google/models/compute/operation.rb', line 33

def ready?
  self.status == DONE_STATE
end

#region_nameObject



41
42
43
# File 'lib/fog/google/models/compute/operation.rb', line 41

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

#reloadObject



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

def reload
  requires :identity

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

#zone_nameObject



45
46
47
# File 'lib/fog/google/models/compute/operation.rb', line 45

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