transip / tipctl
TransIP REST API CLI 客户端
Requires
- php: ^7.2.5|^8.0
- ext-json: *
- symfony/console: ^5.4
- symfony/filesystem: ^5.4
- symfony/finder: ^5.4
- symfony/yaml: ^5.4
- transip/transip-api-php: ^6.48
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan: ^1.5
- rector/rector: ^0.12
- dev-master
- v6.34.1
- 6.34.0
- 6.33.3
- 6.33.2
- 6.33.1
- 6.33.0
- 6.32.0
- 6.31.0
- 6.30.0
- v6.29.3
- v6.29.2
- v6.29.0
- 6.28.0
- v6.27.0
- v6.24.0
- v6.23.1
- v6.23.0
- v6.22.0
- v6.18.0
- v6.17.0
- v6.16.1
- v6.14.0
- v6.12.1
- v6.12.0
- v6.11.0
- v6.10.0
- v6.8.0
- v6.7.1
- v6.7.0
- v6.6.2
- v6.6.1
- v6.6.0
- v6.5.0
- v6.4.0
- v6.3.0
- v6.2.0
- v6.1.1
- v6.1.0
- v6.0.5
- v6.0.4
- v6.0.3
- v6.0.2
- v6.0.1
- v6.0.0
This package is auto-updated.
Last update: 2024-09-20 15:46:17 UTC
README
Tipctl
TransIP Control (tipctl) 是一个工具,可以从终端连接到 TransIP API。它实现了从 TransIP RestAPI 的所有可用资源,并提供命令来从您的 TransIP 账户订购、更新和删除产品。
要求
安装
您可以通过两种方式安装 Tipctl。
下载并安装 PHAR 文件
这可以从我们的最新 GitHub 发布 下载。
一旦文件下载完毕,您必须确保 phar 文件具有正确的权限才能作为可执行文件。
# Go to tipctl.phar cd /path/to/tipctl # Make phar file executable chmod +x ./tipctl.phar # Test if the tipctl is executable ./tipctl.phar --version
请注意,您必须每次都使用 ./
来指示您正在使用当前目录中的 tipctl 可执行文件。这是因为命令行(bash)通过在环境变量 $PATH
描述的位置中查找命令来解释所有命令。如果您想全局使用 tipctl 命令,我们建议使用 composer 安装。
使用 Composer 安装
您可以使用 Composer 安装 Tipctl。运行以下命令
composer global require transip/tipctl
现在 tipctl 二进制文件可用全局后,请确保您的全局 vendor 二进制目录包含在您的环境变量 $PATH
中。您可以使用以下命令获取 vendor 二进制目录
composer global config bin-dir --absolute
现在执行以下命令以查看已安装的 tipctl 版本
tipctl --version
入门
运行用户交互式设置脚本
tipctl setup
您也可以无用户交互地运行设置脚本
tipctl setup --no-interaction --apiUrl='https://api.transip.nl/v6' --loginName='yourUsername' --apiPrivateKey='yourKeyPair' --apiUseWhitelist=true # When using spaces to separate an option from its value, you must escape the beginning of your private key tipctl setup --no-interaction --apiUrl 'https://api.transip.nl/v6' --loginName 'yourUsername' --apiPrivateKey '\-----BEGIN PRIVATE KEY-----...' --apiUseWhitelist=true
使用方法 / 命令
列出所有可用命令
tipctl list
列出您所有的域名
tipctl domain:getall
更新您域名的单个 DNS 记录
# See usage information tipctl domain:dns:updatednsentry -h # Update a DNS record tipctl domain:dns:updatednsentry example.com subdomain 300 A 37.97.254.1
理解如何使用 help 参数
当使用 tipctl 时,您可以使用 -h
参数来获取有关指定命令的信息。
# Passing a help argument to any command # tipctl <anycommand> -h
从上述示例中,help 参数的使用和解释如下
# Example for attach vps command
tipctl bigstorage:attachvps -h
这将输出以下内容
Description:
Attach your big storage to your vps
Usage:
bigstorage:attachvps [options] [--] <BigStorageName> <VpsName>
Arguments:
BigStorageName The name of the big storage
VpsName Name of the vps that the big storage should attach to.
用法示例及其解释
# We look at the following usage example: # bigstorage:attachvps [options] [--] <BigStorageName> <VpsName> # Interpertation of the above tipctl bigstorage:attachvps example-bigstorage3 examples-vps4
演示 / 只读模式
测试模式
测试模式允许您连接到您的 TransIP 账户并执行操作,而不会对您的产品或账户进行任何更改。在测试过程中,所有操作尽可能评估,与生产模式相似。如果任何给定参数不正确,您将看到错误,解释为什么查询失败。
在执行任何命令时,您可以提供一个名为 --test
的参数。这会让我们的 API 知道您执行的命令是测试,您的 TransIP 账户不会进行任何更改。
# Example for all commands # tipctl --test <command> <arguments> # How you should use this tipctl --test vps:order vps-bladevps-x1 debian-9
演示模式
演示模式允许您连接到 TransIP 演示账户,并与之交互,以便您了解如何使用 TransIP 账户使用 Tipctl。
# Example for all commands # tipctl --demo <command> # How this should be used tipctl --demo vps:getall
RestAPI 库
如何实现 PHP 资源调用
由于本项目基于RestAPI PHP库构建,在库的README.md中,我们建议查看这个CLI项目,以了解我们如何在RestAPI库中实现现有资源调用示例。
在哪里找到实现
本项目实现的所有命令都位于src/Command/
目录中。每个类代表一个Tipctl的命令。
每个类都有一个execute方法,其形式如下
protected function execute(InputInterface $input, OutputInterface $output) { $domains = $this->getTransipApi()->domains()->getAll(); $this->output($domains); }
上述代码片段与该库示例等效
$domains = $api->domains()->getAll();
要查看如何检索您的TransIP账户中的所有发票,请查看文件:src/Command/Invoice/GetAll.php
此代码示例应这样解释
/** * Implementation in tipctl */ protected function execute(InputInterface $input, OutputInterface $output) { $page = $input->getArgument(Field::PAGE); $itemsPerPage = $input->getArgument(Field::ITEMS_PER_PAGE); $invoices = $this->getTransipApi()->invoice()->getSelection($page, $itemsPerPage); $this->output($invoices); } /** * How this implementation should be interpreted and used when using the RestAPI library */ $page = 1; $itemsPerPage = 25; $invoices = $api->invoice()->getSelection($page, $itemsPerPage); print_r($invoices);
要查看本项目中的所有实现,可以通过下载Tipctl并列出所有可用命令来查看可用的命令。然后,您可以使用此作为参考点来查找所需的类。