1 | <?php declare(strict_types=1); |
||
16 | class Service extends AbstractService implements IdentityService |
||
17 | { |
||
18 | 5 | public static function factory(ClientInterface $client): self |
|
22 | |||
23 | /** |
||
24 | * Authenticates credentials, giving back a token and a base URL for the service. |
||
25 | * |
||
26 | * @param array $options {@see \OpenStack\Identity\v3\Api::postTokens} |
||
27 | * |
||
28 | * @return array Returns a {@see Models\Token} as the first element, a string base URL as the second |
||
29 | */ |
||
30 | 6 | public function authenticate(array $options): array |
|
56 | 8 | ||
57 | /** |
||
58 | 8 | * Generates authentication token from cached token using `$token->export()` |
|
59 | * |
||
60 | * @param array $cachedToken {@see \OpenStack\Identity\v3\Models\Token::export} |
||
61 | * |
||
62 | * @return Models\Token |
||
63 | * |
||
64 | */ |
||
65 | public function generateTokenFromCache(array $cachedToken): Models\Token |
||
69 | 1 | ||
70 | /** |
||
71 | 1 | * Generates a new authentication token |
|
72 | * |
||
73 | * @param array $options {@see \OpenStack\Identity\v3\Api::postTokens} |
||
74 | * |
||
75 | * @return Models\Token |
||
76 | */ |
||
77 | public function generateToken(array $options): Models\Token |
||
81 | 2 | ||
82 | /** |
||
83 | * Retrieves a token object and populates its unique identifier object. This operation will not perform a GET or |
||
84 | 2 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
85 | 1 | * |
|
86 | 1 | * @param string $id The unique ID of the token to retrieve |
|
87 | 1 | * |
|
88 | * @return Models\Token |
||
89 | */ |
||
90 | public function getToken(string $id): Models\Token |
||
94 | |||
95 | /** |
||
96 | * Validates a token, identified by its ID, and returns TRUE if its valid, FALSE if not. |
||
97 | * |
||
98 | * @param string $id The unique ID of the token |
||
99 | 1 | * |
|
100 | 1 | * @return bool |
|
101 | 1 | */ |
|
102 | 1 | public function validateToken(string $id): bool |
|
111 | 1 | ||
112 | /** |
||
113 | 1 | * Revokes a token, identified by its ID. After this operation completes, users will not be able to use this token |
|
114 | * again for authentication. |
||
115 | * |
||
116 | * @param string $id The unique ID of the token |
||
117 | */ |
||
118 | public function revokeToken(string $id) |
||
122 | |||
123 | /** |
||
124 | * Creates a new service according to the provided options. |
||
125 | 1 | * |
|
126 | * @param array $options {@see \OpenStack\Identity\v3\Api::postServices} |
||
127 | 1 | * |
|
128 | * @return Models\Service |
||
129 | */ |
||
130 | public function createService(array $options): Models\Service |
||
134 | |||
135 | /** |
||
136 | * Returns a generator which will yield a collection of service objects. The elements which generators yield can be |
||
137 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
138 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
139 | * |
||
140 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getServices} |
|
141 | * |
||
142 | * @return \Generator |
||
143 | */ |
||
144 | public function listServices(array $options = []): \Generator |
||
148 | |||
149 | /** |
||
150 | 2 | * Retrieves a service object and populates its unique identifier object. This operation will not perform a GET or |
|
151 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
152 | 2 | * |
|
153 | * @param string $id The unique ID of the service |
||
154 | * |
||
155 | * @return Models\Service |
||
156 | */ |
||
157 | public function getService(string $id): Models\Service |
||
161 | |||
162 | /** |
||
163 | 1 | * Creates a new endpoint according to the provided options. |
|
164 | * |
||
165 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postEndpoints} |
|
166 | * |
||
167 | * @return Models\Endpoint |
||
168 | */ |
||
169 | public function createEndpoint(array $options): Models\Endpoint |
||
173 | |||
174 | /** |
||
175 | * Retrieves an endpoint object and populates its unique identifier object. This operation will not perform a GET or |
||
176 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
177 | 1 | * |
|
178 | * @param string $id The unique ID of the service |
||
179 | 1 | * |
|
180 | * @return Models\Endpoint |
||
181 | */ |
||
182 | public function getEndpoint(string $id): Models\Endpoint |
||
186 | |||
187 | /** |
||
188 | * Returns a generator which will yield a collection of endpoint objects. The elements which generators yield can be |
||
189 | 1 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
|
190 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
191 | 1 | * |
|
192 | * @param array $options {@see \OpenStack\Identity\v3\Api::getEndpoints} |
||
193 | * |
||
194 | * @return \Generator |
||
195 | */ |
||
196 | public function listEndpoints(array $options = []): \Generator |
||
200 | |||
201 | /** |
||
202 | * Creates a new domain according to the provided options. |
||
203 | 1 | * |
|
204 | * @param array $options {@see \OpenStack\Identity\v3\Api::postDomains} |
||
205 | 1 | * |
|
206 | * @return Models\Domain |
||
207 | */ |
||
208 | public function createDomain(array $options): Models\Domain |
||
212 | |||
213 | /** |
||
214 | * Returns a generator which will yield a collection of domain objects. The elements which generators yield can be |
||
215 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
216 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
217 | * |
||
218 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getDomains} |
|
219 | * |
||
220 | * @return \Generator |
||
221 | */ |
||
222 | public function listDomains(array $options = []): \Generator |
||
226 | |||
227 | /** |
||
228 | 1 | * Retrieves a domain object and populates its unique identifier object. This operation will not perform a GET or |
|
229 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
230 | 1 | * |
|
231 | * @param string $id The unique ID of the domain |
||
232 | * |
||
233 | * @return Models\Domain |
||
234 | */ |
||
235 | public function getDomain(string $id): Models\Domain |
||
239 | |||
240 | /** |
||
241 | * Creates a new project according to the provided options. |
||
242 | 1 | * |
|
243 | * @param array $options {@see \OpenStack\Identity\v3\Api::postProjects} |
||
244 | 1 | * |
|
245 | * @return Models\Project |
||
246 | */ |
||
247 | public function createProject(array $options): Models\Project |
||
251 | |||
252 | /** |
||
253 | * Returns a generator which will yield a collection of project objects. The elements which generators yield can be |
||
254 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
255 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
256 | * |
||
257 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getProjects} |
|
258 | * |
||
259 | * @return \Generator |
||
260 | */ |
||
261 | public function listProjects(array $options = []): \Generator |
||
265 | |||
266 | /** |
||
267 | 1 | * Retrieves a project object and populates its unique identifier object. This operation will not perform a GET or |
|
268 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
269 | 1 | * |
|
270 | * @param string $id The unique ID of the project |
||
271 | * |
||
272 | * @return Models\Project |
||
273 | */ |
||
274 | public function getProject(string $id): Models\Project |
||
278 | |||
279 | /** |
||
280 | * Creates a new user according to the provided options. |
||
281 | 1 | * |
|
282 | * @param array $options {@see \OpenStack\Identity\v3\Api::postUsers} |
||
283 | 1 | * |
|
284 | * @return Models\User |
||
285 | */ |
||
286 | public function createUser(array $options): Models\User |
||
290 | |||
291 | /** |
||
292 | * Returns a generator which will yield a collection of user objects. The elements which generators yield can be |
||
293 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
294 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
295 | * |
||
296 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getUsers} |
|
297 | * |
||
298 | * @return \Generator |
||
299 | */ |
||
300 | public function listUsers(array $options = []): \Generator |
||
304 | |||
305 | /** |
||
306 | 1 | * Retrieves a user object and populates its unique identifier object. This operation will not perform a GET or |
|
307 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
308 | 1 | * |
|
309 | * @param string $id The unique ID of the user |
||
310 | * |
||
311 | * @return Models\User |
||
312 | */ |
||
313 | public function getUser(string $id): Models\User |
||
317 | |||
318 | /** |
||
319 | * Creates a new group according to the provided options. |
||
320 | 1 | * |
|
321 | * @param array $options {@see \OpenStack\Identity\v3\Api::postGroups} |
||
322 | 1 | * |
|
323 | * @return Models\Group |
||
324 | */ |
||
325 | public function createGroup(array $options): Models\Group |
||
329 | |||
330 | /** |
||
331 | * Returns a generator which will yield a collection of group objects. The elements which generators yield can be |
||
332 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
333 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
334 | * |
||
335 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getGroups} |
|
336 | * |
||
337 | * @return \Generator |
||
338 | */ |
||
339 | public function listGroups(array $options = []): \Generator |
||
343 | |||
344 | /** |
||
345 | 1 | * Retrieves a group object and populates its unique identifier object. This operation will not perform a GET or |
|
346 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
347 | 1 | * |
|
348 | * @param string $id The unique ID of the group |
||
349 | * |
||
350 | * @return Models\Group |
||
351 | */ |
||
352 | public function getGroup($id): Models\Group |
||
356 | |||
357 | 1 | /** |
|
358 | * Creates a new credential according to the provided options. |
||
359 | 1 | * |
|
360 | * @param array $options {@see \OpenStack\Identity\v3\Api::postCredentials} |
||
361 | * |
||
362 | * @return Models\Credential |
||
363 | */ |
||
364 | public function createCredential(array $options): Models\Credential |
||
368 | |||
369 | /** |
||
370 | 1 | * Returns a generator which will yield a collection of credential objects. The elements which generators yield can |
|
371 | * be accessed using a foreach loop. Often the API will not return the full state of the resource in collections; |
||
372 | 1 | * you will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
373 | * |
||
374 | * @return \Generator |
||
375 | */ |
||
376 | public function listCredentials(): \Generator |
||
380 | |||
381 | /** |
||
382 | 1 | * Retrieves a credential object and populates its unique identifier object. This operation will not perform a GET |
|
383 | * or HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
384 | 1 | * |
|
385 | * @param string $id The unique ID of the credential |
||
386 | * |
||
387 | * @return Models\Credential |
||
388 | */ |
||
389 | public function getCredential(string $id): Models\Credential |
||
393 | |||
394 | /** |
||
395 | * Creates a new role according to the provided options. |
||
396 | 1 | * |
|
397 | * @param array $options {@see \OpenStack\Identity\v3\Api::postRoles} |
||
398 | 1 | * |
|
399 | * @return Models\Role |
||
400 | */ |
||
401 | public function createRole(array $options): Models\Role |
||
405 | |||
406 | /** |
||
407 | * Returns a generator which will yield a collection of role objects. The elements which generators yield can be |
||
408 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
409 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
410 | 1 | * |
|
411 | * @param array $options {@see \OpenStack\Identity\v3\Api::getRoles} |
||
412 | 1 | * |
|
413 | * @return \Generator |
||
414 | */ |
||
415 | public function listRoles(array $options = []): \Generator |
||
419 | |||
420 | /** |
||
421 | * Returns a generator which will yield a collection of role assignment objects. The elements which generators |
||
422 | 1 | * yield can be accessed using a foreach loop. Often the API will not return the full state of the resource in |
|
423 | * collections; you will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
424 | 1 | * |
|
425 | * @param array $options {@see \OpenStack\Identity\v3\Api::getRoleAssignments} |
||
426 | * |
||
427 | * @return \Generator |
||
428 | */ |
||
429 | public function listRoleAssignments(array $options = []): \Generator |
||
433 | |||
434 | /** |
||
435 | * Creates a new policy according to the provided options. |
||
436 | 1 | * |
|
437 | * @param array $options {@see \OpenStack\Identity\v3\Api::postPolicies} |
||
438 | 1 | * |
|
439 | * @return Models\Policy |
||
440 | */ |
||
441 | public function createPolicy(array $options): Models\Policy |
||
445 | |||
446 | /** |
||
447 | * Returns a generator which will yield a collection of policy objects. The elements which generators yield can be |
||
448 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
449 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
450 | * |
||
451 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getPolicies} |
|
452 | * |
||
453 | * @return \Generator |
||
454 | */ |
||
455 | public function listPolicies(array $options = []): \Generator |
||
459 | |||
460 | /** |
||
461 | * Retrieves a policy object and populates its unique identifier object. This operation will not perform a GET or |
||
462 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
463 | * |
||
464 | * @param string $id The unique ID of the policy |
||
465 | * |
||
466 | * @return Models\Policy |
||
467 | */ |
||
468 | public function getPolicy(string $id): Models\Policy |
||
472 | } |
||
473 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: