Module: UU::UDS::Bucket
- Extended by:
- Bucket
- Included in:
- Bucket
- Defined in:
- uu_uds-0.7.6/lib/uu/uds/bucket.rb,
uu_uds-0.7.6/lib/uu/uds/bucket/blob_create.rb,
uu_uds-0.7.6/lib/uu/uds/bucket/bucket_create.rb,
uu_uds-0.7.6/lib/uu/uds/bucket/blob_attributes.rb,
uu_uds-0.7.6/lib/uu/uds/bucket/bucket_attributes.rb,
uu_uds-0.7.6/lib/uu/uds/bucket/bucket_set_attributes.rb
Overview
Bucket is used for storing (and sharing) binary data of application.
Defined Under Namespace
Classes: BlobAttributes, BlobCreate, BucketAttributes, BucketCreate, BucketSetAttributes
Constant Summary
- PATH =
Service path
'/uu/uds/Bucket'
Instance Method Summary (collapse)
-
- (UU::OS::UESURI) create(application_uri, bucket = nil)
Creates new bucket for given application.
-
- (UU::OS::UESURI) create_blob(bucket_uri, blob = nil)
Creates new blob (object representing binary data).
-
- (Object) delete(bucket_uri)
Deletes existing bucket.
-
- (Object) delete_blob(blob_uri)
Deletes existing blob.
-
- (BucketAttributes) get_attributes(bucket_uri)
Returns attributes of bucket.
-
- (BlobAttributes) get_blob_attributes(blob_uri)
Returns attributes of blob.
-
- (UU::OS::REST::BinaryValue) get_blob_data(blob_uri)
Returns binary content of blob (along with binary metadata).
-
- (UU::OS::UESURI) set_attributes(bucket_uri, bucket = nil)
Updates bucket attributes and configuration.
Instance Method Details
- (UU::OS::UESURI) create(application_uri, bucket = nil)
Creates new bucket for given application. Bucket code and bucket name must be given in order to create new bucket.
31 32 33 34 35 36 37 38 |
# File 'uu_uds-0.7.6/lib/uu/uds/bucket.rb', line 31 def create(application_uri, bucket = nil) svc = UU::OS::REST::RemoteClient.new(Bucket) payload = Bucket::BucketCreate.new(bucket).to_json UU::OS::QoS::QoSHandler.auto_retry do res = svc.post(:create, application_uri, payload) return UU::OS::UESURI.new(res) end end |
- (UU::OS::UESURI) create_blob(bucket_uri, blob = nil)
Creates new blob (object representing binary data). Only application which is set as bucket owner is allowed to create new blob.
86 87 88 89 90 91 92 93 94 |
# File 'uu_uds-0.7.6/lib/uu/uds/bucket.rb', line 86 def create_blob(bucket_uri, blob = nil) svc = UU::OS::REST::RemoteClient.new(Bucket) svc.timeout = -1 # Upload may take long time bv = Bucket::BlobCreate.new(blob) bv.serialize_as_stream_handler = false payload = bv.to_hash(false) res = svc.post(:createBlob, bucket_uri, payload) return UU::OS::UESURI.new(res) end |
- (Object) delete(bucket_uri)
Deletes existing bucket. Bucket must be empty to be able to delete it.
72 73 74 75 76 77 |
# File 'uu_uds-0.7.6/lib/uu/uds/bucket.rb', line 72 def delete(bucket_uri) svc = UU::OS::REST::RemoteClient.new(Bucket) UU::OS::QoS::QoSHandler.auto_retry do svc.delete('delete', bucket_uri) end end |
- (Object) delete_blob(blob_uri)
Deletes existing blob. Only application which is set as bucket owner is allowed to delete blob.
131 132 133 134 135 136 |
# File 'uu_uds-0.7.6/lib/uu/uds/bucket.rb', line 131 def delete_blob(blob_uri) svc = UU::OS::REST::RemoteClient.new(Bucket) UU::OS::QoS::QoSHandler.auto_retry do svc.delete(:deleteBlob, blob_uri) end end |
- (BucketAttributes) get_attributes(bucket_uri)
Returns attributes of bucket. In case bucket with given URI does not exist, null is returned.
45 46 47 48 49 50 51 |
# File 'uu_uds-0.7.6/lib/uu/uds/bucket.rb', line 45 def get_attributes(bucket_uri) svc = UU::OS::REST::RemoteClient.new(Bucket) UU::OS::QoS::QoSHandler.auto_retry do res = svc.get('getAttributes', bucket_uri) return Bucket::BucketAttributes.new(res) end end |
- (BlobAttributes) get_blob_attributes(blob_uri)
Returns attributes of blob. In case blob with given URI does not exist, null is returned. Returned DTO does not contain actual binary content of blob. Use method get_blob_data to download blob binary content. Only application which is set as bucket owner is allowed to read blob attributes.
104 105 106 107 108 109 110 |
# File 'uu_uds-0.7.6/lib/uu/uds/bucket.rb', line 104 def get_blob_attributes(blob_uri) svc = UU::OS::REST::RemoteClient.new(Bucket) UU::OS::QoS::QoSHandler.auto_retry do res = svc.get(:getBlobAttributes, blob_uri) return Bucket::BlobAttributes.new(res) end end |
- (UU::OS::REST::BinaryValue) get_blob_data(blob_uri)
Returns binary content of blob (along with binary metadata). In case blob with given URI does not exist, null is returned. Only application which is set as bucket owner is allowed to get blob binary content.
119 120 121 122 123 124 125 126 |
# File 'uu_uds-0.7.6/lib/uu/uds/bucket.rb', line 119 def get_blob_data(blob_uri) svc = UU::OS::REST::RemoteClient.new(Bucket) svc.timeout = -1 # Download may take long time svc.add_header(:accept, :application/octet-stream") UU::OS::QoS::QoSHandler.auto_retry do return svc.get_binary(:getBlobData, blob_uri) end end |
- (UU::OS::UESURI) set_attributes(bucket_uri, bucket = nil)
Updates bucket attributes and configuration. In case bucket with given URI does not exist, exception is thrown.
60 61 62 63 64 65 66 67 |
# File 'uu_uds-0.7.6/lib/uu/uds/bucket.rb', line 60 def set_attributes(bucket_uri, bucket = nil) svc = UU::OS::REST::RemoteClient.new(Bucket) payload = Bucket::BucketSetAttributes.new(bucket).to_json UU::OS::QoS::QoSHandler.auto_retry do res = svc.post(:setAttributes, bucket_uri, payload) return UU::OS::UESURI.new(res) end end |