Issues (19)

src/V20160120/Kms.php (19 issues)

1
<?php
2
3
namespace AlibabaCloud\Kms\V20160120;
4
5
use AlibabaCloud\Client\Result\Result;
6
use AlibabaCloud\Kms\Base;
7
use GuzzleHttp\Exception\GuzzleException;
8
9
/**
10
 * Class Kms
11
 *
12
 * @package AlibabaCloud\V20160120\\Kms
13
 */
14
class Kms extends Base
15
{
16
    /**
17
     * @var string
18
     */
19
    protected $version = '2016-01-20';
20
21
    /**
22
     * @description cancel key deletion which can enable this key
23
     * @see         https://help.aliyun.com/document_detail/44197.html
24
     *
25
     * @param $query
26
     *   - Action string required
27
     *   - KeyId string required: global unique identifier
28
     * @param $runtime
29
     *
30
     * @return Result
31
     * @throws GuzzleException
32
     */
33 1
    public function cancelKeyDeletion($query = [], $runtime = [])
34
    {
35 1
        $query['Action']     = 'CancelKeyDeletion';
36 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
37 1
        $request['method']   = 'GET';
38 1
        $request['pathname'] = '/';
39 1
        $request['query']    = $this->getQuery($query, $request);
40 1
        $request['headers']  = [
41 1
            'host' => $this->endpoint,
42
        ];
43
44 1
        $response = $this->request($request, $runtime);
45
46 1
        return $this->json($response);
47
    }
48
49
    /**
50
     * @description make alias to key
51
     * @see         https://help.aliyun.com/document_detail/68624.html
52
     *
53
     * @param $query
54
     *   - Action string required
55
     *   - KeyId string required: global unique identifier
56
     *   - AliasName string required: cmk alias, prefix must be 'alias/'
57
     * @param $runtime
58
     *
59
     * @return Result
60
     * @throws GuzzleException
61
     */
62 1
    public function createAlias($query = [], $runtime = [])
63
    {
64 1
        $query['Action']     = 'CreateAlias';
65 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
66 1
        $request['method']   = 'GET';
67 1
        $request['pathname'] = '/';
68 1
        $request['query']    = $this->getQuery($query, $request);
69 1
        $request['headers']  = [
70 1
            'host' => $this->endpoint,
71
        ];
72
73 1
        $response = $this->request($request, $runtime);
74
75 1
        return $this->json($response);
76
    }
77
78
    /**
79
     * @description create new key
80
     * @see         https://help.aliyun.com/document_detail/28947.html
81
     *
82
     * @param $query
83
     *   - Action string required
84
     *   - Origin string optional: Aliyun_KMS (default) or EXTERNAL
85
     *   - Description string optional: description of key
86
     *   - KeyUsage string optional: usage of key, default is ENCRYPT/DECRYPT
87
     * @param $runtime
88
     *
89
     * @return Result
90
     * @throws GuzzleException
91
     */
92 3
    public function createKey($query = [], $runtime = [])
93
    {
94 2
        $query['Action']     = 'CreateKey';
95 2
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
96 2
        $request['method']   = 'GET';
97 2
        $request['pathname'] = '/';
98 2
        $request['query']    = $this->getQuery($query, $request);
99 2
        $request['headers']  = [
100 3
            'host' => $this->endpoint,
101
        ];
102
103 2
        $response = $this->request($request, $runtime);
104
105 2
        return $this->json($response);
106
    }
107
108
    /**
109
     * @description decrypt body of CiphertextBlob
110
     * @see         https://help.aliyun.com/document_detail/28950.html
111
     *
112
     * @param $query
113
     *   - Action string required
114
     *   - CiphertextBlob string required: ciphertext to be decrypted.
115
     *   - EncryptionContext string optional: key/value string, must be {string: string}
116
     * @param $runtime
117
     *
118
     * @return Result
119
     * @throws GuzzleException
120
     */
121 1
    public function decrypt($query = [], $runtime = [])
122
    {
123 1
        $query['Action']     = 'Decrypt';
124 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
125 1
        $request['method']   = 'GET';
126 1
        $request['pathname'] = '/';
127 1
        $request['query']    = $this->getQuery($query, $request);
128 1
        $request['headers']  = [
129 1
            'host' => $this->endpoint,
130
        ];
131
132 1
        $response = $this->request($request, $runtime);
133
134 1
        return $this->json($response);
135
    }
136
137
    /**
138
     * @description delete alias
139
     * @see         https://help.aliyun.com/document_detail/68626.html
140
     *
141
     * @param $query
142
     *   - Action string required
143
     *   - AliasName string required: alias name, prefix must be 'alias/'
144
     * @param $runtime
145
     *
146
     * @return Result
147
     * @throws GuzzleException
148
     */
149 1
    public function deleteAlias($query = [], $runtime = [])
150
    {
151 1
        $query['Action']     = 'DeleteAlias';
152 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
153 1
        $request['method']   = 'GET';
154 1
        $request['pathname'] = '/';
155 1
        $request['query']    = $this->getQuery($query, $request);
156 1
        $request['headers']  = [
157 1
            'host' => $this->endpoint,
158
        ];
159
160 1
        $response = $this->request($request, $runtime);
161
162 1
        return $this->json($response);
163
    }
164
165
    /**
166
     * @description delete key material
167
     * @see         https://help.aliyun.com/document_detail/68623.html
168
     *
169
     * @param $query
170
     *   - Action string required
171
     *   - KeyId string required: global unique identifier
172
     * @param $runtime
173
     *
174
     * @return Result
175
     * @throws GuzzleException
176
     */
177 1
    public function deleteKeyMaterial($query = [], $runtime = [])
178
    {
179 1
        $query['Action']     = 'DeleteKeyMaterial';
180 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
181 1
        $request['method']   = 'GET';
182 1
        $request['pathname'] = '/';
183 1
        $request['query']    = $this->getQuery($query, $request);
184 1
        $request['headers']  = [
185 1
            'host' => $this->endpoint,
186
        ];
187
188 1
        $response = $this->request($request, $runtime);
189
190 1
        return $this->json($response);
191
    }
192
193
    /**
194
     * @description get description of main key
195
     * @see         https://help.aliyun.com/document_detail/28952.html
196
     *
197
     * @param $query
198
     *   - Action string required
199
     *   - KeyId string required: global unique identifier
200
     * @param $runtime
201
     *
202
     * @return Result
203
     * @throws GuzzleException
204
     */
205 5
    public function describeKey($query = [], $runtime = [])
206
    {
207 5
        $query['Action']     = 'DescribeKey';
208 5
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
209 5
        $request['method']   = 'GET';
210 5
        $request['pathname'] = '/';
211 5
        $request['query']    = $this->getQuery($query, $request);
212 5
        $request['headers']  = [
213 5
            'host' => $this->endpoint,
214
        ];
215
216 5
        $response = $this->request($request, $runtime);
217
218 5
        return $this->json($response);
219
    }
220
221
    /**
222
     * @description query available regions
223
     * @see         https://help.aliyun.com/document_detail/54560.html
224
     *
225
     * @param $query
226
     *   - Action string required
227
     * @param $runtime
228
     *
229
     * @return Result
230
     * @throws GuzzleException
231
     */
232 2
    public function describeRegions($query = [], $runtime = [])
233
    {
234 2
        $query['Action']     = 'DescribeRegions';
235 2
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
236 2
        $request['method']   = 'GET';
237 2
        $request['pathname'] = '/';
238 2
        $request['query']    = $this->getQuery($query, $request);
239 2
        $request['headers']  = [
240 2
            'host' => $this->endpoint,
241
        ];
242
243 2
        $response = $this->request($request, $runtime);
244
245 1
        return $this->json($response);
246
    }
247
248
    /**
249
     * @description disable key
250
     * @see         https://help.aliyun.com/document_detail/35151.html
251
     *
252
     * @param $query
253
     *   - Action string required
254
     *   - KeyId string required: global unique identifier
255
     * @param $runtime
256
     *
257
     * @return Result
258
     * @throws GuzzleException
259
     */
260 1
    public function disableKey($query = [], $runtime = [])
261
    {
262 1
        $query['Action']     = 'DisableKey';
263 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
264 1
        $request['method']   = 'GET';
265 1
        $request['pathname'] = '/';
266 1
        $request['query']    = $this->getQuery($query, $request);
267 1
        $request['headers']  = [
268 1
            'host' => $this->endpoint,
269
        ];
270
271 1
        $response = $this->request($request, $runtime);
272
273 1
        return $this->json($response);
274
    }
275
276
    /**
277
     * @description enable key
278
     * @see         https://help.aliyun.com/document_detail/35150.html
279
     *
280
     * @param $query
281
     *   - Action string required
282
     *   - KeyId string required: global unique identifier
283
     * @param $runtime
284
     *
285
     * @return Result
286
     * @throws GuzzleException
287
     */
288 1
    public function enableKey($query = [], $runtime = [])
289
    {
290 1
        $query['Action']     = 'EnableKey';
291 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
292 1
        $request['method']   = 'GET';
293 1
        $request['pathname'] = '/';
294 1
        $request['query']    = $this->getQuery($query, $request);
295 1
        $request['headers']  = [
296 1
            'host' => $this->endpoint,
297
        ];
298
299 1
        $response = $this->request($request, $runtime);
300
301 1
        return $this->json($response);
302
    }
303
304
    /**
305
     * @description encrypt content
306
     * @see         https://help.aliyun.com/document_detail/28949.html
307
     *
308
     * @param $query
309
     *   - Action string required
310
     *   - KeyId string required: global unique identifier
311
     *   - Plaintext string required: plaintext to be encrypted (must be Base64 encoded)
312
     *   - EncryptionContext string optional: key/value string, must be {string: string}
313
     * @param $runtime
314
     *
315
     * @return Result
316
     * @throws GuzzleException
317
     */
318 1
    public function encrypt($query = [], $runtime = [])
319
    {
320 1
        $query['Action']     = 'Encrypt';
321 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
322 1
        $request['method']   = 'GET';
323 1
        $request['pathname'] = '/';
324 1
        $request['query']    = $this->getQuery($query, $request);
325 1
        $request['headers']  = [
326 1
            'host' => $this->endpoint,
327
        ];
328
329 1
        $response = $this->request($request, $runtime);
330
331 1
        return $this->json($response);
332
    }
333
334
    /**
335
     * @description generate local data key
336
     * @see         https://help.aliyun.com/document_detail/28948.html
337
     *
338
     * @param $query
339
     *   - Action string required
340
     *   - KeyId string required: global unique identifier
341
     *   - KeySpec string optional: AES_256 or AES_128
342
     *   - NumberOfBytes int optional: length of key
343
     *   - EncryptionContext string optional: key/value string, must be {string: string}
344
     * @param $runtime
345
     *
346
     * @return Result
347
     * @throws GuzzleException
348
     */
349 1
    public function generateDataKey($query = [], $runtime = [])
350
    {
351 1
        $query['Action']     = 'GenerateDataKey';
352 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
353 1
        $request['method']   = 'GET';
354 1
        $request['pathname'] = '/';
355 1
        $request['query']    = $this->getQuery($query, $request);
356 1
        $request['headers']  = [
357 1
            'host' => $this->endpoint,
358
        ];
359
360 1
        $response = $this->request($request, $runtime);
361
362 1
        return $this->json($response);
363
    }
364
365
    /**
366
     * @description get the imported master key (CMK) material
367
     * @see         https://help.aliyun.com/document_detail/68621.html
368
     *
369
     * @param $query
370
     *   - Action string required
371
     *   - KeyId string required: global unique identifier
372
     *   - WrappingAlgorithm string required: algorithm for encrypting key material, RSAES_PKCS1_V1_5, RSAES_OAEP_SHA_1
373
     *   or RSAES_OAEP_SHA_256
374
     *   - WrappingKeySpec string required: public key type used to encrypt key material, RSA_2048
375
     * @param $runtime
376
     *
377
     * @return Result
378
     * @throws GuzzleException
379
     */
380 1
    public function getParametersForImport($query = [], $runtime = [])
381
    {
382 1
        $query['Action']     = 'GetParametersForImport';
383 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
384 1
        $request['method']   = 'GET';
385 1
        $request['pathname'] = '/';
386 1
        $request['query']    = $this->getQuery($query, $request);
387 1
        $request['headers']  = [
388 1
            'host' => $this->endpoint,
389
        ];
390
391 1
        $response = $this->request($request, $runtime);
392
393 1
        return $this->json($response);
394
    }
395
396
    /**
397
     * @description
398
     * @see https://help.aliyun.com/document_detail/68622.html
399
     *
400
     * @param $query
401
     *   - Action string required
402
     *   - KeyId string required: global unique identifier
403
     *   - EncryptedKeyMaterial string required: key material encrypted with base64
404
     *   - ImportToken string required: obtained by calling GetParametersForImport
405
     *   - KeyMaterialExpireUnix {timestamp} optional: Key material expiration time
406
     * @param $runtime
407
     *
408
     * @return Result
409
     * @throws GuzzleException
410
     */
411 1
    public function importKeyMaterial($query = [], $runtime = [])
412
    {
413 1
        $query['Action']     = 'ImportKeyMaterial';
414 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
415 1
        $request['method']   = 'GET';
416 1
        $request['pathname'] = '/';
417 1
        $request['query']    = $this->getQuery($query, $request);
418 1
        $request['headers']  = [
419 1
            'host' => $this->endpoint,
420
        ];
421
422 1
        $response = $this->request($request, $runtime);
423
424 1
        return $this->json($response);
425
    }
426
427
    /**
428
     * @description returns all aliases of the current user in the current zone
429
     * @see         https://help.aliyun.com/document_detail/68627.html
430
     *
431
     * @param $query
432
     *   - Action string required
433
     *   - PageNumber int optional: current page, default 1
434
     *   - PageSize int optional: result count (0 - 100), default 10
435
     * @param $runtime
436
     *
437
     * @return Result
438
     * @throws GuzzleException
439
     */
440 1
    public function listAliases($query = [], $runtime = [])
441
    {
442 1
        $query['Action']     = 'ListAliases';
443 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
444 1
        $request['method']   = 'GET';
445 1
        $request['pathname'] = '/';
446 1
        $request['query']    = $this->getQuery($query, $request);
447 1
        $request['headers']  = [
448 1
            'host' => $this->endpoint,
449
        ];
450
451 1
        $response = $this->request($request, $runtime);
452
453 1
        return $this->json($response);
454
    }
455
456
    /**
457
     * @description list all aliases corresponding to the specified master key (CMK)
458
     * @see         https://help.aliyun.com/document_detail/68628.html
459
     *
460
     * @param $query
461
     *   - Action string required
462
     *   - KeyId string required: global unique identifier
463
     *   - PageNumber int optional: current page, default 1
464
     *   - PageSize int optional: result count (0 - 100), default 10
465
     * @param $runtime
466
     *
467
     * @return Result
468
     * @throws GuzzleException
469
     */
470 2
    public function listAliasesByKeyId($query = [], $runtime = [])
471
    {
472 2
        $query['Action']     = 'ListAliasesByKeyId';
473 2
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
474 2
        $request['method']   = 'GET';
475 2
        $request['pathname'] = '/';
476 2
        $request['query']    = $this->getQuery($query, $request);
477 2
        $request['headers']  = [
478 2
            'host' => $this->endpoint,
479
        ];
480
481 2
        $response = $this->request($request, $runtime);
482
483 2
        return $this->json($response);
484
    }
485
486
    /**
487
     * @description Returns all the master key IDs of the caller in the calling area
488
     * @see         https://help.aliyun.com/document_detail/28951.html
489
     *
490
     * @param $query
491
     *   - Action string required
492
     *   - PageNumber int optional: current page, default 1
493
     *   - PageSize int optional: result count (0 - 100), default 10
494
     * @param $runtime
495
     *
496
     * @return Result
497
     * @throws GuzzleException
498
     */
499 1
    public function listKeys($query = [], $runtime = [])
500
    {
501 1
        $query['Action']     = 'ListKeys';
502 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
503 1
        $request['method']   = 'GET';
504 1
        $request['pathname'] = '/';
505 1
        $request['query']    = $this->getQuery($query, $request);
506 1
        $request['headers']  = [
507 1
            'host' => $this->endpoint,
508
        ];
509
510 1
        $response = $this->request($request, $runtime);
511
512 1
        return $this->json($response);
513
    }
514
515
    /**
516
     * @description request to delete a specified master key (CMK)
517
     * @see         https://help.aliyun.com/document_detail/44196.html
518
     *
519
     * @param $query
520
     *   - Action string required
521
     *   - KeyId string required: global unique identifier
522
     *   - PendingWindowInDays int required: key pre-delete cycle, [7, 30]
523
     * @param $runtime
524
     *
525
     * @return Result
526
     * @throws GuzzleException
527
     */
528 1
    public function scheduleKeyDeletion($query = [], $runtime = [])
529
    {
530 1
        $query['Action']     = 'ScheduleKeyDeletion';
531 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
532 1
        $request['method']   = 'GET';
533 1
        $request['pathname'] = '/';
534 1
        $request['query']    = $this->getQuery($query, $request);
535 1
        $request['headers']  = [
536 1
            'host' => $this->endpoint,
537
        ];
538
539 1
        $response = $this->request($request, $runtime);
540
541 1
        return $this->json($response);
542
    }
543
544
    /**
545
     * @description update the master key (CMK) represented by an existing alias
546
     * @see         https://help.aliyun.com/document_detail/68625.html
547
     *
548
     * @param $query
549
     *   - Action string required
550
     *   - KeyId string required: global unique identifier
551
     *   - AliasName string required: the alias to be operated, prefix must be 'alias/'
552
     * @param $runtime
553
     *
554
     * @return Result
555
     * @throws GuzzleException
556
     */
557 1
    public function updateAlias($query = [], $runtime = [])
558
    {
559 1
        $query['Action']     = 'UpdateAlias';
560 1
        $request['protocol'] = 'https';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
561 1
        $request['method']   = 'GET';
562 1
        $request['pathname'] = '/';
563 1
        $request['query']    = $this->getQuery($query, $request);
564 1
        $request['headers']  = [
565 1
            'host' => $this->endpoint,
566
        ];
567
568 1
        $response = $this->request($request, $runtime);
569
570 1
        return $this->json($response);
571
    }
572
}
573