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 |
|
57 | |||
58 | 8 | public function generateTokenFromCache(array $cache): Models\Token |
|
62 | |||
63 | /** |
||
64 | * Generates a new authentication token |
||
65 | * |
||
66 | * @param array $options {@see \OpenStack\Identity\v3\Api::postTokens} |
||
67 | * |
||
68 | * @return Models\Token |
||
69 | 1 | */ |
|
70 | public function generateToken(array $options): Models\Token |
||
74 | |||
75 | /** |
||
76 | * Retrieves a token object and populates its unique identifier object. This operation will not perform a GET or |
||
77 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
78 | * |
||
79 | * @param string $id The unique ID of the token to retrieve |
||
80 | * |
||
81 | 2 | * @return Models\Token |
|
82 | */ |
||
83 | public function getToken(string $id): Models\Token |
||
87 | 1 | ||
88 | /** |
||
89 | * Validates a token, identified by its ID, and returns TRUE if its valid, FALSE if not. |
||
90 | * |
||
91 | * @param string $id The unique ID of the token |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function validateToken(string $id): bool |
||
104 | |||
105 | /** |
||
106 | * Revokes a token, identified by its ID. After this operation completes, users will not be able to use this token |
||
107 | * again for authentication. |
||
108 | * |
||
109 | * @param string $id The unique ID of the token |
||
110 | */ |
||
111 | 1 | public function revokeToken(string $id) |
|
115 | |||
116 | /** |
||
117 | * Creates a new service according to the provided options. |
||
118 | * |
||
119 | * @param array $options {@see \OpenStack\Identity\v3\Api::postServices} |
||
120 | * |
||
121 | * @return Models\Service |
||
122 | */ |
||
123 | public function createService(array $options): Models\Service |
||
127 | 1 | ||
128 | /** |
||
129 | * Returns a generator which will yield a collection of service objects. The elements which generators yield can be |
||
130 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
131 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
132 | * |
||
133 | * @param array $options {@see \OpenStack\Identity\v3\Api::getServices} |
||
134 | * |
||
135 | * @return \Generator |
||
136 | */ |
||
137 | public function listServices(array $options = []): \Generator |
||
141 | |||
142 | /** |
||
143 | * Retrieves a service object and populates its unique identifier object. This operation will not perform a GET or |
||
144 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
145 | * |
||
146 | * @param string $id The unique ID of the service |
||
147 | * |
||
148 | * @return Models\Service |
||
149 | */ |
||
150 | 2 | public function getService(string $id): Models\Service |
|
154 | |||
155 | /** |
||
156 | * Creates a new endpoint according to the provided options. |
||
157 | * |
||
158 | * @param array $options {@see \OpenStack\Identity\v3\Api::postEndpoints} |
||
159 | * |
||
160 | * @return Models\Endpoint |
||
161 | */ |
||
162 | public function createEndpoint(array $options): Models\Endpoint |
||
166 | |||
167 | /** |
||
168 | * Retrieves an endpoint object and populates its unique identifier object. This operation will not perform a GET or |
||
169 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
170 | * |
||
171 | * @param string $id The unique ID of the service |
||
172 | * |
||
173 | * @return Models\Endpoint |
||
174 | */ |
||
175 | public function getEndpoint(string $id): Models\Endpoint |
||
179 | 1 | ||
180 | /** |
||
181 | * Returns a generator which will yield a collection of endpoint objects. The elements which generators yield can be |
||
182 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
183 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
184 | * |
||
185 | * @param array $options {@see \OpenStack\Identity\v3\Api::getEndpoints} |
||
186 | * |
||
187 | * @return \Generator |
||
188 | */ |
||
189 | 1 | public function listEndpoints(array $options = []): \Generator |
|
193 | |||
194 | /** |
||
195 | * Creates a new domain according to the provided options. |
||
196 | * |
||
197 | * @param array $options {@see \OpenStack\Identity\v3\Api::postDomains} |
||
198 | * |
||
199 | * @return Models\Domain |
||
200 | */ |
||
201 | public function createDomain(array $options): Models\Domain |
||
205 | 1 | ||
206 | /** |
||
207 | * Returns a generator which will yield a collection of domain objects. The elements which generators yield can be |
||
208 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
209 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
210 | * |
||
211 | * @param array $options {@see \OpenStack\Identity\v3\Api::getDomains} |
||
212 | * |
||
213 | * @return \Generator |
||
214 | */ |
||
215 | public function listDomains(array $options = []): \Generator |
||
219 | |||
220 | /** |
||
221 | * Retrieves a domain object and populates its unique identifier object. This operation will not perform a GET or |
||
222 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
223 | * |
||
224 | * @param string $id The unique ID of the domain |
||
225 | * |
||
226 | * @return Models\Domain |
||
227 | */ |
||
228 | 1 | public function getDomain(string $id): Models\Domain |
|
232 | |||
233 | /** |
||
234 | * Creates a new project according to the provided options. |
||
235 | * |
||
236 | * @param array $options {@see \OpenStack\Identity\v3\Api::postProjects} |
||
237 | * |
||
238 | * @return Models\Project |
||
239 | */ |
||
240 | public function createProject(array $options): Models\Project |
||
244 | 1 | ||
245 | /** |
||
246 | * Returns a generator which will yield a collection of project objects. The elements which generators yield can be |
||
247 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
248 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
249 | * |
||
250 | * @param array $options {@see \OpenStack\Identity\v3\Api::getProjects} |
||
251 | * |
||
252 | * @return \Generator |
||
253 | */ |
||
254 | public function listProjects(array $options = []): \Generator |
||
258 | |||
259 | /** |
||
260 | * Retrieves a project object and populates its unique identifier object. This operation will not perform a GET or |
||
261 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
262 | * |
||
263 | * @param string $id The unique ID of the project |
||
264 | * |
||
265 | * @return Models\Project |
||
266 | */ |
||
267 | 1 | public function getProject(string $id): Models\Project |
|
271 | |||
272 | /** |
||
273 | * Creates a new user according to the provided options. |
||
274 | * |
||
275 | * @param array $options {@see \OpenStack\Identity\v3\Api::postUsers} |
||
276 | * |
||
277 | * @return Models\User |
||
278 | */ |
||
279 | public function createUser(array $options): Models\User |
||
283 | 1 | ||
284 | /** |
||
285 | * Returns a generator which will yield a collection of user objects. The elements which generators yield can be |
||
286 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
287 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
288 | * |
||
289 | * @param array $options {@see \OpenStack\Identity\v3\Api::getUsers} |
||
290 | * |
||
291 | * @return \Generator |
||
292 | */ |
||
293 | public function listUsers(array $options = []): \Generator |
||
297 | |||
298 | /** |
||
299 | * Retrieves a user object and populates its unique identifier object. This operation will not perform a GET or |
||
300 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
301 | * |
||
302 | * @param string $id The unique ID of the user |
||
303 | * |
||
304 | * @return Models\User |
||
305 | */ |
||
306 | 1 | public function getUser(string $id): Models\User |
|
310 | |||
311 | /** |
||
312 | * Creates a new group according to the provided options. |
||
313 | * |
||
314 | * @param array $options {@see \OpenStack\Identity\v3\Api::postGroups} |
||
315 | * |
||
316 | * @return Models\Group |
||
317 | */ |
||
318 | public function createGroup(array $options): Models\Group |
||
322 | 1 | ||
323 | /** |
||
324 | * Returns a generator which will yield a collection of group objects. The elements which generators yield can be |
||
325 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
326 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
327 | * |
||
328 | * @param array $options {@see \OpenStack\Identity\v3\Api::getGroups} |
||
329 | * |
||
330 | * @return \Generator |
||
331 | */ |
||
332 | public function listGroups(array $options = []): \Generator |
||
336 | |||
337 | /** |
||
338 | * Retrieves a group object and populates its unique identifier object. This operation will not perform a GET or |
||
339 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
340 | * |
||
341 | * @param string $id The unique ID of the group |
||
342 | * |
||
343 | * @return Models\Group |
||
344 | */ |
||
345 | 1 | public function getGroup($id): Models\Group |
|
349 | |||
350 | /** |
||
351 | * Creates a new credential according to the provided options. |
||
352 | * |
||
353 | * @param array $options {@see \OpenStack\Identity\v3\Api::postCredentials} |
||
354 | * |
||
355 | * @return Models\Credential |
||
356 | */ |
||
357 | 1 | public function createCredential(array $options): Models\Credential |
|
361 | |||
362 | /** |
||
363 | * Returns a generator which will yield a collection of credential objects. The elements which generators yield can |
||
364 | * be accessed using a foreach loop. Often the API will not return the full state of the resource in collections; |
||
365 | * you will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
366 | * |
||
367 | * @return \Generator |
||
368 | */ |
||
369 | public function listCredentials(): \Generator |
||
373 | |||
374 | /** |
||
375 | * Retrieves a credential object and populates its unique identifier object. This operation will not perform a GET |
||
376 | * or HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
377 | * |
||
378 | * @param string $id The unique ID of the credential |
||
379 | * |
||
380 | * @return Models\Credential |
||
381 | */ |
||
382 | 1 | public function getCredential(string $id): Models\Credential |
|
386 | |||
387 | /** |
||
388 | * Creates a new role according to the provided options. |
||
389 | * |
||
390 | * @param array $options {@see \OpenStack\Identity\v3\Api::postRoles} |
||
391 | * |
||
392 | * @return Models\Role |
||
393 | */ |
||
394 | public function createRole(array $options): Models\Role |
||
398 | 1 | ||
399 | /** |
||
400 | * Returns a generator which will yield a collection of role objects. The elements which generators yield can be |
||
401 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
402 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
403 | * |
||
404 | * @param array $options {@see \OpenStack\Identity\v3\Api::getRoles} |
||
405 | * |
||
406 | * @return \Generator |
||
407 | */ |
||
408 | public function listRoles(array $options = []): \Generator |
||
412 | 1 | ||
413 | /** |
||
414 | * Returns a generator which will yield a collection of role assignment objects. The elements which generators |
||
415 | * yield can be accessed using a foreach loop. Often the API will not return the full state of the resource in |
||
416 | * collections; you will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
417 | * |
||
418 | * @param array $options {@see \OpenStack\Identity\v3\Api::getRoleAssignments} |
||
419 | * |
||
420 | * @return \Generator |
||
421 | */ |
||
422 | 1 | public function listRoleAssignments(array $options = []): \Generator |
|
426 | |||
427 | /** |
||
428 | * Creates a new policy according to the provided options. |
||
429 | * |
||
430 | * @param array $options {@see \OpenStack\Identity\v3\Api::postPolicies} |
||
431 | * |
||
432 | * @return Models\Policy |
||
433 | */ |
||
434 | public function createPolicy(array $options): Models\Policy |
||
438 | 1 | ||
439 | /** |
||
440 | * Returns a generator which will yield a collection of policy objects. The elements which generators yield can be |
||
441 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
442 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
443 | * |
||
444 | * @param array $options {@see \OpenStack\Identity\v3\Api::getPolicies} |
||
445 | * |
||
446 | * @return \Generator |
||
447 | */ |
||
448 | public function listPolicies(array $options = []): \Generator |
||
452 | |||
453 | /** |
||
454 | * Retrieves a policy object and populates its unique identifier object. This operation will not perform a GET or |
||
455 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
456 | * |
||
457 | * @param string $id The unique ID of the policy |
||
458 | * |
||
459 | * @return Models\Policy |
||
460 | */ |
||
461 | public function getPolicy(string $id): Models\Policy |
||
465 | } |
||
466 |
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: