Skip to content

Commit

Permalink
change some minor code, and examples to reflect feed pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
weyrick committed Jul 16, 2015
1 parent c75c509 commit 764cca7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
39 changes: 18 additions & 21 deletions examples/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,38 @@
s = sourceAPI.create('my api source', 'nsone_v1')
sourceID = s['id']

# create feeds which will drive the meta data for each answer
# we'll use the id of these feeds when we connect the feeds to the
# answer meta below
feedAPI = nsone.datafeed()
feed1 = feedAPI.create(sourceID,
'feed to server1',
config={'label': 'server1'})

feed2 = feedAPI.create(sourceID,
'feed to server2',
config={'label': 'server2'})

# create a record to connect to this source, with two answers
# specify the up filter so we can send traffic to only those nodes
# which are known to be up. we'll start with just the second answer up.
# each 'up' meta value is a feed pointer, pointing to the feeds we
# created above
record = zone.add_A('record',
[{'answer': ['1.1.1.1'],
'meta': {
'up': False
'up': {'feed': feed1['id']}
}
},
{'answer': ['9.9.9.9'],
'meta': {
'up': True
'up': {'feed': feed2['id']}
}
}],
filters=[{'up': {}}])

# create feeds from this source for each answer
feedAPI = nsone.datafeed()
feedAPI.create(sourceID,
'feed to server1',
config={'label': 'server1'},
destinations=[{'desttype': 'answer',
'record': record.data['id'],
'destid': record.data['answers'][0]['id']
}])

feedAPI.create(sourceID,
'feed to server2',
config={'label': 'server2'},
destinations=[{'desttype': 'answer',
'record': record.data['id'],
'destid': record.data['answers'][1]['id']
}])

# now publish an update via feed to the records
# now publish an update via feed to the records. here we push to both
# feeds at once, but you can push to one or the other individually as well
sourceAPI.publish(sourceID, {
'server1': {
'up': True
Expand Down
2 changes: 1 addition & 1 deletion nsone/rest/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def publish(self, sourceid, data, callback=None, errback=None):
class Feed(resource.BaseResource):

ROOT = 'data/feeds'
PASSTHRU_FIELDS = ['name', 'config', 'destinations']
PASSTHRU_FIELDS = ['name', 'config']

def list(self, sourceid, callback=None, errback=None):
return self._make_request('GET',
Expand Down
2 changes: 1 addition & 1 deletion nsone/rest/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Records(resource.BaseResource):

INT_FIELDS = ['ttl']
BOOL_FIELDS = ['use_csubnet']
PASSTHRU_FIELDS = ['feed', 'networks', 'meta', 'regions', 'link']
PASSTHRU_FIELDS = ['networks', 'meta', 'regions', 'link']

# answers must be:
# 1) a single string
Expand Down

0 comments on commit 764cca7

Please sign in to comment.