Class: Google::Compute::Api::Disk
- Inherits:
-
Object
- Object
- Google::Compute::Api::Disk
- Defined in:
- lib/google/compute/api/gcompute_disk.rb
Overview
A helper class to provide access to (some) Google Compute Engine API.
Instance Method Summary collapse
-
#initialize(name, zone, project, cred) ⇒ Disk
constructor
A new instance of Disk.
-
#snapshot(target) ⇒ Object
TODO(nelsonjr): Implement this as gcompute_disk_snapshot { } TODO(nelsonjr): Make this function wait for the operation to complete.
Constructor Details
#initialize(name, zone, project, cred) ⇒ Disk
Returns a new instance of Disk.
21 22 23 24 25 26 |
# File 'lib/google/compute/api/gcompute_disk.rb', line 21 def initialize(name, zone, project, cred) @name = name @zone = zone @project = project @cred = cred end |
Instance Method Details
#snapshot(target) ⇒ Object
TODO(nelsonjr): Implement this as gcompute_disk_snapshot { } TODO(nelsonjr): Make this function wait for the operation to complete
30 31 32 33 34 35 36 37 38 |
# File 'lib/google/compute/api/gcompute_disk.rb', line 30 def snapshot(target) snapshot_request = ::Google::Compute::Network::Post.new( gcompute_disk_snapshot, @cred, 'application/json', { name: target }.to_json ) response = JSON.parse(snapshot_request.send.body) raise Puppet::Error, response['error']['errors'][0]['message'] \ if response['error'] end |