初始化仓库
This commit is contained in:
61
vendor/alibabacloud/client/src/Traits/ArrayAccessTrait.php
vendored
Normal file
61
vendor/alibabacloud/client/src/Traits/ArrayAccessTrait.php
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
/**
|
||||
* Trait ArrayAccessTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*/
|
||||
trait ArrayAccessTrait
|
||||
{
|
||||
/**
|
||||
* This method returns a reference to the variable to allow for indirect
|
||||
* array modification (e.g., $foo['bar']['baz'] = 'qux').
|
||||
*
|
||||
* @param string $offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function & offsetGet($offset)
|
||||
{
|
||||
if (isset($this->data[$offset])) {
|
||||
return $this->data[$offset];
|
||||
}
|
||||
|
||||
$value = null;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $offset
|
||||
* @param string|mixed $value
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->data[$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->data[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $offset
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->data[$offset]);
|
||||
}
|
||||
}
|
||||
273
vendor/alibabacloud/client/src/Traits/ClientTrait.php
vendored
Normal file
273
vendor/alibabacloud/client/src/Traits/ClientTrait.php
vendored
Normal file
@ -0,0 +1,273 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use AlibabaCloud\Client\SDK;
|
||||
use AlibabaCloud\Client\AlibabaCloud;
|
||||
use AlibabaCloud\Client\Clients\Client;
|
||||
use AlibabaCloud\Client\Clients\StsClient;
|
||||
use AlibabaCloud\Client\Filter\ClientFilter;
|
||||
use AlibabaCloud\Client\Clients\AccessKeyClient;
|
||||
use AlibabaCloud\Client\Clients\EcsRamRoleClient;
|
||||
use AlibabaCloud\Client\Clients\RamRoleArnClient;
|
||||
use AlibabaCloud\Client\Clients\RsaKeyPairClient;
|
||||
use AlibabaCloud\Client\Clients\BearerTokenClient;
|
||||
use AlibabaCloud\Client\Exception\ClientException;
|
||||
use AlibabaCloud\Client\Signature\SignatureInterface;
|
||||
use AlibabaCloud\Client\Credentials\Ini\IniCredential;
|
||||
use AlibabaCloud\Client\Credentials\CredentialsInterface;
|
||||
use AlibabaCloud\Client\Credentials\Providers\CredentialsProvider;
|
||||
|
||||
/**
|
||||
* Trait of the manage clients.
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*
|
||||
* @mixin AlibabaCloud
|
||||
*/
|
||||
trait ClientTrait
|
||||
{
|
||||
/**
|
||||
* @var array Containers of Clients
|
||||
*/
|
||||
protected static $clients = [];
|
||||
|
||||
/**
|
||||
* @param string $clientName
|
||||
* @param Client $client
|
||||
*
|
||||
* @return Client
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function set($clientName, Client $client)
|
||||
{
|
||||
ClientFilter::clientName($clientName);
|
||||
|
||||
return self::$clients[\strtolower($clientName)] = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all clients.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function all()
|
||||
{
|
||||
return self::$clients;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the client by specifying name.
|
||||
*
|
||||
* @param string $clientName
|
||||
*
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function del($clientName)
|
||||
{
|
||||
ClientFilter::clientName($clientName);
|
||||
|
||||
unset(self::$clients[\strtolower($clientName)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all clients.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function flush()
|
||||
{
|
||||
self::$clients = [];
|
||||
self::$defaultRegionId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @throws ClientException
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getGlobalClient()
|
||||
{
|
||||
return self::getDefaultClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default client.
|
||||
*
|
||||
* @return Client
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function getDefaultClient()
|
||||
{
|
||||
return self::get(CredentialsProvider::getDefaultName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Client instance by name.
|
||||
*
|
||||
* @param string $clientName
|
||||
*
|
||||
* @return Client
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function get($clientName)
|
||||
{
|
||||
ClientFilter::clientName($clientName);
|
||||
|
||||
if (self::has($clientName)) {
|
||||
return self::$clients[\strtolower($clientName)];
|
||||
}
|
||||
|
||||
throw new ClientException(
|
||||
"Client '$clientName' not found",
|
||||
SDK::CLIENT_NOT_FOUND
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether there is a client.
|
||||
*
|
||||
* @param string $clientName
|
||||
*
|
||||
* @return bool
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function has($clientName)
|
||||
{
|
||||
ClientFilter::clientName($clientName);
|
||||
|
||||
return isset(self::$clients[\strtolower($clientName)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of additional files to load.
|
||||
*
|
||||
* @return array
|
||||
* @throws ClientException when a file has a syntax error or does not exist or is not readable
|
||||
*/
|
||||
public static function load()
|
||||
{
|
||||
if (\func_get_args() === []) {
|
||||
return (new IniCredential())->load();
|
||||
}
|
||||
$list = [];
|
||||
foreach (\func_get_args() as $filename) {
|
||||
$list[$filename] = (new IniCredential($filename))->load();
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Client.
|
||||
*
|
||||
* @param CredentialsInterface $credentials
|
||||
* @param SignatureInterface $signature
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
public static function client(CredentialsInterface $credentials, SignatureInterface $signature)
|
||||
{
|
||||
return new Client($credentials, $signature);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the AccessKey to complete the authentication.
|
||||
*
|
||||
* @param string $accessKeyId
|
||||
* @param string $accessKeySecret
|
||||
*
|
||||
* @return AccessKeyClient
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function accessKeyClient($accessKeyId, $accessKeySecret)
|
||||
{
|
||||
if (null === $accessKeyId || strpos($accessKeyId, ' ') !== false) {
|
||||
throw new ClientException(
|
||||
'AccessKey ID format is invalid',
|
||||
SDK::INVALID_ARGUMENT
|
||||
);
|
||||
}
|
||||
|
||||
if (null === $accessKeySecret || strpos($accessKeySecret, ' ') !== false) {
|
||||
throw new ClientException(
|
||||
'AccessKey Secret format is invalid',
|
||||
SDK::INVALID_ARGUMENT
|
||||
);
|
||||
}
|
||||
|
||||
return new AccessKeyClient($accessKeyId, $accessKeySecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the AssumeRole of the RAM account to complete the authentication.
|
||||
*
|
||||
* @param string $accessKeyId
|
||||
* @param string $accessKeySecret
|
||||
* @param string $roleArn
|
||||
* @param string $roleSessionName
|
||||
* @param string|array $policy
|
||||
*
|
||||
* @return RamRoleArnClient
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function ramRoleArnClient($accessKeyId, $accessKeySecret, $roleArn, $roleSessionName, $policy = '')
|
||||
{
|
||||
return new RamRoleArnClient($accessKeyId, $accessKeySecret, $roleArn, $roleSessionName, $policy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the RAM role of an ECS instance to complete the authentication.
|
||||
*
|
||||
* @param string $roleName
|
||||
*
|
||||
* @return EcsRamRoleClient
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function ecsRamRoleClient($roleName)
|
||||
{
|
||||
return new EcsRamRoleClient($roleName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Bearer Token to complete the authentication.
|
||||
*
|
||||
* @param string $bearerToken
|
||||
*
|
||||
* @return BearerTokenClient
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function bearerTokenClient($bearerToken)
|
||||
{
|
||||
return new BearerTokenClient($bearerToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the STS Token to complete the authentication.
|
||||
*
|
||||
* @param string $accessKeyId Access key ID
|
||||
* @param string $accessKeySecret Access Key Secret
|
||||
* @param string $securityToken Security Token
|
||||
*
|
||||
* @return StsClient
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function stsClient($accessKeyId, $accessKeySecret, $securityToken = '')
|
||||
{
|
||||
return new StsClient($accessKeyId, $accessKeySecret, $securityToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the RSA key pair to complete the authentication (supported only on Japanese site)
|
||||
*
|
||||
* @param string $publicKeyId
|
||||
* @param string $privateKeyFile
|
||||
*
|
||||
* @return RsaKeyPairClient
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function rsaKeyPairClient($publicKeyId, $privateKeyFile)
|
||||
{
|
||||
return new RsaKeyPairClient($publicKeyId, $privateKeyFile);
|
||||
}
|
||||
}
|
||||
66
vendor/alibabacloud/client/src/Traits/DefaultRegionTrait.php
vendored
Normal file
66
vendor/alibabacloud/client/src/Traits/DefaultRegionTrait.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use AlibabaCloud\Client\AlibabaCloud;
|
||||
use AlibabaCloud\Client\Filter\ClientFilter;
|
||||
use AlibabaCloud\Client\Exception\ClientException;
|
||||
|
||||
/**
|
||||
* Trait DefaultRegionTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*
|
||||
* @mixin AlibabaCloud
|
||||
*/
|
||||
trait DefaultRegionTrait
|
||||
{
|
||||
/**
|
||||
* @var string|null Default RegionId
|
||||
*/
|
||||
protected static $defaultRegionId;
|
||||
|
||||
/**
|
||||
* @param $regionId
|
||||
*
|
||||
* @throws ClientException
|
||||
* @deprecated
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function setGlobalRegionId($regionId)
|
||||
{
|
||||
self::setDefaultRegionId($regionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @deprecated
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function getGlobalRegionId()
|
||||
{
|
||||
return self::getDefaultRegionId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default RegionId.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getDefaultRegionId()
|
||||
{
|
||||
return self::$defaultRegionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default RegionId.
|
||||
*
|
||||
* @param string $regionId
|
||||
*
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function setDefaultRegionId($regionId)
|
||||
{
|
||||
self::$defaultRegionId = ClientFilter::regionId($regionId);
|
||||
}
|
||||
}
|
||||
134
vendor/alibabacloud/client/src/Traits/EndpointTrait.php
vendored
Normal file
134
vendor/alibabacloud/client/src/Traits/EndpointTrait.php
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use AlibabaCloud\Client\AlibabaCloud;
|
||||
use AlibabaCloud\Client\Config\Config;
|
||||
use AlibabaCloud\Client\Exception\ClientException;
|
||||
use AlibabaCloud\Client\Filter\ApiFilter;
|
||||
use AlibabaCloud\Client\Filter\ClientFilter;
|
||||
use AlibabaCloud\Client\Filter\HttpFilter;
|
||||
use AlibabaCloud\Client\Regions\LocationService;
|
||||
use AlibabaCloud\Client\Request\Request;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Help developers set up and get host.
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*
|
||||
* @mixin AlibabaCloud
|
||||
*/
|
||||
trait EndpointTrait
|
||||
{
|
||||
/**
|
||||
* @var array Host cache.
|
||||
*/
|
||||
private static $hosts = [];
|
||||
|
||||
/**
|
||||
* Resolve host based on product name and region.
|
||||
*
|
||||
* @param string $product
|
||||
* @param string $regionId
|
||||
*
|
||||
* @return string
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function resolveHost($product, $regionId = LocationService::GLOBAL_REGION)
|
||||
{
|
||||
ApiFilter::product($product);
|
||||
ClientFilter::regionId($regionId);
|
||||
|
||||
if (isset(self::$hosts[$product][$regionId])) {
|
||||
return self::$hosts[$product][$regionId];
|
||||
}
|
||||
|
||||
$domain = Config::get("endpoints.{$product}.{$regionId}");
|
||||
if (!$domain) {
|
||||
$regionId = LocationService::GLOBAL_REGION;
|
||||
$domain = Config::get("endpoints.{$product}.{$regionId}", '');
|
||||
}
|
||||
|
||||
return $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $productCode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isGlobalProduct($productCode)
|
||||
{
|
||||
$global = LocationService::GLOBAL_REGION;
|
||||
if (self::resolveHostByStatic($productCode, $global)) {
|
||||
return true;
|
||||
}
|
||||
$productCode = null !== $productCode? strtolower($productCode) : null;
|
||||
return (bool)Config::get("endpoints.{$productCode}.{$global}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $product
|
||||
* @param string $regionId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function resolveHostByStatic($product, $regionId)
|
||||
{
|
||||
if (isset(self::$hosts[$product][$regionId])) {
|
||||
return self::$hosts[$product][$regionId];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add host based on product name and region.
|
||||
*
|
||||
* @param string $product
|
||||
* @param string $host
|
||||
* @param string $regionId
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function addHost($product, $host, $regionId = LocationService::GLOBAL_REGION)
|
||||
{
|
||||
ApiFilter::product($product);
|
||||
|
||||
HttpFilter::host($host);
|
||||
|
||||
ClientFilter::regionId($regionId);
|
||||
|
||||
self::$hosts[$product][$regionId] = $host;
|
||||
|
||||
LocationService::addHost($product, $host, $regionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return string
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function resolveHostByRule(Request $request)
|
||||
{
|
||||
$network = $request->network ?: 'public';
|
||||
$suffix = $request->endpointSuffix;
|
||||
if ($network === 'public') {
|
||||
$network = '';
|
||||
}
|
||||
|
||||
if ($request->endpointRegional === 'regional') {
|
||||
$regionId = $request->realRegionId();
|
||||
return "{$request->product}{$suffix}{$network}.{$regionId}.aliyuncs.com";
|
||||
}
|
||||
|
||||
if ($request->endpointRegional === 'central') {
|
||||
return "{$request->product}{$suffix}{$network}.aliyuncs.com";
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException('endpointRegional is invalid.');
|
||||
}
|
||||
}
|
||||
324
vendor/alibabacloud/client/src/Traits/HasDataTrait.php
vendored
Normal file
324
vendor/alibabacloud/client/src/Traits/HasDataTrait.php
vendored
Normal file
@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use Adbar\Dot;
|
||||
use ArrayIterator;
|
||||
use JmesPath\Env as JmesPath;
|
||||
use AlibabaCloud\Client\Result\Result;
|
||||
|
||||
/**
|
||||
* Trait HasDataTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
* @mixin Result
|
||||
*/
|
||||
trait HasDataTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* Instance of the Dot.
|
||||
*
|
||||
* @var Dot
|
||||
*/
|
||||
protected $dot;
|
||||
|
||||
/**
|
||||
* @param string $expression
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function search($expression)
|
||||
{
|
||||
return JmesPath::search($expression, $this->dot->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the contents of a given key or keys
|
||||
*
|
||||
* @param array|int|string|null $keys
|
||||
*/
|
||||
public function clear($keys = null)
|
||||
{
|
||||
$this->dot->clear($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an array with the given character as a key delimiter
|
||||
*
|
||||
* @param string $delimiter
|
||||
* @param array|null $items
|
||||
* @param string $prepend
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function flatten($delimiter = '.', $items = null, $prepend = '')
|
||||
{
|
||||
return $this->dot->flatten($delimiter, $items, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of a given key
|
||||
*
|
||||
* @param int|string|null $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key = null, $default = null)
|
||||
{
|
||||
return $this->dot->get($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a given key / value pair or pairs
|
||||
*
|
||||
* @param array|int|string $keys
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set($keys, $value = null)
|
||||
{
|
||||
$this->dot->set($keys, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given key or keys are empty
|
||||
*
|
||||
* @param array|int|string|null $keys
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty($keys = null)
|
||||
{
|
||||
return $this->dot->isEmpty($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all items with a given array as a reference
|
||||
*
|
||||
* @param array $items
|
||||
*/
|
||||
public function setReference(array &$items)
|
||||
{
|
||||
$this->dot->setReference($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of a given key or all the values as JSON
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param int $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJson($key = null, $options = 0)
|
||||
{
|
||||
return $this->dot->toJson($key, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->dot->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given key exists
|
||||
*
|
||||
* @param int|string $key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return $this->dot->has($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of a given key
|
||||
*
|
||||
* @param int|string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->dot->offsetGet($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a given value to the given key
|
||||
*
|
||||
* @param int|string|null $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
$this->dot->offsetSet($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the given key
|
||||
*
|
||||
* @param int|string $key
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
$this->delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the given key or keys
|
||||
*
|
||||
* @param array|int|string $keys
|
||||
*/
|
||||
public function delete($keys)
|
||||
{
|
||||
$this->dot->delete($keys);
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* ArrayAccess interface
|
||||
* --------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return the number of items in a given key
|
||||
*
|
||||
* @param int|string|null $key
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count($key = null)
|
||||
{
|
||||
return $this->dot->count($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator for the stored items
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
return $this->dot->getIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return items for JSON serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->dot->jsonSerialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (!isset($this->all()[$name])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return \json_decode(\json_encode($this->all()))->$name;
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* Countable interface
|
||||
* --------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return all the stored items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return $this->dot->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->add($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a given key / value pair or pairs
|
||||
* if the key doesn't exist already
|
||||
*
|
||||
* @param array|int|string $keys
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function add($keys, $value = null)
|
||||
{
|
||||
$this->dot->add($keys, $value);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* ObjectAccess
|
||||
* --------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
return $this->has($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given key or keys exists
|
||||
*
|
||||
* @param array|int|string $keys
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($keys)
|
||||
{
|
||||
return $this->dot->has($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($name)
|
||||
{
|
||||
$this->delete($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
protected function dot(array $data = [])
|
||||
{
|
||||
$this->dot = new Dot($data);
|
||||
}
|
||||
}
|
||||
68
vendor/alibabacloud/client/src/Traits/HistoryTrait.php
vendored
Normal file
68
vendor/alibabacloud/client/src/Traits/HistoryTrait.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
/**
|
||||
* Trait HistoryTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*/
|
||||
trait HistoryTrait
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $history = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private static $isRememberHistory = false;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getHistory()
|
||||
{
|
||||
return self::$history;
|
||||
}
|
||||
|
||||
public static function forgetHistory()
|
||||
{
|
||||
self::$history = [];
|
||||
}
|
||||
|
||||
public static function notRememberHistory()
|
||||
{
|
||||
self::$isRememberHistory = false;
|
||||
}
|
||||
|
||||
public static function rememberHistory()
|
||||
{
|
||||
self::$isRememberHistory = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRememberHistory()
|
||||
{
|
||||
return self::$isRememberHistory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function &referenceHistory()
|
||||
{
|
||||
return self::$history;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public static function countHistory()
|
||||
{
|
||||
return count(self::$history);
|
||||
}
|
||||
}
|
||||
141
vendor/alibabacloud/client/src/Traits/HttpTrait.php
vendored
Normal file
141
vendor/alibabacloud/client/src/Traits/HttpTrait.php
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use AlibabaCloud\Client\Support\Arrays;
|
||||
use AlibabaCloud\Client\Filter\ClientFilter;
|
||||
use AlibabaCloud\Client\Exception\ClientException;
|
||||
|
||||
/**
|
||||
* Trait HttpTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*/
|
||||
trait HttpTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $options = [];
|
||||
|
||||
/**
|
||||
* @param int|float $seconds
|
||||
*
|
||||
* @return $this
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function timeout($seconds)
|
||||
{
|
||||
$this->options['timeout'] = ClientFilter::timeout($seconds);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $milliseconds
|
||||
*
|
||||
* @return $this
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function timeoutMilliseconds($milliseconds)
|
||||
{
|
||||
ClientFilter::milliseconds($milliseconds);
|
||||
$seconds = $milliseconds / 1000;
|
||||
|
||||
return $this->timeout($seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|float $seconds
|
||||
*
|
||||
* @return $this
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function connectTimeout($seconds)
|
||||
{
|
||||
$this->options['connect_timeout'] = ClientFilter::connectTimeout($seconds);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $milliseconds
|
||||
*
|
||||
* @return $this
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function connectTimeoutMilliseconds($milliseconds)
|
||||
{
|
||||
ClientFilter::milliseconds($milliseconds);
|
||||
$seconds = $milliseconds / 1000;
|
||||
|
||||
return $this->connectTimeout($seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $debug
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function debug($debug)
|
||||
{
|
||||
$this->options['debug'] = $debug;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param array $cert
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cert($cert)
|
||||
{
|
||||
$this->options['cert'] = $cert;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param array|string $proxy
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function proxy($proxy)
|
||||
{
|
||||
$this->options['proxy'] = $proxy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $verify
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function verify($verify)
|
||||
{
|
||||
$this->options['verify'] = $verify;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function options(array $options)
|
||||
{
|
||||
if ($options !== []) {
|
||||
$this->options = Arrays::merge([$this->options, $options]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
97
vendor/alibabacloud/client/src/Traits/LogTrait.php
vendored
Normal file
97
vendor/alibabacloud/client/src/Traits/LogTrait.php
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Trait LogTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*/
|
||||
trait LogTrait
|
||||
{
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private static $logger;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private static $logStartTime = 0;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private static $logFormat;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
private static $ts;
|
||||
|
||||
/**
|
||||
* @return LoggerInterface
|
||||
*/
|
||||
public static function getLogger()
|
||||
{
|
||||
return self::$logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoggerInterface $logger
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setLogger(LoggerInterface $logger)
|
||||
{
|
||||
self::$logger = $logger;
|
||||
self::$logStartTime = microtime(true);
|
||||
$timezone = new DateTimeZone(date_default_timezone_get() ?: 'UTC');
|
||||
if (PHP_VERSION_ID < 70100) {
|
||||
self::$ts = DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), $timezone);
|
||||
} else {
|
||||
self::$ts = new DateTime('now', $timezone);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getLogFormat()
|
||||
{
|
||||
$template = self::$logFormat
|
||||
?: '"{method} {uri} HTTP/{version}" {code} {cost} {hostname} {pid}';
|
||||
|
||||
return str_replace(
|
||||
['{pid}', '{cost}', '{start_time}'],
|
||||
[getmypid(), self::getCost(), self::$ts->format('Y-m-d H:i:s.u')],
|
||||
$template
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apache Common Log Format.
|
||||
*
|
||||
* @param string $formatter
|
||||
*
|
||||
* @link http://httpd.apache.org/docs/2.4/logs.html#common
|
||||
* @see \GuzzleHttp\MessageFormatter
|
||||
*/
|
||||
public static function setLogFormat($formatter)
|
||||
{
|
||||
self::$logFormat = $formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float|mixed
|
||||
*/
|
||||
private static function getCost()
|
||||
{
|
||||
return microtime(true) - self::$logStartTime;
|
||||
}
|
||||
}
|
||||
97
vendor/alibabacloud/client/src/Traits/MockTrait.php
vendored
Normal file
97
vendor/alibabacloud/client/src/Traits/MockTrait.php
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
/**
|
||||
* Class MockTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Request\Traits
|
||||
* @mixin Request
|
||||
*/
|
||||
trait MockTrait
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $mockQueue = [];
|
||||
|
||||
/**
|
||||
* @var MockHandler
|
||||
*/
|
||||
private static $mock;
|
||||
|
||||
/**
|
||||
* @param integer $status
|
||||
* @param array $headers
|
||||
* @param array|string|object $body
|
||||
*/
|
||||
public static function mockResponse($status = 200, array $headers = [], $body = null)
|
||||
{
|
||||
if (is_array($body) || is_object($body)) {
|
||||
$body = json_encode($body);
|
||||
}
|
||||
|
||||
self::$mockQueue[] = new Response($status, $headers, $body);
|
||||
self::createHandlerStack();
|
||||
}
|
||||
|
||||
private static function createHandlerStack()
|
||||
{
|
||||
self::$mock = new MockHandler(self::$mockQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param RequestInterface $request
|
||||
* @param ResponseInterface|null $response
|
||||
* @param Exception|null $previous
|
||||
* @param array $handlerContext
|
||||
*/
|
||||
public static function mockRequestException(
|
||||
$message,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response = null,
|
||||
Exception $previous = null,
|
||||
array $handlerContext = []
|
||||
) {
|
||||
self::$mockQueue[] = new RequestException(
|
||||
$message,
|
||||
$request,
|
||||
$response,
|
||||
$previous,
|
||||
$handlerContext
|
||||
);
|
||||
|
||||
self::createHandlerStack();
|
||||
}
|
||||
|
||||
public static function cancelMock()
|
||||
{
|
||||
self::$mockQueue = [];
|
||||
self::$mock = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasMock()
|
||||
{
|
||||
return (bool)self::$mockQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockHandler
|
||||
*/
|
||||
public static function getMock()
|
||||
{
|
||||
return self::$mock;
|
||||
}
|
||||
}
|
||||
54
vendor/alibabacloud/client/src/Traits/ObjectAccessTrait.php
vendored
Normal file
54
vendor/alibabacloud/client/src/Traits/ObjectAccessTrait.php
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
/**
|
||||
* Trait ObjectAccessTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*/
|
||||
trait ObjectAccessTrait
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (!isset($this->data[$name])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return \json_decode(\json_encode($this->data))->$name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->data[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
return isset($this->data[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($name)
|
||||
{
|
||||
unset($this->data[$name]);
|
||||
}
|
||||
}
|
||||
33
vendor/alibabacloud/client/src/Traits/RegionTrait.php
vendored
Normal file
33
vendor/alibabacloud/client/src/Traits/RegionTrait.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use AlibabaCloud\Client\Filter\ClientFilter;
|
||||
use AlibabaCloud\Client\Exception\ClientException;
|
||||
|
||||
/**
|
||||
* Trait RegionTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*/
|
||||
trait RegionTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $regionId;
|
||||
|
||||
/**
|
||||
* @param string $regionId
|
||||
*
|
||||
* @return $this
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function regionId($regionId)
|
||||
{
|
||||
$this->regionId = ClientFilter::regionId($regionId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
90
vendor/alibabacloud/client/src/Traits/RequestTrait.php
vendored
Normal file
90
vendor/alibabacloud/client/src/Traits/RequestTrait.php
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Client\Traits;
|
||||
|
||||
use AlibabaCloud\Client\AlibabaCloud;
|
||||
use AlibabaCloud\Client\Filter\Filter;
|
||||
use AlibabaCloud\Client\Request\UserAgent;
|
||||
use AlibabaCloud\Client\Request\RpcRequest;
|
||||
use AlibabaCloud\Client\Request\RoaRequest;
|
||||
use AlibabaCloud\Client\Exception\ClientException;
|
||||
|
||||
/**
|
||||
* Trait RequestTrait
|
||||
*
|
||||
* @package AlibabaCloud\Client\Traits
|
||||
*
|
||||
* @mixin AlibabaCloud
|
||||
*/
|
||||
trait RequestTrait
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function appendUserAgent($name, $value)
|
||||
{
|
||||
Filter::name($name);
|
||||
Filter::value($value);
|
||||
|
||||
UserAgent::append($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $userAgent
|
||||
*/
|
||||
public static function withUserAgent(array $userAgent)
|
||||
{
|
||||
UserAgent::with($userAgent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return RpcRequest
|
||||
* @throws ClientException
|
||||
* @deprecated
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function rpcRequest(array $options = [])
|
||||
{
|
||||
return self::rpc($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return RpcRequest
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function rpc(array $options = [])
|
||||
{
|
||||
return new RpcRequest($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return RoaRequest
|
||||
* @throws ClientException
|
||||
* @deprecated
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function roaRequest(array $options = [])
|
||||
{
|
||||
return self::roa($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return RoaRequest
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static function roa(array $options = [])
|
||||
{
|
||||
return new RoaRequest($options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user