Library and command line to use the Gandi V5 API.
This library is not developed or maintained by Gandi.
Minimum version of PHP is 7.2.5.
To use the Gandi API, you should retrieve an API key from your account, in the security section.
You can store it into several place:
- in a file
.gandi-apikey
in the same directory of thegandi
script - in a file
.gandi-apikey
in your home directory - in any file, if you set the environment variable
GANDI_APIKEY_FILE
with the full path to the file.
Use the gandi
script to execute command.
# show global help and list all commands
./gandi
# a simple command to get the status of Gandi
./gandi status
You should first create a Jelix\GandiApi\Configuration
object, with the API key:
<?php
use Jelix\GandiApi\Configuration;
$configuration = new Configuration('my api key');
Then give this object to all classes that use the Gandi API v5.
Example:
<?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);
- get Gandi Status (no api key is needed)
- list of organizations
- retrieve an organization by name
- LiveDNS: domains list
- LiveDNS: records list
- LiveDNS: create/update/delete a record into a zone
Feel free to help us to implement other API ;-)