1 | <?php |
||
16 | class Forge implements ArrayAccess, Iterator, ResourceContract |
||
17 | { |
||
18 | use AbstractCollection, LazyIterator, LazyArrayAccess; |
||
19 | |||
20 | /** |
||
21 | * API provider. |
||
22 | * |
||
23 | * @var \Laravel\Forge\ApiProvider |
||
24 | */ |
||
25 | protected $api; |
||
26 | |||
27 | /** |
||
28 | * Servers [id => name] map. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $serversMap = []; |
||
33 | |||
34 | /** |
||
35 | * Single servers cache. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $serversCache = []; |
||
40 | |||
41 | /** |
||
42 | * Create new Servers manager instance. |
||
43 | * |
||
44 | * @param \Laravel\Forge\ApiProvider $api |
||
45 | */ |
||
46 | public function __construct(ApiProvider $api) |
||
50 | |||
51 | /** |
||
52 | * Get API provider. |
||
53 | * |
||
54 | * @return \Laravel\Forge\ApiProvider |
||
55 | */ |
||
56 | public function getApi(): ApiProvider |
||
60 | |||
61 | /** |
||
62 | * Get underlying API provider's HTTP client. |
||
63 | * |
||
64 | * @return \GuzzleHttp\ClientInterface |
||
65 | */ |
||
66 | public function getHttpClient(): ClientInterface |
||
70 | |||
71 | /** |
||
72 | * Resource API URL. |
||
73 | * |
||
74 | * @param string $path = '' |
||
75 | * @param bool $withPropagation = true |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | public function apiUrl(string $path = '', bool $withPropagation = true): string |
||
83 | |||
84 | /** |
||
85 | * Resource name. |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | public function name() |
||
93 | |||
94 | /** |
||
95 | * @{inheritdocs} |
||
96 | */ |
||
97 | public function lazyLoad() |
||
116 | |||
117 | /** |
||
118 | * Generate items keys. |
||
119 | */ |
||
120 | public function generateKeys() |
||
124 | |||
125 | /** |
||
126 | * Initialize servers factory. |
||
127 | * |
||
128 | * @return \Laravel\Forge\Servers\Factory |
||
129 | */ |
||
130 | public function create() |
||
134 | |||
135 | /** |
||
136 | * Returns single server. |
||
137 | * |
||
138 | * @param int $serverId |
||
139 | * @param bool $reload (optional) indicates whether the server should be reloaded |
||
140 | * |
||
141 | * @return \Laravel\Forge\Server |
||
142 | */ |
||
143 | public function get(int $serverId, bool $reload = false) |
||
157 | |||
158 | /** |
||
159 | * Get server provider credentials. |
||
160 | * |
||
161 | * @return array |
||
162 | */ |
||
163 | public function credentials(): array |
||
174 | |||
175 | /** |
||
176 | * Get first credential for given provider. |
||
177 | * |
||
178 | * @param string $provider |
||
179 | * |
||
180 | * @return int|null |
||
181 | */ |
||
182 | public function credentialFor(string $provider) |
||
196 | |||
197 | /** |
||
198 | * Load single server from API and save it to memory cache. |
||
199 | * |
||
200 | * @param int $serverId |
||
201 | * |
||
202 | * @throws \Laravel\Forge\Exceptions\Servers\ServerWasNotFoundException |
||
203 | * |
||
204 | * @return \Laravel\Forge\Server |
||
205 | */ |
||
206 | protected function loadSingleServer(int $serverId) |
||
220 | |||
221 | /** |
||
222 | * Sets an optional rate limiting function on the api provider. |
||
223 | * |
||
224 | * @param callable $rateLimiter |
||
225 | */ |
||
226 | public function setRateLimiter(callable $rateLimiter) |
||
230 | } |
||
231 |