Attempting to retrieve a CDN service instance from OpenCloud\Rackspace results in an OpenCloud\Common\Exceptions\EndpointError exception. The only workaround I've found which seems to work consistently is to hard-code the region to DFW when requesting the service instance.
Either the API or the CDN service class seem to be somehow broken when detecting or handling the region flag for this service.
Versions
Both v1.14.2 and dev-master@dev yield the same results.
Base code
<?php
require __DIR__ . "/vendor/autoload.php";
use OpenCloud\Rackspace;
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
"username" => MY_RS_USERNAME,
"apiKey" => MY_RS_APIKEY,
));
$cdnService = $client->cdnService();
Result
Fatal error: Uncaught exception 'OpenCloud\Common\Exceptions\EndpointError' with message 'This service [rackCDN] does not have access to the [] endpoint.' in vendor\rackspace\php-opencloud\lib\OpenCloud\Common\Service\CatalogItem.php on line 151
Variations
Default region
Attempting to utilize the authenticated user's default region works for some users and not for others. The result on failure is the same exception with a slightly different message based on the user's default region.
<?php
require __DIR__ . "/vendor/autoload.php";
use OpenCloud\Rackspace;
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
"username" => MY_RS_USERNAME,
"apiKey" => MY_RS_APIKEY,
));
$client->authenticate();
$cdnService = $client->cdnService(null, $client->getUser()->getDefaultRegion());
Result
Fatal error: Uncaught exception 'OpenCloud\Common\Exceptions\EndpointError' with message 'This service [rackCDN] does not have access to the [IAD] endpoint.' in vendor\rackspace\php-opencloud\lib\OpenCloud\Common\Service\CatalogItem.php on line 151
Curiously, users with the default region of DFW always seem to work, which led to testing the next variation.
Hardcode region
Hard coding the region to DFW appears to work for all the accounts tested, but this may be an unsafe assumption in production; Non-US based accounts would likely not work, for example.
<?php
require __DIR__ . "/vendor/autoload.php";
use OpenCloud\Rackspace;
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
"username" => MY_RS_USERNAME,
"apiKey" => MY_RS_APIKEY,
));
$cdnService = $client->cdnService(null, "DFW");
Result
Operations on $cdnService function as expected.
Attempting to retrieve a CDN service instance from
OpenCloud\Rackspaceresults in anOpenCloud\Common\Exceptions\EndpointErrorexception. The only workaround I've found which seems to work consistently is to hard-code the region to DFW when requesting the service instance.Either the API or the CDN service class seem to be somehow broken when detecting or handling the region flag for this service.
Versions
Both v1.14.2 and dev-master@dev yield the same results.
Base code
Result
Variations
Default region
Attempting to utilize the authenticated user's default region works for some users and not for others. The result on failure is the same exception with a slightly different message based on the user's default region.
Result
Curiously, users with the default region of DFW always seem to work, which led to testing the next variation.
Hardcode region
Hard coding the region to
DFWappears to work for all the accounts tested, but this may be an unsafe assumption in production; Non-US based accounts would likely not work, for example.Result
Operations on
$cdnServicefunction as expected.