Projects

Projects represent the base unit of ownership in OpenStack, in that all resources in OpenStack should be owned by a specific project. A project itself must be owned by a specific domain, and hence all project names are not globally unique, but unique to their domain. If the domain for a project is not specified, then it is added to the default domain.

More information can be found in the official documentation.

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

Create

$identity = $openstack->identityV3();

$project = $identity->createProject([
    'description' => '{description}',
    'enabled'     => true,
    'name'        => '{name}'
]);

Read

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');
$project->retrieve();

Update

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

$project->enabled = false;

$project->update();

Delete

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

$project->delete();

List

$identity = $openstack->identityV3();

foreach ($identity->listProjects() as $project) {
}

List roles for project user

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

foreach ($project->listUserRoles(['userId' => '{projectUserId}']) as $role) {
    /** @var $role \OpenStack\Identity\v3\Models\Role */
}

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

Grant role to project user

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

$project->grantUserRole([
    'userId' => '{projectUserId}',
    'roleId' => '{roleId}',
]);

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

Check role for project user

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

$result = $project->checkUserRole([
    'userId' => '{projectUserId}',
    'roleId' => '{roleId}',
]);

if (true === $result) {
}

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

Revoke role for project user

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

$project->revokeUserRole([
    'userId' => '{projectUserId}',
    'roleId' => '{roleId}',
]);

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

List roles for project group

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

foreach ($project->listGroupRoles(['groupId' => '{groupId}']) as $role) {
    /** @var $role \OpenStack\Identity\v3\Models\Role */
}

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

Grant role to project group

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

$project->grantGroupRole([
    'groupId' => '{groupId}',
    'roleId'  => '{roleId}',
]);

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

Check role for project group

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

$result = $project->checkGroupRole([
    'groupId' => '{groupId}',
    'roleId'  => '{roleId}',
]);

if (true === $result) {
}

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

Revoke role for project group

$identity = $openstack->identityV3();

$project = $identity->getProject('{id}');

$project->revokeGroupRole([
    'groupId' => '{groupId}',
    'roleId'  => '{roleId}',
]);

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