antcool/easy-cloud-pods
最新稳定版本:1.1.2
Composer 安装命令:
composer require antcool/easy-cloud-pods
包简介
PHP SDK for Cloud Pods
README 文档
README
PHP SDK for Cloud Pods.
Overtrue! Respect!
文档链接
安装
$ composer require antcool/easy-cloud-pods -vvv
使用
需开启统一API入口, 查看文档
配置项
$config = [ 'default' => 'production', 'projects' => [ 'production' => [ 'api_gateway' => 'https://<ip_or_domain_of_apigatway>/api/s/', 'project_id' => '****', 'project_name' => null, 'auth_type' => 'password', // ak/sk 'user_name' => '****', 'user_password' => '****', 'key_id' => '****', 'secret' => '****', 'domain' => null, 'domain_name' => null, ], ], /** * 默认使用各 endpoint type 字段作为统一 API 入口请求时的服务类型路径 * 由于每个版本的路径会有不同, 当默认路径错误时, 可通过此配置覆盖 * compute_v2: compute_v2 * image: image/v1 * identity: identity/v3 */ 'endpoint_path' => [ 'image' => 'image/v1', 'identity' => 'identity/v3', ], 'debug' => true, 'runtime_path' => storage_path('cloud-pods'), 'http' => [ 'timeout' => 30, 'verify' => false, ], ];
创建实例
use AntCool\CloudPods\Application; $app = new Application(new Config(\config('cloudpods')); // use other project config $config = $app->getConfig()->useProject('project_name'); /** @var \AntCool\CloudPods\Kernel\Client $client */ $client = $app->getClient();
API 调用示范
\AntCool\CloudPods\Middleware\AccessTokenMiddleware 已经实现对 AuthToken 和 Endpoints 的自动处理
// 查看 Endpoints $client->getEndpoints(); // 获取支持的镜像 $client->withService('image')->getJson('images', ['limit' => 1000, 'details' => true]) // 实际请求 URL: https://<gateway>/api/s/image/v1/images?limit=1000&details=1 // 获取主机规格 $client->withService('compute_v2')->getJson('serverskus', ['limit' => 1000, 'details' => true]); // 创建秘钥对 $client->withService('compute_v2')->postJson('keypairs', [ 'count' => 1, 'keypair' => [ 'description' => 'description', 'name' => 'name', ], ]); // 创建虚拟机 $client->withService('compute_v2')->postJson('servers', $params); // 删除虚拟机 $client->withService('compute_v2')->deleteJson('servers/' . $id, [ 'OverridePendingDelete' => true, 'Purge' => true, 'DeleteSnapshots' => true, 'DeleteEip' => true, 'DeleteDisks' => true, ]); // 获取 monitor 监控服务 unified monitor 的查询接口签名 $app->getUtils()->unifiedMonitorSign($params);
Contributing
You can contribute in one of three ways:
- ...
- ...
License
MIT
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-11