diff --git a/CHANGELOG.md b/CHANGELOG.md index bf004c8..16bed54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ CHANGELOG ========= -6.1.0 [WiP - not yet released] +6.1.0 ----- +* Added SSH Key resource commands +* Added CloudInit installation functionality to order and install VPS commands * Added bigstorage description parameter to order command -* 6.0.5 ----- diff --git a/composer.json b/composer.json index 14aa7cb..9e29fb0 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "symfony/console": "^4.3", "symfony/finder": "^4.3", "symfony/filesystem": "^4.3", - "transip/transip-api-php": "6.0.*", + "transip/transip-api-php": "6.1.*", "symfony/yaml": "^4.3", "webmozart/path-util": "^2.3" }, diff --git a/composer.lock b/composer.lock index f3efbaf..9c002ba 100644 --- a/composer.lock +++ b/composer.lock @@ -4,27 +4,28 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ae9ce6cb5112aef6b1b00264d9ed4c05", + "content-hash": "1cbba6363dbd80cc70348795c7af7ea7", "packages": [ { "name": "guzzlehttp/guzzle", - "version": "6.5.2", + "version": "6.5.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "43ece0e75098b7ecd8d13918293029e555a50f82" + "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82", - "reference": "43ece0e75098b7ecd8d13918293029e555a50f82", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/aab4ebd862aa7d04f01a4b51849d657db56d882e", + "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e", "shasum": "" }, "require": { "ext-json": "*", "guzzlehttp/promises": "^1.0", "guzzlehttp/psr7": "^1.6.1", - "php": ">=5.5" + "php": ">=5.5", + "symfony/polyfill-intl-idn": "^1.11" }, "require-dev": { "ext-curl": "*", @@ -32,7 +33,6 @@ "psr/log": "^1.1" }, "suggest": { - "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, "type": "library", @@ -71,7 +71,7 @@ "rest", "web service" ], - "time": "2019-12-23T11:57:10+00:00" + "time": "2020-04-18T10:38:46+00:00" }, { "name": "guzzlehttp/promises", @@ -342,16 +342,16 @@ }, { "name": "psr/log", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", "shasum": "" }, "require": { @@ -385,7 +385,7 @@ "psr", "psr-3" ], - "time": "2019-11-01T11:05:21+00:00" + "time": "2020-03-23T09:12:05+00:00" }, { "name": "ralouphie/getallheaders", @@ -429,16 +429,16 @@ }, { "name": "symfony/cache", - "version": "v5.0.5", + "version": "v5.0.8", "source": { "type": "git", "url": "https://github.com/symfony/cache.git", - "reference": "c6255e419e8592dab7de6e29b014ae9e8926989a" + "reference": "0c5f5b1882dc82b255a4bdead4ed3c7738cddc04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/c6255e419e8592dab7de6e29b014ae9e8926989a", - "reference": "c6255e419e8592dab7de6e29b014ae9e8926989a", + "url": "https://api.github.com/repos/symfony/cache/zipball/0c5f5b1882dc82b255a4bdead4ed3c7738cddc04", + "reference": "0c5f5b1882dc82b255a4bdead4ed3c7738cddc04", "shasum": "" }, "require": { @@ -504,7 +504,7 @@ "caching", "psr6" ], - "time": "2020-02-24T15:05:31+00:00" + "time": "2020-04-28T17:58:55+00:00" }, { "name": "symfony/cache-contracts", @@ -566,16 +566,16 @@ }, { "name": "symfony/console", - "version": "v4.4.5", + "version": "v4.4.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9" + "reference": "10bb3ee3c97308869d53b3e3d03f6ac23ff985f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", - "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", + "url": "https://api.github.com/repos/symfony/console/zipball/10bb3ee3c97308869d53b3e3d03f6ac23ff985f7", + "reference": "10bb3ee3c97308869d53b3e3d03f6ac23ff985f7", "shasum": "" }, "require": { @@ -638,20 +638,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2020-02-24T13:10:00+00:00" + "time": "2020-03-30T11:41:10+00:00" }, { "name": "symfony/filesystem", - "version": "v4.4.5", + "version": "v4.4.8", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd" + "reference": "a3ebf3bfd8a98a147c010a568add5a8aa4edea0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/266c9540b475f26122b61ef8b23dd9198f5d1cfd", - "reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/a3ebf3bfd8a98a147c010a568add5a8aa4edea0f", + "reference": "a3ebf3bfd8a98a147c010a568add5a8aa4edea0f", "shasum": "" }, "require": { @@ -688,20 +688,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2020-01-21T08:20:44+00:00" + "time": "2020-04-12T14:39:55+00:00" }, { "name": "symfony/finder", - "version": "v4.4.5", + "version": "v4.4.8", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357" + "reference": "5729f943f9854c5781984ed4907bbb817735776b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ea69c129aed9fdeca781d4b77eb20b62cf5d5357", - "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357", + "url": "https://api.github.com/repos/symfony/finder/zipball/5729f943f9854c5781984ed4907bbb817735776b", + "reference": "5729f943f9854c5781984ed4907bbb817735776b", "shasum": "" }, "require": { @@ -737,20 +737,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2020-02-14T07:42:58+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.14.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38" + "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", - "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/4719fa9c18b0464d399f1a63bf624b42b6fa8d14", + "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14", "shasum": "" }, "require": { @@ -762,7 +762,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.14-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -795,20 +795,82 @@ "polyfill", "portable" ], - "time": "2020-01-13T11:15:53+00:00" + "time": "2020-02-27T09:26:54+00:00" + }, + { + "name": "symfony/polyfill-intl-idn", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-idn.git", + "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", + "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-php72": "^1.10" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Idn\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Laurent Bassin", + "email": "laurent@bassin.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "idn", + "intl", + "polyfill", + "portable", + "shim" + ], + "time": "2020-03-09T19:04:49+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.14.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2" + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2", - "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", "shasum": "" }, "require": { @@ -820,7 +882,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.14-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -854,20 +916,75 @@ "portable", "shim" ], - "time": "2020-01-13T11:15:53+00:00" + "time": "2020-03-09T19:04:49+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "37b0976c78b94856543260ce09b460a7bc852747" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", + "reference": "37b0976c78b94856543260ce09b460a7bc852747", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.14.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "5e66a0fa1070bf46bec4bea7962d285108edd675" + "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/5e66a0fa1070bf46bec4bea7962d285108edd675", - "reference": "5e66a0fa1070bf46bec4bea7962d285108edd675", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", + "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", "shasum": "" }, "require": { @@ -876,7 +993,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.14-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -912,7 +1029,7 @@ "portable", "shim" ], - "time": "2020-01-13T11:15:53+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/service-contracts", @@ -974,16 +1091,16 @@ }, { "name": "symfony/var-exporter", - "version": "v5.0.5", + "version": "v5.0.8", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "30779a25c736b4290449eaedefe4196c1d060378" + "reference": "5d18811da9e1ae2bb86b0a97fb2d784e27ffd59f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/30779a25c736b4290449eaedefe4196c1d060378", - "reference": "30779a25c736b4290449eaedefe4196c1d060378", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/5d18811da9e1ae2bb86b0a97fb2d784e27ffd59f", + "reference": "5d18811da9e1ae2bb86b0a97fb2d784e27ffd59f", "shasum": "" }, "require": { @@ -1030,20 +1147,20 @@ "instantiate", "serialize" ], - "time": "2020-02-04T09:47:34+00:00" + "time": "2020-04-15T15:59:10+00:00" }, { "name": "symfony/yaml", - "version": "v4.4.5", + "version": "v4.4.8", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "94d005c176db2080e98825d98e01e8b311a97a88" + "reference": "b385dce1c0e9f839b384af90188638819433e252" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/94d005c176db2080e98825d98e01e8b311a97a88", - "reference": "94d005c176db2080e98825d98e01e8b311a97a88", + "url": "https://api.github.com/repos/symfony/yaml/zipball/b385dce1c0e9f839b384af90188638819433e252", + "reference": "b385dce1c0e9f839b384af90188638819433e252", "shasum": "" }, "require": { @@ -1089,20 +1206,20 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2020-02-03T10:46:43+00:00" + "time": "2020-04-28T17:55:16+00:00" }, { "name": "transip/transip-api-php", - "version": "v6.0.3", + "version": "v6.1.0", "source": { "type": "git", "url": "https://github.com/transip/transip-api-php.git", - "reference": "7cda63222b32c44dfc5201123f41c3041f5fec2d" + "reference": "18f7c6b9cc517e665ff756a88fc61e52b6f4c710" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/transip/transip-api-php/zipball/7cda63222b32c44dfc5201123f41c3041f5fec2d", - "reference": "7cda63222b32c44dfc5201123f41c3041f5fec2d", + "url": "https://api.github.com/repos/transip/transip-api-php/zipball/18f7c6b9cc517e665ff756a88fc61e52b6f4c710", + "reference": "18f7c6b9cc517e665ff756a88fc61e52b6f4c710", "shasum": "" }, "require": { @@ -1110,7 +1227,7 @@ "ext-openssl": "*", "guzzlehttp/guzzle": "^6.3", "php": "^7.2.0", - "symfony/cache": "^5.0" + "symfony/cache": "^3.4|^4.4|^5.0" }, "type": "library", "autoload": { @@ -1129,20 +1246,20 @@ } ], "description": "TransIP Rest API Library", - "time": "2020-03-06T12:48:58+00:00" + "time": "2020-05-01T13:30:32+00:00" }, { "name": "webmozart/assert", - "version": "1.7.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "aed98a490f9a8f78468232db345ab9cf606cf598" + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598", - "reference": "aed98a490f9a8f78468232db345ab9cf606cf598", + "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", "shasum": "" }, "require": { @@ -1150,7 +1267,7 @@ "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "vimeo/psalm": "<3.6.0" + "vimeo/psalm": "<3.9.1" }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^7.5.13" @@ -1177,7 +1294,7 @@ "check", "validate" ], - "time": "2020-02-14T12:15:55+00:00" + "time": "2020-04-18T12:12:48+00:00" }, { "name": "webmozart/path-util", diff --git a/src/Command/Field.php b/src/Command/Field.php index 46f2568..26dcbe9 100644 --- a/src/Command/Field.php +++ b/src/Command/Field.php @@ -132,7 +132,12 @@ class Field public const VPS_BASE64INSTALLTEXT__DESC = 'Base64 encoded preseed / kickstart instructions, when installing unattended'; public const VPS_SET_LOCK = 'SetLock'; public const VPS_SET_LOCK__DESC = 'VPS SetLock `true` or `false`'; - + public const VPS_USERNAME = 'Username'; + public const VPS_USERNAME__DESC = 'The username you will be able to login with when installing with cloudinit flavour'; + public const VPS_INSTALL_FLAVOUR = 'installFlavour'; + public const VPS_INSTALL_FLAVOUR__DESC = 'The type of installation to use, installer, cloudinit or preinstallable'; + public const VPS_SSH_KEYS = 'SshKeys'; + public const VPS_SSH_KEYS__DESC = 'Add a public sshKey use for authentication with username in a cloudinit installation (use comma to seperate multiple keys)'; public const PRIVATENETWORK_NAME = 'PrivateNetworkName'; public const PRIVATENETWORK_NAME__DESC = 'The private network name'; @@ -259,4 +264,11 @@ class Field public const READ_ONLY__DESC = 'Whether the token should be read only (true|false)'; public const TOKEN_END_DATE = 'TokenEndDate'; public const TOKEN_END_DATE__DESC = "Token end date '10 min', '1 day', '1 week', '1 month'"; + + public const SSH_KEY_ID = 'SSHKeyId'; + public const SSH_KEY_ID__DESC = 'SSH key identifier'; + public const SSH_KEY = 'SSHKey'; + public const SSH_KEY__DESC = 'SSH Key'; + public const SSH_KEY_DESCRIPTION = 'Description'; + public const SSH_KEY_DESCRIPTION__DESC = 'SSH key description'; } diff --git a/src/Command/SSHKey/Add.php b/src/Command/SSHKey/Add.php new file mode 100644 index 0000000..8f1a5a8 --- /dev/null +++ b/src/Command/SSHKey/Add.php @@ -0,0 +1,29 @@ +setName('sshkey:add') + ->setDescription('Add a new SSH key') + ->addArgument(Field::SSH_KEY, InputArgument::REQUIRED, Field::SSH_KEY__DESC) + ->addArgument(Field::SSH_KEY_DESCRIPTION, InputArgument::OPTIONAL, Field::SSH_KEY_DESCRIPTION__DESC, '') + ->setHelp(''); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $sshKey = $input->getArgument(Field::SSH_KEY); + $sshKeyDescription = $input->getArgument(Field::SSH_KEY_DESCRIPTION); + + $this->getTransipApi()->sshKey()->create($sshKey, $sshKeyDescription); + } +} diff --git a/src/Command/SSHKey/Delete.php b/src/Command/SSHKey/Delete.php new file mode 100644 index 0000000..4c63477 --- /dev/null +++ b/src/Command/SSHKey/Delete.php @@ -0,0 +1,27 @@ +setName('sshkey:delete') + ->setDescription('Delete an existing SSH key') + ->addArgument(Field::SSH_KEY_ID, InputArgument::REQUIRED, Field::SSH_KEY_ID__DESC) + ->setHelp(''); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $sshKeyId = $input->getArgument(Field::SSH_KEY_ID); + + $this->getTransipApi()->sshKey()->delete($sshKeyId); + } +} diff --git a/src/Command/SSHKey/GetAll.php b/src/Command/SSHKey/GetAll.php new file mode 100644 index 0000000..a949640 --- /dev/null +++ b/src/Command/SSHKey/GetAll.php @@ -0,0 +1,31 @@ +setName('sshkey:getall') + ->setDescription('List all SSH keys in your account') + ->addArgument(Field::PAGE, InputArgument::OPTIONAL, Field::PAGE__DESC . Field::OPTIONAL, 0) + ->addArgument(Field::ITEMS_PER_PAGE, InputArgument::OPTIONAL, Field::ITEMS_PER_PAGE__DESC . Field::OPTIONAL, 0) + ->setHelp('This command supports pagination, using this command you can limit the amount of ssh keys returned by the api call, which might be useful if you expect a lot of response objects and you want to spread that over to multiple requests.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $page = $input->getArgument(Field::PAGE); + $itemsPerPage = $input->getArgument(Field::ITEMS_PER_PAGE); + + $sshKeyList = $this->getTransipApi()->sshKey()->getSelection($page, $itemsPerPage); + + $this->output($sshKeyList); + } +} diff --git a/src/Command/SSHKey/GetById.php b/src/Command/SSHKey/GetById.php new file mode 100644 index 0000000..8f8e517 --- /dev/null +++ b/src/Command/SSHKey/GetById.php @@ -0,0 +1,29 @@ +setName('sshkey:getbyid') + ->setDescription('Request information about an existing SSH key') + ->addArgument(Field::SSH_KEY_ID, InputArgument::REQUIRED, Field::SSH_KEY_ID) + ->setHelp(''); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $sshKeyId = $input->getArgument(Field::SSH_KEY_ID); + + $sshKey = $this->getTransipApi()->sshKey()->getById($sshKeyId); + + $this->output($sshKey); + } +} diff --git a/src/Command/SSHKey/SetDescription.php b/src/Command/SSHKey/SetDescription.php new file mode 100644 index 0000000..449db40 --- /dev/null +++ b/src/Command/SSHKey/SetDescription.php @@ -0,0 +1,29 @@ +setName('sshkey:setdescription') + ->setDescription('Set the description of an existing SSH key') + ->addArgument(Field::SSH_KEY_ID, InputArgument::REQUIRED, Field::SSH_KEY_ID__DESC) + ->addArgument(Field::SSH_KEY_DESCRIPTION, InputArgument::REQUIRED, Field::SSH_KEY_DESCRIPTION__DESC) + ->setHelp(''); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $sshKeyId = $input->getArgument(Field::SSH_KEY_ID); + $sshKeyDescription = $input->getArgument(Field::SSH_KEY_DESCRIPTION); + + $this->getTransipApi()->sshKey()->update($sshKeyId, $sshKeyDescription); + } +} diff --git a/src/Command/Vps/OperatingSystem/Install.php b/src/Command/Vps/OperatingSystem/Install.php index 65af0a3..c92c141 100644 --- a/src/Command/Vps/OperatingSystem/Install.php +++ b/src/Command/Vps/OperatingSystem/Install.php @@ -16,7 +16,10 @@ protected function configure(): void ->setDescription('Install an operating system on a VPS') ->addArgument(Field::VPS_NAME, InputArgument::REQUIRED, Field::VPS_NAME) ->addArgument(Field::VPS_OS_NAME, InputArgument::REQUIRED, Field::VPS_OS_NAME__DESC) + ->addArgument(Field::VPS_INSTALL_FLAVOUR, InputArgument::OPTIONAL, Field::VPS_INSTALL_FLAVOUR__DESC . Field::OPTIONAL) ->addArgument(Field::VPS_HOSTNAME, InputArgument::OPTIONAL, Field::VPS_HOSTNAME__DESC . Field::OPTIONAL) + ->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); } @@ -24,14 +27,22 @@ protected function execute(InputInterface $input, OutputInterface $output) { $vpsName = $input->getArgument(Field::VPS_NAME); $operatingSystemName = $input->getArgument(Field::VPS_OS_NAME); + $installFlavour = $input->getArgument(Field::VPS_INSTALL_FLAVOUR) ?? ''; $hostname = $input->getArgument(Field::VPS_HOSTNAME) ?? ''; + $username = $input->getArgument(Field::VPS_USERNAME) ?? ''; + $sshKeys = $input->getArgument(Field::VPS_SSH_KEYS); $base64InstallText = $input->getArgument(Field::VPS_BASE64INSTALLTEXT) ?? ''; + $sshKeys = (strlen($sshKeys) > 1) ? explode(',', $sshKeys) : []; + $this->getTransipApi()->vpsOperatingSystems()->install( $vpsName, $operatingSystemName, $hostname, - $base64InstallText + $base64InstallText, + $installFlavour, + $username, + $sshKeys ); } } diff --git a/src/Command/Vps/Order.php b/src/Command/Vps/Order.php index 596bfb6..386aa58 100644 --- a/src/Command/Vps/Order.php +++ b/src/Command/Vps/Order.php @@ -14,25 +14,34 @@ protected function configure(): void { $this->setName('vps:order') ->setDescription('Order a new VPS') - ->setHelp('Order a Vps with this command. After the order process has been completed (payment will occur at a later stage should direct debit be used) the VPS will automatically be provisioned and deployed. Use Products:getAll to get a list of products') ->addArgument(Field::PRODUCT_NAME, InputArgument::REQUIRED, Field::PRODUCT_NAME__DESC) ->addArgument(Field::VPS_OS_NAME, InputArgument::REQUIRED, Field::VPS_OS_NAME__DESC) ->addArgument(Field::AVAILABILITY_ZONE, InputArgument::OPTIONAL, Field::AVAILABILITY_ZONE__DESC . Field::OPTIONAL, '') ->addArgument(Field::VPS_ADDONS, InputArgument::OPTIONAL, Field::VPS_ADDONS__DESC . Field::OPTIONAL, '') + ->addArgument(Field::VPS_INSTALL_FLAVOUR, InputArgument::OPTIONAL, Field::VPS_INSTALL_FLAVOUR__DESC) + ->addArgument(Field::VPS_USERNAME, InputArgument::OPTIONAL, Field::VPS_USERNAME__DESC . Field::OPTIONAL, '') ->addArgument(Field::VPS_HOSTNAME, InputArgument::OPTIONAL, Field::VPS_HOSTNAME__DESC . Field::OPTIONAL, '') - ->addArgument(Field::VPS_DESCRIPTION, InputArgument::OPTIONAL, Field::VPS_DESCRIPTION__DESC . Field::OPTIONAL, ''); + ->addArgument(Field::VPS_DESCRIPTION, InputArgument::OPTIONAL, Field::VPS_DESCRIPTION__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, '') + ->setHelp('Order a Vps with this command. After the order process has been completed (payment will occur at a later stage should direct debit be used) the VPS will automatically be provisioned and deployed. Use Products:getAll to get a list of products'); } protected function execute(InputInterface $input, OutputInterface $output) { - $productName = $input->getArgument(Field::PRODUCT_NAME); - $operatingSystem = $input->getArgument(Field::VPS_OS_NAME); - $addons = $input->getArgument(Field::VPS_ADDONS); - $hostname = $input->getArgument(Field::VPS_HOSTNAME); - $availabilityZone = $input->getArgument(Field::AVAILABILITY_ZONE); - $description = $input->getArgument(Field::VPS_DESCRIPTION); + $productName = $input->getArgument(Field::PRODUCT_NAME); + $operatingSystem = $input->getArgument(Field::VPS_OS_NAME); + $addons = $input->getArgument(Field::VPS_ADDONS); + $hostname = $input->getArgument(Field::VPS_HOSTNAME); + $availabilityZone = $input->getArgument(Field::AVAILABILITY_ZONE); + $description = $input->getArgument(Field::VPS_DESCRIPTION); + $installFlavour = $input->getArgument(Field::VPS_INSTALL_FLAVOUR); + $username = $input->getArgument(Field::VPS_USERNAME); + $sshKeys = $input->getArgument(Field::VPS_SSH_KEYS); + $base64InstallText = $input->getArgument(Field::VPS_BASE64INSTALLTEXT); - $addons = (strlen($addons) > 1) ? explode(',', $addons) : []; + $addons = (strlen($addons) > 1) ? explode(',', $addons) : []; + $sshKeys = (strlen($sshKeys) > 1) ? explode(',', $sshKeys) : []; $this->getTransipApi()->vps()->order( $productName, @@ -40,7 +49,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $addons, $hostname, $availabilityZone, - $description + $description, + $base64InstallText, + $installFlavour, + $username, + $sshKeys ); } } diff --git a/src/Command/Vps/OrderMultiple.php b/src/Command/Vps/OrderMultiple.php index 163e6b1..adb19c8 100644 --- a/src/Command/Vps/OrderMultiple.php +++ b/src/Command/Vps/OrderMultiple.php @@ -14,39 +14,51 @@ protected function configure(): void { $this->setName('vps:ordermultiple') ->setDescription('Order multiple new VPSs') - ->setHelp('Order multiple VPSs with this command. After the order process has been completed (payment will occur at a later stage should direct debit be used) the VPS will automatically be provisioned and deployed. Use Products:getAll to get a list of products') ->addArgument(Field::VPS_MULTIPLE_COUNT, InputArgument::REQUIRED, Field::VPS_MULTIPLE_COUNT__DESC) ->addArgument(Field::PRODUCT_NAME, InputArgument::REQUIRED, Field::PRODUCT_NAME__DESC) ->addArgument(Field::VPS_OS_NAME, InputArgument::REQUIRED, Field::VPS_OS_NAME__DESC) + ->addArgument(Field::AVAILABILITY_ZONE, InputArgument::OPTIONAL, Field::AVAILABILITY_ZONE__DESC . Field::OPTIONAL, '') ->addArgument(Field::VPS_ADDONS, InputArgument::OPTIONAL, Field::VPS_ADDONS__DESC . Field::OPTIONAL, '') + ->addArgument(Field::VPS_INSTALL_FLAVOUR, InputArgument::OPTIONAL, Field::VPS_INSTALL_FLAVOUR__DESC) + ->addArgument(Field::VPS_USERNAME, InputArgument::OPTIONAL, Field::VPS_USERNAME__DESC . Field::OPTIONAL, '') ->addArgument(Field::VPS_HOSTNAME, InputArgument::OPTIONAL, Field::VPS_HOSTNAME__DESC . Field::OPTIONAL, '') - ->addArgument(Field::AVAILABILITY_ZONE, InputArgument::OPTIONAL, Field::AVAILABILITY_ZONE__DESC . Field::OPTIONAL, '') - ->addArgument(Field::VPS_DESCRIPTION, InputArgument::OPTIONAL, Field::VPS_DESCRIPTION__DESC . Field::OPTIONAL, ''); + ->addArgument(Field::VPS_DESCRIPTION, InputArgument::OPTIONAL, Field::VPS_DESCRIPTION__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, '') + ->setHelp('Order multiple VPSs with this command. After the order process has been completed (payment will occur at a later stage should direct debit be used) the VPS will automatically be provisioned and deployed. Use Products:getAll to get a list of products'); } protected function execute(InputInterface $input, OutputInterface $output) { - $count = $input->getArgument(Field::VPS_MULTIPLE_COUNT); - $productName = $input->getArgument(Field::PRODUCT_NAME); - $operatingSystem = $input->getArgument(Field::VPS_OS_NAME); - $addons = $input->getArgument(Field::VPS_ADDONS); - $hostname = $input->getArgument(Field::VPS_HOSTNAME); - $availabilityZone = $input->getArgument(Field::AVAILABILITY_ZONE); - $description = $input->getArgument(Field::VPS_DESCRIPTION); + $count = $input->getArgument(Field::VPS_MULTIPLE_COUNT); + $productName = $input->getArgument(Field::PRODUCT_NAME); + $operatingSystem = $input->getArgument(Field::VPS_OS_NAME); + $addons = $input->getArgument(Field::VPS_ADDONS); + $hostname = $input->getArgument(Field::VPS_HOSTNAME); + $availabilityZone = $input->getArgument(Field::AVAILABILITY_ZONE); + $description = $input->getArgument(Field::VPS_DESCRIPTION); + $installFlavour = $input->getArgument(Field::VPS_INSTALL_FLAVOUR); + $username = $input->getArgument(Field::VPS_USERNAME); + $sshKeys = $input->getArgument(Field::VPS_SSH_KEYS); + $base64InstallText = $input->getArgument(Field::VPS_BASE64INSTALLTEXT); - $addons = (strlen($addons) > 1) ? explode(',', $addons) : []; + $addons = (strlen($addons) > 1) ? explode(',', $addons) : []; + $sshKeys = (strlen($sshKeys) > 1) ? explode(',', $sshKeys) : []; $vpss = []; - for ($i=0; $i < $count; $i++) { + for ($i = 0; $i < $count; $i++) { $vpss[] = [ - "productName" => $productName, - "operatingSystem" => $operatingSystem, - "addons" => $addons, - "hostname" => $hostname, - "availabilityZone" => $availabilityZone, - "description" => $description - + "productName" => $productName, + "operatingSystem" => $operatingSystem, + "addons" => $addons, + "hostname" => $hostname, + "availabilityZone" => $availabilityZone, + "description" => $description, + "installFlavour" => $installFlavour, + "username" => $username, + "sshKeys" => $sshKeys, + "base64InstallText" => $base64InstallText, ]; }