object_store methods

class ecl.object_store.v1._proxy.Proxy(session)[source]

Bases: ecl.proxy.BaseProxy

containers(**query)[source]

Obtain Container objects for this account.

Parameters:query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
Return type:A generator of Container objects.
copy_object()[source]

Copy an object.

create_container(**attrs)[source]

Create a new container from attributes

Parameters:attrs (dict) – Keyword arguments which will be used to create a Container, comprised of the properties on the Container class.
Returns:The results of container creation
Return type:Container
delete_account_metadata(keys)[source]

Delete metadata for this account.

Parameters:keys – The keys of metadata to be deleted.
delete_container(container, ignore_missing=True)[source]

Delete a container

Parameters:
  • container – The value can be either the name of a container or a Container instance.
  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the container does not exist. When set to True, no exception will be set when attempting to delete a nonexistent server.
Returns:

None

delete_container_metadata(container, keys)[source]

Delete metadata for a container.

Parameters:
  • container – The value can be the ID of a container or a Container instance.
  • keys – The keys of metadata to be deleted.
delete_object(obj, ignore_missing=True, container=None)[source]

Delete an object

Parameters:
  • obj – The value can be either the name of an object or a Container instance.
  • container – The value can be the ID of a container or a Container instance.
  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the object does not exist. When set to True, no exception will be set when attempting to delete a nonexistent server.
Returns:

None

delete_object_metadata(obj, container=None, keys=None)[source]

Delete metadata for an object.

Parameters:
  • obj – The value can be the name of an object or a Object instance.
  • container – The value can be the ID of a container or a Container instance.
  • keys – The keys of metadata to be deleted.
download_object(obj, container=None, path=None)[source]

Download the data contained inside an object to disk.

Parameters:
  • obj – The value can be the name of an object or a Object instance.
  • container – The value can be the name of a container or a Container instance.
  • str (path) – Location to write the object contents.
Raises:

ResourceNotFound when no resource can be found.

get_account_metadata()[source]

Get metadata for this account.

Return type:Account
get_container_metadata(container)[source]

Get metadata for a container

Parameters:container – The value can be the name of a container or a Container instance.
Returns:One Container
Raises:ResourceNotFound when no resource can be found.
get_object(obj, container=None)[source]

Get the data associated with an object

Parameters:
  • obj – The value can be the name of an object or a Object instance.
  • container – The value can be the name of a container or a Container instance.
Returns:

The contents of the object. Use the get_object_metadata() method if you want an object resource.

Raises:

ResourceNotFound when no resource can be found.

get_object_metadata(obj, container=None)[source]

Get metadata for an object.

Parameters:
  • obj – The value can be the name of an object or a Object instance.
  • container – The value can be the ID of a container or a Container instance.
Returns:

One Object

Raises:

ResourceNotFound when no resource can be found.

objects(container, **query)[source]

Return a generator that yields the Container’s objects.

Parameters:
  • container (Container) – A container object or the name of a container that you want to retrieve objects from.
  • **query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
Return type:

A generator of Object objects.

set_account_metadata(**metadata)[source]

Set metadata for this account.

Parameters:metadata (kwargs) – Key/value pairs to be set as metadata on the container. Custom metadata can be set. Custom metadata are keys and values defined by the user.
set_container_metadata(container, **metadata)[source]

Set metadata for a container.

Parameters:
  • container – The value can be the name of a container or a Container instance.
  • metadata (kwargs) –

    Key/value pairs to be set as metadata on the container. Both custom and system metadata can be set. Custom metadata are keys and values defined by the user. System metadata are keys defined by the Object Store and values defined by the user. The system metadata keys are:

    • content_type
    • is_content_type_detected
    • versions_location
    • read_ACL
    • write_ACL
    • sync_to
    • sync_key
set_object_metadata(obj, container=None, **metadata)[source]

Set metadata for an object.

Note: This method will do an extra HEAD call.

Parameters:
  • obj – The value can be the name of an object or a Object instance.
  • container – The value can be the name of a container or a Container instance.
  • metadata (kwargs) –

    Key/value pairs to be set as metadata on the container. Both custom and system metadata can be set. Custom metadata are keys and values defined by the user. System metadata are keys defined by the Object Store and values defined by the user. The system metadata keys are:

    • content_type
    • content_encoding
    • content_disposition
    • delete_after
    • delete_at
    • is_content_type_detected
upload_object(**attrs)[source]

Upload a new object from attributes

Parameters:attrs (dict) – Keyword arguments which will be used to create a Object, comprised of the properties on the Object class. Required: A container argument must be specified, which is either the ID of a container or a Container instance.
Returns:The results of object creation
Return type:Container

account

class ecl.object_store.v1.account.Account(attrs=None, loaded=False)[source]

Bases: ecl.object_store.v1._base.BaseResource

account_bytes_used = None

The total number of bytes that are stored in Object Storage for the account.

account_container_count = None

The number of containers.

account_object_count = None

The number of objects in the account.

allow_head = True
allow_retrieve = True
allow_update = True
base_path = '/'
meta_temp_url_key = None

The secret key value for temporary URLs. If not set, this header is not returned by this operation.

meta_temp_url_key_2 = None

A second secret key value for temporary URLs. If not set, this header is not returned by this operation.

timestamp = None

The timestamp of the transaction.

container

class ecl.object_store.v1.container.Container(attrs=None, loaded=False)[source]

Bases: ecl.object_store.v1._base.BaseResource

allow_create = True
allow_delete = True
allow_head = True
allow_list = True
allow_retrieve = True
allow_update = True
base_path = '/'
bytes = None

The total number of bytes that are stored in Object Storage for the container.

bytes_used = None

The count of bytes used in total.

content_type = None

The MIME type of the list of names.

count = None

The number of objects in the container.

create(session)[source]

Create a Resource from this instance.

Parameters:session (Session) – The session to use for making this request.
Returns:This instance.
classmethod create_by_id(session, attrs, resource_id=None)[source]

Create a Resource from its attributes.

Parameters:
  • session (Session) – The session to use for making this request.
  • attrs (dict) – The attributes to be sent in the body of the request.
  • resource_id – This resource’s identifier, if needed by the request. The default is None.
Returns:

A dict representing the response headers.

id_attribute = 'name'
if_none_match = None

In combination with Expect: 100-Continue, specify an “If-None-Match: *” header to query whether the server already has a copy of the object before any data is sent.

is_content_type_detected = None

If set to true, Object Storage guesses the content type based on the file extension and ignores the value sent in the Content-Type header, if present. Type: bool

is_newest = None

If set to True, Object Storage queries all replicas to return the most recent one. If you omit this header, Object Storage responds faster after it finds one valid replica. Because setting this header to True is more expensive for the back end, use it only when it is absolutely needed. Type: bool

name = None

The name of the container.

object_count = None

The number of objects.

read_ACL = None

The ACL that grants read access. If not set, this header is not returned by this operation.

sync_key = None

The secret key for container synchronization. If not set, this header is not returned by this operation.

sync_to = None

The destination for container synchronization. If not set, this header is not returned by this operation.

timestamp = None

The timestamp of the transaction.

versions_location = None

Enables versioning on this container. The value is the name of another container. You must UTF-8-encode and then URL-encode the name before you include it in the header. To disable versioning, set the header to an empty string.

write_ACL = None

The ACL that grants write access. If not set, this header is not returned by this operation.

obj

class ecl.object_store.v1.obj.Object(attrs=None, loaded=False)[source]

Bases: ecl.object_store.v1._base.BaseResource

accept_ranges = None

The type of ranges that the object accepts.

allow_create = True
allow_delete = True
allow_head = True
allow_list = True
allow_retrieve = True
allow_update = True
base_path = '/%(container)s'
bytes = None
container = None

The unique name for the container.

content_disposition = None

If set, specifies the override behavior for the browser. For example, this header might specify that the browser use a download program to save this file rather than show the file, which is the default. If not set, this header is not returned by this operation.

content_encoding = None

If set, the value of the Content-Encoding metadata. If not set, this header is not returned by this operation.

content_length = None

HEAD operations do not return content. However, in this operation the value in the Content-Length header is not the size of the response body. Instead it contains the size of the object, in bytes.

content_type = None

The MIME type of the object.

copy_from = None

If set, this is the name of an object used to create the new object by copying the X-Copy-From object. The value is in form {container}/{object}. You must UTF-8-encode and then URL-encode the names of the container and object before you include them in the header. Using PUT with X-Copy-From has the same effect as using the COPY operation to copy an object.

create(session)[source]
data = None
delete_after = None

Specifies the number of seconds after which the object is removed. Internally, the Object Storage system stores this value in the X-Delete-At metadata item.

delete_at = None

If set, the time when the object will be deleted by the system in the format of a UNIX Epoch timestamp. If not set, this header is not returned by this operation.

delete_metadata(session, keys)[source]
etag = None

For objects smaller than 5 GB, this value is the MD5 checksum of the object content. The value is not quoted. For manifest objects, this value is the MD5 checksum of the concatenated string of MD5 checksums and ETags for each of the segments in the manifest, and not the MD5 checksum of the content that was downloaded. Also the value is enclosed in double-quote characters. You are strongly recommended to compute the MD5 checksum of the response body as it is received and compare this value with the one in the ETag header. If they differ, the content was corrupted, so retry the operation.

expires_at = None

Used with temporary URLs to specify the expiry time of the signature. For more information about temporary URLs, see OpenStack Object Storage API v1 Reference.

get(session, include_headers=False, args=None)[source]
hash = None
id_attribute = 'name'
if_match = None

See http://www.ietf.org/rfc/rfc2616.txt.

if_modified_since = None

See http://www.ietf.org/rfc/rfc2616.txt.

if_none_match = None

In combination with Expect: 100-Continue, specify an “If-None-Match: *” header to query whether the server already has a copy of the object before any data is sent.

if_unmodified_since = None

See http://www.ietf.org/rfc/rfc2616.txt.

is_content_type_detected = None

If set to true, Object Storage guesses the content type based on the file extension and ignores the value sent in the Content-Type header, if present. Type: bool

is_newest = None

If set to True, Object Storage queries all replicas to return the most recent one. If you omit this header, Object Storage responds faster after it finds one valid replica. Because setting this header to True is more expensive for the back end, use it only when it is absolutely needed. Type: bool

is_static_large_object = None

Set to True if this object is a static large object manifest object. Type: bool

last_modified_at = None

The date and time that the object was created or the last time that the metadata was changed.

multipart_manifest = None

If you include the multipart-manifest=get query parameter and the object is a large object, the object contents are not returned. Instead, the manifest is returned in the X-Object-Manifest response header for dynamic large objects or in the response body for static large objects.

name = None

The unique name for the object.

object_manifest = None

If set, to this is a dynamic large object manifest object. The value is the container and object name prefix of the segment objects in the form container/prefix.

range = None

TODO(briancurtin) there’s a lot of content here...

service = {'region_name': None, 'service_name': None, 'interface': 'public', 'version': None, 'service_type': 'object-store', 'requires_project_id': False, 'api_version': None}
set_metadata(session, metadata)[source]
signature = None

Used with temporary URLs to sign the request. For more information about temporary URLs, see OpenStack Object Storage API v1 Reference.

timestamp = None

The timestamp of the transaction.

transfer_encoding = None

Set to chunked to enable chunked transfer encoding. If used, do not set the Content-Length header to a non-zero value.