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

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#destroyObject


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

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)

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

def pending?
  status == PENDING_STATE
end

#ready?Boolean

Returns:

  • (Boolean)

29
30
31
# File 'lib/fog/compute/google/models/operation.rb', line 29

def ready?
  status == DONE_STATE
end

#region_nameObject


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

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

#reloadObject


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

def reload
  requires :identity

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

#zone_nameObject


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

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