Module: UU::UDS::Bucket
- Extended by:
- Bucket
- Included in:
- Bucket
- Defined in:
- uu_uds-0.26.16/lib/uu/uds/bucket.rb,
uu_uds-0.26.16/lib/uu/uds/bucket/blob_create.rb,
uu_uds-0.26.16/lib/uu/uds/bucket/bucket_create.rb,
uu_uds-0.26.16/lib/uu/uds/bucket/blob_attributes.rb,
uu_uds-0.26.16/lib/uu/uds/bucket/bucket_attributes.rb,
uu_uds-0.26.16/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.
29 30 31 32 33 34 35 36 |
# File 'uu_uds-0.26.16/lib/uu/uds/bucket.rb', line 29 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.
84 85 86 87 88 89 90 91 92 |
# File 'uu_uds-0.26.16/lib/uu/uds/bucket.rb', line 84 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.
70 71 72 73 74 75 |
# File 'uu_uds-0.26.16/lib/uu/uds/bucket.rb', line 70 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.
129 130 131 132 133 134 |
# File 'uu_uds-0.26.16/lib/uu/uds/bucket.rb', line 129 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.
43 44 45 46 47 48 49 |
# File 'uu_uds-0.26.16/lib/uu/uds/bucket.rb', line 43 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.
102 103 104 105 106 107 108 |
# File 'uu_uds-0.26.16/lib/uu/uds/bucket.rb', line 102 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.
117 118 119 120 121 122 123 124 |
# File 'uu_uds-0.26.16/lib/uu/uds/bucket.rb', line 117 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.
58 59 60 61 62 63 64 65 |
# File 'uu_uds-0.26.16/lib/uu/uds/bucket.rb', line 58 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 |