Обновление клиента (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
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v2\Models;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Transport\Utils;
use Psr\Http\Message\ResponseInterface;
/**
* Represents an Identity v2 service catalog.
*/
class Catalog extends OperatorResource implements \OpenStack\Common\Auth\Catalog
{
public const DEFAULT_URL_TYPE = 'publicURL';
/**
* The catalog entries.
*
* @var []Entry
*/
public $entries = [];
protected function getAliases(): array
{
return parent::getAliases() + [
'entries' => new Alias('entries', Entry::class, true),
];
}
public function populateFromResponse(ResponseInterface $response): self
{
$entries = Utils::jsonDecode($response)['access']['serviceCatalog'];
foreach ($entries as $entry) {
$this->entries[] = $this->model(Entry::class, $entry);
}
return $this;
}
public function getServiceUrl(
string $serviceName,
string $serviceType,
string $region,
string $urlType = self::DEFAULT_URL_TYPE
): string {
foreach ($this->entries as $entry) {
if ($entry->matches($serviceName, $serviceType) && ($url = $entry->getEndpointUrl($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", $serviceName, $serviceType, $region, $urlType));
}
}
@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v2\Models;
use OpenStack\Common\HydratorStrategyTrait;
use OpenStack\Common\Resource\OperatorResource;
/**
* Represents an Identity v2 catalog entry endpoint.
*/
class Endpoint extends OperatorResource
{
use HydratorStrategyTrait;
/** @var string */
public $adminUrl;
/** @var string */
public $region;
/** @var string */
public $internalUrl;
/** @var string */
public $publicUrl;
protected $aliases = [
'adminURL' => 'adminUrl',
'internalURL' => 'internalUrl',
'publicURL' => 'publicUrl',
];
/**
* Indicates whether a given region is supported.
*/
public function supportsRegion(string $region): bool
{
return $this->region == $region;
}
/**
* Indicates whether a given URL type is supported.
*/
public function supportsUrlType(string $urlType): bool
{
$supported = false;
switch (strtolower($urlType)) {
case 'internalurl':
case 'publicurl':
case 'adminurl':
$supported = true;
break;
}
return $supported;
}
/**
* Retrieves a URL for the endpoint based on a specific type.
*
* @param string $urlType Either "internalURL", "publicURL" or "adminURL" (case insensitive)
*
* @return bool|string
*/
public function getUrl(string $urlType): string
{
$url = false;
switch (strtolower($urlType)) {
case 'internalurl':
$url = $this->internalUrl;
break;
case 'publicurl':
$url = $this->publicUrl;
break;
case 'adminurl':
$url = $this->adminUrl;
break;
}
return $url;
}
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v2\Models;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Resource\OperatorResource;
/**
* Represents an Identity v2 Catalog Entry.
*/
class Entry extends OperatorResource
{
/** @var string */
public $name;
/** @var string */
public $type;
/** @var []Endpoint */
public $endpoints = [];
protected function getAliases(): array
{
return parent::getAliases() + [
'endpoints' => new Alias('endpoints', Endpoint::class, true),
];
}
/**
* Indicates whether this catalog entry matches a certain name and type.
*
* @return bool TRUE if it's a match, FALSE if not
*/
public function matches(string $name, string $type): bool
{
return $this->name == $name && $this->type == $type;
}
/**
* Retrieves the catalog entry's URL according to a specific region and URL type.
*/
public function getEndpointUrl(string $region, string $urlType): string
{
foreach ($this->endpoints as $endpoint) {
if ($endpoint->supportsRegion($region) && $endpoint->supportsUrlType($urlType)) {
return $endpoint->getUrl($urlType);
}
}
return '';
}
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v2\Models;
use OpenStack\Common\Resource\OperatorResource;
/**
* Represents an Identity v2 Tenant.
*/
class Tenant extends OperatorResource
{
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v2\Models;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Transport\Utils;
use Psr\Http\Message\ResponseInterface;
/**
* Represents an Identity v2 Token.
*/
class Token extends OperatorResource implements \OpenStack\Common\Auth\Token
{
/** @var \DateTimeImmutable */
public $issuedAt;
/** @var string */
public $id;
/** @var \DateTimeImmutable */
public $expires;
/** @var Tenant */
public $tenant;
protected function getAliases(): array
{
return parent::getAliases() + [
'tenant' => new Alias('tenant', Tenant::class),
'expires' => new Alias('expires', \DateTimeImmutable::class),
'issued_at' => new Alias('issuedAt', \DateTimeImmutable::class),
];
}
public function populateFromResponse(ResponseInterface $response): self
{
$this->populateFromArray(Utils::jsonDecode($response)['access']['token']);
return $this;
}
public function getId(): string
{
return $this->id;
}
public function hasExpired(): bool
{
return $this->expires <= new \DateTimeImmutable('now', $this->expires->getTimezone());
}
}