1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the KongAdminApi package. |
5
|
|
|
* |
6
|
|
|
* (c) Unikorp <https://github.com/unikorp> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Unikorp\KongAdminApi\Node; |
13
|
|
|
|
14
|
|
|
use Psr\Http\Message\ResponseInterface; |
15
|
|
|
use Unikorp\KongAdminApi\AbstractNode; |
16
|
|
|
use Unikorp\KongAdminApi\Document\Plugin as Document; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* plugin |
20
|
|
|
* |
21
|
|
|
* @author VEBER Arnaud <https://github.com/VEBERArnaud> |
22
|
|
|
*/ |
23
|
|
|
class Plugin extends AbstractNode |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* add plugin |
27
|
|
|
* |
28
|
|
|
* @param string $nameOrId |
29
|
|
|
* @param \Unikorp\KongAdminApi\Document\Plugin $document |
30
|
|
|
* |
31
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
32
|
|
|
*/ |
33
|
1 |
|
public function addPlugin(string $nameOrId, Document $document): ResponseInterface |
34
|
|
|
{ |
35
|
1 |
|
return $this->post(sprintf('/apis/%1$s/plugins/', $nameOrId), $document); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* retrieve plugin |
40
|
|
|
* |
41
|
|
|
* @param string $id |
42
|
|
|
* |
43
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
44
|
|
|
*/ |
45
|
1 |
|
public function retrievePlugin(string $id): ResponseInterface |
46
|
|
|
{ |
47
|
1 |
|
return $this->get(sprintf('/plugins/%1$s', $id)); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* list all plugins |
52
|
|
|
* |
53
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
54
|
|
|
*/ |
55
|
1 |
|
public function listAllPlugins(): ResponseInterface |
56
|
|
|
{ |
57
|
1 |
|
return $this->get('/plugins/'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* list plugins per api |
62
|
|
|
* |
63
|
|
|
* @param string $apiNameOrId |
64
|
|
|
* |
65
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
66
|
|
|
*/ |
67
|
1 |
|
public function listPluginsPerApi(string $apiNameOrId): ResponseInterface |
68
|
|
|
{ |
69
|
1 |
|
return $this->get(sprintf('/apis/%1$s/plugins/', $apiNameOrId)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* update plugin |
74
|
|
|
* |
75
|
|
|
* @param string $apiNameOrId |
76
|
|
|
* @param string $id |
77
|
|
|
* @param \Unikorp\KongAdminApi\Document\Plugin $document |
78
|
|
|
* |
79
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
80
|
|
|
*/ |
81
|
1 |
|
public function updatePlugin(string $apiNameOrId, string $id, Document $document): ResponseInterface |
82
|
|
|
{ |
83
|
1 |
|
return $this->patch(sprintf('/apis/%1$s/plugins/%2$s', $apiNameOrId, $id), $document); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* update or add plugin |
88
|
|
|
* |
89
|
|
|
* @param string $apiNameOrId |
90
|
|
|
* @param \Unikorp\KongAdminApi\Document\Plugin $document |
91
|
|
|
* |
92
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
93
|
|
|
*/ |
94
|
1 |
|
public function updateOrAddPlugin(string $apiNameOrId, Document $document): ResponseInterface |
95
|
|
|
{ |
96
|
1 |
|
return $this->put(sprintf('/apis/%1$s/plugins/', $apiNameOrId), $document); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* delete plugin |
101
|
|
|
* |
102
|
|
|
* @param string $apiNameOrId |
103
|
|
|
* @param string $id |
104
|
|
|
* |
105
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
106
|
|
|
*/ |
107
|
1 |
|
public function deletePlugin(string $apiNameOrId, string $id): ResponseInterface |
108
|
|
|
{ |
109
|
1 |
|
return $this->delete(sprintf('/apis/%1$s/plugins/%2$s', $apiNameOrId, $id)); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* retrieve enabled plugin |
114
|
|
|
* |
115
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
116
|
|
|
*/ |
117
|
1 |
|
public function retrieveEnabledPlugin(): ResponseInterface |
118
|
|
|
{ |
119
|
1 |
|
return $this->get('/plugins/enabled'); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* retrieve plugin schema |
124
|
|
|
* |
125
|
|
|
* @param string $pluginName |
126
|
|
|
* |
127
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
128
|
|
|
*/ |
129
|
1 |
|
public function retrievePluginSchema(string $pluginName): ResponseInterface |
130
|
|
|
{ |
131
|
1 |
|
return $this->get(sprintf('/plugins/schema/%1$s', $pluginName)); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|