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.
35 36 37 38 39 40 |
# File 'lib/google/storage/api/gstorage_object.rb', line 35 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
44 45 46 47 48 49 50 51 |
# File 'lib/google/storage/api/gstorage_object.rb', line 44 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 |