Skip to content

Commit

Permalink
Merge branch 'objectstoreTokens' into 'master'
Browse files Browse the repository at this point in the history
Add get assignable users for project to phplib

See merge request transip/restapi-php-library!216
  • Loading branch information
roeldijkstra committed Dec 19, 2022
2 parents 217e006 + 9567476 commit 073267c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
CHANGELOG
=========

6.30.0
----

* Added Assignable Openstack Users Repository

6.29.2
----
* Fixed getEntries in certain conditions on mailLists.
Expand Down
5 changes: 5 additions & 0 deletions src/Repository/AuthRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ private function createSignature(string $privateKey, array $parameters): string

$key = $matches[2];
$key = preg_replace('/\s*/s', '', $key);
if ($key === null) {
throw new RuntimeException(
'The provided private key is invalid'
);
}
$key = chunk_split($key, 64, "\n");

$key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----";
Expand Down
39 changes: 39 additions & 0 deletions src/Repository/OpenStack/Project/AssignableUsersRepository.php
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;
}
}
8 changes: 7 additions & 1 deletion src/TransipAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use Transip\Api\Library\Repository\OpenStack\ProjectRepository as OpenStackProjectRepository;
use Transip\Api\Library\Repository\OpenStack\TokenRepository as OpenStackTokenRepository;
use Transip\Api\Library\Repository\OpenStack\UserRepository as OpenStackUserRepository;
use Transip\Api\Library\Repository\OpenStack\Project\AssignableUsersRepository as OpenStackProjectAssignableUsersRepository;
use Transip\Api\Library\Repository\OpenStack\Project\UserRepository as OpenStackProjectUserRepository;
use Transip\Api\Library\Repository\OperatingSystemFilterRepository;
use Transip\Api\Library\Repository\PrivateNetworkRepository;
Expand Down Expand Up @@ -83,7 +84,7 @@
class TransipAPI
{
public const TRANSIP_API_ENDPOINT = "https://api.transip.nl/v6";
public const TRANSIP_API_LIBRARY_VERSION = "6.29.3";
public const TRANSIP_API_LIBRARY_VERSION = "6.30.0";
public const TRANSIP_API_DEMO_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImN3MiFSbDU2eDNoUnkjelM4YmdOIn0.eyJpc3MiOiJhcGkudHJhbnNpcC5ubCIsImF1ZCI6ImFwaS50cmFuc2lwLm5sIiwianRpIjoiY3cyIVJsNTZ4M2hSeSN6UzhiZ04iLCJpYXQiOjE1ODIyMDE1NTAsIm5iZiI6MTU4MjIwMTU1MCwiZXhwIjoyMTE4NzQ1NTUwLCJjaWQiOiI2MDQ0OSIsInJvIjpmYWxzZSwiZ2siOmZhbHNlLCJrdiI6dHJ1ZX0.fYBWV4O5WPXxGuWG-vcrFWqmRHBm9yp0PHiYh_oAWxWxCaZX2Rf6WJfc13AxEeZ67-lY0TA2kSaOCp0PggBb_MGj73t4cH8gdwDJzANVxkiPL1Saqiw2NgZ3IHASJnisUWNnZp8HnrhLLe5ficvb1D9WOUOItmFC2ZgfGObNhlL2y-AMNLT4X7oNgrNTGm-mespo0jD_qH9dK5_evSzS3K8o03gu6p19jxfsnIh8TIVRvNdluYC2wo4qDl5EW5BEZ8OSuJ121ncOT1oRpzXB0cVZ9e5_UVAEr9X3f26_Eomg52-PjrgcRJ_jPIUYbrlo06KjjX2h0fzMr21ZE023Gw";

/**
Expand Down Expand Up @@ -466,6 +467,11 @@ public function openStackUsers(): OpenStackUserRepository
return new OpenStackUserRepository($this->httpClient);
}

public function openStackAssignableUsers(): OpenStackProjectAssignableUsersRepository
{
return new OpenStackProjectAssignableUsersRepository($this->httpClient);
}

public function openStackTokens(): OpenStackTokenRepository
{
return new OpenStackTokenRepository($this->httpClient);
Expand Down

0 comments on commit 073267c

Please sign in to comment.