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\Document; |
13
|
|
|
|
14
|
|
|
use Unikorp\KongAdminApi\AbstractDocument; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* api document |
18
|
|
|
* |
19
|
|
|
* @author VEBER Arnaud <https://github.com/VEBERArnaud> |
20
|
|
|
*/ |
21
|
|
|
class ApiDocument extends AbstractDocument |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* name |
25
|
|
|
* @var string $name |
26
|
|
|
*/ |
27
|
|
|
protected $name = null; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* hosts |
31
|
|
|
* @var string $hosts |
32
|
|
|
*/ |
33
|
|
|
protected $hosts = null; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* uris |
37
|
|
|
* @var string $uris |
38
|
|
|
*/ |
39
|
|
|
protected $uris = null; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* methods |
43
|
|
|
* @var string $methods |
44
|
|
|
*/ |
45
|
|
|
protected $methods = null; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* upstream url |
49
|
|
|
* @var string $upstreamUrl |
50
|
|
|
*/ |
51
|
|
|
protected $upstreamUrl = null; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* strip uri |
55
|
|
|
* @var bool $stripUri |
56
|
|
|
*/ |
57
|
|
|
protected $stripUri = true; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* preserve host |
61
|
|
|
* @var bool $preserveHost |
62
|
|
|
*/ |
63
|
|
|
protected $preserveHost = false; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* retries |
67
|
|
|
* @var int $retries |
68
|
|
|
*/ |
69
|
|
|
protected $retries = 5; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* upstream connect timeout |
73
|
|
|
* @var int $upstreamConnectTimeout |
74
|
|
|
*/ |
75
|
|
|
protected $upstreamConnectTimeout = 60000; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* upstream send timeout |
79
|
|
|
* @var int $upstreamSendTimeout |
80
|
|
|
*/ |
81
|
|
|
protected $upstreamSendTimeout = 60000; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* upstream read timeout |
85
|
|
|
* @var int $upstreamReadTimeout |
86
|
|
|
*/ |
87
|
|
|
protected $upstreamReadTimeout = 60000; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* https only |
91
|
|
|
* @var bool $httpsOnly |
92
|
|
|
*/ |
93
|
|
|
protected $httpsOnly = false; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* http if terminated |
97
|
|
|
* @var bool $httpIfTerminated |
98
|
|
|
*/ |
99
|
|
|
protected $httpIfTerminated = true; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* set name |
103
|
|
|
* |
104
|
|
|
* @param string $name |
105
|
|
|
* |
106
|
|
|
* @return this |
107
|
|
|
*/ |
108
|
1 |
|
public function setName(string $name): self |
109
|
|
|
{ |
110
|
1 |
|
$this->name = $name; |
111
|
|
|
|
112
|
1 |
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* get name |
117
|
|
|
* |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
1 |
|
public function getName(): string |
121
|
|
|
{ |
122
|
1 |
|
return $this->name; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* set hosts |
127
|
|
|
* |
128
|
|
|
* @param string $hosts |
129
|
|
|
* |
130
|
|
|
* @return this |
131
|
|
|
*/ |
132
|
1 |
|
public function setHosts(string $hosts): self |
133
|
|
|
{ |
134
|
1 |
|
$this->hosts = $hosts; |
135
|
|
|
|
136
|
1 |
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* get hosts |
141
|
|
|
* |
142
|
|
|
* @return string |
143
|
|
|
*/ |
144
|
1 |
|
public function getHosts(): string |
145
|
|
|
{ |
146
|
1 |
|
return $this->hosts; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* set uris |
151
|
|
|
* |
152
|
|
|
* @param string $uris |
153
|
|
|
* |
154
|
|
|
* @return this |
155
|
|
|
*/ |
156
|
1 |
|
public function setUris(string $uris): self |
157
|
|
|
{ |
158
|
1 |
|
$this->uris = $uris; |
159
|
|
|
|
160
|
1 |
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* get uris |
165
|
|
|
* |
166
|
|
|
* @return string |
167
|
|
|
*/ |
168
|
1 |
|
public function getUris(): string |
169
|
|
|
{ |
170
|
1 |
|
return $this->uris; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* set methods |
175
|
|
|
* |
176
|
|
|
* @param string $methods |
177
|
|
|
* |
178
|
|
|
* @return this |
179
|
|
|
*/ |
180
|
1 |
|
public function setMethods(string $methods): self |
181
|
|
|
{ |
182
|
1 |
|
$this->methods = $methods; |
183
|
|
|
|
184
|
1 |
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* get methods |
189
|
|
|
* |
190
|
|
|
* @return string |
191
|
|
|
*/ |
192
|
1 |
|
public function getMethods(): string |
193
|
|
|
{ |
194
|
1 |
|
return $this->methods; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* set upstream url |
199
|
|
|
* |
200
|
|
|
* @param string $upstreamUrl |
201
|
|
|
* |
202
|
|
|
* @return this |
203
|
|
|
*/ |
204
|
1 |
|
public function setUpstreamUrl(string $upstreamUrl): self |
205
|
|
|
{ |
206
|
1 |
|
$this->upstreamUrl = $upstreamUrl; |
207
|
|
|
|
208
|
1 |
|
return $this; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* get upstream url |
213
|
|
|
* |
214
|
|
|
* @return string |
215
|
|
|
*/ |
216
|
1 |
|
public function getUpstreamUrl(): string |
217
|
|
|
{ |
218
|
1 |
|
return $this->upstreamUrl; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* set strip uri |
223
|
|
|
* |
224
|
|
|
* @param bool $stripUri |
225
|
|
|
* |
226
|
|
|
* @return this |
227
|
|
|
*/ |
228
|
1 |
|
public function setStripUri(bool $stripUri): self |
229
|
|
|
{ |
230
|
1 |
|
$this->stripUri = $stripUri; |
231
|
|
|
|
232
|
1 |
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* get strip uri |
237
|
|
|
* |
238
|
|
|
* @return bool |
239
|
|
|
*/ |
240
|
1 |
|
public function getStripUri(): bool |
241
|
|
|
{ |
242
|
1 |
|
return $this->stripUri; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* set preserve host |
247
|
|
|
* |
248
|
|
|
* @param bool $preserveHost |
249
|
|
|
* |
250
|
|
|
* @return this |
251
|
|
|
*/ |
252
|
1 |
|
public function setPreserveHost(bool $preserveHost): self |
253
|
|
|
{ |
254
|
1 |
|
$this->preserveHost = $preserveHost; |
255
|
|
|
|
256
|
1 |
|
return $this; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* get preserve host |
261
|
|
|
* |
262
|
|
|
* @return bool |
263
|
|
|
*/ |
264
|
1 |
|
public function getPreserveHost(): bool |
265
|
|
|
{ |
266
|
1 |
|
return $this->preserveHost; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* set retries |
271
|
|
|
* |
272
|
|
|
* @param int $retries |
273
|
|
|
* |
274
|
|
|
* @return this |
275
|
|
|
*/ |
276
|
1 |
|
public function setRetries(int $retries): self |
277
|
|
|
{ |
278
|
1 |
|
$this->retries = $retries; |
279
|
|
|
|
280
|
1 |
|
return $this; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* get retries |
285
|
|
|
* |
286
|
|
|
* @return int |
287
|
|
|
*/ |
288
|
1 |
|
public function getRetries(): int |
289
|
|
|
{ |
290
|
1 |
|
return $this->retries; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* set upstream connect timeout |
295
|
|
|
* |
296
|
|
|
* @param int $upstreamConnectTimeout |
297
|
|
|
* |
298
|
|
|
* @return this |
299
|
|
|
*/ |
300
|
1 |
|
public function setUpstreamConnectTimeout(int $upstreamConnectTimeout): self |
301
|
|
|
{ |
302
|
1 |
|
$this->upstreamConnectTimeout = $upstreamConnectTimeout; |
303
|
|
|
|
304
|
1 |
|
return $this; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* get upstream connect timeout |
309
|
|
|
* |
310
|
|
|
* @return int |
311
|
|
|
*/ |
312
|
1 |
|
public function getUpstreamConnectTimeout(): int |
313
|
|
|
{ |
314
|
1 |
|
return $this->upstreamConnectTimeout; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* set upstream send timeout |
319
|
|
|
* |
320
|
|
|
* @param int $upstreamSendTimeout |
321
|
|
|
* |
322
|
|
|
* @return this |
323
|
|
|
*/ |
324
|
1 |
|
public function setUpstreamSendTimeout(int $upstreamSendTimeout): self |
325
|
|
|
{ |
326
|
1 |
|
$this->upstreamSendTimeout = $upstreamSendTimeout; |
327
|
|
|
|
328
|
1 |
|
return $this; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* get upstream send timeout |
333
|
|
|
* |
334
|
|
|
* @return int |
335
|
|
|
*/ |
336
|
1 |
|
public function getUpstreamSendTimeout(): int |
337
|
|
|
{ |
338
|
1 |
|
return $this->upstreamSendTimeout; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
/** |
342
|
|
|
* set upstream read timeout |
343
|
|
|
* |
344
|
|
|
* @param int $upstreamReadTimeout |
345
|
|
|
* |
346
|
|
|
* @return this |
347
|
|
|
*/ |
348
|
1 |
|
public function setUpstreamReadTimeout(int $upstreamReadTimeout): self |
349
|
|
|
{ |
350
|
1 |
|
$this->upstreamReadTimeout = $upstreamReadTimeout; |
351
|
|
|
|
352
|
1 |
|
return $this; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* get upstream read timeout |
357
|
|
|
* |
358
|
|
|
* @return int |
359
|
|
|
*/ |
360
|
1 |
|
public function getUpstreamReadTimeout(): int |
361
|
|
|
{ |
362
|
1 |
|
return $this->upstreamReadTimeout; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* set https only |
367
|
|
|
* |
368
|
|
|
* @param bool $httpsOnly |
369
|
|
|
* |
370
|
|
|
* @return this |
371
|
|
|
*/ |
372
|
1 |
|
public function setHttpsOnly(bool $httpsOnly): self |
373
|
|
|
{ |
374
|
1 |
|
$this->httpsOnly = $httpsOnly; |
375
|
|
|
|
376
|
1 |
|
return $this; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* get https only |
381
|
|
|
* |
382
|
|
|
* @return bool |
383
|
|
|
*/ |
384
|
1 |
|
public function getHttpsOnly(): bool |
385
|
|
|
{ |
386
|
1 |
|
return $this->httpsOnly; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* set http if terminated |
391
|
|
|
* |
392
|
|
|
* @param bool $httpIfTerminated |
393
|
|
|
* |
394
|
|
|
* @return this |
395
|
|
|
*/ |
396
|
1 |
|
public function setHttpIfTerminated(bool $httpIfTerminated): self |
397
|
|
|
{ |
398
|
1 |
|
$this->httpIfTerminated = $httpIfTerminated; |
399
|
|
|
|
400
|
1 |
|
return $this; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* get http if terminated |
405
|
|
|
* |
406
|
|
|
* @return bool |
407
|
|
|
*/ |
408
|
1 |
|
public function getHttpIfTerminated(): bool |
409
|
|
|
{ |
410
|
1 |
|
return $this->httpIfTerminated; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* get fields |
415
|
|
|
* |
416
|
|
|
* @return array |
417
|
|
|
*/ |
418
|
2 |
|
protected function getFields(): array |
419
|
|
|
{ |
420
|
|
|
return [ |
421
|
2 |
|
'name', |
422
|
|
|
'hosts', |
423
|
|
|
'uris', |
424
|
|
|
'methods', |
425
|
|
|
'upstreamUrl', |
426
|
|
|
'stripUri', |
427
|
|
|
'preserveHost', |
428
|
|
|
'retries', |
429
|
|
|
'upstreamConnectTimeout', |
430
|
|
|
'upstreamSendTimeout', |
431
|
|
|
'upstreamReadTimeout', |
432
|
|
|
'httpsOnly', |
433
|
|
|
'httpIfTerminated', |
434
|
|
|
]; |
435
|
|
|
} |
436
|
|
|
} |
437
|
|
|
|