public function doROARequest()

in php/src/OpenApiClient.php [552:779]


  public function doROARequest($action, $version, $protocol, $method, $authType, $pathname, $bodyType, $request, $runtime)
  {
    $_runtime = [
      'key' => ''.($runtime->key ? $runtime->key : $this->_key),
      'cert' => ''.($runtime->cert ? $runtime->cert : $this->_cert),
      'ca' => ''.($runtime->ca ? $runtime->ca : $this->_ca),
      'readTimeout' => (($runtime->readTimeout ? $runtime->readTimeout : $this->_readTimeout) + 0),
      'connectTimeout' => (($runtime->connectTimeout ? $runtime->connectTimeout : $this->_connectTimeout) + 0),
      'httpProxy' => ''.($runtime->httpProxy ? $runtime->httpProxy : $this->_httpProxy),
      'httpsProxy' => ''.($runtime->httpsProxy ? $runtime->httpsProxy : $this->_httpsProxy),
      'noProxy' => ''.($runtime->noProxy ? $runtime->noProxy : $this->_noProxy),
      'socks5Proxy' => ''.($runtime->socks5Proxy ? $runtime->socks5Proxy : $this->_socks5Proxy),
      'socks5NetWork' => ''.($runtime->socks5NetWork ? $runtime->socks5NetWork : $this->_socks5NetWork),
      'maxIdleConns' => (($runtime->maxIdleConns ? $runtime->maxIdleConns : $this->_maxIdleConns) + 0),
      'retryOptions' => $this->_retryOptions,
      'ignoreSSL' => $runtime->ignoreSSL,
      'tlsMinVersion' => $this->_tlsMinVersion,
    ];

    $_retriesAttempted = 0;
    $_lastRequest = null;
    $_lastResponse = null;
    $_context = new RetryPolicyContext([
      'retriesAttempted' => $_retriesAttempted,
    ]);
    while (Dara::shouldRetry($_runtime['retryOptions'], $_context)) {
      if ($_retriesAttempted > 0) {
        $_backoffTime = Dara::getBackoffDelay($_runtime['retryOptions'], $_context);
        if ($_backoffTime > 0) {
          Dara::sleep($_backoffTime);
        }
      }

      $_retriesAttempted++;
      try {
        $_request = new Request();
        $_request->protocol = ''.($this->_protocol ? $this->_protocol : $protocol);
        $_request->method = $method;
        $_request->pathname = $pathname;
        $globalQueries = [ ];
        $globalHeaders = [ ];
        if (!is_null($this->_globalParameters)) {
          $globalParams = $this->_globalParameters;
          if (!is_null($globalParams->queries)) {
            $globalQueries = $globalParams->queries;
          }

          if (!is_null($globalParams->headers)) {
            $globalHeaders = $globalParams->headers;
          }

        }

        $extendsHeaders = [ ];
        $extendsQueries = [ ];
        if (!is_null($runtime->extendsParameters)) {
          $extendsParameters = $runtime->extendsParameters;
          if (!is_null($extendsParameters->headers)) {
            $extendsHeaders = $extendsParameters->headers;
          }

          if (!is_null($extendsParameters->queries)) {
            $extendsQueries = $extendsParameters->queries;
          }

        }

        $_request->headers = Dara::merge([
          'date' => Utils::getDateUTCString(),
          'host' => $this->_endpoint,
          'accept' => 'application/json',
          'x-acs-signature-nonce' => Utils::getNonce(),
          'x-acs-signature-method' => 'HMAC-SHA1',
          'x-acs-signature-version' => '1.0',
          'x-acs-version' => $version,
          'x-acs-action' => $action,
          'user-agent' => Utils::getUserAgent($this->_userAgent),
        ], $globalHeaders, $extendsHeaders, $request->headers);
        if (!is_null($request->body)) {
          $_request->body = json_encode($request->body, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES);
          @$_request->headers['content-type'] = 'application/json; charset=utf-8';
        }

        $_request->query = Dara::merge([
        ], $globalQueries, $extendsQueries);
        if (!is_null($request->query)) {
          $_request->query = Dara::merge([
          ], $_request->query, $request->query);
        }

        if ($authType != 'Anonymous') {
          if (is_null($this->_credential)) {
            throw new ClientException([
              'code' => 'InvalidCredentials',
              'message' => 'Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.',
            ]);
          }

          $credentialModel = $this->_credential->getCredential();
          if (!is_null($credentialModel->providerName)) {
            @$_request->headers['x-acs-credentials-provider'] = $credentialModel->providerName;
          }

          $credentialType = $credentialModel->type;
          if ($credentialType == 'bearer') {
            $bearerToken = $credentialModel->bearerToken;
            @$_request->headers['x-acs-bearer-token'] = $bearerToken;
            @$_request->headers['x-acs-signature-type'] = 'BEARERTOKEN';
          } else {
            $accessKeyId = $credentialModel->accessKeyId;
            $accessKeySecret = $credentialModel->accessKeySecret;
            $securityToken = $credentialModel->securityToken;
            if (!is_null($securityToken) && $securityToken != '') {
              @$_request->headers['x-acs-accesskey-id'] = $accessKeyId;
              @$_request->headers['x-acs-security-token'] = $securityToken;
            }

            $stringToSign = Utils::getStringToSign($_request);
            @$_request->headers['authorization'] = 'acs ' . $accessKeyId . ':' . Utils::getROASignature($stringToSign, $accessKeySecret) . '';
          }

        }

        $_response = Dara::send($_request, $_runtime);
        $_lastRequest = $_request;
        $_lastResponse = $_response;

        if ($_response->statusCode == 204) {
          return [
            'headers' => $_response->headers,
          ];
        }

        if (($_response->statusCode >= 400) && ($_response->statusCode < 600)) {
          $_res = StreamUtil::readAsJSON($_response->body);
          $err = $_res;
          $requestId = ''.(@$err['RequestId'] ? @$err['RequestId'] : @$err['requestId']);
          $requestId = ''.($requestId ? $requestId : @$err['requestid']);
          $code = ''.(@$err['Code'] ? @$err['Code'] : @$err['code']);
          if (('' . $code . '' == 'Throttling') || ('' . $code . '' == 'Throttling.User') || ('' . $code . '' == 'Throttling.Api')) {
            throw new ThrottlingException([
              'statusCode' => $_response->statusCode,
              'code' => '' . $code . '',
              'message' => 'code: ' . (string)$_response->statusCode . ', ' . (string)(@$err['Message'] ? @$err['Message'] : @$err['message']) . ' request id: ' . $requestId . '',
              'description' => '' . (string)(@$err['Description'] ? @$err['Description'] : @$err['description']) . '',
              'retryAfter' => Utils::getThrottlingTimeLeft($_response->headers),
              'data' => $err,
              'requestId' => '' . $requestId . '',
            ]);
          } else if (($_response->statusCode >= 400) && ($_response->statusCode < 500)) {
            throw new ClientException([
              'statusCode' => $_response->statusCode,
              'code' => '' . $code . '',
              'message' => 'code: ' . (string)$_response->statusCode . ', ' . (string)(@$err['Message'] ? @$err['Message'] : @$err['message']) . ' request id: ' . $requestId . '',
              'description' => '' . (string)(@$err['Description'] ? @$err['Description'] : @$err['description']) . '',
              'data' => $err,
              'accessDeniedDetail' => $this->getAccessDeniedDetail($err),
              'requestId' => '' . $requestId . '',
            ]);
          } else {
            throw new ServerException([
              'statusCode' => $_response->statusCode,
              'code' => '' . $code . '',
              'message' => 'code: ' . (string)$_response->statusCode . ', ' . (string)(@$err['Message'] ? @$err['Message'] : @$err['message']) . ' request id: ' . $requestId . '',
              'description' => '' . (string)(@$err['Description'] ? @$err['Description'] : @$err['description']) . '',
              'data' => $err,
              'requestId' => '' . $requestId . '',
            ]);
          }

        }

        if ($bodyType == 'binary') {
          $resp = [
            'body' => $_response->body,
            'headers' => $_response->headers,
            'statusCode' => $_response->statusCode,
          ];
          return $resp;
        } else if ($bodyType == 'byte') {
          $byt = StreamUtil::readAsBytes($_response->body);
          return [
            'body' => $byt,
            'headers' => $_response->headers,
            'statusCode' => $_response->statusCode,
          ];
        } else if ($bodyType == 'string') {
          $_str = StreamUtil::readAsString($_response->body);
          return [
            'body' => $_str,
            'headers' => $_response->headers,
            'statusCode' => $_response->statusCode,
          ];
        } else if ($bodyType == 'json') {
          $obj = StreamUtil::readAsJSON($_response->body);
          $res = $obj;
          return [
            'body' => $res,
            'headers' => $_response->headers,
            'statusCode' => $_response->statusCode,
          ];
        } else if ($bodyType == 'array') {
          $arr = StreamUtil::readAsJSON($_response->body);
          return [
            'body' => $arr,
            'headers' => $_response->headers,
            'statusCode' => $_response->statusCode,
          ];
        } else {
          return [
            'headers' => $_response->headers,
            'statusCode' => $_response->statusCode,
          ];
        }

      } catch (DaraException $e) {
        $_context = new RetryPolicyContext([
          'retriesAttempted' => $_retriesAttempted,
          'lastRequest' => $_lastRequest,
          'lastResponse' => $_lastResponse,
          'exception' => $e,
        ]);
        continue;
      }
    }

    throw new DaraUnableRetryException($_context);
  }