Volume Types

Volume type is a group of volume policies. They can be used to specify which driver must be used on volume creation.

More information can be found in the official documentation.

In order to work with volume types you have to create the service first.

Create

The only attributes that are required when creating a volume are a name.

$service = $openstack->blockStorageV3();

$volumeType = $service->createVolumeType([
    'name' => '{name}',
]);

Read

$service = $openstack->blockStorageV3();

$volumeType = $service->getVolumeType('{volumeTypeId}');
$volumeType->retrieve();

Update

$service = $openstack->blockStorageV3();

$volumeType = $service->getVolumeType('{volumeTypeId}');
$volumeType->name = '{newName}';
$volumeType->update();

Delete

To permanently delete a volume type:

$service = $openstack->blockStorageV3();

$volumeType = $service->getVolumeType('{volumeTypeId}');
$volumeType->delete();

List

$service = $openstack->blockStorageV3();

$volumeTypes = $service->listVolumeTypes();

foreach ($volumeTypes as $volumeType) {
    /** @var \OpenStack\BlockStorage\v2\Models\VolumeType $volumeType */
}

Each iteration will return a VolumeType instance <OpenStack/BlockStorage/v2/Models/VolumeType.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.