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