Acquire.ObjectStore._objstore module

class ObjectStore[source]

Bases: object

static clear_all_except(bucket, keys)[source]

Removes all objects from the passed ‘bucket’ except those whose keys are or start with any key in ‘keys’

static close_par(par=None, par_uid=None, url_checksum=None)[source]

Close the passed PAR, which provides access to data in the passed bucket

static create_bucket(bucket, bucket_name, compartment=None)[source]

Create and return a new bucket in the object store called ‘bucket_name’, optionally placing it into the compartment identified by ‘compartment’. This will raise an ObjectStoreError if this bucket already exists

Parameters:
  • bucket (the) – Bucket to store data in
  • bucket_name (str) – Name for bucket
  • compartment (str, default=None) – Compartment to store
  • bucket
Returns:

New bucket

Return type:

dict

static create_par(bucket, encrypt_key, key=None, readable=True, writeable=False, duration=3600, cleanup_function=None)[source]

Create a pre-authenticated request for the passed bucket and key (if key is None then the request is for the entire bucket). This will return a PAR object that will contain a URL that can be used to access the object/bucket. If writeable is true, then the URL will also allow the object/bucket to be written to. PARs are time-limited. Set the lifetime in seconds by passing in ‘duration’ (by default this is one hour). Note that you must pass in a public key that will be used to encrypt this PAR. This is necessary as the PAR grants access to anyone who can decrypt the URL

static delete_all_objects(bucket, prefix=None)[source]

Deletes all objects…

static delete_bucket(bucket, force=False)[source]

Delete the passed bucket. This should be used with caution. Normally you can only delete a bucket if it is empty. If ‘force’ is True then it will remove all objects/pars from the bucket first, and then delete the bucket. This can cause a LOSS OF DATA!

static delete_object(bucket, key)[source]

Removes the object at ‘key’

static get_all_object_names(bucket, prefix=None)[source]

Returns the names of all objects in the passed bucket

static get_all_objects(bucket, prefix=None)[source]

Return all of the objects in the passed bucket

static get_all_objects_from_json(bucket, prefix=None)[source]

Return all of the objects in the passed bucket as json-deserialised objects

static get_all_strings(bucket, prefix=None)[source]

Return all of the strings in the passed bucket

static get_bucket(bucket, bucket_name, compartment=None, create_if_needed=True)[source]

Find and return a new bucket in the object store called ‘bucket_name’, optionally placing it into the compartment identified by ‘compartment’. If ‘create_if_needed’ is True then the bucket will be created if it doesn’t exist. Otherwise, if the bucket does not exist then an exception will be raised.

Parameters:
  • bucket (the) – Bucket to store data in
  • bucket_name (str) – Name for bucket
  • compartment (str, default=None) – Compartment to store
  • bucket
  • create_if_needed (bool, default=True) – Create new bucket if
  • don't if False (true,) –
    Returns:
    dict: Requested bucket
static get_bucket_name(bucket)[source]

Return the name of the passed bucket

static get_object(bucket, key)[source]

Return the binary data contained in the key ‘key’ in the passed bucket

static get_object_as_file(bucket, key, filename)[source]

Get the object contained in the key ‘key’ in the passed ‘bucket’ and writing this to the file called ‘filename’

static get_object_from_json(bucket, key)[source]

Return an object constructed from json stored at ‘key’ in the passed bucket. This returns None if there is no data at this key

static get_size_and_checksum(bucket, key)[source]

Return the object size (in bytes) and checksum of the object in the passed bucket at the specified key

static get_string_object(bucket, key)[source]

Return the string in ‘bucket’ associated with ‘key’

static is_bucket_empty(bucket)[source]

Return whether or not the passed bucket is empty

static set_ins_object_from_json(bucket, key, data)[source]

Set the value of ‘key’ in ‘bucket’ to equal to contents of ‘data’, which has been encoded to json, if (and only if) this key has not already been set (ins = ‘if not set’). This returns the object at this key after the operation (either the set object or the value that was previously set

static set_ins_string_object(bucket, key, string_data)[source]

Set the value of ‘key’ in ‘bucket’ to the string ‘string_data’, if (and only if) this key has not already been set (ins = ‘if not set’). This returns the object at this key after the operation (either the set string, or the value that was previously set)

static set_object(bucket, key, data)[source]

Set the value of ‘key’ in ‘bucket’ to binary ‘data’

static set_object_from_file(bucket, key, filename)[source]

Set the value of ‘key’ in ‘bucket’ to equal the contents of the file located by ‘filename’

static set_object_from_json(bucket, key, data)[source]

Set the value of ‘key’ in ‘bucket’ to equal to contents of ‘data’, which has been encoded to json

static set_string_object(bucket, key, string_data)[source]

Set the value of ‘key’ in ‘bucket’ to the string ‘string_data’

static take_object(bucket, key)[source]

Take (delete) the object from the object store, returning the object

static take_object_as_file(bucket, key, filename)[source]

Take (delete) the object contained in the key ‘key’ in the passed ‘bucket’ and writing this to the file called ‘filename’

static take_object_from_json(bucket, key)[source]

Take (delete) the object from the object store, returning the json-deserialised object

static take_string_object(bucket, key)[source]

Take (delete) the string object from the object store, returning the object

set_object_store_backend(backend)[source]

Set the backend that is used to actually connect to the object store. This can only be set once in the program!

use_testing_object_store_backend(backend)[source]
use_oci_object_store_backend()[source]