otcextensions.sdk.obs.v1.obj

The OBS Object Class

The Object class inherits from Resource.

class otcextensions.sdk.obs.v1.obj.Object(data=None, **attrs)

The base resource

Parameters:
  • _synchronized (bool) – This is not intended to be used directly. See new() and existing().

  • connection (openstack.connection.Connection) – Reference to the Connection being used. Defaults to None to allow Resource objects to be used without an active Connection, such as in unit tests. Use of self._connection in Resource code should protect itself with a check for None.

base_path: str = '/'

The base part of the URI for this resource.

allow_create = True

Allow create operation for this resource.

allow_commit = True

Allow update operation for this resource.

allow_delete = True

Allow delete operation for this resource.

allow_list = True

Allow list operation for this resource.

allow_head = True

Allow head operation for this resource.

resources_key: ty.Optional[str] = ''

Plural form of key for resource.

resource_key: ty.Optional[str] = 'Contents'

Singular form of key for resource.

container

The unique name for the container.

name: ty.Union[Body, URI]

The unique name for the object.

last_modified

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

content_length

size of the response body. Instead it contains the size of the object, in bytes.

acl

private, public-read, public-read-write, authenticated-read bucket-owner-read, bucket-owner-full-control

content_md5

The MD5 digest string of the message body is calculated according to the RFC 1864 standard. That is, calculate the 128-bit binary array (the message header data encrypted with MD5) first, and then use Base 64 encoding to convert the binary data to a character string.

content_type

Indicates the content type of a requested resource, for example, text/plain.

etag

Indicates the hash value of an object. The entity tag (ETag) only reflects changes to the contents of an object, not its metadata.

request_id

Indicates the value created by OBS to uniquely identify a request. OBS uses this value to troubleshoot faults.

request_id_2

Indicates a special token that helps OBS troubleshoot faults.

sse

Indicates that SSE-KMS is used. Example: x-amz-server-side-encryption:aws:kms

sse_key_id

Indicates the master key ID. This header is used in SSE-KMS mode. If the customer does not provide the master key, the default master key will be used.

sse_algorithm

Indicates a decryption algorithm. The header is used in SSE-C mode. Constraints: This header must be used together with x-amz-server-side-encryption-customer-key and x-amz-server-side-encryption-customer-key-MD5.

sse_key_md5

Indicates the MD5 value of a key used to decrypt objects. The header is used in SSE-C mode. The MD5 value is used to check whether any error occurs during the transmission of the key. Constraints: This header is a base64-encoded 128-bit MD5 value and must be used together with x-amz-server-side-encryption-customer-algorithm and x-amz-server-side-encryption-customer-key.

storage_class

When creating an object, you can add this header in the request to set the storage class of the object. If you do not add this header, the object will use the default storage class of the bucket. Note: The storage class can be STANDARD (OBS Standard), STANDARD_IA (OBS Warm), or GLACIER (OBS Cold). Note that the three storage class values are case-sensitive.

server

Server name

website_redirect

If a bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. OBS stores the value of this header in the object metadata.

range

Obtains the specified range bytes of an object. The value is a range starting from 0 to maximum object length minus one. If the range is invalid, all object data is returned.

if_modified_since

Returns the object only if it has been modified since the time specified by this header, otherwise 304 Not Modified is returned.

if_unmodified_since

Returns the object only if it has not been modified since the time specified by this header, otherwise 412 Precondition Failed is returned. http://www.ietf.org/rfc/rfc2616.txt.

if_match

Returns the object only if its ETag is the same as the one specified by this header, otherwise 412 Precondition Failed is returned. http://www.ietf.org/rfc/rfc2616.txt.

if_none_match

Returns the object only if its ETag is different from the one specified by this header, otherwise 304 Not Modified is returned.

origin

Indicates an origin specified by a pre-request. Generally, it is a domain name

classmethod list(session, paginated=False, endpoint_override=None, headers=None, requests_auth=None, **params)

Override default list to incorporate endpoint overriding and custom headers

Since SDK Resource.list method is passing hardcoded headers do override the function

This resource object list generator handles pagination and takes query params for response filtering.

Parameters:
  • session (Adapter) – The session to use for making this request.

  • paginated (bool) – True if a GET to this resource returns a paginated series of responses, or False if a GET returns only one page of data. When paginated is False only one page of data will be returned regardless of the API’s support of pagination.

  • params (dict) – These keyword arguments are passed through the _transpose() method to find if any of them match expected query parameters to be sent in the params argument to get(). They are additionally checked against the base_path format string to see if any path fragments need to be filled in by the contents of this argument.

Returns:

A generator of Resource objects.

Raises:

MethodNotSupported if Resource.allow_list is not set to True.

Raises:

InvalidResourceQuery if query contains invalid params.

create(session, prepend_key=True, endpoint_override=None, headers=None, requests_auth=None)

Create a remote resource based on this instance.

Parameters:
  • session (Adapter) – The session to use for making this request.

  • prepend_key – A boolean indicating whether the resource_key should be prepended in a resource creation request. Default to True.

Returns:

This Resource instance.

Raises:

MethodNotSupported if Resource.allow_create is not set to True.

delete(session, error_message=None, endpoint_override=None, headers=None, requests_auth=None, params=None)

Delete the remote resource based on this instance.

This function overrides default Resource.delete to enable headers

Parameters:

session (Adapter) – The session to use for making this request.

Returns:

This Resource instance.

Raises:

MethodNotSupported if Resource.allow_update is not set to True.