Skip to content

Commit

Permalink
Merge branch 'operatingSystemAction' into 'master'
Browse files Browse the repository at this point in the history
Operating system action

See merge request transip/restapi-cli-client!178
  • Loading branch information
roeldijkstra committed Oct 27, 2023
2 parents 89ebf5c + e26b9ed commit 3817b12
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

6.33.0
-----
* Added ability to fetch Action from Operating Install

6.32.0
-----
* Added block storage commands. Deprecated big storage methods.
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 29 additions & 5 deletions src/Command/Vps/OperatingSystem/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace Transip\Api\CLI\Command\Vps\OperatingSystem;

use Transip\Api\CLI\Command\Field;
use Transip\Api\CLI\Command\AbstractCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Transip\Api\CLI\Command\AbstractCommand;
use Transip\Api\CLI\Command\Field;

class Install extends AbstractCommand
{
Expand All @@ -21,7 +23,8 @@ protected function configure(): void
->addArgument(Field::VPS_USERNAME, InputArgument::OPTIONAL, Field::VPS_USERNAME__DESC . Field::OPTIONAL)
->addArgument(Field::VPS_SSH_KEYS, InputArgument::OPTIONAL, Field::VPS_SSH_KEYS__DESC . Field::OPTIONAL)
->addArgument(Field::VPS_BASE64INSTALLTEXT, InputArgument::OPTIONAL, Field::VPS_BASE64INSTALLTEXT__DESC . Field::OPTIONAL)
->addArgument(Field::LICENSE_NAMES, InputArgument::OPTIONAL, Field::LICENSE_NAMES__DESC . Field::OPTIONAL, '');
->addArgument(Field::LICENSE_NAMES, InputArgument::OPTIONAL, Field::LICENSE_NAMES__DESC . Field::OPTIONAL, '')
->addOption(Field::ACTION_WAIT, 'w', InputOption::VALUE_NONE, Field::ACTION_WAIT_DESC);
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand All @@ -33,12 +36,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$username = $input->getArgument(Field::VPS_USERNAME) ?? '';
$sshKeys = $input->getArgument(Field::VPS_SSH_KEYS);
$base64InstallText = $input->getArgument(Field::VPS_BASE64INSTALLTEXT) ?? '';
$licenseNames = $input->getArgument(Field::LICENSE_NAMES);
$licenseNames = $input->getArgument(Field::LICENSE_NAMES);
$waitForAction = $input->getOption(Field::ACTION_WAIT);

$sshKeys = (strlen($sshKeys) > 1) ? explode(',', $sshKeys) : [];
$licenseNames = (strlen($licenseNames) > 1) ? explode(',', $licenseNames) : [];

$this->getTransipApi()->vpsOperatingSystems()->install(
$response = $this->getTransipApi()->vpsOperatingSystems()->install(
$vpsName,
$operatingSystemName,
$hostname,
Expand All @@ -48,6 +52,26 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$sshKeys,
$licenseNames
);

$action = $this->getTransipApi()->actions()->parseActionFromResponse($response);

if ($action && $waitForAction) {
$app = $this->getApplication();

if (!$app) {
return 0;
}

$command = $app->get('action:pollstatus');

$arguments = [
'actionUuid' => $action->getUuid()
];

$actionInput = new ArrayInput($arguments);
$command->run($actionInput, $output);
}

return 0;
}
}
4 changes: 2 additions & 2 deletions src/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Helper\HelperInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Path;
use Transip\Api\CLI\Command\Field;
use Transip\Api\CLI\Settings\Provider\Json;
use Symfony\Component\Filesystem\Path;

class Settings
{
Expand All @@ -17,7 +17,7 @@ class Settings

public const TRANSIP_API_ENDPOINT = 'https://api.transip.nl/v6';

public const TRANSIP_CLI_VERSION = '6.32.0';
public const TRANSIP_CLI_VERSION = '6.33.0';

/**
* @var string
Expand Down

0 comments on commit 3817b12

Please sign in to comment.