DefaultAcsClient.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace AlibabaCloud\Client;
  3. use AlibabaCloud\Client\Result\Result;
  4. use AlibabaCloud\Client\Clients\Client;
  5. use AlibabaCloud\Client\Request\Request;
  6. use AlibabaCloud\Client\Exception\ClientException;
  7. use AlibabaCloud\Client\Exception\ServerException;
  8. /**
  9. * Class DefaultAcsClient
  10. *
  11. * @package AlibabaCloud
  12. *
  13. * @deprecated deprecated since version 2.0, Use AlibabaCloud instead.
  14. * @codeCoverageIgnore
  15. */
  16. class DefaultAcsClient
  17. {
  18. /**
  19. * @var string
  20. */
  21. public $randClientName;
  22. /**
  23. * DefaultAcsClient constructor.
  24. *
  25. * @param Client $client
  26. *
  27. * @throws ClientException
  28. */
  29. public function __construct(Client $client)
  30. {
  31. $this->randClientName = \uniqid('', true);
  32. $client->name($this->randClientName);
  33. }
  34. /**
  35. * @param Request|Result $request
  36. *
  37. * @return Result|string
  38. * @throws ClientException
  39. * @throws ServerException
  40. */
  41. public function getAcsResponse($request)
  42. {
  43. if ($request instanceof Result) {
  44. return $request;
  45. }
  46. return $request->client($this->randClientName)->request();
  47. }
  48. }