Groups

Groups are a container representing a collection of users. A group itself must be owned by a specific domain, and hence all group names are not globally unique, but only unique to their domain.

More information can be found in the official documentation.

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

Create

$identity = $openstack->identityV3();

$group = $identity->createGroup([
    'description' => '{description}',
    'name'        => '{name}',
]);

Read

$identity = $openstack->identityV3();

$group = $identity->getGroup('{groupId}');
$group->retrieve();

Update

$identity = $openstack->identityV3();

$group = $identity->getGroup('{groupId}');

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

$group->update();

Delete

$identity = $openstack->identityV3();

$group = $identity->getGroup('{groupId}');

$group->delete();

List

$identity = $openstack->identityV3();

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

List users in a group

$identity = $openstack->identityV3();

$group = $identity->getGroup('{groupId}');

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

To see all the required and optional parameters for this operation, along with their types and descriptions, view the reference documentation.

Add user to group

$identity = $openstack->identityV3();

$group = $identity->getGroup('{groupId}');

$group->addUser(['userId' => '{groupUserId}']);

To see all the required and optional parameters for this operation, along with their types and descriptions, view the reference documentation.

Remove user from group

$identity = $openstack->identityV3();

$group = $identity->getGroup('{groupId}');

$group->removeUser(['userId' => '{groupUserId}']);

To see all the required and optional parameters for this operation, along with their types and descriptions, view the reference documentation.

Check user membership in a group

$identity = $openstack->identityV3();

$group = $identity->getGroup('{groupId}');

$hasMembership = $group->checkMembership(['userId' => '{groupUserId}']);

To see all the required and optional parameters for this operation, along with their types and descriptions, view the reference documentation.