Sessions ID are sensitive information and therefore must be kept secret. If a session ID was to be disclosed a malicious user would be able to execute commands with your credentials during 12 hours.
import sys
import xmlrpclib
proxy = xmlrpclib.ServerProxy("https://api.gandi.net/xmlrpc/")
try:
session = proxy.login("AA1234-GANDI", "mypassword", True)
except xmlrpclib.Fault, e:
print "could not login because: " + e.faultString
sys.exit(67)
<?php
require_once("xmlrpc.inc");
$proxy = new xmlrpc_client("https://api.gandi.net/xmlrpc/");
$msg = new xmlrpcmsg(
"login",
array(new xmlrpcval("AA1234-GANDI"),
new xmlrpcval("mypassword"),
new xmlrpcval(True, "boolean"))
);
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
echo "could not login because: " . $reply->faultString() . "\n";
exit(67);
}
$session = $reply->value();
?>
my $safe_mode = XMLRPC::Data->type('boolean')->value(1);
my $proxy = XMLRPC::Lite->proxy("https://api.gandi.net/xmlrpc/");
my $reply = $proxy->call("login", "AA1234-GANDI", "mypassword", $safe_mode);
my $session = $reply->result();
die "could not login because: " . $reply->faultstring . "\n" unless defined $session;
Sessions ID are sensitive information and therefore must be kept secret. If a session ID was to be disclosed a malicious user would be able to execute commands with your credentials during 12 hours.
try: session = proxy.su(session, "AA4321-GANDI") except xmlrpclib.Fault, e: print "could not su to user AA4321-GANDI because: " + e.faultString sys.exit(67)
<?php
$msg = new xmlrpcmsg(
"su",
array($session, new xmlrpcval("AA4321-GANDI"))
);
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
echo "could not su to user AA4321-GANDI because: " . $reply->faultString() . "\n";
exit(67);
}
$session = $reply->value();
?>
my $reply = $proxy->call("su", $session, "AA4321-GANDI");
my $session = $reply->result();
die "could not su to user AA4321-GANDI because: " . $reply->faultstring . "\n" unless defined $session;
try: proxy.password(session, "mynewpassword") except xmlrpclib.Fault, e: print "could not change the password because: " + e.faultString sys.exit(67)
<?php
$msg = new xmlrpcmsg(
"password",
array($session, new xmlrpcval("mynewpassword"))
);
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
echo "could not change the password because: " . $reply->faultString() . "\n";
exit(67);
}
?>
my $reply = $proxy->call("password", $session, "mynewpassword");
my $result = $reply->result();
die "could not change the password because: " . $reply->faultstring . "\n" unless defined $result;
print "prepaid account currency: %s" % proxy.account_currency(session)
$msg = new xmlrpcmsg("account_currency", array($session));
$reply = $proxy->send($msg);
$val = $reply->value();
$val = $val->scalarval();
print "prepaid account currency: " . $val . "\n";
my $reply = $proxy->call("account_currency", $session);
my $currency = $reply->result();
print "prepaid account currency: " . $currency . "\n";
print "prepaid account balance: %d" % proxy.account_balance(session)
$msg = new xmlrpcmsg("account_balance", array($session));
$reply = $proxy->send($msg);
$val = $reply->value();
$val = $val->scalarval();
print "prepaid account currency: " . $val . "\n";
my $reply = $proxy->call("account_balance", $session);
my $balance = $reply->result();
print "prepaid account balance: " . $balance . "\n";
import pprint try: domains = proxy.domain_list(session) print "domains:" pprint.pprint(domains) except xmlrpclib.Fault, e: print "could not retrieve the list of domains because: %s" % e.faultString
$msg = new xmlrpcmsg("domain_list", array($session));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not retrieve the list of domains because: %s\n", $reply->faultString());
}
else {
$val = php_xmlrpc_decode($reply->value());
print_r($val);
}
my $reply = $proxy->call("domain_list", $session);
my $domains = $reply->result();
unless (defined $domains) {
print "could not retrieve the list of domains because: " . $reply->faultstring . "\n";
}
else {
print Dumper($domains);
}
import pprint domains = ["example.net", "example.org", "example.com"] try: availability = proxy.domain_available(session, domains) print "available domains:" pprint.pprint(availability) except xmlrpclib.Fault, e: print "could not check for availability because: %s" % e.faultString
$domains = array(
new xmlrpcval("example.net"),
new xmlrpcval("example.org"),
new xmlrpcval("example.com")
);
$msg = new xmlrpcmsg("domain_available", array($session, new xmlrpcval($domains, "array")));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not check for availability because: %s\n", $reply->faultString());
}
else {
$val = $reply->value();
$val->structreset();
print "available domains:\n";
while (list($key, $value) = $val->structeach()) {
printf("%s : %s\n", $key, $value->scalarval() ? "True" : "False");
}
}
my $domains = ["example.net", "example.org", "example.com"];
my $reply = $proxy->call("domain_available", $session, $domains);
my $availability = $reply->result();
unless (defined $availability) {
print "could not check for availability because: " . $reply->faultstring . "\n";
}
else {
while (($domain, $available) = each (%$availability)) {
print $domain . " : " . ($available ? "True" : "False") . "\n";
}
}
domain = "example.net" try: opid = proxy.domain_lock(session, domain) print "locking of domain '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not lock domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$msg = new xmlrpcmsg("domain_lock", array($session, new xmlrpcval($domain)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not lock domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("locking of domain '%s' is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.net";
my $reply = $proxy->call("domain_lock", $session, $domain);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not lock domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "locking of domain '%s' is Gandi operation #%d\n", $domain, $opid;
}
domain = "example.net" try: opid = proxy.domain_unlock(session, domain) print "unlocking of domain '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not unlock domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$msg = new xmlrpcmsg("domain_unlock", array($session, new xmlrpcval($domain)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not unlock domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("unlocking of domain '%s' is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.net";
my $reply = $proxy->call("domain_unlock", $session, $domain);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not unlock domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "unlocking of domain '%s' is Gandi operation #%d\n", $domain, $opid;
}
True: The domain cannot be transferred. It must be unlocked first.False: The domain can be transferred.import pprint domain = "example.net" try: info = proxy.domain_info(session, domain) pprint.pprint(info) except xmlrpclib.Fault, e: print "could not get information for domain '%s': %s" % (domain, e.faultString)
$domain = "example.net";
$msg = new xmlrpcmsg("domain_info", array($session, new xmlrpcval($domain)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not get information for domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = php_xmlrpc_decode($reply->value());
print_r($val);
}
my $domain = "example.net";
my $reply = $proxy->call("domain_info", $session, $domain);
my $info = $reply->result();
unless (defined $opid) {
printf "could not get information for domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
print Dumper($info);
}
domain = "example.net" try: opid = proxy.domain_renew(session, domain, 4) print "renewal of '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not renew domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$msg = new xmlrpcmsg("domain_renew", array($session, new xmlrpcval($domain), new xmlrpcval(4, "int")));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not renew domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("renewal of '%s' is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.net";
my $reply = $proxy->call("domain_renew", $session, $domain, 4);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not renew domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "renewal of domain '%s' is Gandi operation #%d\n", $domain, $opid;
}
domain = "example.org" period = 1 owner_handle = "AA1234-GANDI" admin_handle = "BB2345-GANDI" tech_handle = "CC3456-GANDI" billing_handle = "DD4567-GANDI" ns_list = ["ns1.example.net", "ns2.example.net", "ns1.example.com"] try: opid = proxy.domain_create(session, domain, period, owner_handle, admin_handle, tech_handle, billing_handle, ns_list) print "creation of domain '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not create domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.org";
$period = new xmlrpcval(1, "int");
$owner_handle = new xmlrpcval("AA1234-GANDI");
$admin_handle = new xmlrpcval("AA1234-GANDI");
$tech_handle = new xmlrpcval("CC3456-GANDI");
$billing_handle = new xmlrpcval("DD4567-GANDI");
$nameservers = php_xmlrpc_encode(array("ns1.example.net", "ns2.example.net", "ns1.example.com"));
$msg = new xmlrpcmsg("domain_create",
array($session, new xmlrpcval($domain),
$period, $owner_handle,
$admin_handle, $tech_handle,
$billing_handle, $nameservers
)
);
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not create domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("creation of domain '%s' is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.org";
my $period = 1;
my $owner_handle = "AA1234-GANDI";
my $admin_handle = "AA1234-GANDI";
my $tech_handle = "CC3456-GANDI";
my $billing_handle = "DD4567-GANDI";
my $nameservers = ["ns1.example.net", "ns2.example.net", "ns1.example.com"]
my $reply = $proxy->call("domain_create", $session, $domain, $period, $owner_handle, $admin_handle, $tech_handle, $billing_handle, $nameservers);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not create domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "creation of domain '%s' is Gandi operation #%d\n", $domain, $opid;
}
domain = "example.net" try: opid = proxy.domain_restore(session, domain) print "restoration domain '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not restore domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$msg = new xmlrpcmsg("domain_restore", array($session, new xmlrpcval($domain)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not restore domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("restoration of '%s' is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.net";
my $reply = $proxy->call("domain_restore", $session, $domain);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not restore domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "restoration of domain '%s' is Gandi operation #%d\n", $domain, $opid;
}
This function will be available in v1.10
domain = "example.com" try: opid = proxy.domain_del(session, domain) print "deletion of '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not delete domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.com";
$msg = new xmlrpcmsg("domain_del", array($session, new xmlrpcval($domain)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not delete domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("deletion of '%s' is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.com";
my $reply = $proxy->call("domain_delete", $session, $domain);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not delete domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "deletion of domain '%s' is Gandi operation #%d\n", $domain, $opid;
}
domain = "example.net" try: result = proxy.domain_transfer_in_available(session, domain) print "could the domain '%s' be transfered to Gandi: %s" % (domain, result) except xmlrpclib.Fault, e: print "could not check for the transfer feasibility of the domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$msg = new xmlrpcmsg("domain_transfer_in_available", array($session, new xmlrpcval($domain)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not check for the transfer feasibility of the domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("could the domain '%s' be transfered to Gandi: %s\n", $domain, $val ? "True" : "False");
}
my $domain = "example.net";
my $reply = $proxy->call("domain_transfer_in_available", $session, $domain);
my $val = $reply->result();
unless (defined $opid) {
printf "could not check for the transfer feasibility of the domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "could the domain '%s' be transfered to Gandi: %s\n", $domain, $val ? "True" : "False";
}
ns_list = ["ns1.example.net", "ns2.example.net", "ns1.example.com"] try: opid = proxy.domain_transfer_in(session, "example.net", "AA1234-GANDI", "BB2345-GANDI", "BB2345-GANDI", "BB2345-GANDI", ns_list, "G0R7Y568B740DK27") print "transfer of '%s' to Gandi is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not transfer domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$auth_code = new xmlrpcval("G0R7Y568B740DK27");
$owner_handle = new xmlrpcval("AA1234-GANDI");
$admin_handle = new xmlrpcval("BB2345-GANDI");
$tech_handle = new xmlrpcval("BB2345-GANDI");
$billing_handle = new xmlrpcval("BB2345-GANDI");
$nameservers = php_xmlrpc_encode(array("ns1.example.net", "ns2.example.net", "ns1.example.com"));
$msg = new xmlrpcmsg("domain_transfer_in", array($session, new xmlrpcval($domain), $owner_handle, $admin_handle, $tech_handle, $billing_handle, $nameserver, $auth_code));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not transfer the domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("transfer of '%s' to Gandi is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.net";
my $auth_code = "G0R7Y568B740DK27";
my $owner_handle = "AA1234-GANDI";
my $admin_handle = "BB2345-GANDI";
my $tech_handle = "BB2345-GANDI";
my $billing_handle = "BB2345-GANDI";
my $nameservers = ["ns1.example.net", "ns2.example.net", "ns1.example.com"]
my $reply = $proxy->call("domain_transfer_in", $session, $domain, $owner_handle, $admin_handle, $tech_handle, $billing_handle, $nameservers, $auth_code);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not transfer the domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "transfer of domain '%s' to Gandi is Gandi operation #%d\n", $domain, $opid;
}
This function will be available in v1.10
True: Allow the transfer.False: Refuse the transfer.# opid = 1234, retrieved via operation_list try: proxy.domain_transfer_out(session, opid, True) except xmlrpclib.Fault, e: print "Invalid operation ID: #%d" % opid
# $opid = new xmlrpcval(1234);
$ack = new xmlrpcval(True, "boolean");
$msg = new xmlrpcmsg("domain_transfer_out", array($session, $opid, $ack));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("Invalid operation ID: #%d\n", $opid->scalarval());
}
# my $opid = 1234;
my $reply = $proxy->call("domain_transfer_out", $session, $opid, XMLRPC::Data->type('boolean')->value(1));
my $opid = $reply->result();
unless (defined $opid) {
printf "Invalid operation ID #%d\n", $opid;
}
try: opid = proxy.trade(session, "example.net", "AA1234-GANDI", "BB2345-GANDI", "BB2345-GANDI", "BB2345-GANDI") print "trade of '%s' to Gandi is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not trade domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$owner_handle = new xmlrpcval("AA1234-GANDI");
$admin_handle = new xmlrpcval("BB2345-GANDI");
$tech_handle = new xmlrpcval("BB2345-GANDI");
$billing_handle = new xmlrpcval("BB2345-GANDI");
$msg = new xmlrpcmsg("domain_trade", array($session, new xmlrpcval($domain), $owner_handle, $admin_handle, $tech_handle, $billing_handle));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not trade the domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("trade of '%s' to Gandi is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.net";
my $owner_handle = "AA1234-GANDI";
my $admin_handle = "BB2345-GANDI";
my $tech_handle = "BB2345-GANDI";
my $billing_handle = "BB2345-GANDI";
my $reply = $proxy->call("domain_trade", $session, $domain, $owner_handle, $admin_handle, $tech_handle, $billing_handle);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not trade domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "trade of '%s' to Gandi is Gandi operation #%d\n", $domain, $opid;
}
This function will be available in v1.10
try: opid = proxy.domain_change_owner(session, "example.net", "AA9876-GANDI") print "changing owner of domain '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not change the owner of domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$owner = new xmlrpcval("AA9876-GANDI");
$msg = new xmlrpcmsg("domain_change_owner", array($session, new xmlrpcval($domain), $owner));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not change the owner of domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("changing owner of domain '%s' is Gandi operation #%d\n", $domain, $val)
}
my $domain = "example.net";
my $owner = "AA9876-GANDI";
my $reply = $proxy->call("domain_change_owner", $session, $domain, $owner);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not change the owner of domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "changing owner of domain '%s' is Gandi operation #%d\n", $domain, $opid;
}
"admin": the administrative contact"billing": the billing contact"tech": the technical contactdomain = "example.net" type = "billing" handle = "BL4444-GANDI" try: opid = proxy.domain_change_contact(session, domain, type, handle) print "changing %s contact of domain '%s' to '%s' is Gandi operation #%d" % (type, domain, handle, opid) except xmlrpclib.Fault, e: print "could not change the %s contact of domain '%s' because: %s" % (type, domain, e.faultString)
$domain = "example.net";
$type = "billing";
$handle = "BL4444-GANDI";
$msg = new xmlrpcmsg("domain_change_contact", array($session, new xmlrpcval($domain), new xmlrpcval($type), new xmlrpcval($handle)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not change the %s contact of domain '%s' because: %s\n", $type, $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("changing %s contact of domain '%s' to '%s' is Gandi operation #%d\n", $type, $domain, $handle, $val);
}
my $domain = "example.net";
my $handle = "BL4444-GANDI";
my $type = "billing"
my $reply = $proxy->call("domain_change_contact", $session, $domain, $type, $handle);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not change the %s contact of domain '%s' because: %s\n", $type, $domain, $reply->faultstring;
}
else {
printf "changing %s contact of domain '%s' to '%s' is Gandi operation #%d\n", $type, $domain, $handle, $opid;
}
import pprint domain = "example.net" print "%s:" % domain try: ns_list = proxy.domain_ns_list(session, domain) pprint.pprint(ns_list) except xmlrpclib.Fault, e: print "could not retrieve domain '%s' name servers list because: %s" % (domain, e.faultString)
$domain = "example.net";
$msg = new xmlrpcmsg("domain_ns_list", array($session, new xmlrpcval($domain)));
$reply = $proxy->send($msg);
printf("%s:\n", domain);
if ($reply->faultCode()) {
printf("could not retrieve domain '%s' name servers list because: %s\n", $domain, $reply->faultString());
}
else {
$val = php_xmlrpc_decode($reply->value());
print_r($val);
}
my $domain = "example.net";
my $reply = $proxy->call("domain_ns_list", $session, $domain);
printf "%s:\n", $domain;
my $ns_list = $reply->result();
unless (defined $ns_list) {
printf "could not retrieve domain '%s' name servers list because: %s\n", $domain, $reply->faultstring;
}
else {
print Dumper($ns_list);
}
domain = "example.net" ns_list = ["ns1.example.org", "ns2.example.org"] try: opid = proxy.domain_ns_add(session, domain, ns_list) print "adding the name servers is Gandi operation #%d" % opid except xmlrpclib.Fault, e: print "could not add name servers to '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$ns_list = php_xmlrpc_encode(array("ns1.example.org", "ns2.example.org"));
$msg = new xmlrpcmsg("domain_ns_add", array($session, new xmlrpcval($domain), $ns_list));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not add name servers to '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("adding the name servers is Gandi operation #%d\n", $val);
}
my $domain = "example.net";
my $ns_list = ["ns1.example.org", "ns2.example.org"]
my $reply = $proxy->call("domain_ns_add", $session, $domain, $ns_list);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not add name servers to '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "adding the name servers is Gandi operation #%d\n", $opid;
}
domain = "example.net" ns_list = ["ns1.example.org", "ns2.example.org"] try: opid = proxy.domain_ns_del(session, domain, ns_list) print "removing the name servers from '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not remove name servers from '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$ns_list = php_xmlrpc_encode(array("ns1.example.org", "ns2.example.org"));
$msg = new xmlrpcmsg("domain_ns_del", array($session, new xmlrpcval($domain), $ns_list));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not remove name servers from '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("removing the name servers from '%s' is Gandi operation #%d\n", $domain, $val);
}
my $domain = "example.net";
my $ns_list = ["ns1.example.org", "ns2.example.org"]
my $reply = $proxy->call("domain_ns_del", $session, $domain, $ns_list);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not remove name servers from '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "removing the name servers from '%s' is Gandi operation #%d\n", $domain, $opid;
}
domain = "example.net" ns_list = ["ns1.example.org", "ns2.example.org"] try: opid = proxy.domain_ns_set(session, domain, ns_list) print "setting the nameservers of '%s' is Gandi operation #%d" % (domain, opid) except xmlrpclib.Fault, e: print "could not set the name servers list of '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$ns_list = php_xmlrpc_encode(array("ns1.example.org", "ns2.example.org"));
$msg = new xmlrpcmsg("domain_ns_set", array($session, new xmlrpcval($domain), $ns_list));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not set the name servers of '%s' because: %s\n", $domain, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("setting the nameservers is Gandi operation #%d\n", $val);
}
my $domain = "example.net";
my $ns_list = ["ns1.example.org", "ns2.example.org"]
my $reply = $proxy->call("domain_ns_set", $session, $domain, $ns_list);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not set the name servers of '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "setting the nameservers of '%s' is Gandi operation #%d\n", $domain, $opid;
}
import pprint try: domain = "example.net" redir_array = proxy.domain_web_redir_list(session, domain) print "web redirections for '%s':" % domain pprint.pprint(redir_array) except xmlrpclib.Fault, e: print "could not get the list of web redirections of domain '%s' because: %s" % (domain, e.faultString)
$domain = "example.net";
$msg = new xmlrpcmsg("domain_web_redir_list", array($session, new xmlrpcval($domain)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not get the list of web redirections of domain '%s' because: %s\n", $domain, $reply->faultString());
}
else {
printf("web redirections for '%s':\n", $domain);
$val = php_xmlrpc_decode($reply->value());
print_r($val);
}
my $domain = "example.net";
my $reply = $proxy->call("domain_web_redir_list", $session, $domain);
my $redir_array = $reply->result();
unless (defined $redir_array) {
printf "could not get the list of web redirections of domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
printf "web redirections for '%s':\n", $domain;
print Dumper($redir_array);
}
"http302": Moved Temporarily / Found (rfc1945, rfc2616)"http301": Moved Permanently (rfc1945, rfc2616)"cloak": Cloaking (in a frameset)fqdn = "example.net" url = "http://www.example.org/~johndoe/" try: opid = proxy.domain_web_redir_add(session, fqdn, url, "http302") print "adding the web redirection 'http://%s/' -> '%s' (http302) is Gandi operation #%d" % (fqdn, url, opid) except xmlrpclib.Fault, e: print "could not add the web redirection 'http://%s' -> '%s' because: %s" % (fqdn, url, e.faultString)
$fqdn = "example.net";
$url = "http://www.example.org/~johndoe/";
$msg = new xmlrpcmsg("domain_web_redir_add", array($session, new xmlrpcval($fqdn), new xmlrpcval($url), new xmlrpcval("http302")));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not add the web redirection 'http://%s' -> '%s' because: %s\n", $fqdn, $url, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("adding the web redirection 'http://%s' -> '%s' is Gandi operation #%d\n", $fqdn, $url, $val);
}
my $fqdn = "example.net";
my $url = "http://www.example.org/~johndoe/";
my $reply = $proxy->call("domain_web_redir_add", $session, $fqdn, $url, "http302");
my $opid = $reply->result();
unless (defined $opid) {
printf "could not add the web redirection 'http://%s' -> '%s' because: %s\n", $fqdn, $url, $reply->faultstring;
}
else {
printf "adding the web redirection 'http://%s' -> '%s' is Gandi operation #%d\n", $fqdn, $url, $opid;
}
fqdn = "example.net" try: opid = proxy.domain_web_redir_del(session, fqdn) print "deleting the web redirection 'http://%s' is Gandi operation #%d" % (fqdn, opid) except xmlrpclib.Fault, e: print "could not delete the web redirection 'http://%s' because: %s" % (fqdn, e.faultString)
$fqdn = "example.net";
$msg = new xmlrpcmsg("domain_web_redir_del", array($session, new xmlrpcval($fqdn)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not delete the web redirection 'http://%s' -> '%s' because: %s\n", $fqdn, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("deleting the web redirection 'http://%s -> $s' is Gandi operation #%d\n", $fqdn, $val);
}
my $fqdn = "example.net";
my $reply = $proxy->call("domain_web_redir_del", $session, $fqdn);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not delete the web redirection '%s' because: %s\n", $fqdn, $reply->faultstring;
}
else {
printf "deleting the web redirection '%s' is Gandi operation #%d\n", $fqdn, $opid;
}
"individual": an individual"company": a company"public": a public body"association": an associationTrue: Default. Hide the owner's e-mail.False: Do not hide the owner's e-mail.False: Default. Do not resell this contact's personal data.True: Resell this contact's personal data to any party that requests it.
class = "individual"
firstname = "Sophie"
lastname = "Gandi"
address = "15 place de la Nation"
zipcode = "75011"
city = "Paris"
country = "FR"
phone = "+33.102030405"
email = "sophie@example.com"
params = {}
params['birth_date'] = xmlrpclib.DateTime("1981-10-06")
params['birth_place'] = "Versailles"
params['birth_dpt'] = "78"
params['birth_country'] = "FR"
try:
handle = proxy.contact_create(session, class, firstname, lastname, address, zipcode, city, country, phone, email, params)
print "created contact: %s" % handle
except xmlrpclib.Fault, e:
print "could not create contact because: %d" % (e.faultString)
$class = new xmlrpcval("individual");
$firstname = new xmlrpcval("Sophie");
$lastname = new xmlrpcval("Gandi");
$address = new xmlrpcval("15 place de la Nation");
$zipcode = new xmlrpcval("75011");
$city = new xmlrpcval("Paris");
$country = new xmlrpcval("FR");
$phone = new xmlrpcval("+33.102030405", "string");
$email = new xmlrpcval("sophie@example.com");
$params["birth_date"] = new xmlrpcval("19811006T00:00:00", "dateTime.iso8601");
$params["birth_place"] = new xmlrpcval("Versailles");
$params["birth_dpt"] = new xmlrpcval("78", "string");
$params["birth_country"] = new xmlrpcval("FR");
$params = php_xmlrpc_encode($params);
$msg = new xmlrpcmsg("contact_create", array($session, $class, $firstname, $lastname, $address, $zipcode, $city, $country, $phone, $email, $params));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not create contact because: %s\n", $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("created contact: %s\n", $val);
}
my $class = "individual";
my $firstname = "Sophie";
my $lastname = "Gandi";
my $address = "15 place de la Nation";
my $zipcode = "75011";
my $city = "Paris";
my $country = "FR";
my $phone = "+33.102030405";
my $email = "sophie\@example.com";
my $params = {};
$params["birth_date"] = XMLRPC::Data->type('datetime')->value('19811006T00:00:00');
$params["birth_place"] = "Versailles";
$params["birth_dpt"] = "78";
$params["birth_country"] = "FR";
my $reply = $proxy->call("contact_create", $session, $class, $firstname, $lastname, $address, $zipcode, $city, $country, $phone, $email, $params);
my $handle = $reply->result();
unless (defined $handle) {
printf "could not create contact because: %s\n", $reply->faultstring;
}
else {
printf "created contact: %s\n", $handle;
}
class = "company"
firstname = "Marc"
lastname = "Reseau"
address = "38 rue des hirondelles"
zipcode = "75012"
city = "Paris"
country = "FR"
phone = "+33.504030201"
email = "marc@example.org"
params = {}
params['company_name'] = "Example Inc."
params['insee_siren'] = "48327119900024"
params['trademark_number'] = "385070345"
params['tva'] = "FR3744103456"
try:
handle = proxy.contact_create(session, class, firstname, lastname, address, zipcode, city, country, phone, email, params)
print "created contact: %s" % handle
except xmlrpclib.Fault, e:
print "could not create contact because: %s" % e.faultString
$class = new xmlrpcval("company");
$firstname = new xmlrpcval("Marc");
$lastname = new xmlrpcval("Reseau");
$address = new xmlrpcval("38 rue des hirondelles");
$zipcode = new xmlrpcval("75012");
$city = new xmlrpcval("Paris");
$country = new xmlrpcval("FR");
$phone = new xmlrpcval("+33.504030201", "string");
$email = new xmlrpcval("marc@example.org");
$params = php_xmlrpc_encode(array(
"company_name" => "Example Inc.",
"insee_siren" => "48327119900024",
"trademark_number" => "385070345",
"tva" => "FR3744103456"
)
);
$msg = new xmlrpcmsg("contact_create", array($session, $class, $firstname, $lastname, $address, $zipcode, $city, $country, $phone, $email, $params));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not create contact because: %s\n", $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("created contact: %s\n", $val);
}
my $class = "company";
my $firstname = "Marc";
my $lastname = "Reseau";
my $address = "38 rue des hirondelles";
my $zipcode = "75012";
my $city = "Paris";
my $country = "FR";
my $phone = "+33.504030201";
my $email = "marc\@example.org";
my $params = {};
$params["company_name"] = "Example Inc.";
$params["insee_siren"] = "48327119900024";
$params["trademark_number"] = "385070345";
$params["tva"] = "FR3744103456";
my $reply = $proxy->call("contact_create", $session, $class, $firstname, $lastname, $address, $zipcode, $city, $country, $phone, $email, $params);
my $handle = $reply->result();
unless (defined $handle) {
printf "could not create contact because: %s\n", $reply->faultstring;
}
else {
printf "created contact: %s\n", $handle;
}
firstnamelastnameclasscompany_nameassociation_namebody_name
handle = "AA1234-GANDI"
params = {}
params['address'] = "123 rue des alouettes"
params['city'] = "Versailles"
params['zipcode'] = "78000"
try:
opid = proxy.contact_update(session, handle, params)
print "update of contact '%s' is Gandi operation #%d" % (handle, opid)
except xmlrpclib.Fault, e:
print "could not update contact '%s' because: %s" % handle, e.faultString
$handle = "AA1234-GANDI";
$params = php_xmlrpc_encode(array(
"address" => "123 rue des alouettes",
"city" => "Versailles",
"zipcode" => "78000",
)
);
$msg = new xmlrpcmsg("contact_update", array($session, new xmlrpcval($handle), $params));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not update contact '%s' because: %s\n", $handle, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("update of contact '%s' is Gandi operation: #%d\n", $handle, $val);
}
my $handle = "AA1234-GANDI";
my $params = {};
$params["address"] = "123 rue des alouettes";
$params["city"] = "Versailles";
$params["zipcode"] = "78000";
my $reply = $proxy->call("contact_update", $session, $handle, $params);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not update contact '%s' because: %s\n", $opid, $reply->faultstring;
}
else {
printf "update of contact '%s' is Gandi operation #%d\n", $handle, $opid;
}
handle = "AA1234-GANDI" try: opid = proxy.contact_del(session, handle) print "deletion of contact '%s' is Gandi operation #%d" % (handle, opid) except xmlrpclib.Fault, e: print "could not delete contact '%s' because: %s" % (handle, e.faultString)
$handle = "AA1234-GANDI";
$msg = new xmlrpcmsg("contact_del", array($session, new xmlrpcval($handle)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not delete contact '%s' because: %s\n", $handle, $reply->faultString());
}
else {
$val = $reply->value();
$val = $val->scalarval();
printf("deletion of contact '%s' is Gandi operation: #%d\n", $handle, $val);
}
my $handle = "AA1234-GANDI";
my $reply = $proxy->call("contact_del", $session, $handle);
my $opid = $reply->result();
unless (defined $opid) {
printf "could not update contact '%s' because: %s\n", $opid, $reply->faultstring;
}
else {
printf "deletion of contact '%s' is Gandi operation #%d\n", $handle, $opid;
}
import pprint handle = "AA1234-GANDI" try: contact_info = proxy.contact_info(session, handle) print "informations for contact '%s'" % handle pprint.pprint(contact_info) except xmlrpclib.Fault, e: print "could not retrieve informations of contact '%s' because: %s" % (handle, e.faultString)
$handle = "AA1234-GANDI";
$msg = new xmlrpcmsg("contact_info", array($session, new xmlrpcval($handle)));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not retrieve informations of contact '%s' because: %s\n", $handle, $reply->faultString());
}
else {
$val = php_xmlrpc_decode($reply->value());
printf("informations for contact '%s'\n", $handle);
print_r($val);
}
my $handle = "AA1234-GANDI";
my $reply = $proxy->call("contact_info", $session, $handle);
my $info = $reply->result();
unless (defined $opid) {
printf "could not retrieve informations of contact '%s' because: %s\n", $handle, $reply->faultstring;
}
else {
printf "informations for contact '%s'\n", $handle;
print Dumper($info);
}
domain_create)ALL: all operationsPENDING: queued operationsRUN: operations being processedERROR: operations that ended in error and must be modified or canceledCANCEL: operations canceled and terminatedDONE: successfully completed operations
import pprint
try:
updated_after = xmlrpclib.DateTime("2006-01-01")
updated_before = xmlrpclib.DateTime("2006-02-01")
state = "DONE"
type = "domain_create"
filter = { "updated_after": updated_after, "updated_before": updated_before, "state": state, "type": domain_create }
oplist = proxy.operation_list(session, filter)
print "operations list:"
pprint.pprint(oplist)
except xmlrpclib.Fault, e:
print "could not retrieve operations list because: %s" % e.faultString
$filter = new xmlrpcval(
array(
"updated_after" => new xmlrpcval("20060101T00:00:00", "dateTime.iso8601"),
"updated_before" => new xmlrpcval("20060201T00:00:00", "dateTime.iso8601"),
"state" => new xmlrpcval("DONE"),
"type" => new xmlrpcval("domain_create"),
),
"struct"
);
$msg = new xmlrpcmsg("operation_list", array($session, $filter));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not retrieve operations list because: %s\n", $reply->faultString());
}
else {
$val = php_xmlrpc_decode($reply->value());
print("operations list:\n");
print_r($val);
}
my $filter = {}
$filter["updated_after"] = XMLRPC::Data->type("datetime")->value("20060101T00:00:00");
$filter["updated_before"] = XMLRPC::Data->type("datetime")->value("20060201T00:00:00");
$filter["state"] = "DONE";
$filter["type"] = "domain_create";
my $reply = $proxy->call("operation_list", $session, $filter);
my $oplist = $reply->result();
unless (defined $oplist) {
printf "could not retrieve operations list because: %s\n", $reply->faultstring;
}
else {
print "operations list:\n";
print Dumper($oplist);
}
"contact": the parameter describe a contact. A "contact" field is present, except for a contact_create operation."domain": the parameter describe a domain. A "domain" field is present, except for a domain_create operation.import pprint opid = 1234 try: opdetails = proxy.operation_details(session, opid) pprint.pprint(opdetails) except xmlrpclib.Fault, e: print "could not retrieve operation #%d details because: %s" % (opid, e.faultString)
$opid = 1234;
$msg = new xmlrpcmsg("operation_details", array($session, new xmlrpcval($opid, "int")));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not retrieve operation #%d details because: %s\n", $opid, $reply->faultString());
}
else {
$val = php_xmlrpc_decode($reply->value());
print_r($val);
}
my $opid = 1234;
my $reply = $proxy->call("operation_details", $session, $opid);
my $opdetails = $reply->result();
unless (defined $opdetails) {
printf "could not retrieve operation #%d details because: %s\n", $opid, $reply->faultstring;
}
else {
print Dumper($opdetails);
}
opid = 1234
try:
proxy.operation_relaunch(session, opid, {'auth_code': 'abababab'})
catch xmlrpclib.Fault, e:
print "could not relaunch operation #%d because: %s" % (opid, e.faultString)
$opid = 1234;
$params["auth_code"] = new xmlrpcval("abababab");
$params = php_xmlrpc_encode($params);
$msg = new xmlrpcmsg("operation_relaunch", array($session, new xmlrpcval($opid, "int"), $params));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not relaunch operation #%d because: %s\n", $opid, $reply->faultString());
}
my $opid = 1234;
my $params = {};
$params["auth_code"] = "abababab";
my $reply = $proxy->call("operation_relaunch", $session, $opid, $params);
my $result = $reply->result();
unless (defined $result) {
printf "could not relaunch operation #%d because: %s\n", $opid, $reply->faultstring;
}
opid = 1234 try: proxy.operation_cancel(session, opid) except xmlrpclib.Fault, e: print "could not cancel operation #%d because: %s" % (opid, e.faultString)
$opid = 1234;
$msg = new xmlrpcmsg("operation_cancel", array($session, new xmlrpcval($opid, "int")));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not cancel operation #%d because: %s\n", $opid, $reply->faultString());
}
my $opid = 1234;
my $reply = $proxy->call("operation_cancel", $session, $opid);
my $result = $reply->result();
unless (defined $result) {
printf "could not cancel operation #%d because: %s\n", $opid, $reply->faultstring;
}
try: ret = proxy.tld_list(session) pprint.pprint(ret) except xmlrpclib.Fault, e: print "could not retrieve the TLD list because: %s" % (e.faultString,)
$msg = new xmlrpcmsg("tld_list", array($session));
$reply = $proxy->send($msg);
if ($reply->faultCode()) {
printf("could not retrieve the TLD list because: %s\n", $reply->faultString());
}
else {
$val = php_xmlrpc_decode($reply->value());
print_r($val);
}
my $reply = $proxy->call("tld_list", $session);
my $result = $reply->result();
unless (defined $result) {
printf "could not retrieve the TLD list because: %s\n", $reply->faultstring;
}
else {
print Dumper($result);
}
XML-RPC errors are contained in < faults > that have a value (faultCode) encoded as an integer and a message (faultString). The Gandi XML-RPC interface error codes are normalized. The format of Gandi errors is hierarchical and built upon the scheme:
| qualification (one digit) | object (three digits) | cause (two digits) |
The qualification, encoded on one digit, helps distinguishing between an input error and something that went wrong on the server side. There are two qualifications:
The object, encoded on three digits, depends on the qualification. For a Server qualification it may be Network, Database, System etc. For a Data qualification it is related to the objects passed as arguments, for instance a Phone Number.
The cause, encoded on two digits, depends on the object. For a Database object it may be a failed query and for a Phone Number it may be a Syntax Error.
The message associated to an error code is formatted as follow: ServerError: plain text description of the problem
| faultCode | faultString |
|---|---|
| 110020 | ServerError: database query failed |
| 110040 | ServerError: database could not find object |
| 150000 | ServerError: internal error (error has been logged and will be reported) |
In this qualification, all the objects share the same causes.
Checks on data are done sequentially. Depending on the type, not all checks apply. However, a data validation cycle is the following: first the type is checked, then the syntax and the value, then the existence of the object, then the privileges and, finally, the state.
The message associated to an error code is a plain text representations of the problem. It is formated as follow: DataError: plain text description of the problem [element: value]
Element is the name of the faulty parameter with its value appended after a colon and a space.
| faultCode | faultString |
|---|---|
| 500130 | DataError: invalid value for password [password: 123456] |
| 510210 | DataError: invalid type for operation id [opid: test] |
| 510050 | DataError: not enough privileges to access domain [domain: gandi.net] |
A domain name is an alpha-numeric Internet address, formed by the name that you have chosen, and a TLD. A domain name is most often used to name a website (such as www.gandi.net) or an email address (example@gandi.net). In these examples, "gandi.net" is the domain name; "gandi" the chosen name and "net" the TLD.
A domain name (like gandi.net) is easier to remember than an IP address (such as 217.70.177.41). Moreover, the domain name does not change according to the place where your web or e-mail data is actually hosted: you can change your hosting company or your Internet access provider without having to change the name of your website or your e-mail address.
In terms of syntax, a domain name must contain less than 63 alphanumeric characters (no spaces); domain names are not case-sensitive.
Change of the name and the address of the domain owner (Registrant). An ownership change does not modify the contacts, nor the DNS of the domain name.
To transfer a domain and change his owner during the transfer process
Gandi provides a domain restoration service. It means that if your domain is in "Redemption Period" status, we can restore it for you. The restoration process consists in recovering the domain's previous settings (same owner) and adding one year to the domain's validity. Please, notice that when your domain falls into "Redemption Period" status, it is no longer managed by Gandi, but by the related Registry.
A transfer is a change of registrar. This is not to be confused with a change of owner (Change of ownership) or a change of web host.
Final part of the domain name, that comes after a dot. TLD (Top Level Domain) refers to the Internet zone in which your domain name is located. It is also known as "extension". There are several TLDs:
.com, .net, .org, .biz, .info, .name....fr for France, .be for Belgium..For each TLD, a worldwide database guarantees that each domain name is the only one in the world. The organization that manages this database is called a registry. Each TLD is created and regulated by a trustee authority.
This is a code (login, ID) used to identify a person who manages one or several domain names. Each registrar uses their own handle system.
Organization that manages the centralized database of domain names registered in a TLD zone. It is the authoritative source of information, which updates whois and root nameservers for the TLD with the content of its database.
Administrative directory, available to everyone on the Internet (for example on our website at http://www.gandi.net/whois). This database has records of all registered domain names, together with the names and contact information of their respective owners.
Publishing and updating this Whois database is a contractual obligation applying to all accredited Registrars such as Gandi. This directory is a useful tool for visualizing owner and contact information of domain names, and in particular to facilitate the notification of a technical or legal problem.
When logging in in safe mode (default), you must use the su function to restrict temporarily your rights to the user you su'ed to before calling another function that handles existing objects (contacts, domains...). This is especially useful if you intend to map the Gandi registration API on a web interface for your clients as it can help mitigate the effects of parameter injection. When logging in unsafe mode, you do not have to su to a particular user.