Snapshots
A snapshot is read-only point in time copy of a volume. The snapshot can be created from a volume that is currently in use or in an available state. The snapshot can then be used to create a new volume.
More information can be found in the official documentation.
In order to work with snapshots you have to create the service first.
List
$service = $openstack->blockStorageV3();
$snapshots = $service->listSnapshots();
foreach ($snapshots as $snapshot) {
/** @var \OpenStack\BlockStorage\v2\Models\Snapshot $snapshot */
}
Each iteration will return a php:class:Snapshot instance <OpenStack/BlockStorage/v2/Models/Snapshot.html>.
By default, PHP generators are used to represent collections of resources in the SDK. The benefit of using
generators is that it generally improves performance, since objects are not saved in memory as the iteration cycle goes
on; instead, each resource is directly output to the user-defined foreach
loop. For all intents and purposes, you
interact with generators like any other Traversable object, but to retain collections in memory, you will need to
implement your own logic.
List sorted
Possible values for sort_key are:
display_name
Possible values for sort_dir are:
asc
desc
$service = $openstack->blockStorageV3();
$snapshots = $service->listSnapshots(false, ['sortKey' => '{sortKey}', 'sortDir' => '{sortDir}']);
foreach ($snapshots as $snapshot) {
/** @var \OpenStack\BlockStorage\v2\Models\Snapshot $snapshot */
}