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