1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OpenStack\Common\Api; |
4
|
|
|
|
5
|
|
|
abstract class AbstractParams |
6
|
|
|
{ |
7
|
|
|
// locations |
8
|
|
|
const QUERY = 'query'; |
9
|
|
|
const HEADER = 'header'; |
10
|
|
|
const URL = 'url'; |
11
|
|
|
const JSON = 'json'; |
12
|
|
|
const RAW = 'raw'; |
13
|
|
|
|
14
|
|
|
// types |
15
|
|
|
const STRING_TYPE = "string"; |
16
|
|
|
const BOOL_TYPE = "boolean"; |
17
|
|
|
const OBJECT_TYPE = "object"; |
18
|
|
|
const ARRAY_TYPE = "array"; |
19
|
|
|
const NULL_TYPE = "NULL"; |
20
|
|
|
const INT_TYPE = 'integer'; |
21
|
|
|
|
22
|
|
|
public static function isSupportedLocation($val) |
23
|
|
|
{ |
24
|
|
|
return in_array($val, [self::QUERY, self::HEADER, self::URL, self::JSON, self::RAW]); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function limit() |
28
|
|
|
{ |
29
|
|
|
return [ |
30
|
|
|
'type' => self::INT_TYPE, |
31
|
|
|
'location' => 'query', |
32
|
|
|
'description' => <<<DESC |
33
|
|
|
This will limit the total amount of elements returned in a list up to the number specified. For example, specifying a |
34
|
|
|
limit of 10 will return 10 elements, regardless of the actual count. |
35
|
|
|
DESC |
36
|
|
|
]; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function marker() |
40
|
|
|
{ |
41
|
|
|
return [ |
42
|
|
|
'type' => 'string', |
43
|
|
|
'location' => 'query', |
44
|
|
|
'description' => <<<DESC |
45
|
|
|
Specifying a marker will begin the list from the value specified. Elements will have a particular attribute that |
46
|
|
|
identifies them, such as a name or ID. The marker value will search for an element whose identifying attribute matches |
47
|
|
|
the marker value, and begin the list from there. |
48
|
|
|
DESC |
49
|
|
|
]; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function id($type) |
53
|
|
|
{ |
54
|
|
|
return [ |
55
|
|
|
'description' => sprintf("The unique ID, or identifier, for the %s", $type), |
56
|
|
|
'type' => self::STRING_TYPE, |
57
|
|
|
]; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function name($resource) |
61
|
|
|
{ |
62
|
|
|
return [ |
63
|
|
|
'description' => sprintf("The name of the %s", $resource), |
64
|
|
|
'type' => self::STRING_TYPE, |
65
|
|
|
]; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|