corbpie / hosthatch-api
HostHatch API 类
dev-master
2023-11-12 11:02 UTC
Requires
- php: ^8.2
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-12 12:46:40 UTC
README
这是一个易于实现和使用的 PHP 类封装,用于 HostHatch VPS API 版本 1 的 HostHatch。
目录
注意:HostHatch API 似乎仍在开发中,尚未最终确定或可靠
0.1 更改
- 初始提交和文件
需求
- PHP 8.2
使用方法
使用 composer 安装
composer require corbpie/hosthatch-api
使用方式
require __DIR__ . '/vendor/autoload.php'; use Corbpie\HostHatchAPI\HostHatch; $hh = new HostHatch();
设置 API 密钥
选项 1
第 9 行 HostHatch.php
const API_KEY = 'XXXX-XXXX-XXXX';
选项 2
当你调用一个新的类时,你可以使用 API 密钥进行初始化
$hh = new HostHatch('PUT-API-KEY-HERE');
列出可用的 HostHatch 服务器以进行部署
$hh->getProducts();
返回 array
获取您当前的服务器
$hh->getServers();
返回 array
获取服务器
int $server_id
$hh->getServer($server_id);
返回 array
获取服务器状态
int $server_id
$hh->getServerStatus($server_id);
返回 array
启动服务器
int $server_id
$hh->bootServer($server_id);
返回 array
关闭服务器
int $server_id
$hh->shutdownServer($server_id);
返回 array
重启服务器
int $server_id
$hh->rebootServer($server_id);
返回 array
升级服务器
int $server_id
array $parameters
$parameters = [ 'product' => 'nvme-8gb', 'upgrade_disk' => false ]; $hh->upgradeServer($server_id, $parameters);
返回 array
取消服务器
int $server_id
array $parameters
$parameters = [ 'reason' => 'No longer need this VPS', 'immediate' => false ]; $hh->cancelServer($server_id, $parameters);
返回 array
部署 / 创建服务器
array $parameters
$parameters = [ 'product' => 'nvme-2gb', 'location' => 'AMS', 'billing' => 'monthly', 'image' => 'ubuntu22', 'hostname' => 'test.com' ]; $hh->deployServer($parameters);
返回 array