jelix / gandi-v5
使用 Gandi API V5 的库和命令行脚本
v1.0.0
2023-11-15 14:38 UTC
Requires
- php: ^7.2.5 || ^8.0
- guzzlehttp/guzzle: ^7.8.0
- symfony/console: ^4.4.0 || ^5.2.8 || ^6.3.8
This package is auto-updated.
Last update: 2024-09-15 16:25:01 UTC
README
用于使用 Gandi V5 API 的库和命令行。
此库不是由 Gandi 开发或维护的。
使用 CLI 命令
要求
PHP 的最小版本是 7.2.5。
API 密钥
要使用 Gandi API,您应从您的账户安全部分获取 API 密钥 这里。
您可以将它存储在以下位置
- 在
gandi
脚本所在目录中的.gandi-apikey
文件中 - 在您的家目录中的
.gandi-apikey
文件中 - 在任何文件中,如果您设置环境变量
GANDI_APIKEY_FILE
为文件的完整路径。
用法
使用 gandi
脚本来执行命令。
# show global help and list all commands
./gandi
# a simple command to get the status of Gandi
./gandi status
在您的代码中使用库
您首先应该创建一个 Jelix\GandiApi\Configuration
对象,并传入 API 密钥
<?php use Jelix\GandiApi\Configuration; $configuration = new Configuration('my api key');
然后将此对象提供给所有使用 Gandi API v5 的类。
示例
<?php // List of organizations use Jelix\GandiApi\ApiV5\Organizations; $organizations = new Organizations($configuration); $list = $organizations->getList(); foreach($list as $organization) { echo $organization->getName() . ", " . $organization->getType(). ", ".$organization->getId() . "\n" ; } // Create a zone Record use Jelix\GandiApi\ApiV5\LiveDns\ZoneRecord; $apiLiveDns = new \Jelix\GandiApi\ApiV5\LiveDns($configuration); $record = new ZoneRecord( 'myrecordname', // name 'A', // type ['127.0.0.1'], // values 10800 // ttl ); $message = $apiLiveDns->createRecord('my.domain', $record);
支持的 API
- 获取 Gandi 状态(无需 API 密钥)
- 组织列表
- 按名称检索组织
- LiveDNS:域名列表
- LiveDNS:记录列表
- LiveDNS:在区域中创建/更新/删除记录
请随时帮助我们实现其他 API ;-)