ObjectBlockStorage OBS API

For details on how to use database, see /user/guides/obs (NEEDS TO BE DONE)

The OBS Class

The obs high-level interface is available through the obs member of a Connection object. The obs member will only be added if the otcextensions.sdk.register_otc_Extensions(conn) method is called.

Container Operations

class otcextensions.sdk.obs.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
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.

get_container(container)

Get the detail of a container

Parameters:

container – Container name or an object of class Container

Returns:

Detail of container

Return type:

Container

create_container(**attrs)

Create a new container from attributes

Parameters:
  • container – Name of the container to create.

  • 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

Object Operations

class otcextensions.sdk.obs.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
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, **attrs)

Download the data contained inside 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.

Raises:

ResourceNotFound when no resource can be found.

create_object(container, name, filename=None, data=None, segment_size=None, md5=None, generate_checksums=None, **headers)

Upload a new object from attributes

Parameters:
  • generate_checksums – Whether to generate checksums on the client side that get added to headers for later prevention of double uploads of identical data. (optional, defaults to True)

  • md5 – A hexadecimal md5 of the file. (Optional), if it is known and can be passed here, it will save repeating the expensive md5 process. It is assumed to be accurate.

  • segment_size – Break the uploaded object into segments of this many bytes. (Optional) SDK will attempt to discover the maximum value for this from the server if it is not specified, or will use a reasonable default.

  • container – The value can be the name of a container or a Container instance.

  • name – Name of the object to create.

  • data – The content to upload to the object. Mutually exclusive with filename.

  • filename – The path to the local file whose contents will be uploaded. Mutually exclusive with data.

  • attrs (dict) – Keyword arguments which will be used to create a Object, comprised of the properties on the Object class.

Returns:

The results of object creation

Return type:

Container

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