-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'objectstoreTokens' into 'master'
Add get assignable users for project to phplib See merge request transip/restapi-php-library!216
- Loading branch information
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Repository/OpenStack/Project/AssignableUsersRepository.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Transip\Api\Library\Repository\OpenStack\Project; | ||
|
||
use Transip\Api\Library\Entity\OpenStackUser; | ||
use Transip\Api\Library\Repository\ApiRepository; | ||
use Transip\Api\Library\Repository\OpenStack\ProjectRepository; | ||
|
||
class AssignableUsersRepository extends ApiRepository | ||
{ | ||
public const RESOURCE_NAME = 'assignable-users'; | ||
|
||
public const RESOURCE_PARAMETER_PLURAL = 'assignable-users'; | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getRepositoryResourceNames(): array | ||
{ | ||
return [ProjectRepository::RESOURCE_NAME, self::RESOURCE_NAME]; | ||
} | ||
|
||
/** | ||
* @param string $projectId | ||
* @return OpenStackUser[] | ||
*/ | ||
public function getByProjectId(string $projectId): array | ||
{ | ||
$users = []; | ||
$response = $this->httpClient->get($this->getResourceUrl($projectId)); | ||
$usersArray = $this->getParameterFromResponse($response, self::RESOURCE_PARAMETER_PLURAL); | ||
|
||
foreach ($usersArray as $userArray) { | ||
$users[] = new OpenStackUser($userArray); | ||
} | ||
|
||
return $users; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters