Skip to content

Commit

Permalink
Merge branch 'acronis-upgrade-downgrade' into 'master'
Browse files Browse the repository at this point in the history
Add upgrade/downgrade acronis methods

See merge request transip/restapi-php-library!279
  • Loading branch information
Jordi Donadeu committed Jun 25, 2024
2 parents 8220309 + a7dca7c commit 04400bd
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 6 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CHANGELOG
=========
=======
6.51.2

6.51.4
---
* Add acronisTenantId field to operating system install
* Upgrade/Downgrade acronis products

6.51.3
---
Expand Down
35 changes: 35 additions & 0 deletions src/Repository/Acronis/Tenant/AddonsRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Transip\Api\Library\Repository\Acronis\Tenant;

use Psr\Http\Message\ResponseInterface;
use Transip\Api\Library\Repository\Acronis\TenantRepository;
use Transip\Api\Library\Repository\ApiRepository;

class AddonsRepository extends ApiRepository
{
public const RESOURCE_NAME = 'addons';

/**
* @return string[]
*/
protected function getRepositoryResourceNames(): array
{
return [TenantRepository::RESOURCE_NAME, self::RESOURCE_NAME];
}

/**
* @param string $tenantUuid
* @param array<string> $addons
* @return ResponseInterface
*/
public function order(string $tenantUuid, array $addons): ResponseInterface
{
return $this->httpClient->post($this->getResourceUrl($tenantUuid), ['addons' => $addons]);
}

public function cancel(string $tenantUuid, string $addonName): void
{
$this->httpClient->delete($this->getResourceUrl($tenantUuid, $addonName), []);
}
}
25 changes: 25 additions & 0 deletions src/Repository/Acronis/Tenant/DowngradesRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Transip\Api\Library\Repository\Acronis\Tenant;

use Psr\Http\Message\ResponseInterface;
use Transip\Api\Library\Repository\Acronis\TenantRepository;
use Transip\Api\Library\Repository\ApiRepository;

class DowngradesRepository extends ApiRepository
{
public const RESOURCE_NAME = 'downgrades';

/**
* @return string[]
*/
protected function getRepositoryResourceNames(): array
{
return [TenantRepository::RESOURCE_NAME, self::RESOURCE_NAME];
}

public function downgrade(string $tenantUuid, string $productName): ResponseInterface
{
return $this->httpClient->put($this->getResourceUrl($tenantUuid), ['productName' => $productName]);
}
}
25 changes: 25 additions & 0 deletions src/Repository/Acronis/Tenant/UpgradesRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Transip\Api\Library\Repository\Acronis\Tenant;

use Psr\Http\Message\ResponseInterface;
use Transip\Api\Library\Repository\Acronis\TenantRepository;
use Transip\Api\Library\Repository\ApiRepository;

class UpgradesRepository extends ApiRepository
{
public const RESOURCE_NAME = 'upgrades';

/**
* @return string[]
*/
protected function getRepositoryResourceNames(): array
{
return [TenantRepository::RESOURCE_NAME, self::RESOURCE_NAME];
}

public function upgrade(string $tenantUuid, string $productName): ResponseInterface
{
return $this->httpClient->put($this->getResourceUrl($tenantUuid), ['productName' => $productName]);
}
}
9 changes: 7 additions & 2 deletions src/Repository/Acronis/TenantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ protected function getRepositoryResourceNames(): array
return [self::RESOURCE_NAME];
}

public function order(string $productName): ResponseInterface
/**
* @param string $productName
* @param array<string> $addons
* @return ResponseInterface
*/
public function order(string $productName, array $addons = []): ResponseInterface
{
return $this->httpClient->post($this->getResourceUrl(), ['productName' => $productName]);
return $this->httpClient->post($this->getResourceUrl(), ['productName' => $productName, 'addons' => $addons]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/TransipAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
class TransipAPI
{
public const TRANSIP_API_ENDPOINT = "https://api.transip.nl/v6";
public const TRANSIP_API_LIBRARY_VERSION = "6.51.3";
public const TRANSIP_API_LIBRARY_VERSION = "6.51.4";
public const TRANSIP_API_DEMO_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImN3MiFSbDU2eDNoUnkjelM4YmdOIn0.eyJpc3MiOiJhcGkudHJhbnNpcC5ubCIsImF1ZCI6ImFwaS50cmFuc2lwLm5sIiwianRpIjoiY3cyIVJsNTZ4M2hSeSN6UzhiZ04iLCJpYXQiOjE1ODIyMDE1NTAsIm5iZiI6MTU4MjIwMTU1MCwiZXhwIjoyMTE4NzQ1NTUwLCJjaWQiOiI2MDQ0OSIsInJvIjpmYWxzZSwiZ2siOmZhbHNlLCJrdiI6dHJ1ZX0.fYBWV4O5WPXxGuWG-vcrFWqmRHBm9yp0PHiYh_oAWxWxCaZX2Rf6WJfc13AxEeZ67-lY0TA2kSaOCp0PggBb_MGj73t4cH8gdwDJzANVxkiPL1Saqiw2NgZ3IHASJnisUWNnZp8HnrhLLe5ficvb1D9WOUOItmFC2ZgfGObNhlL2y-AMNLT4X7oNgrNTGm-mespo0jD_qH9dK5_evSzS3K8o03gu6p19jxfsnIh8TIVRvNdluYC2wo4qDl5EW5BEZ8OSuJ121ncOT1oRpzXB0cVZ9e5_UVAEr9X3f26_Eomg52-PjrgcRJ_jPIUYbrlo06KjjX2h0fzMr21ZE023Gw";

/**
Expand Down

0 comments on commit 04400bd

Please sign in to comment.