Scalr\Service\Aws\Client\QueryClient::call PHP Method

call() public method

It ensures execution of the certain AWS action by transporting the request and receiving response.
public call ( string $action, array $options, string $path = '/' ) : Scalr\Service\Aws\Client\ClientResponseInterface
$action string An Web service API action name.
$options array An options array. It may contain "_host" option which overrides host.
$path string optional A relative path.
return Scalr\Service\Aws\Client\ClientResponseInterface
    public function call($action, $options, $path = '/')
    {
        if (substr($path, -1) !== '/') {
            $path .= '/';
        }
        $this->lastApiCall = null;
        $options['Action'] = isset($options['Action']) ? $options['Action'] : $action;
        $options['Version'] = isset($options['Version']) ? $options['Version'] : $this->getApiVersion();
        $this->lastApiCall = $options['Action'];
        if (isset($options['_host'])) {
            $host = $options['_host'];
            unset($options['_host']);
        } else {
            $host = $this->url;
        }
        if (isset($options['_region'])) {
            $region = $options['_region'];
            unset($options['_region']);
        } else {
            $region = null;
        }
        if (strpos($host, 'http') === 0) {
            $arr = parse_url($host);
            $scheme = $arr['scheme'];
            $host = $arr['host'] . (isset($arr['port']) ? ':' . $arr['port'] : '');
            $path = (!empty($arr['path']) && $arr['path'] != '/' ? rtrim($arr['path'], '/') : '') . $path;
        } else {
            $scheme = 'https';
        }
        $httpRequest = $this->createRequest();
        $httpRequest->addHeaders(['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8', 'Cache-Control' => 'no-cache']);
        $httpRequest->setRequestUrl($scheme . '://' . $host . $path);
        $httpRequest->setRequestMethod("POST");
        $httpRequest->append($options);
        if (true) {
            $this->signRequestV4($httpRequest, $region);
        } else {
            $this->signRequestV2($httpRequest);
        }
        $response = $this->tryCall($httpRequest);
        if ($this->getAws() && $this->getAws()->getDebug()) {
            echo "\n", "{$httpRequest}\n", "{$response->getResponse()}\n";
        }
        return $response;
    }