How to get complete list of dnsresources using the maas api?


I can query all the dns resources in MAAS from CLI using maas admin dnsresources read all=True . I have to use the cli flag all=True to get the full list. I only get a partial list if I don’t use it.

I am trying to query the same information accessing the maas api from python but I cannot get the full list of dns resources from the api.

I tested python-libmaas but client.dnsresources.list() only returns a partial list and I couldn’t find how to pass flag all=True to get the complete list.

I also tried to do a simple query using python requests library with the same result. Cannot figure out how to use all=True to get the complete list.

Could anyone provide an example to get the full list of dnsresources when querying the api?

In case it helps, this is the python snippet I am using for testing

import json

from requests import Request, Session
from requests_oauthlib import OAuth1

# <consumer_key>:<token_key>:<token_secret>
# xxxxxxxxxxxxxx:yyyyyyyyyyy:zzzzzzzzzzzzzz
auth1 = OAuth1(u'xxxxxxxxxx', u'',u'yyyyyyyyyyy', u'zzzzzzzzzz')

headers = {'Accept': 'application/json'}
url = u''

s = Session()
req = Request('GET', url, headers=headers, auth=auth1)
prepped = req.prepare()
resp = s.send(prepped)

Can anyone share a python snippet to get the complete list of dns entries by querying the maas api?

Hi @pescobar-scicore ,

you can try with /MAAS/api/2.0/dnsresources/?all=True. You can find the entire doc here

1 Like

Thanks for the quick answer @r00ta ! it works like a charm

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.