class Container extends OperatorResource implements Creatable, Deletable, Retrievable, Listable, HasMetadata

Traits

Constants

METADATA_PREFIX

Properties

$objectCount int
$bytesUsed int
$name string
$metadata array

Methods

populateFromResponse (ResponseInterface $response) : AbstractResource

All models which represent an API resource should be able to be populated from a {see ResponseInterface} object.

listObjects (array $options = array(), callable $mapFn = null) : Generator

Retrieves a collection of object resources in the form of a generator.

retrieve () : void

Retrieve details of the current resource from the remote API.

create (array $data) : $this

Create a new resource according to the configuration set in the options.

delete () : void

Permanently delete this resource.

mergeMetadata (array $metadata) : void

Merges a set of new values with those which already exist (on the remote API) for a resource. For example, if the resource has this metadata already set:

resetMetadata (array $metadata) : void

Replaces all of the existing metadata items for a resource with a new set of values. Any metadata items which are not provided in the call are removed from the resource. For example, if the resource has this metadata already set:

getMetadata () : array

Retrieves the metadata for the resource in the form of an associative array or hash. Each key represents the metadata item's name, and each value represents the metadata item's remote value.

getObject (string $name) : Object

Retrieves an Object and populates its name and containerName properties according to the name provided and the name of this container. A HTTP call will not be executed by default - you need to call {see Object::retrieve} or {see Object::download} on the returned Object object to do that.

objectExists (string $name) : bool

Identifies whether an object exists in this container.

createObject (array $data) : Object

Creates a single object according to the values provided.

createLargeObject (array $data) : Object

Creates a Dynamic Large Object by chunking a file into smaller segments and uploading them into a holding container. When this completes, a manifest file is uploaded which references the prefix of the segments, allowing concatenation when a request is executed against the manifest.

Details

populateFromResponse(ResponseInterface $response)

All models which represent an API resource should be able to be populated from a {see ResponseInterface} object.

Parameters

$response ResponseInterface

Return value

AbstractResource

Example code

$abstractResource = $container->populateFromResponse($response);

listObjects(array $options = array(), callable $mapFn = null)

Retrieves a collection of object resources in the form of a generator.

Parameters

$options array {see \OpenStack\ObjectStore\v1\Api::getContainer}
$mapFn callable Allows a function to be mapped over each element.

Return value

Generator

Example code

$generator = $container->listObjects($options, $mapFn);

retrieve()

Retrieve details of the current resource from the remote API.

Return value

void

Example code

$container->retrieve();

create(array $data)

Create a new resource according to the configuration set in the options.

Parameters

$data array {see \OpenStack\ObjectStore\v1\Api::putContainer}

Return value

$this

Example code

$models = $container->create($data);

delete()

Permanently delete this resource.

Return value

void

Example code

$container->delete();

mergeMetadata(array $metadata)

Merges a set of new values with those which already exist (on the remote API) for a resource. For example, if the resource has this metadata already set:

Foo: val1 Bar: val2

and mergeMetadata(['Foo' => 'val3', 'Baz' => 'val4']); is called, then the resource will have the following metadata:

Foo: val3 Bar: val2 Baz: val4

You will notice that any metadata items which are not specified in the call are preserved.

Parameters

$metadata array The new metadata items

Return value

void

Example code

$container->mergeMetadata($metadata);

resetMetadata(array $metadata)

Replaces all of the existing metadata items for a resource with a new set of values. Any metadata items which are not provided in the call are removed from the resource. For example, if the resource has this metadata already set:

Foo: val1 Bar: val2

and resetMetadata(['Foo' => 'val3', 'Baz' => 'val4']); is called, then the resource will have the following metadata:

Foo: val3 Baz: val4

Parameters

$metadata array The new metadata items

Return value

void

Example code

$container->resetMetadata($metadata);

getMetadata()

Retrieves the metadata for the resource in the form of an associative array or hash. Each key represents the metadata item's name, and each value represents the metadata item's remote value.

Return value

array

Example code

$array = $container->getMetadata();

getObject(string $name)

Retrieves an Object and populates its name and containerName properties according to the name provided and the name of this container. A HTTP call will not be executed by default - you need to call {see Object::retrieve} or {see Object::download} on the returned Object object to do that.

Parameters

$name string The name of the object

Return value

Object

Example code

$object = $container->getObject($name);

objectExists(string $name)

Identifies whether an object exists in this container.

Parameters

$name string The name of the object.

Return value

bool TRUE if the object exists, FALSE if it does not.

Exceptions

BadResponseError For any other HTTP error which does not have a 404 Not Found status.
Exception For any other type of fatal error.

Example code

$bool = $container->objectExists($name);

createObject(array $data)

Creates a single object according to the values provided.

Parameters

$data array {see \OpenStack\ObjectStore\v1\Api::putObject}

Return value

Object

Example code

$object = $container->createObject($data);

createLargeObject(array $data)

Creates a Dynamic Large Object by chunking a file into smaller segments and uploading them into a holding container. When this completes, a manifest file is uploaded which references the prefix of the segments, allowing concatenation when a request is executed against the manifest.

Parameters

$data array

Return value

Object

Example code

$object = $container->createLargeObject($data);