/** * {@inheritdoc} * @see RequestInterface::makeRequest() */ public function makeRequest(OpenStackConfig $config) { if ($config->getApiKey() !== null) { $requestBody = ['auth' => ['identity' => ['methods' => ['token'], 'token' => ['id' => $config->getApiKey()]]]]; } else { if ($config->getPassword() !== null) { $requestBody = ['auth' => ['identity' => ['methods' => ['password'], 'password' => ['user' => ['password' => $config->getPassword()]]]]]; if ($config->getUserId()) { $requestBody['auth']['identity']['password']['user']['id'] = $config->getUserId(); } else { if ($config->getUsername()) { $requestBody['auth']['identity']['password']['user']['name'] = $config->getUsername(); } else { throw new OpenStackException('Neither user name nor user id was provided for the OpenStack config.'); } } } else { throw new OpenStackException('Neither api key nor password was provided for the OpenStack config.'); } } if ($config->getProjectId() !== null) { $requestBody['auth']['scope']['project']['id'] = $config->getProjectId(); } else { if ($config->getTenantName() !== null) { $requestBody['auth']['scope']['project']['name'] = $config->getTenantName(); } } return $requestBody; }
/** * {@inheritdoc} * @see RequestInterface::makeRequest() */ public function makeRequest(OpenStackConfig $config) { if (!empty($config->getApiKey())) { $requestBody = ['auth' => ["RAX-KSKEY:apiKeyCredentials" => ['username' => $config->getUsername(), 'apiKey' => $config->getApiKey()]]]; } else { if (!empty($config->getPassword())) { $requestBody = ['auth' => ["passwordCredentials" => ['username' => $config->getUsername(), 'password' => $config->getPassword()]]]; } else { throw new OpenStackException('Neither api key nor password was provided for the OpenStack config.'); } } if ($config->getTenantName() !== null) { $requestBody['auth']['tenantName'] = $config->getTenantName(); } return $requestBody; }