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