@@ -46,10 +46,10 @@ def __init__(self, username, password, server, debug = 0):
4646
4747 Usage:
4848 import netdot
49- dot = netdot.client (username,
50- password,
51- "https://netdot.localdomain/netdot",
52- [ debug] )
49+ dot = netdot.Client.connect (username,
50+ password,
51+ "https://netdot.localdomain/netdot",
52+ debug)
5353
5454 Returns: NetDot.client object.
5555 """
@@ -101,10 +101,10 @@ def get(self, url):
101101 url -- Url to append to the base url
102102
103103 Usage:
104- response = netdot.client .get("/url")
104+ response = netdot.Client .get("/url")
105105
106106 Returns:
107- Result as a multi-level dictionary on sucsess.
107+ XML string output from Netdot
108108 """
109109 response = self .http .get (self .base_url + url )
110110 if self .debug :
@@ -114,10 +114,18 @@ def get(self, url):
114114
115115 def get_xml (self , url ):
116116 """
117- This function delegates to .get and parses the
118- response as xml
119- """
117+ This function delegates to get() and parses the
118+ response xml to return a dict
120119
120+ Arguments:
121+ url -- Url to append to the base url
122+
123+ Usage:
124+ dict = netdot.Client.get_xml("/url")
125+
126+ Returns:
127+ Result as a multi-level dictionary on success.
128+ """
121129 return Util .parse_xml (self .get (url ))
122130
123131 def post (self , url , data ):
@@ -132,7 +140,7 @@ def post(self, url, data):
132140 data -- dict of key/value pairs that the form requires
133141
134142 Usage:
135- response = netdot.client .post("/url", {form-data})
143+ response = netdot.Client .post("/url", {form-data})
136144
137145 Returns:
138146 Result as a multi-level dictionary on success
@@ -156,28 +164,27 @@ def delete(self, url):
156164 url -- Url to append to the base url
157165
158166 Usage:
159- response = netdot.client .delete("/url")
167+ response = netdot.Client .delete("/url")
160168
161169 Returns:
162170 Result as an empty multi-level dictionary
163171 """
164- response = requests .delete (self .base_url + url )
172+ response = self . http .delete (self .base_url + url )
165173 if self .debug :
166174 Util .dump (response )
167175 response .raise_for_status ()
168- Util .validate_xml (response .content )
169176 return response .content
170177
171178 def get_host_by_ipid (self , id ):
172179 """
173- This function returns a NetDot-XML object
174- for the requested IP ID.
180+ Given an Ipblock ID, returns the Ipblock and associated
181+ resource records' data
175182
176183 Arguments:
177- id -- NetDot IP ID
184+ id -- NetDot Ipblock ID
178185
179186 Usage:
180- response = netdot.client.getHostByIPID ("1111")
187+ response = netdot.Client.get_host_by_ipid ("1111")
181188
182189 Returns:
183190 Multi-level dictionary on success.
@@ -186,14 +193,14 @@ def get_host_by_ipid(self, id):
186193
187194 def get_host_by_rrid (self , id ):
188195 """
189- This function returns a NetDot-XML object
190- for the requested RR ID.
196+ Given a resource record ID, returns the
197+ RR's data
191198
192199 Arguments:
193200 id -- NetDot RR ID
194201
195202 Usage:
196- response = netdot.client.getHostByRRID ("1111")
203+ response = netdot.Client.get_host_by_rrid ("1111")
197204
198205 Returns:
199206 Multi-level dictionary on success.
@@ -202,14 +209,13 @@ def get_host_by_rrid(self, id):
202209
203210 def get_host_by_name (self , name ):
204211 """
205- This function returns a NetDot-XML object
206- for the requested shortname
212+ Given a RR name, returns the RR's data
207213
208214 Arguments:
209- name -- DNS shortname
215+ name -- RR label ( DNS name)
210216
211217 Usage:
212- response = netdot.client.getHostByName ("foo")
218+ response = netdot.Client.get_host_by_name ("foo")
213219
214220 Returns:
215221 Multi-level dictionary on success.
@@ -219,13 +225,13 @@ def get_host_by_name(self, name):
219225 def get_ipblock (self , ipblock ):
220226 """
221227 This function returns all of the host
222- records from the provided ip block.
228+ records from the provided IP block
223229
224230 Arguments:
225- ipblock - IpBlock in CIDR notation
231+ ipblock - Subnet address in CIDR notation
226232
227233 Usage:
228- response = netdot.client.getIPBlock ('192.168.1.0/24')
234+ response = netdot.Client.get_ipblock ('192.168.1.0/24')
229235
230236 Returns:
231237 Array of NetDot-XML objects on success
@@ -234,14 +240,14 @@ def get_ipblock(self, ipblock):
234240
235241 def get_host_address (self , address ):
236242 """
237- This function returns a NetDot-XML object
238- for the requested IP Address.
243+ Given an IP address, returns the associated
244+ records' data
239245
240246 Arguments:
241247 address -- IP Address in "dotted-quad" syntax
242248
243249 Usage:
244- response = netdot.client.getHostByIPID ("192.168.0.1")
250+ response = netdot.Client.get_host_address ("192.168.0.1")
245251
246252 Returns:
247253 Multi-level dictionary on success.
@@ -256,7 +262,7 @@ def get_person_by_username(self, user):
256262 user -- Desired username
257263
258264 Usage:
259- response = netdot.client.getPersonByUsername ("user")
265+ response = netdot.Client.get_person_by_username ("user")
260266
261267 Returns:
262268 Multi-level dictionary on success.
@@ -271,7 +277,7 @@ def get_person_by_id(self, id):
271277 id -- Desired User ID
272278
273279 Usage:
274- response = netdot.client.getPersonById ("id")
280+ response = netdot.Client.get_person_by_id ("id")
275281
276282 Returns:
277283 Multi-level dictionary on success.
@@ -289,11 +295,11 @@ def get_object_by_id(self, object, id):
289295 Returns a single-level dict of the requested object and id
290296
291297 Arguments:
292- object -- 'device' or 'host' etc...
298+ object -- 'device', 'person', etc...
293299 id -- Object ID
294300
295301 Usage:
296- response = netdot.client.getObjectByID ("object", "id")
302+ response = netdot.Client.get_object_by_id ("object", "id")
297303
298304 Returns:
299305 Multi-level dictionary on success
@@ -302,13 +308,13 @@ def get_object_by_id(self, object, id):
302308
303309 def get_contact_by_person_id (self , id ):
304310 """
305- Returns a single-level dict of the requested Person
311+ Returns contact information for given person ID
306312
307313 Arguments:
308314 id -- person id
309315
310316 Usage:
311- response = netdot.client.getContactByPersonID ('id')
317+ response = netdot.Client.get_contact_by_person_id ('id')
312318
313319 Returns:
314320 Single-level dictionary on success
@@ -323,13 +329,13 @@ def get_contact_by_person_id(self, id):
323329
324330 def get_contact_by_username (self , user ):
325331 """
326- Returns a single-level dict of the requested Username
332+ Returns contact information for given person username
327333
328334 Arguments:
329335 user -- NetDot Username
330336
331337 Usage:
332- response = netdot.client.getContactByUsername ("mary")
338+ response = netdot.Client.get_contact_by_username ("mary")
333339
334340 Returns:
335341 Multi-level dictionary on success
@@ -346,7 +352,7 @@ def get_grouprights_by_conlist_id(self, id):
346352 id -- NetDot Contact List ID
347353
348354 Usage:
349- response = netdot.client.getGrouprightsByConlistID ("id")
355+ response = netdot.Client.get_grouprights_by_conlist_id ("id")
350356
351357 Returns:
352358 Multi-level dictionary on success
@@ -363,7 +369,7 @@ def add_cname_to_record(self, name, cname):
363369 cname -- Desired CNAME
364370
365371 Usage:
366- response = dot.addCnameToARecord ('foo.example.com', 'bar.example.com')
372+ response = dot.add_cname_to_record ('foo.example.com', 'bar.example.com')
367373 """
368374 data = { 'cname' : cname }
369375 host = self .getHostByName (name )
@@ -385,7 +391,7 @@ def rename_host(self, old, new):
385391 new -- New DNS shortname
386392
387393 Usage:
388- netdot.client .renameHost('old-name','new-name')
394+ netdot.Client .renameHost('old-name','new-name')
389395 """
390396 host = self .getHostByName (old )
391397 rrid = host ['RR' ]['id' ]
@@ -395,27 +401,33 @@ def rename_host(self, old, new):
395401
396402 def create_host (self , data ):
397403 """
398- This function takes a dict and creates a new
399- record in the subnet '192.168.1.0/24' with an ethernet
400- address of 'XX:XX:XX:XX:XX:XX' and a comment of 'My Server'.
404+ Create DNS records (and optionally) DHCP entries
405+ for a given IP address, using the given
406+ name and description.
407+ Passing a subnet address instead of an IP address,
408+ the function will create records for the next
409+ available IP address in the subnet.
401410
402411 Arguments:
403- data -- dict with at least the following key:value pairs:
404- name:'servername'
405- subnet: 'CIDR notation'
412+ data -- dict with the following key:value pairs:
413+ name: 'servername'
414+ address: 'IP'
415+ subnet: 'CIDR'
416+ ethernet: 'MAC'
417+ info: 'Description string'
406418
407419 Usage:
408- response = netdot.client.createHost ({'name':'my-server',
409- 'subnet':'192.168.1.0/24',
410- 'ethernet':'XX:XX:XX:XX:XX:XX',
411- 'info':'My Server'})
420+ response = netdot.Client.create_host ({'name':'my-server',
421+ 'subnet':'192.168.1.0/24',
422+ 'ethernet':'XX:XX:XX:XX:XX:XX',
423+ 'info':'My Server'})
412424
413425 Returns:
414426 Created record as a multi-level dictionary.
415427 """
416428 return self .post ("/host" , data )
417429
418- def delete_host_by_rrid (self , rrid ):
430+ def delete_host_by_rrid (self , id ):
419431 """
420432 This function deletes a hostname record
421433 for the requested RR ID. This also frees the IP.
@@ -424,13 +436,23 @@ def delete_host_by_rrid(self, rrid):
424436 rrid -- NetDot Resource Record ID
425437
426438 Usage:
427- response = netdot.client.deleteHostByRRD ("1111")
439+ response = netdot.Client.delete_host_by_rrid ("1111")
428440
429441 Returns:
430442 """
431- return self .delete ("/host?rrid=" + rrid )
432-
433-
443+ return self .delete ("/host?rrid=" + id )
434444
445+ def delete_host_by_ipid (self , id ):
446+ """
447+ This function deletes all hostname records
448+ for the requested Ipblock ID.
435449
450+ Arguments:
451+ ipid -- NetDot Ipblock ID
436452
453+ Usage:
454+ response = netdot.Client.delete_host_by_ipid("1111")
455+
456+ Returns:
457+ """
458+ return self .delete ("/host?ipid=" + id )
0 commit comments