1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Freyo\ApiGateway\Key; |
4
|
|
|
|
5
|
|
|
use Freyo\ApiGateway\Kernel\TencentCloudClient; |
6
|
|
|
|
7
|
|
|
class Client extends TencentCloudClient |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @return string |
11
|
|
|
*/ |
12
|
|
|
protected function getBaseUri() |
13
|
|
|
{ |
14
|
|
|
return 'https://apigateway.api.qcloud.com/v2/'; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param $secretId |
19
|
|
|
* |
20
|
|
|
* @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
21
|
|
|
* @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException |
22
|
|
|
*/ |
23
|
|
|
public function get($secretId) |
24
|
|
|
{ |
25
|
|
|
$params = [ |
26
|
|
|
'Action' => 'DescribeApiKey', |
27
|
|
|
'secretId' => $secretId, |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
return $this->httpPost('index.php', $params); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param $secretName |
35
|
|
|
* @param $secretId |
36
|
|
|
* @param $secretKey |
37
|
|
|
* |
38
|
|
|
* @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
39
|
|
|
* @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException |
40
|
|
|
*/ |
41
|
|
|
public function create($secretName, $secretId = null, $secretKey = null) |
42
|
|
|
{ |
43
|
|
|
$params = [ |
44
|
|
|
'Action' => 'CreateApiKey', |
45
|
|
|
'secretName' => $secretName, |
46
|
|
|
'secretId' => $secretId, |
47
|
|
|
'secretKey' => $secretKey, |
48
|
|
|
'type' => isset($secretId, $secretKey) ? 'manunal' : 'auto', |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
return $this->httpPost('index.php', $params); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param $secretId |
56
|
|
|
* |
57
|
|
|
* @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
58
|
|
|
* @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException |
59
|
|
|
*/ |
60
|
|
|
public function delete($secretId) |
61
|
|
|
{ |
62
|
|
|
$params = [ |
63
|
|
|
'Action' => 'DeleteApiKey', |
64
|
|
|
'secretId' => $secretId, |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
return $this->httpPost('index.php', $params); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param $secretId |
72
|
|
|
* |
73
|
|
|
* @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
74
|
|
|
* @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException |
75
|
|
|
*/ |
76
|
|
|
public function enable($secretId) |
77
|
|
|
{ |
78
|
|
|
$params = [ |
79
|
|
|
'Action' => 'EnableApiKey', |
80
|
|
|
'secretId' => $secretId, |
81
|
|
|
]; |
82
|
|
|
|
83
|
|
|
return $this->httpPost('index.php', $params); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param $secretId |
88
|
|
|
* |
89
|
|
|
* @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
90
|
|
|
* @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException |
91
|
|
|
*/ |
92
|
|
|
public function disable($secretId) |
93
|
|
|
{ |
94
|
|
|
$params = [ |
95
|
|
|
'Action' => 'DisableApiKey', |
96
|
|
|
'secretId' => $secretId, |
97
|
|
|
]; |
98
|
|
|
|
99
|
|
|
return $this->httpPost('index.php', $params); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param $secretId |
104
|
|
|
* @param $secretKey |
105
|
|
|
* |
106
|
|
|
* @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
107
|
|
|
* @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException |
108
|
|
|
*/ |
109
|
|
|
public function update($secretId, $secretKey = null) |
110
|
|
|
{ |
111
|
|
|
$params = [ |
112
|
|
|
'Action' => 'UpdateApiKey', |
113
|
|
|
'secretId' => $secretId, |
114
|
|
|
'secretKey' => $secretKey, |
115
|
|
|
]; |
116
|
|
|
|
117
|
|
|
return $this->httpPost('index.php', $params); |
118
|
|
|
} |
119
|
|
|
} |