Class: Atmos::Metadata
- Inherits:
-
AttributeHashBase
- Object
- Hash
- AttributeHashBase
- Atmos::Metadata
- Defined in:
- lib/atmos/attributes.rb
Overview
Metadata
In all cases, metadata
refers to key/value pairs, and is represented as a ruby Hash attached to an Atmos::Object object.
Standard Metadata
In Atmos, metadata
with no modifier (e.g. listable
or system
) refers to metadata on an object that is not indexed. In other words, objects cannot be referenced by the metadata information. The only way to get this metadata information is to already have the object the metadata is attached to.
Defaults
By default, when you create an object, there is no metadata. So:
obj. => {}
Adding
Add metadata in key/value pairs as you would to a hash. Keys and values must be ruby Strings.
obj.[key] = value
obj..store(key, value)
obj..merge!({key => value})
Modifying
Modify metadata as you would a hash. Keys and values must be ruby Strings.
obj.[pre-existing-key] = new-value
obj..store(pre-existing-key, new-value)
obj..merge!({pre-existing-key => new-value})
Deleting
Delete metadata as you would a hash. Keys must be ruby Strings.
obj..delete(key)
obj..clear
Listable Metadata
Listable metadata means atmos indexes the object by the key in the key/value metadata pair. The keys of listable metadata are also known as listable tags. Currently, an Atmos server can handle about 10k listable tags easily, so use judiciously with very large datasets.
Defaults
By default, when you create an object, there is no listable metadata. So:
obj. => {}
Adding
Add metadata in key/value pairs as you would to a hash. Keys and values must be ruby Strings.
obj.[key] = value
obj..store(key, value)
obj..merge!({key => value})
Modifying
Modify metadata as you would a hash. Keys and values must be ruby Strings.
obj.[pre-existing-key] = new-value
obj..store(pre-existing-key, new-value)
obj..merge!({pre-existing-key => new-value})
Deleting
Delete metadata as you would a hash. Keys must be ruby Strings.
obj..delete(key)
obj..clear
System Metadata
System metadata is a standard group of information maintained by Atmos for each object, such as atime
, mtime
, type
, policyname
.
System metadata is not modifiable.
Constant Summary collapse
- LISTABLE =
1
- NON_LISTABLE =
2
- SYSTEM =
3
Instance Attribute Summary
Attributes inherited from AttributeHashBase
Instance Method Summary collapse
-
#[]=(key, value) ⇒ Object
Adds the specified metadata to the object unless the object is representing system metadata.
-
#clear ⇒ Object
Deletes all metadata from the object unless the object is representing system metadata.
-
#delete(key) ⇒ Object
Deletes the specified metadata from the object unless the object is representing system metadata.
-
#initialize(obj, type) ⇒ Metadata
constructor
This constructor is only meant for internal use.
-
#listable? ⇒ Boolean
Returns
true
if this Metadata object is representing listable metadata. -
#non_listable? ⇒ Boolean
Returns
true
if this Metadata object is representing non-listable metadata. -
#system? ⇒ Boolean
Returns
true
if this Metadata object is representing system metadata.
Methods inherited from AttributeHashBase
#clear_with_atmos, #default_with_atmos=, #delete_with_atmos, #header_name, #header_value, #merge_with_atmos, #merge_with_atmos!, #replace_with_atmos, #store, #to_canonicalized_header, #to_header
Constructor Details
#initialize(obj, type) ⇒ Metadata
This constructor is only meant for internal use. To get the metadata on an object:
obj. => Hash
obj. => Hash
obj. => Hash
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/atmos/attributes.rb', line 422 def initialize(obj, type) raise Atmos::Exceptions::ArgumentException, "The 'obj' parameter cannot be nil." if (obj.nil?) raise Atmos::Exceptions::ArgumentException, "The 'obj' parameter must have an id." if (obj.aoid.nil?) raise Atmos::Exceptions::ArgumentException, "The 'type' parameter must be one of Atmos::Metadata::LISTABLE Atmos::Metadata::NON_LISTABLE Atmos::Metadata::SYSTEM." if (![SYSTEM, LISTABLE, NON_LISTABLE].include?(type)) super() @obj = obj @type = type @header = (@type == LISTABLE) ? 'x-emc-listable-meta' : 'x-emc-meta' @reload_action = (@type == SYSTEM) ? :list_system_metadata : :list_metadata @set_action = (@type == LISTABLE) ? :set_listable_metadata : :set_metadata reload(@reload_action, @obj.aoid) end |
Instance Method Details
#[]=(key, value) ⇒ Object
Adds the specified metadata to the object unless the object is representing system metadata.
System metadata cannot be modified, so an Atmos::Exceptions::NotImplementedException is thrown.
The change is made on the Atmos server immediately.
448 449 450 451 452 453 |
# File 'lib/atmos/attributes.rb', line 448 def []=(key,value) raise Atmos::Exceptions::NotImplementedException, "System metadata cannot be modified." if (@type == SYSTEM) raise Atmos::Exceptions::ArgumentException, "The 'value' parameter must be of type String'." if (!value.nil? && !value.kind_of?(String)) response = @obj.request.do(@set_action, :id => @obj.aoid, @header => "#{key}=#{value}") reload(@reload_action, @obj.aoid) end |
#clear ⇒ Object
Deletes all metadata from the object unless the object is representing system metadata.
System metadata cannot be modified, so an Atmos::Exceptions::NotImplementedException is thrown.
The change is made on the Atmos server immediately.
464 465 466 467 468 469 470 |
# File 'lib/atmos/attributes.rb', line 464 def clear raise Atmos::Exceptions::NotImplementedException, "System metadata cannot be modified." if (@type == SYSTEM) reload(@reload_action, @obj.aoid) response = @obj.request.do(:delete_metadata, :id => @obj.aoid, 'x-emc-tags' => self.keys.join(',')) self.clear_without_atmos reload(@reload_action, @obj.aoid) end |
#delete(key) ⇒ Object
Deletes the specified metadata from the object unless the object is representing system metadata. System metadata cannot be modified, so an Atmos::Exceptions::NotImplementedException
is thrown.
The deleted is executed on the Atmos server immediately.
Required:
*<tt>key</tt> -
483 484 485 486 487 488 |
# File 'lib/atmos/attributes.rb', line 483 def delete(key) raise Atmos::Exceptions::NotImplementedException, "System metadata cannot be modified." if (@type == SYSTEM) response = @obj.request.do(:delete_metadata, :id => @obj.aoid, 'x-emc-tags' => key) self.delete_without_atmos(key) reload(@reload_action, @obj.aoid) end |
#listable? ⇒ Boolean
Returns true
if this Metadata object is representing listable metadata.
494 495 496 |
# File 'lib/atmos/attributes.rb', line 494 def listable? @type == LISTABLE end |
#non_listable? ⇒ Boolean
Returns true
if this Metadata object is representing non-listable metadata.
502 503 504 |
# File 'lib/atmos/attributes.rb', line 502 def non_listable? @type == NON_LISTABLE end |
#system? ⇒ Boolean
Returns true
if this Metadata object is representing system metadata.
510 511 512 |
# File 'lib/atmos/attributes.rb', line 510 def system? @type == SYSTEM end |