@@ -0,0 +1,2194 @@
+#%0A# Copyright (c) 2014 NSONE, Inc.%0A#%0A# License under The MIT License (MIT). See LICENSE in project root.%0A#%0A%0Afrom nsone import NSONE%0A%0A# NSONE will use config in ~/.nsone by default%0Ansone = NSONE()%0A%0A# to specify an apikey here instead, use:%0A%0A# from nsone import Config%0A# config = Config()%0A# config.createFromAPIKey('qACMD09OJXBxT7XOuRs8')%0A# nsone = NSONE(config=config)%0A%0A# create a zone to play in%0Azone = nsone.createZone('testzone.com')%0A%0A# create an NSONE API data source%0AsourceAPI = nsone.datasource()%0As = sourceAPI.create('my api source', 'nsone_v1')%0AsourceID = s%5B'id'%5D%0A%0A# create a record to connect to this source, with two answers%0A# specify the up filter so we can send traffic to only those nodes%0A# which are known to be up. we'll start with just the second answer up.%0Arecord = zone.add_A('record',%0A                    %5B%7B'answer': %5B'1.1.1.1'%5D,%0A                      'meta': %7B%0A                          'up': False%0A                          %7D%0A                      %7D,%0A                     %7B'answer': %5B'9.9.9.9'%5D,%0A                      'meta': %7B%0A                          'up': True%0A                          %7D%0A                      %7D%5D,%0A                    filters=%5B%7B'up': %7B%7D%7D%5D)%0A%0A# create feeds from this source for each answer%0AfeedAPI = nsone.datafeed()%0AfeedAPI.create(sourceID,%0A               'feed to server1',%0A               config=%7B'label': 'server1'%7D,%0A               destinations=%5B%7B'desttype': 'answer',%0A                              'record': record.data%5B'id'%5D,%0A                              'destid': record.data%5B'answers'%5D%5B0%5D%5B'id'%5D%0A                              %7D%5D)%0A%0AfeedAPI.create(sourceID,%0A               'feed to server2',%0A               config=%7B'label': 'server2'%7D,%0A               destinations=%5B%7B'desttype': 'answer',%0A                              'record': record.data%5B'id'%5D,%0A                              'destid': record.data%5B'answers'%5D%5B1%5D%5B'id'%5D%0A                              %7D%5D)%0A%0A# now publish an update via feed to the records%0AsourceAPI.publish(sourceID, %7B%0A    'server1': %7B%0A        'up': True%0A    %7D,%0A    'server2': %7B%0A        'up': False%0A    %7D%7D)%0A%0A# NSONE will instantly notify DNS servers at the edges, causing traffic to be%0A# sent to server1, and ceasing traffic to server2%0A

add data feed example