mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-20 13:23:47 -07:00
v2: Updates
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
This commit is contained in:
parent
ad0726e41e
commit
e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions
|
@ -1,19 +1,41 @@
|
|||
<?php
|
||||
namespace Aws\Endpoint;
|
||||
|
||||
use JmesPath\Env;
|
||||
|
||||
class PartitionEndpointProvider
|
||||
{
|
||||
/** @var Partition[] */
|
||||
private $partitions;
|
||||
/** @var string */
|
||||
private $defaultPartition;
|
||||
/** @var array */
|
||||
private $options;
|
||||
|
||||
public function __construct(array $partitions, $defaultPartition = 'aws')
|
||||
{
|
||||
/**
|
||||
* The 'options' parameter accepts the following arguments:
|
||||
*
|
||||
* - sts_regional_endpoints: For STS legacy regions, set to 'regional' to
|
||||
* use regional endpoints, 'legacy' to use the legacy global endpoint.
|
||||
* Defaults to 'legacy'.
|
||||
* - s3_us_east_1_regional_endpoint: For S3 us-east-1 region, set to 'regional'
|
||||
* to use the regional endpoint, 'legacy' to use the legacy global endpoint.
|
||||
* Defaults to 'legacy'.
|
||||
*
|
||||
* @param array $partitions
|
||||
* @param string $defaultPartition
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(
|
||||
array $partitions,
|
||||
$defaultPartition = 'aws',
|
||||
$options = []
|
||||
) {
|
||||
$this->partitions = array_map(function (array $definition) {
|
||||
return new Partition($definition);
|
||||
}, array_values($partitions));
|
||||
$this->defaultPartition = $defaultPartition;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function __invoke(array $args = [])
|
||||
|
@ -22,6 +44,7 @@ class PartitionEndpointProvider
|
|||
isset($args['region']) ? $args['region'] : '',
|
||||
isset($args['service']) ? $args['service'] : ''
|
||||
);
|
||||
$args['options'] = $this->options;
|
||||
|
||||
return $partition($args);
|
||||
}
|
||||
|
@ -66,12 +89,42 @@ class PartitionEndpointProvider
|
|||
/**
|
||||
* Creates and returns the default SDK partition provider.
|
||||
*
|
||||
* @param array $options
|
||||
* @return PartitionEndpointProvider
|
||||
*/
|
||||
public static function defaultProvider()
|
||||
public static function defaultProvider($options = [])
|
||||
{
|
||||
$data = \Aws\load_compiled_json(dirname(__FILE__) . '/../data/endpoints.json');
|
||||
$data = \Aws\load_compiled_json(__DIR__ . '/../data/endpoints.json');
|
||||
$prefixData = \Aws\load_compiled_json(__DIR__ . '/../data/endpoints_prefix_history.json');
|
||||
$mergedData = self::mergePrefixData($data, $prefixData);
|
||||
|
||||
return new self($data['partitions']);
|
||||
return new self($mergedData['partitions'], 'aws', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy endpoint data for other prefixes used by a given service
|
||||
*
|
||||
* @param $data
|
||||
* @param $prefixData
|
||||
* @return array
|
||||
*/
|
||||
public static function mergePrefixData($data, $prefixData)
|
||||
{
|
||||
$prefixGroups = $prefixData['prefix-groups'];
|
||||
|
||||
foreach ($data["partitions"] as $index => $partition) {
|
||||
foreach ($prefixGroups as $current => $old) {
|
||||
$serviceData = Env::search("services.\"{$current}\"", $partition);
|
||||
if (!empty($serviceData)) {
|
||||
foreach ($old as $prefix) {
|
||||
if (empty(Env::search("services.\"{$prefix}\"", $partition))) {
|
||||
$data["partitions"][$index]["services"][$prefix] = $serviceData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue