Class: Fog::Compute::Google::Image

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

Constant Summary collapse

READY_STATE =
"READY".freeze

Instance Method Summary collapse

Instance Method Details

#destroy(async = true) ⇒ Object


50
51
52
53
54
55
56
# File 'lib/fog/compute/google/models/image.rb', line 50

def destroy(async = true)
  data = service.delete_image(name)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.name)
  operation.wait_for { ready? } unless async
  operation
end

#ready?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'lib/fog/compute/google/models/image.rb', line 46

def ready?
  status == READY_STATE
end

#reloadObject


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

def reload
  requires :name
  data = service.get_image(name, project)
  merge_attributes(data.to_h)
  self
end

#resource_urlObject


75
76
77
# File 'lib/fog/compute/google/models/image.rb', line 75

def resource_url
  "#{project}/global/images/#{name}"
end

#saveObject


65
66
67
68
69
70
71
72
73
# File 'lib/fog/compute/google/models/image.rb', line 65

def save
  requires :name

  data = service.insert_image(name, attributes)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.name)
  operation.wait_for { ready? }
  reload
end