1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace CCT\Kong\Http\Request; |
6
|
|
|
|
7
|
|
|
use CCT\Kong\Config; |
8
|
|
|
use CCT\Kong\Http\Request; |
9
|
|
|
use CCT\Kong\Http\Response; |
10
|
|
|
use CCT\Kong\Http\ResponseInterface; |
11
|
|
|
use CCT\Kong\Model\Certificate; |
12
|
|
|
|
13
|
|
|
class CertificateRequest extends Request |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* {@inheritdoc} |
17
|
|
|
*/ |
18
|
11 |
|
protected function setUp() |
19
|
|
|
{ |
20
|
11 |
|
if (!$this->config->has(Config::URI_PREFIX)) { |
21
|
11 |
|
$this->config->set(Config::URI_PREFIX, '/certificates/'); |
22
|
|
|
} |
23
|
11 |
|
} |
24
|
|
|
|
25
|
1 |
|
public function list(): ResponseInterface |
26
|
|
|
{ |
27
|
1 |
|
$this->setSerializationContextFor(['read']); |
28
|
|
|
|
29
|
1 |
|
return parent::requestGet($this->getUri(), null); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
2 |
|
public function create(Certificate $certificate): ResponseInterface |
33
|
|
|
{ |
34
|
2 |
|
$this->setSerializationContextFor(['create']); |
35
|
|
|
|
36
|
2 |
|
return parent::requestPost($this->getUri(), $certificate); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
5 |
|
public function retrieve(string $sniOrCertificateId): ResponseInterface |
40
|
|
|
{ |
41
|
5 |
|
$this->setSerializationContextFor(['read']); |
42
|
|
|
|
43
|
5 |
|
return parent::requestGet($this->appendToUri($sniOrCertificateId)); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
1 |
|
public function update(Certificate $certificate): Response |
47
|
|
|
{ |
48
|
1 |
|
$this->validateObjectId($certificate); |
49
|
1 |
|
$this->setSerializationContextFor(['update']); |
50
|
|
|
|
51
|
1 |
|
return parent::requestPatch($this->appendToUri($certificate->getId()), $certificate); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
2 |
|
public function updateOrCreate(Certificate $certificate): Response |
55
|
|
|
{ |
56
|
2 |
|
$this->setSerializationContextFor(['update', 'create']); |
57
|
|
|
|
58
|
2 |
|
return parent::requestPut($this->getUri(), $certificate); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
2 |
|
public function delete(Certificate $certificate) |
62
|
|
|
{ |
63
|
2 |
|
$this->validateObjectId($certificate); |
64
|
1 |
|
$this->setSerializationContextFor(['delete']); |
65
|
|
|
|
66
|
1 |
|
return parent::requestDelete($this->appendToUri($certificate->getId())); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|