28 namespace HPCloud\Services;
209 $parts = parse_url($url);
211 if (!empty($parts[
'path'])) {
212 $this->endpoint = rtrim($url,
'/');
273 $url = $this->
url() .
'/tokens';
278 $body = json_encode($envelope);
281 'Content-Type' =>
'application/json',
282 'Accept' => self::ACCEPT_TYPE,
283 'Content-Length' => strlen($body),
288 $client = \HPCloud\Transport::instance();
290 $response = $client->doRequest($url,
'POST', $headers, $body);
295 return $this->
token();
337 'passwordCredentials' => array(
338 'username' => $username,
339 'password' => $password,
347 elseif (!empty($tenantName)) {
348 $ops[
'tenantName'] = $tenantName;
398 'apiAccessKeyCredentials' => array(
407 elseif (!empty($tenantName)) {
408 $ops[
'tenantName'] = $tenantName;
516 if (empty($details[
'expires'])) {
520 $currentDateTime = new \DateTime(
'now');
521 $expireDateTime = new \DateTime($details[
'expires']);
523 return $currentDateTime > $expireDateTime;
600 return $this->serviceCatalog;
605 if ($entry[
'type'] == $type) {
684 $url = $this->
url() .
'/tenants';
692 'Accept' =>
'application/json',
696 $client = \HPCloud\Transport::instance();
697 $response = $client->doRequest($url,
'GET', $headers);
699 $raw = $response->content();
700 $json = json_decode($raw, TRUE);
702 return $json[
'tenants'];
746 $url = $this->
url() .
'/tokens';
756 $body = json_encode($data);
759 'Accept' => self::ACCEPT_TYPE,
760 'Content-Type' =>
'application/json',
761 'Content-Length' => strlen($body),
765 $client = \HPCloud\Transport::instance();
766 $response = $client->doRequest($url,
'POST', $headers, $body);
769 return $this->
token();
804 $url = $this->
url() .
'/tokens';
808 'tenantName' => $tenantName,
814 $body = json_encode($data);
817 'Accept' => self::ACCEPT_TYPE,
818 'Content-Type' =>
'application/json',
819 'Content-Length' => strlen($body),
823 $client = \HPCloud\Transport::instance();
824 $response = $client->doRequest($url,
'POST', $headers, $body);
827 return $this->
token();
844 $json = json_decode($response->content(), TRUE);
848 $this->userDetails = $json[
'access'][
'user'];