Users

A user is an individual API consumer that is owned by a domain. A role explicitly associates a user with projects or domains. A user with no assigned roles has no access to OpenStack resources.

More information can be found in the official documentation.

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

Create

$identity = $openstack->identityV3();

$user = $identity->createUser([
    'defaultProjectId' => '{defaultProjectId}',
    'description'      => '{description}',
    'domainId'         => '{domainId}',
    'email'            => '{email}',
    'enabled'          => true,
    'name'             => '{name}',
    'password'         => '{userPass}'
]);

Read

$identity = $openstack->identityV3();

$user = $identity->getUser('{id}');
$user->retrieve();

Update

$identity = $openstack->identityV3();

$user = $identity->getUser('{id}');

$user->description = '{description}';
$user->name = '{name}';

$user->update();

Delete

$identity = $openstack->identityV3();

$user = $identity->getUser('{id}');
$user->delete();

List

$identity = $openstack->identityV3();

foreach ($identity->listUsers() as $user) {
    /** @var $user \OpenStack\Identity\v3\Models\User */
}

List groups for user

$identity = $openstack->identityV3();

$user = $identity->getUser('{id}');

foreach ($user->listGroups() as $group) {
    /** @var $group \OpenStack\Identity\v3\Models\Group */
}

List projects for user

$identity = $openstack->identityV3();

$user = $identity->getUser('{id}');

foreach ($user->listProjects() as $project) {
    /** @var $project \OpenStack\Identity\v3\Models\Project */
}