Class: Fog::Compute::Google::Snapshot

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

Constant Summary collapse

CREATING_STATE =
"CREATING".freeze
DELETING_STATE =
"DELETING".freeze
FAILED_STATE =
"FAILED".freeze
READY_STATE =
"READY".freeze
UPLOADING_STATE =
"UPLOADING".freeze

Instance Method Summary collapse

Instance Method Details

#destroy(async = true) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/fog/compute/google/models/snapshot.rb', line 30

def destroy(async = true)
  requires :identity

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

#ready?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/fog/compute/google/models/snapshot.rb', line 52

def ready?
  status == READY_STATE
end

#resource_urlObject



56
57
58
# File 'lib/fog/compute/google/models/snapshot.rb', line 56

def resource_url
  "#{service.project}/global/snapshots/#{name}"
end

#set_labels(new_labels) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/compute/google/models/snapshot.rb', line 40

def set_labels(new_labels)
  requires :identity, :label_fingerprint

  unless new_labels.is_a? Hash
    raise ArgumentError,
          "Labels should be a hash, e.g. {foo: \"bar\",fog: \"test\"}"
  end

  service.set_snapshot_labels(identity, label_fingerprint, new_labels)
  reload
end