{"action":"closed","issue":{"url":"https://api.github.com/repos/rackspace/php-opencloud/issues/614","labels_url":"https://api.github.com/repos/rackspace/php-opencloud/issues/614/labels{/name}","comments_url":"https://api.github.com/repos/rackspace/php-opencloud/issues/614/comments","events_url":"https://api.github.com/repos/rackspace/php-opencloud/issues/614/events","html_url":"https://github.com/rackspace/php-opencloud/issues/614","id":94592758,"number":614,"title":"EndpointError thrown when instantiating CDN service","user":{"login":"rchouinard","id":146878,"avatar_url":"https://avatars.githubusercontent.com/u/146878?v=3","gravatar_id":"","url":"https://api.github.com/users/rchouinard","html_url":"https://github.com/rchouinard","followers_url":"https://api.github.com/users/rchouinard/followers","following_url":"https://api.github.com/users/rchouinard/following{/other_user}","gists_url":"https://api.github.com/users/rchouinard/gists{/gist_id}","starred_url":"https://api.github.com/users/rchouinard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rchouinard/subscriptions","organizations_url":"https://api.github.com/users/rchouinard/orgs","repos_url":"https://api.github.com/users/rchouinard/repos","events_url":"https://api.github.com/users/rchouinard/events{/privacy}","received_events_url":"https://api.github.com/users/rchouinard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rackspace/php-opencloud/labels/CDN","name":"CDN","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-07-12T19:27:47Z","updated_at":"2015-07-17T15:02:30Z","closed_at":"2015-07-17T15:02:30Z","body":"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.\r\n\r\nEither the API or the CDN service class seem to be somehow broken when detecting or handling the region flag for this service.\r\n\r\n### Versions\r\nBoth v1.14.2 and dev-master@dev yield the same results.\r\n\r\n### Base code\r\n```php\r\n<?php\r\n\r\nrequire __DIR__ . \"/vendor/autoload.php\";\r\n\r\nuse OpenCloud\\Rackspace;\r\n\r\n$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(\r\n    \"username\"  => MY_RS_USERNAME,\r\n    \"apiKey\"    => MY_RS_APIKEY,\r\n));\r\n\r\n$cdnService = $client->cdnService();\r\n```\r\n\r\n###### Result\r\n    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\r\n\r\n### Variations\r\n\r\n#### Default region\r\nAttempting 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.\r\n\r\n```php\r\n<?php\r\n\r\nrequire __DIR__ . \"/vendor/autoload.php\";\r\n\r\nuse OpenCloud\\Rackspace;\r\n\r\n$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(\r\n    \"username\"  => MY_RS_USERNAME,\r\n    \"apiKey\"    => MY_RS_APIKEY,\r\n));\r\n\r\n$client->authenticate();\r\n$cdnService = $client->cdnService(null, $client->getUser()->getDefaultRegion());\r\n```\r\n\r\n##### Result\r\n    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\r\n\r\nCuriously, users with the default region of DFW always seem to work, which led to testing the next variation.\r\n\r\n#### Hardcode region\r\nHard 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.\r\n\r\n```php\r\n<?php\r\n\r\nrequire __DIR__ . \"/vendor/autoload.php\";\r\n\r\nuse OpenCloud\\Rackspace;\r\n\r\n$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(\r\n    \"username\"  => MY_RS_USERNAME,\r\n    \"apiKey\"    => MY_RS_APIKEY,\r\n));\r\n\r\n$cdnService = $client->cdnService(null, \"DFW\");\r\n```\r\n\r\n##### Result\r\nOperations on `$cdnService` function as expected."}}