Object Store API

For details on how to use this API, see Using OpenStack Object Store

The Object Store Class

The Object Store high-level interface is exposed as the object_store object on Connection objects.

class openstack.object_store.v1._proxy.Proxy(session)
get_account_metadata()

Get metadata for this account.

Return type:Account
set_account_metadata(**metadata)

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.
delete_account_metadata(keys)

Delete metadata for this account.

Parameters:keys (list) – The keys of metadata to be deleted.
containers(**query)

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.
create_container(**attrs)

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_container(container, ignore_missing=True)

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

get_container_metadata(container)

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.
set_container_metadata(container, **metadata)

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
delete_container_metadata(container, keys)

Delete metadata for a container.

Parameters:
  • container – The value can be the ID of a container or a Container instance.
  • keys (list) – The keys of metadata to be deleted.
objects(container, **query)

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.

get_object(obj, container=None)

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.

download_object(obj, container=None, path=None)

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.

upload_object(**attrs)

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
copy_object()

Copy an object.

delete_object(obj, ignore_missing=True, container=None)

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

get_object_metadata(obj, container=None)

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.

set_object_metadata(obj, container=None, **metadata)

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
delete_object_metadata(obj, container=None, keys=None)

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 (list) – The keys of metadata to be deleted.