Class ApiProvider
API providers.
An API provider is a function that accepts a type, service, and version and returns an array of API data on success or NULL if no API data can be created for the provided arguments.
You can wrap your calls to an API provider with the
ApiProvider::resolve method to ensure that API data is created. If the
API data is not created, then the resolve() method will throw a
Aws\Exception\UnresolvedApiException
.
use Aws\Api\ApiProvider; $provider = ApiProvider::defaultProvider(); // Returns an array or NULL. $data = $provider('api', 's3', '2006-03-01'); // Returns an array or throws. $data = ApiProvider::resolve($provider, 'api', 'elasticfood', '2020-01-01');
You can compose multiple providers into a single provider using
Aws\or_chain()
. This method accepts providers as arguments and
returns a new function that will invoke each provider until a non-null value
is returned.
$a = ApiProvider::filesystem(sys_get_temp_dir() . '/aws-beta-models'); $b = ApiProvider::manifest();
$c = \Aws\or_chain($a, $b); $data = $c('api', 'betaservice', '2015-08-08'); // $a handles this. $data = $c('api', 's3', '2006-03-01'); // $b handles this. $data = $c('api', 'invalid', '2014-12-15'); // Neither handles this.
Methods Summary
-
static
resolve ( callable $provider, string $type, string $service, string $version )
Resolves an API provider and ensures a non-null return value.
-
static
defaultProvider ( )
Default SDK API provider.
-
static
manifest ( string $dir, array $manifest )
Loads API data after resolving the version to the latest, compatible, available version based on the provided manifest data.
-
static
filesystem ( string $dir )
Loads API data from the specified directory.
-
getVersions ( string $service )
Retrieves a list of valid versions for the specified service.
-
__invoke ( string $type, string $service, string $version )
Execute the provider.
Methods Details
static array resolve ( callable $provider, string $type, string $service, string $version )
Resolves an API provider and ensures a non-null return value.
Parameters
callable | $provider | Provider function to invoke. |
string | $type | Type of data ('api', 'waiter', 'paginator'). |
string | $service | Service name. |
string | $version | API version. |
Returns
array |
Exceptions
Aws\Exception\UnresolvedApiException |
static
Aws\Api\ApiProvider
defaultProvider (
)
Default SDK API provider.
This provider loads pre-built manifest data from the data
directory.
Returns
Aws\Api\ApiProvider |
static
Aws\Api\ApiProvider
manifest (
string
$dir,
array
$manifest
)
Loads API data after resolving the version to the latest, compatible, available version based on the provided manifest data.
Manifest data is essentially an associative array of service names to associative arrays of API version aliases.
[ ... 'ec2' => [ 'latest' => '2014-10-01', '2014-10-01' => '2014-10-01', '2014-09-01' => '2014-10-01', '2014-06-15' => '2014-10-01', ... ], 'ecs' => [...], 'elasticache' => [...], ... ]
Parameters
string | $dir | Directory containing service models. |
array | $manifest | The API version manifest data. |
Returns
Aws\Api\ApiProvider |
static
Aws\Api\ApiProvider
filesystem (
string
$dir
)
Loads API data from the specified directory.
If "latest" is specified as the version, this provider must glob the directory to find which is the latest available version.
Parameters
string | $dir | Directory containing service models. |
Returns
Aws\Api\ApiProvider |
Exceptions
InvalidArgumentException if the provided $dir is invalid. |
array getVersions ( string $service )
Retrieves a list of valid versions for the specified service.
Parameters
string | $service | Service name |
Returns
array |
array|null __invoke ( string $type, string $service, string $version )
Execute the provider.
Parameters
string | $type | Type of data ('api', 'waiter', 'paginator'). |
string | $service | Service name. |
string | $version | API version. |
Returns
array|null |