EcsRamRoleCredential.php 905 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace AlibabaCloud\Client\Credentials;
  3. use AlibabaCloud\Client\Filter\CredentialFilter;
  4. use AlibabaCloud\Client\Exception\ClientException;
  5. /**
  6. * Use the RAM role of an ECS instance to complete the authentication.
  7. *
  8. * @package AlibabaCloud\Client\Credentials
  9. */
  10. class EcsRamRoleCredential implements CredentialsInterface
  11. {
  12. /**
  13. * @var string
  14. */
  15. private $roleName;
  16. /**
  17. * Class constructor.
  18. *
  19. * @param string $roleName
  20. *
  21. * @throws ClientException
  22. */
  23. public function __construct($roleName)
  24. {
  25. CredentialFilter::roleName($roleName);
  26. $this->roleName = $roleName;
  27. }
  28. /**
  29. * @return string
  30. */
  31. public function getRoleName()
  32. {
  33. return $this->roleName;
  34. }
  35. /**
  36. * @return string
  37. */
  38. public function __toString()
  39. {
  40. return "roleName#$this->roleName";
  41. }
  42. }