1 | <?php |
||
2 | |||
3 | namespace AlibabaCloud\Client\Credentials\Requests; |
||
4 | |||
5 | use AlibabaCloud\Client\Request\RpcRequest; |
||
6 | use AlibabaCloud\Client\Exception\ClientException; |
||
7 | use AlibabaCloud\Client\Credentials\Providers\Provider; |
||
8 | use AlibabaCloud\Client\Credentials\RamRoleArnCredential; |
||
9 | |||
10 | /** |
||
11 | * Retrieving assume role credentials. |
||
12 | * |
||
13 | * @package AlibabaCloud\Client\Credentials\Requests |
||
14 | */ |
||
15 | class AssumeRole extends RpcRequest |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * AssumeRole constructor. |
||
20 | * |
||
21 | * @param RamRoleArnCredential $arnCredential |
||
22 | * |
||
23 | * @throws ClientException |
||
24 | */ |
||
25 | 7 | public function __construct(RamRoleArnCredential $arnCredential) |
|
26 | { |
||
27 | 7 | parent::__construct(); |
|
28 | 7 | $this->product('Sts'); |
|
29 | 7 | $this->version('2015-04-01'); |
|
30 | 7 | $this->action('AssumeRole'); |
|
31 | 7 | $this->host('sts.aliyuncs.com'); |
|
32 | 7 | $this->scheme('https'); |
|
33 | 7 | $this->regionId('cn-hangzhou'); |
|
34 | 7 | $this->options['verify'] = false; |
|
35 | 7 | $this->options['query']['RoleArn'] = $arnCredential->getRoleArn(); |
|
36 | 7 | $this->options['query']['RoleSessionName'] = $arnCredential->getRoleSessionName(); |
|
37 | 7 | $this->options['query']['DurationSeconds'] = Provider::DURATION_SECONDS; |
|
38 | 7 | if ($arnCredential->getPolicy()) { |
|
39 | 2 | if (is_array($arnCredential->getPolicy())) { |
|
0 ignored issues
–
show
introduced
by
![]() |
|||
40 | 1 | $this->options['query']['Policy'] = json_encode($arnCredential->getPolicy()); |
|
41 | 1 | } |
|
42 | 2 | if (is_string($arnCredential->getPolicy())) { |
|
0 ignored issues
–
show
|
|||
43 | 1 | $this->options['query']['Policy'] = $arnCredential->getPolicy(); |
|
44 | 1 | } |
|
45 | 2 | } |
|
46 | 7 | } |
|
47 | } |
||
48 |