Обновление клиента (apps, 3rdparty, install)

This commit is contained in:
root
2026-03-16 08:42:57 +00:00
parent b8905de237
commit f390426546
3354 changed files with 505213 additions and 3 deletions
+882
View File
@@ -0,0 +1,882 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3;
use OpenStack\Common\Api\AbstractApi;
class Api extends AbstractApi
{
public function __construct()
{
$this->params = new Params();
}
public function postTokens(): array
{
return [
'method' => 'POST',
'path' => 'auth/tokens',
'skipAuth' => true,
'params' => [
'methods' => $this->params->methods(),
'user' => $this->params->user(),
'application_credential' => $this->params->applicationCredential(),
'tokenId' => $this->params->tokenBody(),
'scope' => $this->params->scope(),
],
];
}
public function getTokens(): array
{
return [
'method' => 'GET',
'path' => 'auth/tokens',
'params' => ['tokenId' => $this->params->tokenId()],
];
}
public function headTokens(): array
{
return [
'method' => 'HEAD',
'path' => 'auth/tokens',
'params' => ['tokenId' => $this->params->tokenId()],
];
}
public function deleteTokens(): array
{
return [
'method' => 'DELETE',
'path' => 'auth/tokens',
'params' => ['tokenId' => $this->params->tokenId()],
];
}
public function postServices(): array
{
return [
'method' => 'POST',
'path' => 'services',
'jsonKey' => 'service',
'params' => [
'name' => $this->params->name('service'),
'type' => $this->params->type('service'),
'description' => $this->params->desc('service'),
],
];
}
public function getServices(): array
{
return [
'method' => 'GET',
'path' => 'services',
'params' => ['type' => $this->params->typeQuery()],
];
}
public function getService(): array
{
return [
'method' => 'GET',
'path' => 'services/{id}',
'params' => ['id' => $this->params->idUrl('service')],
];
}
public function patchService(): array
{
return [
'method' => 'PATCH',
'path' => 'services/{id}',
'jsonKey' => 'service',
'params' => [
'id' => $this->params->idUrl('service'),
'name' => $this->params->name('service'),
'type' => $this->params->type('service'),
'description' => $this->params->desc('service'),
],
];
}
public function deleteService(): array
{
return [
'method' => 'DELETE',
'path' => 'services/{id}',
'params' => ['id' => $this->params->idUrl('service')],
];
}
public function postEndpoints(): array
{
return [
'method' => 'POST',
'path' => 'endpoints',
'jsonKey' => 'endpoint',
'params' => [
'interface' => $this->params->interf(),
'name' => $this->isRequired($this->params->name('endpoint')),
'region' => $this->params->region(),
'url' => $this->params->endpointUrl(),
'serviceId' => $this->params->serviceId(),
],
];
}
public function getEndpoints(): array
{
return [
'method' => 'GET',
'path' => 'endpoints',
'params' => [
'interface' => $this->query($this->params->interf()),
'serviceId' => $this->query($this->params->serviceId()),
],
];
}
public function getEndpoint(): array
{
return [
'method' => 'GET',
'path' => 'endpoints/{id}',
'params' => [
'id' => $this->params->idUrl('service'),
],
];
}
public function patchEndpoint(): array
{
return [
'method' => 'PATCH',
'path' => 'endpoints/{id}',
'jsonKey' => 'endpoint',
'params' => [
'id' => $this->params->idUrl('endpoint'),
'interface' => $this->params->interf(),
'name' => $this->params->name('endpoint'),
'region' => $this->params->region(),
'url' => $this->params->endpointUrl(),
'serviceId' => $this->params->serviceId(),
],
];
}
public function deleteEndpoint(): array
{
return [
'method' => 'DELETE',
'path' => 'endpoints/{id}',
'params' => ['id' => $this->params->idUrl('endpoint')],
];
}
public function postDomains(): array
{
return [
'method' => 'POST',
'path' => 'domains',
'jsonKey' => 'domain',
'params' => [
'name' => $this->isRequired($this->params->name('domain')),
'enabled' => $this->params->enabled('domain'),
'description' => $this->params->desc('domain'),
],
];
}
public function getDomains(): array
{
return [
'method' => 'GET',
'path' => 'domains',
'params' => [
'name' => $this->query($this->params->name('domain')),
'enabled' => $this->query($this->params->enabled('domain')),
],
];
}
public function getDomain(): array
{
return [
'method' => 'GET',
'path' => 'domains/{id}',
'params' => ['id' => $this->params->idUrl('domain')],
];
}
public function patchDomain(): array
{
return [
'method' => 'PATCH',
'path' => 'domains/{id}',
'jsonKey' => 'domain',
'params' => [
'id' => $this->params->idUrl('domain'),
'name' => $this->params->name('domain'),
'enabled' => $this->params->enabled('domain'),
'description' => $this->params->desc('domain'),
],
];
}
public function deleteDomain(): array
{
return [
'method' => 'DELETE',
'path' => 'domains/{id}',
'params' => ['id' => $this->params->idUrl('domain')],
];
}
public function getUserRoles(): array
{
return [
'method' => 'GET',
'path' => 'domains/{domainId}/users/{userId}/roles',
'params' => [
'domainId' => $this->params->idUrl('domain'),
'userId' => $this->params->idUrl('user'),
],
];
}
public function putUserRoles(): array
{
return [
'method' => 'PUT',
'path' => 'domains/{domainId}/users/{userId}/roles/{roleId}',
'params' => [
'domainId' => $this->params->idUrl('domain'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function headUserRole(): array
{
return [
'method' => 'HEAD',
'path' => 'domains/{domainId}/users/{userId}/roles/{roleId}',
'params' => [
'domainId' => $this->params->idUrl('domain'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function deleteUserRole(): array
{
return [
'method' => 'DELETE',
'path' => 'domains/{domainId}/users/{userId}/roles/{roleId}',
'params' => [
'domainId' => $this->params->idUrl('domain'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function getGroupRoles(): array
{
return [
'method' => 'GET',
'path' => 'domains/{domainId}/groups/{groupId}/roles',
'params' => [
'domainId' => $this->params->idUrl('domain'),
'groupId' => $this->params->idUrl('group'),
],
];
}
public function putGroupRole(): array
{
return [
'method' => 'PUT',
'path' => 'domains/{domainId}/groups/{groupId}/roles/{roleId}',
'params' => [
'domainId' => $this->params->idUrl('domain'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function headGroupRole(): array
{
return [
'method' => 'HEAD',
'path' => 'domains/{domainId}/groups/{groupId}/roles/{roleId}',
'params' => [
'domainId' => $this->params->idUrl('domain'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function deleteGroupRole(): array
{
return [
'method' => 'DELETE',
'path' => 'domains/{domainId}/groups/{groupId}/roles/{roleId}',
'params' => [
'domainId' => $this->params->idUrl('domain'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function postProjects(): array
{
return [
'method' => 'POST',
'path' => 'projects',
'jsonKey' => 'project',
'params' => [
'description' => $this->params->desc('project'),
'domainId' => $this->params->domainId('project'),
'parentId' => $this->params->parentId(),
'enabled' => $this->params->enabled('project'),
'name' => $this->isRequired($this->params->name('project')),
],
];
}
public function getProjects(): array
{
return [
'method' => 'GET',
'path' => 'projects',
'params' => [
'domainId' => $this->query($this->params->domainId('project')),
'enabled' => $this->query($this->params->enabled('project')),
'name' => $this->query($this->params->name('project')),
],
];
}
public function getProject(): array
{
return [
'method' => 'GET',
'path' => 'projects/{id}',
'params' => ['id' => $this->params->idUrl('project')],
];
}
public function patchProject(): array
{
return [
'method' => 'PATCH',
'path' => 'projects/{id}',
'jsonKey' => 'project',
'params' => [
'id' => $this->params->idUrl('project'),
'description' => $this->params->desc('project'),
'domainId' => $this->params->domainId('project'),
'parentId' => $this->params->parentId(),
'enabled' => $this->params->enabled('project'),
'name' => $this->params->name('project'),
],
];
}
public function deleteProject(): array
{
return [
'method' => 'DELETE',
'path' => 'projects/{id}',
'params' => ['id' => $this->params->idUrl('project')],
];
}
public function getProjectUserRoles(): array
{
return [
'method' => 'GET',
'path' => 'projects/{projectId}/users/{userId}/roles',
'params' => [
'projectId' => $this->params->idUrl('project'),
'userId' => $this->params->idUrl('user'),
],
];
}
public function putProjectUserRole(): array
{
return [
'method' => 'PUT',
'path' => 'projects/{projectId}/users/{userId}/roles/{roleId}',
'params' => [
'projectId' => $this->params->idUrl('project'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function headProjectUserRole(): array
{
return [
'method' => 'HEAD',
'path' => 'projects/{projectId}/users/{userId}/roles/{roleId}',
'params' => [
'projectId' => $this->params->idUrl('project'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function deleteProjectUserRole(): array
{
return [
'method' => 'DELETE',
'path' => 'projects/{projectId}/users/{userId}/roles/{roleId}',
'params' => [
'projectId' => $this->params->idUrl('project'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function getProjectGroupRoles(): array
{
return [
'method' => 'GET',
'path' => 'projects/{projectId}/groups/{groupId}/roles',
'params' => [
'projectId' => $this->params->idUrl('project'),
'groupId' => $this->params->idUrl('group'),
],
];
}
public function putProjectGroupRole(): array
{
return [
'method' => 'PUT',
'path' => 'projects/{projectId}/groups/{groupId}/roles/{roleId}',
'params' => [
'projectId' => $this->params->idUrl('project'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function headProjectGroupRole(): array
{
return [
'method' => 'HEAD',
'path' => 'projects/{projectId}/groups/{groupId}/roles/{roleId}',
'params' => [
'projectId' => $this->params->idUrl('project'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function deleteProjectGroupRole(): array
{
return [
'method' => 'DELETE',
'path' => 'projects/{projectId}/groups/{groupId}/roles/{roleId}',
'params' => [
'projectId' => $this->params->idUrl('project'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
],
];
}
public function postUsers(): array
{
return [
'method' => 'POST',
'path' => 'users',
'jsonKey' => 'user',
'params' => [
'defaultProjectId' => $this->params->defaultProjectId(),
'description' => $this->params->desc('user'),
'domainId' => $this->params->domainId('user'),
'email' => $this->params->email(),
'enabled' => $this->params->enabled('user'),
'name' => $this->isRequired($this->params->name('user')),
'password' => $this->params->password(),
],
];
}
public function getUsers(): array
{
return [
'method' => 'GET',
'path' => 'users',
'params' => [
'domainId' => $this->query($this->params->domainId('user')),
'enabled' => $this->query($this->params->enabled('user')),
'name' => $this->query($this->params->name('user')),
],
];
}
public function getUser(): array
{
return [
'method' => 'GET',
'path' => 'users/{id}',
'params' => ['id' => $this->params->idUrl('user')],
];
}
public function patchUser(): array
{
return [
'method' => 'PATCH',
'path' => 'users/{id}',
'jsonKey' => 'user',
'params' => [
'id' => $this->params->idUrl('user'),
'defaultProjectId' => $this->params->defaultProjectId(),
'description' => $this->params->desc('user'),
'email' => $this->params->email(),
'enabled' => $this->params->enabled('user'),
'name' => $this->params->name('user'),
'password' => $this->params->password(),
],
];
}
public function deleteUser(): array
{
return [
'method' => 'DELETE',
'path' => 'users/{id}',
'params' => ['id' => $this->params->idUrl('user')],
];
}
public function getUserGroups(): array
{
return [
'method' => 'GET',
'path' => 'users/{id}/groups',
'params' => ['id' => $this->params->idUrl('user')],
];
}
public function getUserProjects(): array
{
return [
'method' => 'GET',
'path' => 'users/{id}/projects',
'params' => ['id' => $this->params->idUrl('user')],
];
}
public function postGroups(): array
{
return [
'method' => 'POST',
'path' => 'groups',
'jsonKey' => 'group',
'params' => [
'description' => $this->params->desc('group'),
'domainId' => $this->params->domainId('group'),
'name' => $this->params->name('group'),
],
];
}
public function getGroups(): array
{
return [
'method' => 'GET',
'path' => 'groups',
'params' => ['domainId' => $this->query($this->params->domainId('group'))],
];
}
public function getGroup(): array
{
return [
'method' => 'GET',
'path' => 'groups/{id}',
'params' => ['id' => $this->params->idUrl('group')],
];
}
public function patchGroup(): array
{
return [
'method' => 'PATCH',
'path' => 'groups/{id}',
'jsonKey' => 'group',
'params' => [
'id' => $this->params->idUrl('group'),
'description' => $this->params->desc('group'),
'name' => $this->params->name('group'),
],
];
}
public function deleteGroup(): array
{
return [
'method' => 'DELETE',
'path' => 'groups/{id}',
'params' => ['id' => $this->params->idUrl('group')],
];
}
public function getGroupUsers(): array
{
return [
'method' => 'GET',
'path' => 'groups/{id}/users',
'params' => ['id' => $this->params->idUrl('group')],
];
}
public function putGroupUser(): array
{
return [
'method' => 'PUT',
'path' => 'groups/{groupId}/users/{userId}',
'params' => [
'groupId' => $this->params->idUrl('group'),
'userId' => $this->params->idUrl('user'),
],
];
}
public function deleteGroupUser(): array
{
return [
'method' => 'DELETE',
'path' => 'groups/{groupId}/users/{userId}',
'params' => [
'groupId' => $this->params->idUrl('group'),
'userId' => $this->params->idUrl('user'),
],
];
}
public function headGroupUser(): array
{
return [
'method' => 'HEAD',
'path' => 'groups/{groupId}/users/{userId}',
'params' => [
'groupId' => $this->params->idUrl('group'),
'userId' => $this->params->idUrl('user'),
],
];
}
public function postCredentials(): array
{
return [
'method' => 'POST',
'path' => 'credentials',
'params' => [
'blob' => $this->params->blob(),
'projectId' => $this->params->projectId(),
'type' => $this->params->type('credential'),
'userId' => $this->params->userId(),
],
];
}
public function getCredentials(): array
{
return [
'method' => 'GET',
'path' => 'credentials',
'params' => [],
];
}
public function getCredential(): array
{
return [
'method' => 'GET',
'path' => 'credentials/{id}',
'params' => ['id' => $this->params->idUrl('credential')],
];
}
public function patchCredential(): array
{
return [
'method' => 'PATCH',
'path' => 'credentials/{id}',
'params' => ['id' => $this->params->idUrl('credential')] + $this->postCredentials()['params'],
];
}
public function deleteCredential(): array
{
return [
'method' => 'DELETE',
'path' => 'credentials/{id}',
'params' => ['id' => $this->params->idUrl('credential')],
];
}
public function postRoles(): array
{
return [
'method' => 'POST',
'path' => 'roles',
'jsonKey' => 'role',
'params' => ['name' => $this->isRequired($this->params->name('role'))],
];
}
public function getRoles(): array
{
return [
'method' => 'GET',
'path' => 'roles',
'params' => ['name' => $this->query($this->params->name('role'))],
];
}
public function deleteRole(): array
{
return [
'method' => 'DELETE',
'path' => 'roles/{id}',
'params' => ['id' => $this->params->idUrl('role')],
];
}
public function getRoleAssignments(): array
{
return [
'method' => 'GET',
'path' => 'role_assignments',
'params' => [
'userId' => $this->params->userIdQuery(),
'groupId' => $this->params->groupIdQuery(),
'roleId' => $this->params->roleIdQuery(),
'domainId' => $this->params->domainIdQuery(),
'projectId' => $this->params->projectIdQuery(),
'effective' => $this->params->effective(),
],
];
}
public function postPolicies(): array
{
return [
'method' => 'POST',
'path' => 'policies',
'jsonKey' => 'policy',
'params' => [
'blob' => $this->params->blob(),
'projectId' => $this->params->projectId('policy'),
'type' => $this->params->type('policy'),
'userId' => $this->params->userId('policy'),
],
];
}
public function getPolicies(): array
{
return [
'method' => 'GET',
'path' => 'policies',
'params' => ['type' => $this->query($this->params->type('policy'))],
];
}
public function getPolicy(): array
{
return [
'method' => 'GET',
'path' => 'policies/{id}',
'params' => ['id' => $this->params->idUrl('policy')],
];
}
public function patchPolicy(): array
{
return [
'method' => 'PATCH',
'path' => 'policies/{id}',
'jsonKey' => 'policy',
'params' => [
'id' => $this->params->idUrl('policy'),
'blob' => $this->params->blob(),
'projectId' => $this->params->projectId('policy'),
'type' => $this->params->type('policy'),
'userId' => $this->params->userId(),
],
];
}
public function deletePolicy(): array
{
return [
'method' => 'DELETE',
'path' => 'policies/{id}',
'params' => ['id' => $this->params->idUrl('policy')],
];
}
public function getApplicationCredential(): array
{
return [
'method' => 'GET',
'path' => 'users/{userId}/application_credentials/{id}',
'jsonKey' => 'application_credential',
'params' => [
'id' => $this->params->idUrl('application_credential'),
'userId' => $this->params->idUrl('user'),
],
];
}
public function postApplicationCredential(): array
{
return [
'method' => 'POST',
'path' => 'users/{userId}/application_credentials',
'jsonKey' => 'application_credential',
'params' => [
'userId' => $this->params->idUrl('user'),
'name' => $this->params->name('application_credential'),
'description' => $this->params->desc('application_credential'),
],
];
}
public function deleteApplicationCredential(): array
{
return [
'method' => 'DELETE',
'path' => 'users/{userId}/application_credentials/{id}',
'params' => [
'id' => $this->params->idUrl('application_credential'),
'userId' => $this->params->idUrl('user'),
],
];
}
}
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3;
abstract class Enum
{
public const INTERFACE_INTERNAL = 'internal';
public const INTERFACE_PUBLIC = 'public';
public const INTERFACE_ADMIN = 'admin';
}
@@ -0,0 +1,69 @@
<?php
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class ApplicationCredential extends OperatorResource implements Creatable, Listable, Retrievable, Deletable
{
/** @var string */
public $id;
/** @var string */
public $userId;
/** @var string */
public $name;
/** @var string */
public $description;
/** @var string|null */
public $secret = null;
protected $aliases = [
'user_id' => 'userId',
];
protected $resourceKey = 'application_credential';
protected $resourcesKey = 'application_credentials';
/**
* {@inheritdoc}
*
* @param array $userOptions {@see \OpenStack\Identity\v3\Api::postApplicationCredential}
*/
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postApplicationCredential(), $userOptions);
return $this->populateFromResponse($response);
}
/**
* {@inheritdoc}
*/
public function retrieve()
{
$response = $this->execute(
$this->api->getApplicationCredential(),
['id' => $this->id, 'userId' => $this->userId]
);
$this->populateFromResponse($response);
}
/**
* {@inheritdoc}
*/
public function delete()
{
$this->executeWithState($this->api->deleteApplicationCredential());
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
class Assignment extends OperatorResource implements Listable
{
/** @var Role */
public $role;
/** @var array */
public $scope;
/** @var Group */
public $group;
/** @var User */
public $user;
protected $resourcesKey = 'role_assignments';
protected $resourceKey = 'role_assignment';
protected function getAliases(): array
{
return parent::getAliases() + [
'role' => new Alias('role', Role::class),
'user' => new Alias('user', User::class),
'group' => new Alias('group', Group::class),
];
}
}
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Resource\OperatorResource;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Catalog extends OperatorResource implements \OpenStack\Common\Auth\Catalog
{
/** @var []Service */
public $services;
protected function getAliases(): array
{
return parent::getAliases() + [
'services' => new Alias('services', Service::class, true),
];
}
public function populateFromArray(array $data): self
{
foreach ($data as $service) {
$this->services[] = $this->model(Service::class, $service);
}
return $this;
}
/**
* Retrieve a base URL for a service, according to its catalog name, type, region.
*
* @param string $name the name of the service as it appears in the catalog
* @param string $type the type of the service as it appears in the catalog
* @param string $region the region of the service as it appears in the catalog
* @param string $urlType unused
*
* @return false|string FALSE if no URL found
*/
public function getServiceUrl(string $name, string $type, string $region, string $urlType): string
{
if (empty($this->services)) {
throw new \RuntimeException('No services are defined');
}
foreach ($this->services as $service) {
if (false !== ($url = $service->getUrl($name, $type, $region, $urlType))) {
return $url;
}
}
throw new \RuntimeException(sprintf("Endpoint URL could not be found in the catalog for this service.\nName: %s\nType: %s\nRegion: %s\nURL type: %s", $name, $type, $region, $urlType));
}
}
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Credential extends OperatorResource implements Creatable, Updateable, Retrievable, Listable, Deletable
{
/** @var string */
public $blob;
/** @var string */
public $id;
/** @var array */
public $links;
/** @var string */
public $projectId;
/** @var string */
public $type;
/** @var string */
public $userId;
protected $aliases = [
'project_id' => 'projectId',
'user_id' => 'userId',
];
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postCredentials(), $userOptions);
return $this->populateFromResponse($response);
}
public function retrieve()
{
$response = $this->executeWithState($this->api->getCredential());
$this->populateFromResponse($response);
}
public function update()
{
$response = $this->executeWithState($this->api->patchCredential());
$this->populateFromResponse($response);
}
public function delete()
{
$this->executeWithState($this->api->deleteCredential());
}
}
@@ -0,0 +1,148 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Domain extends OperatorResource implements Creatable, Listable, Retrievable, Updateable, Deletable
{
/** @var string */
public $id;
/** @var string */
public $name;
/** @var array */
public $links;
/** @var bool */
public $enabled;
/** @var string */
public $description;
protected $resourceKey = 'domain';
protected $resourcesKey = 'domains';
/**
* @param array $data {@see \OpenStack\Identity\v3\Api::postDomains}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postDomains(), $data);
return $this->populateFromResponse($response);
}
public function retrieve()
{
$response = $this->executeWithState($this->api->getDomain());
$this->populateFromResponse($response);
}
public function update()
{
$response = $this->executeWithState($this->api->patchDomain());
$this->populateFromResponse($response);
}
public function delete()
{
$this->executeWithState($this->api->deleteDomain());
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::getUserRoles}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Role>
*/
public function listUserRoles(array $options = []): \Generator
{
$options['domainId'] = $this->id;
return $this->model(Role::class)->enumerate($this->api->getUserRoles(), $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::putUserRoles}
*/
public function grantUserRole(array $options = [])
{
$this->execute($this->api->putUserRoles(), ['domainId' => $this->id] + $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::headUserRole}
*/
public function checkUserRole(array $options = []): bool
{
try {
$this->execute($this->api->headUserRole(), ['domainId' => $this->id] + $options);
return true;
} catch (BadResponseError $e) {
return false;
}
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::deleteUserRole}
*/
public function revokeUserRole(array $options = [])
{
$this->execute($this->api->deleteUserRole(), ['domainId' => $this->id] + $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::getGroupRoles}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Role>
*/
public function listGroupRoles(array $options = []): \Generator
{
$options['domainId'] = $this->id;
return $this->model(Role::class)->enumerate($this->api->getGroupRoles(), $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::putGroupRole}
*/
public function grantGroupRole(array $options = [])
{
$this->execute($this->api->putGroupRole(), ['domainId' => $this->id] + $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::headGroupRole}
*/
public function checkGroupRole(array $options = []): bool
{
try {
$this->execute($this->api->headGroupRole(), ['domainId' => $this->id] + $options);
return true;
} catch (BadResponseError $e) {
return false;
}
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::deleteGroupRole}
*/
public function revokeGroupRole(array $options = [])
{
$this->execute($this->api->deleteGroupRole(), ['domainId' => $this->id] + $options);
}
}
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Endpoint extends OperatorResource implements Creatable, Updateable, Deletable, Retrievable
{
/** @var string */
public $id;
/** @var string */
public $interface;
/** @var string */
public $name;
/** @var string */
public $serviceId;
/** @var string */
public $region;
/** @var array */
public $links;
/** @var string */
public $url;
protected $resourceKey = 'endpoint';
protected $resourcesKey = 'endpoints';
protected $aliases = ['service_id' => 'serviceId'];
/**
* @param array $data {@see \OpenStack\Identity\v3\Api::postEndpoints}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postEndpoints(), $data);
return $this->populateFromResponse($response);
}
public function retrieve()
{
$response = $this->executeWithState($this->api->getEndpoint());
$this->populateFromResponse($response);
}
public function update()
{
$response = $this->executeWithState($this->api->patchEndpoint());
$this->populateFromResponse($response);
}
public function delete()
{
$this->execute($this->api->deleteEndpoint(), $this->getAttrs(['id']));
}
public function regionMatches(string $value): bool
{
return in_array($this->region, ['*', $value]);
}
public function interfaceMatches(string $value): bool
{
return $this->interface && $this->interface == $value;
}
}
@@ -0,0 +1,108 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Group extends OperatorResource implements Creatable, Listable, Retrievable, Updateable, Deletable
{
/** @var string */
public $domainId;
/** @var string */
public $id;
/** @var string */
public $description;
/** @var array */
public $links;
/** @var string */
public $name;
protected $aliases = ['domain_id' => 'domainId'];
protected $resourceKey = 'group';
protected $resourcesKey = 'groups';
/**
* @param array $data {@see \OpenStack\Identity\v3\Api::postGroups}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postGroups(), $data);
return $this->populateFromResponse($response);
}
public function retrieve()
{
$response = $this->execute($this->api->getGroup(), ['id' => $this->id]);
$this->populateFromResponse($response);
}
public function update()
{
$response = $this->executeWithState($this->api->patchGroup());
$this->populateFromResponse($response);
}
public function delete()
{
$this->execute($this->api->deleteGroup(), ['id' => $this->id]);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::getGroupUsers}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\User>
*/
public function listUsers(array $options = []): \Generator
{
$options['id'] = $this->id;
return $this->model(User::class)->enumerate($this->api->getGroupUsers(), $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::putGroupUser}
*/
public function addUser(array $options)
{
$this->execute($this->api->putGroupUser(), ['groupId' => $this->id] + $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::deleteGroupUser}
*/
public function removeUser(array $options)
{
$this->execute($this->api->deleteGroupUser(), ['groupId' => $this->id] + $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::headGroupUser}
*/
public function checkMembership(array $options): bool
{
try {
$this->execute($this->api->headGroupUser(), ['groupId' => $this->id] + $options);
return true;
} catch (BadResponseError $e) {
return false;
}
}
}
@@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Policy extends OperatorResource implements Creatable, Listable, Retrievable, Updateable, Deletable
{
/** @var string */
public $blob;
/** @var string */
public $id;
/** @var array */
public $links;
/** @var string */
public $projectId;
/** @var string */
public $type;
/** @var string */
public $userId;
protected $resourceKey = 'policy';
protected $resourcesKey = 'policies';
protected $aliases = [
'project_id' => 'projectId',
'user_id' => 'userId',
];
/**
* @param array $data {@see \OpenStack\Identity\v3\Api::postPolicies}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postPolicies(), $data);
return $this->populateFromResponse($response);
}
public function retrieve()
{
$response = $this->execute($this->api->getPolicy(), ['id' => $this->id]);
$this->populateFromResponse($response);
}
public function update()
{
$response = $this->executeWithState($this->api->patchPolicy());
$this->populateFromResponse($response);
}
public function delete()
{
$this->execute($this->api->deletePolicy(), ['id' => $this->id]);
}
}
@@ -0,0 +1,160 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Project extends OperatorResource implements Creatable, Retrievable, Listable, Updateable, Deletable
{
/** @var string */
public $domainId;
/** @var string */
public $parentId;
/** @var bool */
public $enabled;
/** @var string */
public $description;
/** @var string */
public $id;
/** @var array */
public $links;
/** @var string */
public $name;
protected $aliases = [
'domain_id' => 'domainId',
'parent_id' => 'parentId',
];
protected $resourceKey = 'project';
protected $resourcesKey = 'projects';
/**
* @param array $data {@see \OpenStack\Identity\v3\Api::postProjects}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postProjects(), $data);
$this->populateFromResponse($response);
return $this;
}
public function retrieve()
{
$response = $this->executeWithState($this->api->getProject());
$this->populateFromResponse($response);
}
public function update()
{
$response = $this->executeWithState($this->api->patchProject());
$this->populateFromResponse($response);
}
public function delete()
{
$this->executeWithState($this->api->deleteProject());
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::getProjectUserRoles}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Role>
*/
public function listUserRoles(array $options = []): \Generator
{
$options['projectId'] = $this->id;
return $this->model(Role::class)->enumerate($this->api->getProjectUserRoles(), $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::putProjectUserRole}
*/
public function grantUserRole(array $options)
{
$this->execute($this->api->putProjectUserRole(), ['projectId' => $this->id] + $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::headProjectUserRole}
*/
public function checkUserRole(array $options): bool
{
try {
$this->execute($this->api->headProjectUserRole(), ['projectId' => $this->id] + $options);
return true;
} catch (BadResponseError $e) {
return false;
}
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::deleteProjectUserRole}
*/
public function revokeUserRole(array $options)
{
$this->execute($this->api->deleteProjectUserRole(), ['projectId' => $this->id] + $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::getProjectGroupRoles}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Role>
*/
public function listGroupRoles(array $options = []): \Generator
{
$options['projectId'] = $this->id;
return $this->model(Role::class)->enumerate($this->api->getProjectGroupRoles(), $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::putProjectGroupRole}
*/
public function grantGroupRole(array $options)
{
$this->execute($this->api->putProjectGroupRole(), ['projectId' => $this->id] + $options);
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::headProjectGroupRole}
*/
public function checkGroupRole(array $options): bool
{
try {
$this->execute($this->api->headProjectGroupRole(), ['projectId' => $this->id] + $options);
return true;
} catch (BadResponseError $e) {
return false;
}
}
/**
* @param array $options {@see \OpenStack\Identity\v3\Api::deleteProjectGroupRole}
*/
public function revokeGroupRole(array $options)
{
$this->execute($this->api->deleteProjectGroupRole(), ['projectId' => $this->id] + $options);
}
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Role extends OperatorResource implements Creatable, Listable, Deletable
{
/** @var string */
public $id;
/** @var string */
public $name;
/** @var array */
public $links;
protected $resourceKey = 'role';
protected $resourcesKey = 'roles';
/**
* @param array $data {@see \OpenStack\Identity\v3\Api::postRoles}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postRoles(), $data);
return $this->populateFromResponse($response);
}
public function delete()
{
$this->executeWithState($this->api->deleteRole());
}
}
@@ -0,0 +1,109 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Service extends OperatorResource implements Creatable, Listable, Retrievable, Updateable, Deletable
{
/** @var string */
public $id;
/** @var string */
public $name;
/** @var string */
public $type;
/** @var string */
public $description;
/** @var []Endpoint */
public $endpoints;
/** @var array */
public $links;
protected $resourceKey = 'service';
protected $resourcesKey = 'services';
protected function getAliases(): array
{
return parent::getAliases() + [
'endpoints' => new Alias('endpoints', Endpoint::class, true),
];
}
/**
* @param array $data {@see \OpenStack\Identity\v3\Api::postServices}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postServices(), $data);
return $this->populateFromResponse($response);
}
public function retrieve()
{
$response = $this->executeWithState($this->api->getService());
$this->populateFromResponse($response);
}
public function update()
{
$response = $this->executeWithState($this->api->patchService());
$this->populateFromResponse($response);
}
public function delete()
{
$this->executeWithState($this->api->deleteService());
}
private function nameMatches(string $value): bool
{
return $this->name && $this->name == $value;
}
private function typeMatches(string $value): bool
{
return $this->type && $this->type == $value;
}
/**
* Retrieve the base URL for a service.
*
* @param string $name the name of the service as it appears in the catalog
* @param string $type the type of the service as it appears in the catalog
* @param string $region the region of the service as it appears in the catalog
* @param string $interface the interface of the service as it appears in the catalog
*
* @return string|false
*/
public function getUrl(string $name, string $type, string $region, string $interface)
{
if (!$this->nameMatches($name) || !$this->typeMatches($type)) {
return false;
}
foreach ($this->endpoints as $endpoint) {
if ($endpoint->regionMatches($region) && $endpoint->interfaceMatches($interface)) {
return $endpoint->url;
}
}
return false;
}
}
@@ -0,0 +1,150 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use InvalidArgumentException;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Transport\Utils;
use Psr\Http\Message\ResponseInterface;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class Token extends OperatorResource implements Creatable, Retrievable, \OpenStack\Common\Auth\Token
{
/** @var array */
public $methods;
/** @var Role[] */
public $roles;
/** @var \DateTimeImmutable */
public $expires;
/** @var Project */
public $project;
/** @var Catalog */
public $catalog;
public $extras;
/** @var User */
public $user;
/** @var \DateTimeImmutable */
public $issued;
/** @var string */
public $id;
protected $resourceKey = 'token';
protected $resourcesKey = 'tokens';
protected $cachedToken;
protected function getAliases(): array
{
return parent::getAliases() + [
'roles' => new Alias('roles', Role::class, true),
'expires_at' => new Alias('expires', \DateTimeImmutable::class),
'project' => new Alias('project', Project::class),
'catalog' => new Alias('catalog', Catalog::class),
'user' => new Alias('user', User::class),
'issued_at' => new Alias('issued', \DateTimeImmutable::class),
];
}
public function populateFromResponse(ResponseInterface $response)
{
parent::populateFromResponse($response);
$this->id = $response->getHeaderLine('X-Subject-Token');
return $this;
}
public function getId(): string
{
return $this->id;
}
/**
* @return bool TRUE if the token has expired (and is invalid); FALSE otherwise
*/
public function hasExpired(): bool
{
return $this->expires <= new \DateTimeImmutable('now', $this->expires->getTimezone());
}
public function retrieve()
{
$response = $this->execute($this->api->getTokens(), ['tokenId' => $this->id]);
$this->populateFromResponse($response);
}
/**
* @param array $userOptions {@see \OpenStack\Identity\v3\Api::postTokens}
*/
public function create(array $userOptions): Creatable
{
if (isset($userOptions['user'])) {
$userOptions['methods'] = ['password'];
if (!isset($userOptions['user']['id']) && empty($userOptions['user']['domain'])) {
throw new InvalidArgumentException('When authenticating with a username, you must also provide either the domain name '.'or domain ID to which the user belongs to. Alternatively, if you provide a user ID instead, '.'you do not need to provide domain information.');
}
} elseif (isset($userOptions['application_credential'])) {
$userOptions['methods'] = ['application_credential'];
if (!isset($userOptions['application_credential']['id']) || !isset($userOptions['application_credential']['secret'])) {
throw new InvalidArgumentException('When authenticating with a application_credential, you must provide application credential ID '.' and application credential secret.');
}
} elseif (isset($userOptions['tokenId'])) {
$userOptions['methods'] = ['token'];
} else {
throw new InvalidArgumentException('Either a user, tokenId or application_credential must be provided.');
}
$response = $this->execute($this->api->postTokens(), $userOptions);
$token = $this->populateFromResponse($response);
// Cache response as an array to export if needed.
// Added key `id` which is auth token from HTTP header X-Subject-Token
$this->cachedToken = Utils::flattenJson(Utils::jsonDecode($response), $this->resourceKey);
$this->cachedToken['id'] = $token->id;
return $token;
}
/**
* Returns a serialized representation of an authentication token.
*
* Initialize OpenStack object using $params['cachedToken'] to reduce the amount of HTTP calls.
*
* This array is a modified version of response from `/auth/tokens`. Do not manually modify this array.
*/
public function export(): array
{
return $this->cachedToken;
}
/**
* Checks if the token is valid.
*
* @return bool TRUE if the token is valid; FALSE otherwise
*/
public function validate(): bool
{
try {
$this->execute($this->api->headTokens(), ['tokenId' => $this->id]);
return true;
} catch (BadResponseError $e) {
return false;
}
}
}
@@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class User extends OperatorResource implements Creatable, Listable, Retrievable, Updateable, Deletable
{
/** @var string */
public $domainId;
/** @var string */
public $defaultProjectId;
/** @var string */
public $id;
/** @var string */
public $email;
/** @var bool */
public $enabled;
/** @var string */
public $description;
/** @var array */
public $links;
/** @var string */
public $name;
protected $aliases = [
'domain_id' => 'domainId',
'default_project_id' => 'defaultProjectId',
];
protected $resourceKey = 'user';
protected $resourcesKey = 'users';
/**
* @param array $data {@see \OpenStack\Identity\v3\Api::postUsers}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postUsers(), $data);
return $this->populateFromResponse($response);
}
public function retrieve()
{
$response = $this->execute($this->api->getUser(), ['id' => $this->id]);
$this->populateFromResponse($response);
}
public function update()
{
$response = $this->executeWithState($this->api->patchUser());
$this->populateFromResponse($response);
}
public function delete()
{
$this->execute($this->api->deleteUser(), ['id' => $this->id]);
}
/**
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Group>
*/
public function listGroups(): \Generator
{
return $this->model(Group::class)->enumerate($this->api->getUserGroups(), ['id' => $this->id]);
}
/**
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Project>
*/
public function listProjects(): \Generator
{
return $this->model(Project::class)->enumerate($this->api->getUserProjects(), ['id' => $this->id]);
}
/**
* Creates a new application credential according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postApplicationCredential}
*/
public function createApplicationCredential(array $options): ApplicationCredential
{
return $this->model(ApplicationCredential::class)->create(['userId' => $this->id] + $options);
}
/**
* Retrieves an application credential object and populates its unique identifier object. This operation will not
* perform a GET or HEAD request by default; you will need to call retrieve() if you want to pull in remote state
* from the API.
*/
public function getApplicationCredential(string $id): ApplicationCredential
{
return $this->model(ApplicationCredential::class, ['id' => $id, 'userId' => $this->id]);
}
}
@@ -0,0 +1,336 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3;
use OpenStack\Common\Api\AbstractParams;
class Params extends AbstractParams
{
public function methods(): array
{
return [
'type' => self::ARRAY_TYPE,
'path' => 'auth.identity',
'items' => ['type' => self::STRING_TYPE],
'description' => <<<EOT
An array of authentication methods (in string form) that the SDK will use to authenticate. The only acceptable methods
are "password" or "token".
EOT
];
}
public function applicationCredential(): array
{
return [
'type' => self::OBJECT_TYPE,
'path' => 'auth.identity',
'properties' => [
'id' => [
'type' => self::STRING_TYPE,
'description' => $this->id('application credential id'),
],
'secret' => [
'type' => self::STRING_TYPE,
'description' => 'The secret of the application credential',
],
],
];
}
public function user(): array
{
return [
'type' => self::OBJECT_TYPE,
'path' => 'auth.identity.password',
'properties' => [
'id' => [
'type' => self::STRING_TYPE,
'description' => $this->id('user'),
],
'name' => [
'type' => self::STRING_TYPE,
'description' => 'The username of the user',
],
'password' => [
'type' => self::STRING_TYPE,
'description' => 'The password of the user',
],
'domain' => $this->domain(),
],
];
}
public function tokenBody(): array
{
return [
'path' => 'auth.identity.token',
'sentAs' => 'id',
'type' => self::STRING_TYPE,
'description' => $this->id('token'),
];
}
public function scope(): array
{
return [
'type' => self::OBJECT_TYPE,
'path' => 'auth',
'properties' => [
'project' => $this->project(),
'domain' => $this->domain(),
],
];
}
public function typeQuery(): array
{
return [
'type' => 'string',
'location' => 'query',
'description' => 'Filters all the available services according to a given type',
];
}
public function interf(): array
{
return [
'description' => <<<EOT
Denotes the type of visibility the endpoint will have. Acceptable values are "admin", "public" or "internal". Admin
endpoints are only accessible to users who have authenticated with an admin role. Public endpoints are available to
all users and use a public IP. Internal endpoints are available to all users, but only via an internal, private IP.
EOT
];
}
public function region(): array
{
return [
'description' => <<<EOT
Denotes the geographic location that the endpoint will serve traffic from. This provides greater redundancy and also
offers better latency to your regions, but will require the system administrator to set up.
EOT
];
}
public function endpointUrl(): array
{
return [
'description' => <<<EOT
The HTTP or HTTPS URL that clients will communicate with when accessing your service endpoint.
EOT
];
}
public function serviceId(): array
{
return [
'type' => 'string',
'sentAs' => 'service_id',
'description' => $this->id('service')['description'].' that this endpoint belongs to',
];
}
public function password(): array
{
return [
'description' => <<<EOT
The password for the user that they will use to authenticate with. Please ensure it is sufficiently long and random. If
you want a password generated for you, you can use TODO.
EOT
];
}
public function email(): array
{
return [
'description' => 'The personal e-mail address of the user',
];
}
public function effective(): array
{
return [
'type' => self::BOOL_TYPE,
'location' => self::QUERY,
'description' => <<<EOT
Use the effective query parameter to list effective assignments at the user, project, and domain level. This parameter
allows for the effects of group membership. The group role assignment entities themselves are not returned in the
collection. This represents the effective role assignments that would be included in a scoped token. You can use the
other query parameters with the effective parameter.
For example, to determine what a user can actually do, issue this request: GET /role_assignments?user.id={user_id}&effective
To return the equivalent set of role assignments that would be included in the token response of a project-scoped
token, issue: GET /role_assignments?user.id={user_id}&scope.project.id={project_id}&effective
EOT
];
}
public function projectIdQuery(): array
{
return [
'sentAs' => 'scope.project.id',
'location' => 'query',
'description' => 'Filter by project ID',
];
}
public function domainIdQuery(): array
{
return [
'sentAs' => 'scope.domain.id',
'location' => 'query',
'description' => $this->id('domain')['description'].' associated with the role assignments',
];
}
public function roleIdQuery(): array
{
return [
'sentAs' => 'role.id',
'location' => 'query',
'description' => 'Filter by role ID',
];
}
public function groupIdQuery(): array
{
return [
'sentAs' => 'group.id',
'location' => 'query',
'description' => 'Filter by group ID',
];
}
public function userIdQuery(): array
{
return [
'sentAs' => 'user.id',
'location' => 'query',
'description' => 'Filter by user ID',
];
}
public function domain(): array
{
return [
'type' => 'object',
'properties' => [
'id' => $this->id('domain'),
'name' => $this->name('domain'),
],
];
}
public function project(): array
{
return [
'type' => 'object',
'properties' => [
'id' => $this->id('project'),
'name' => $this->name('project'),
'domain' => $this->domain(),
],
];
}
public function idUrl($type)
{
return [
'required' => true,
'location' => self::URL,
'description' => sprintf('The unique ID, or identifier, for the %s', $type),
];
}
public function tokenId(): array
{
return [
'location' => self::HEADER,
'sentAs' => 'X-Subject-Token',
'description' => 'The unique token ID',
];
}
public function domainId($type)
{
return [
'sentAs' => 'domain_id',
'description' => sprintf('%s associated with this %s', $this->id('domain')['description'], $type),
];
}
public function parentId(): array
{
return [
'sentAs' => 'parent_id',
'description' => <<<EOT
The unique ID of the project which serves as the parent for this project. For more information about hierarchical
multitenancy in Keystone v3, see: http://specs.openstack.org/openstack/keystone-specs/specs/juno/hierarchical_multitenancy.html
EOT
];
}
public function type($resource)
{
return [
'description' => sprintf('The type of the %s', $resource),
];
}
public function desc($resource)
{
return [
'description' => sprintf('A human-friendly summary that explains what the %s does', $resource),
];
}
public function enabled($resource)
{
return [
'type' => self::BOOL_TYPE,
'description' => sprintf(
'Indicates whether this %s is enabled or not. If not, the %s will be unavailable for use.',
$resource,
$resource
),
];
}
public function defaultProjectId(): array
{
return [
'sentAs' => 'default_project_id',
'description' => <<<EOT
The unique ID of the project which will serve as a default for the user. Unless another project ID is specified in an
API operation, it is assumed that this project was meant - and so it is used as a default throughout.
EOT
];
}
public function projectId(): array
{
return [
'sentAs' => 'project_id',
'description' => $this->id('project'),
];
}
public function userId(): array
{
return [
'sentAs' => 'user_id',
'description' => $this->id('user'),
];
}
public function blob(): array
{
return [
'type' => 'string',
'description' => "This does something, but it's not explained in the docs (as of writing this)",
];
}
}
@@ -0,0 +1,430 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3;
use GuzzleHttp\ClientInterface;
use OpenStack\Common\Auth\IdentityService;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Common\Service\AbstractService;
/**
* Represents the Keystone v3 service.
*
* @property Api $api
*/
class Service extends AbstractService implements IdentityService
{
public static function factory(ClientInterface $client): self
{
return new static($client, new Api());
}
/**
* Authenticates credentials, giving back a token and a base URL for the service.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postTokens}
*
* @return array Returns a {@see Models\Token} as the first element, a string base URL as the second
*/
public function authenticate(array $options): array
{
$authOptions = array_intersect_key($options, $this->api->postTokens()['params']);
if (!empty($options['cachedToken'])) {
$token = $this->generateTokenFromCache($options['cachedToken']);
if ($token->hasExpired()) {
throw new \RuntimeException(sprintf('Cached token has expired on "%s".', $token->expires->format(\DateTime::ISO8601)));
}
} else {
$token = $this->generateToken($authOptions);
}
$name = $options['catalogName'];
$type = $options['catalogType'];
$region = $options['region'];
$interface = $options['interface'] ?? Enum::INTERFACE_PUBLIC;
if ($baseUrl = $token->catalog->getServiceUrl($name, $type, $region, $interface)) {
return [$token, $baseUrl];
}
throw new \RuntimeException(sprintf('No service found with type [%s] name [%s] region [%s] interface [%s]', $type, $name, $region, $interface));
}
/**
* Generates authentication token from cached token using `$token->export()`.
*
* @param array $cachedToken {@see \OpenStack\Identity\v3\Models\Token::export}
*/
public function generateTokenFromCache(array $cachedToken): Models\Token
{
return $this->model(Models\Token::class)->populateFromArray($cachedToken);
}
/**
* Generates a new authentication token.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postTokens}
*/
public function generateToken(array $options): Models\Token
{
return $this->model(Models\Token::class)->create($options);
}
/**
* Retrieves a token object and populates its unique identifier object. This operation will not perform a GET or
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the token to retrieve
*/
public function getToken(string $id): Models\Token
{
return $this->model(Models\Token::class, ['id' => $id]);
}
/**
* Validates a token, identified by its ID, and returns TRUE if its valid, FALSE if not.
*
* @param string $id The unique ID of the token
*/
public function validateToken(string $id): bool
{
try {
$this->execute($this->api->headTokens(), ['tokenId' => $id]);
return true;
} catch (BadResponseError $e) {
return false;
}
}
/**
* Revokes a token, identified by its ID. After this operation completes, users will not be able to use this token
* again for authentication.
*
* @param string $id The unique ID of the token
*/
public function revokeToken(string $id)
{
$this->execute($this->api->deleteTokens(), ['tokenId' => $id]);
}
/**
* Creates a new service according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postServices}
*/
public function createService(array $options): Models\Service
{
return $this->model(Models\Service::class)->create($options);
}
/**
* Returns a generator which will yield a collection of service objects. The elements which generators yield can be
* accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you
* will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getServices}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Service>
*/
public function listServices(array $options = []): \Generator
{
return $this->model(Models\Service::class)->enumerate($this->api->getServices(), $options);
}
/**
* Retrieves a service object and populates its unique identifier object. This operation will not perform a GET or
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the service
*/
public function getService(string $id): Models\Service
{
return $this->model(Models\Service::class, ['id' => $id]);
}
/**
* Creates a new endpoint according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postEndpoints}
*/
public function createEndpoint(array $options): Models\Endpoint
{
return $this->model(Models\Endpoint::class)->create($options);
}
/**
* Retrieves an endpoint object and populates its unique identifier object. This operation will not perform a GET or
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the service
*/
public function getEndpoint(string $id): Models\Endpoint
{
return $this->model(Models\Endpoint::class, ['id' => $id]);
}
/**
* Returns a generator which will yield a collection of endpoint objects. The elements which generators yield can be
* accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you
* will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getEndpoints}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Endpoint>
*/
public function listEndpoints(array $options = []): \Generator
{
return $this->model(Models\Endpoint::class)->enumerate($this->api->getEndpoints(), $options);
}
/**
* Creates a new domain according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postDomains}
*/
public function createDomain(array $options): Models\Domain
{
return $this->model(Models\Domain::class)->create($options);
}
/**
* Returns a generator which will yield a collection of domain objects. The elements which generators yield can be
* accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you
* will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getDomains}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Domain>
*/
public function listDomains(array $options = []): \Generator
{
return $this->model(Models\Domain::class)->enumerate($this->api->getDomains(), $options);
}
/**
* Retrieves a domain object and populates its unique identifier object. This operation will not perform a GET or
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the domain
*/
public function getDomain(string $id): Models\Domain
{
return $this->model(Models\Domain::class, ['id' => $id]);
}
/**
* Creates a new project according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postProjects}
*/
public function createProject(array $options): Models\Project
{
return $this->model(Models\Project::class)->create($options);
}
/**
* Returns a generator which will yield a collection of project objects. The elements which generators yield can be
* accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you
* will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getProjects}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Project>
*/
public function listProjects(array $options = []): \Generator
{
return $this->model(Models\Project::class)->enumerate($this->api->getProjects(), $options);
}
/**
* Retrieves a project object and populates its unique identifier object. This operation will not perform a GET or
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the project
*/
public function getProject(string $id): Models\Project
{
return $this->model(Models\Project::class, ['id' => $id]);
}
/**
* Creates a new user according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postUsers}
*/
public function createUser(array $options): Models\User
{
return $this->model(Models\User::class)->create($options);
}
/**
* Returns a generator which will yield a collection of user objects. The elements which generators yield can be
* accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you
* will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getUsers}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\User>
*/
public function listUsers(array $options = []): \Generator
{
return $this->model(Models\User::class)->enumerate($this->api->getUsers(), $options);
}
/**
* Retrieves a user object and populates its unique identifier object. This operation will not perform a GET or
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the user
*/
public function getUser(string $id): Models\User
{
return $this->model(Models\User::class, ['id' => $id]);
}
/**
* Creates a new group according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postGroups}
*/
public function createGroup(array $options): Models\Group
{
return $this->model(Models\Group::class)->create($options);
}
/**
* Returns a generator which will yield a collection of group objects. The elements which generators yield can be
* accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you
* will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getGroups}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Group>
*/
public function listGroups(array $options = []): \Generator
{
return $this->model(Models\Group::class)->enumerate($this->api->getGroups(), $options);
}
/**
* Retrieves a group object and populates its unique identifier object. This operation will not perform a GET or
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the group
*/
public function getGroup($id): Models\Group
{
return $this->model(Models\Group::class, ['id' => $id]);
}
/**
* Creates a new credential according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postCredentials}
*/
public function createCredential(array $options): Models\Credential
{
return $this->model(Models\Credential::class)->create($options);
}
/**
* Returns a generator which will yield a collection of credential objects. The elements which generators yield can
* be accessed using a foreach loop. Often the API will not return the full state of the resource in collections;
* you will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Credential>
*/
public function listCredentials(): \Generator
{
return $this->model(Models\Credential::class)->enumerate($this->api->getCredentials());
}
/**
* Retrieves a credential object and populates its unique identifier object. This operation will not perform a GET
* or HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the credential
*/
public function getCredential(string $id): Models\Credential
{
return $this->model(Models\Credential::class, ['id' => $id]);
}
/**
* Creates a new role according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postRoles}
*/
public function createRole(array $options): Models\Role
{
return $this->model(Models\Role::class)->create($options);
}
/**
* Returns a generator which will yield a collection of role objects. The elements which generators yield can be
* accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you
* will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getRoles}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Role>
*/
public function listRoles(array $options = []): \Generator
{
return $this->model(Models\Role::class)->enumerate($this->api->getRoles(), $options);
}
/**
* Returns a generator which will yield a collection of role assignment objects. The elements which generators
* yield can be accessed using a foreach loop. Often the API will not return the full state of the resource in
* collections; you will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getRoleAssignments}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Assignment>
*/
public function listRoleAssignments(array $options = []): \Generator
{
return $this->model(Models\Assignment::class)->enumerate($this->api->getRoleAssignments(), $options);
}
/**
* Creates a new policy according to the provided options.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postPolicies}
*/
public function createPolicy(array $options): Models\Policy
{
return $this->model(Models\Policy::class)->create($options);
}
/**
* Returns a generator which will yield a collection of policy objects. The elements which generators yield can be
* accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you
* will need to use retrieve() to pull in the full state of the remote resource from the API.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::getPolicies}
*
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Policy>
*/
public function listPolicies(array $options = []): \Generator
{
return $this->model(Models\Policy::class)->enumerate($this->api->getPolicies(), $options);
}
/**
* Retrieves a policy object and populates its unique identifier object. This operation will not perform a GET or
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
*
* @param string $id The unique ID of the policy
*/
public function getPolicy(string $id): Models\Policy
{
return $this->model(Models\Policy::class, ['id' => $id]);
}
}