-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'block-storage-methods' into 'master'
Block storage methods See merge request transip/restapi-cli-client!177
- Loading branch information
Showing
28 changed files
with
548 additions
and
21 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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,60 @@ | ||
<?php | ||
|
||
namespace Transip\Api\CLI\Command\BlockStorage; | ||
|
||
use Symfony\Component\Console\Exception\ExceptionInterface; | ||
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; | ||
|
||
class AttachVps extends AbstractCommand | ||
{ | ||
protected function configure(): void | ||
{ | ||
$this->setName('blockstorage:attachvps') | ||
->setDescription('Attach your block storage to your vps') | ||
->addArgument(Field::BLOCKSTORAGE_NAME, InputArgument::REQUIRED, Field::BLOCKSTORAGE_NAME__DESC) | ||
->addArgument(Field::VPS_NAME, InputArgument::REQUIRED, 'Name of the vps that the block storage should attach to.') | ||
->addOption(Field::ACTION_WAIT, 'w', InputOption::VALUE_NONE, Field::ACTION_WAIT_DESC) | ||
->setHelp('This command will attach your block storage to your vps.'); | ||
} | ||
|
||
/** | ||
* @throws ExceptionInterface | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$blockStorageName = $input->getArgument(Field::BLOCKSTORAGE_NAME); | ||
$blockStorageVpsName = $input->getArgument(Field::VPS_NAME); | ||
$waitForAction = $input->getOption(Field::ACTION_WAIT); | ||
|
||
$blockStorage = $this->getTransipApi()->blockStorages()->getByName($blockStorageName); | ||
$blockStorage->setVpsName($blockStorageVpsName); | ||
|
||
$response = $this->getTransipApi()->blockStorages()->update($blockStorage); | ||
$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; | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace Transip\Api\CLI\Command\BlockStorage\Backup; | ||
|
||
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 GetByBlockStorageName extends AbstractCommand | ||
{ | ||
protected function configure(): void | ||
{ | ||
$this->setName('blockstorage:backup:getbyblockstoragename') | ||
->setDescription('Get a list of backups for a block storage') | ||
->addArgument(Field::BLOCKSTORAGE_NAME, InputArgument::REQUIRED, Field::BLOCKSTORAGE_NAME__DESC) | ||
->setHelp('This command lists backups for any given block storage.'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$blockStorageName = $input->getArgument(Field::BLOCKSTORAGE_NAME); | ||
$vps = $this->getTransipApi()->blockStorageBackups()->getByBlockStorageName($blockStorageName); | ||
$this->output($vps); | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.