Gandi Wiki


Questions

Operations methods

operation_list

Signature

array operation_list(string session [, struct filter ])

Description

Retrieves the last 300 operation IDs matching the specified criterias.

Parameters

  • string session: the session id (returned by login)
  • struct filter: a filter struct, containing some or all of the following fields:
    • string type: the operation type (for instance: domain_create)
    • string state: only get operations in the following state:
      • ALL: all operations
      • PENDING: queued operations
      • RUN: operations being processed
      • ERROR: operations that ended in error and must be modified or canceled
      • CANCEL: operations canceled and terminated
      • DONE: successfully completed operations
    • dateTime.iso8601 created_after: select operations created after this date
    • dateTime.iso8601 created_before: select operations created before this date
    • dateTime.iso8601 updated_after: select operations updated after this date
    • dateTime.iso8601 updated_before: select operations updated before this date
    • struct param: find operations that have specified parameters values. Valid key/value pairs include:
      • string domain: a domain name

Returns

The XML-RPC response will contain an array of operations IDs (int) or a fault describing the problem. Possible faults are described in section Error Codes Format.

  • Sample code (python)
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
  • Sample code (php)
$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);
}
  • Sample code (perl)
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);
}



operation_details

Signature

struct operation_details(string session, int opid)

Description

Retrieve an operation details.

Parameters

  • string session: the session id (returned by login)
  • int opid: the operation ID

Returns

The XML-RPC response will contain an operation details (struct) or a fault describing the problem. The returned struct contains the following keys:

  • int uid: the operation Unique ID
  • string type: the operation type
  • string state: the current state of the operation
  • dateTime.iso8601 date_create: the date the operation was created
  • dateTime.iso8601 date_update: the date the operation was last updated
  • struct param: a struct containing the parameters that were used to create the operation. Parameters vary with the state and the operation type.
    • string param_type: Always present, precise the object on which the operation applies. Valid values include:
      • 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.
  • string comment: if the operation is in the <i>ERROR</i> state, contains the underlying error message.

Possible faults are described in section Error Codes Format.

  • Sample code (python)
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)
  • Sample code (php)
$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);
}
  • Sample code (perl)
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);
}



operation_relaunch

Signature

boolean operation_relaunch(string session, int opid, struct param)

Description

Relaunch an operation, modifying the given parameters.

Parameters

  • string session: the session id (returned by login)
  • int opid: the operation to relaunch
  • struct param: the parameters to modify. May be :
    • string auth_code: the transfer auth_code.

Returns

The XML-RPC response will return True (boolean) or a fault describing the problem.

Possible faults are described in section Error Codes Format.

  • Sample code (python)
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)
  • Sample code (php)
$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());
}
  • Sample code (perl)
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;
}



operation_cancel

Signature

boolean operation_cancel(string session, int opid)

Description

Cancel an operation.

Parameters

  • string session: the session id (returned by login)
  • int opid: the operation to cancel

Returns

The XML-RPC response will return True (boolean) or a fault describing the problem. Possible faults are described in section Error Codes Format.

  • Sample code (python)
opid  = 1234
try:
    proxy.operation_cancel(session, opid)
except xmlrpclib.Fault, e:
    print "could not cancel operation #%d because: %s" % (opid, e.faultString)
  • Sample code (php)
$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());
}
  • Sample code (perl)
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;
}

Questions

Flux RSS des questions correspondant à ce filtre (Aide)

Dernière modification: le 04/06/2009 à 18:04 par Pierrick P. (Gandi)