Пример #1
0
$zone = $nsone->loadZone('newtestzone.com');
// adding simple records
$zone->add_A('newrecord', '1.2.3.4');
$zone->add_CNAME('newcname', 'newrecord.newtestzone.com');
// complex configuration. this will be simplied via
// the high levels objects eventually
$answers[] = array('answer' => array('1.2.3.4'), 'meta' => array('up' => true, 'country' => array('US')));
$answers[] = array('answer' => array('2.3.4.5'), 'meta' => array('up' => true, 'country' => array('FR')));
$filters = array('geotarget_country' => array(), 'select_first_n' => array('N' => 1));
// complete list of options in src/Rest/Records.php, the *_FIELDS class properties
$options['filters'] = $filters;
$options['use_csubnet'] = true;
$rec = $zone->add_A('complex', $answers, $options);
// DATA SOURCES/FEEDS
// create an NSONE API data source. note, this only needs to happen once!
$sourceClient = $nsone->datasource();
$s = $sourceClient->create('my api source', 'nsone_v1');
$sourceID = $s['id'];
// create feeds from this source for each answer
$feedClient = $nsone->datafeed();
// feed for server 1
$feedClient->create($sourceID, 'feed to server1', array('label' => 'server1'), array('destinations' => array(array('desttype' => 'answer', 'record' => $rec['id'], 'destid' => $rec['answers'][0]['id']))));
// feed for server 2
$feedClient->create($sourceID, 'feed to server2', array('label' => 'server2'), array('destinations' => array(array('desttype' => 'answer', 'record' => $rec['id'], 'destid' => $rec['answers'][1]['id']))));
// now publish an update via feed to the records
$sourceClient->publish($sourceID, array('server1' => array('up' => true), 'server2' => array('up' => false)));
// cleanup
// deletes all records, including their meta and feeds
$zone->delete();
// delete the data source. not normally necessary.
$sourceClient->delete($sourceID);