• Welcome to The Network People Support Forums. Please login or sign up.

API use - Missing global list options?

Started by abeeson, May 05, 2014, 06:30:22 pm

Previous topic - Next topic

abeeson

May 05, 2014, 06:30:22 pm Last Edit: May 05, 2014, 06:36:57 pm by abeeson
I'm having a look at the API now to do reverse zone creation and host forward and reverse A/AAAA/PTR creation and I have run into a problem, i'm not able to find the zone_record_id of existing zones, in particular the forward zones without already knowing them.

I was looking at using get_zone_list but it requires a list of nt_zone_id's to be passed to it, otherwise it doesnt work.

Is the expected behaviour? the API documentation doesnt show it as a required variable but any attempt to run it with a blank or undef value results in a error saying a required variable is needed, rather than my expected behaviour of it just dumping out every zone in a big hash....

Without the ability to look up forward zone ID's i can't do the host A/AAAA injection easily, i'm trying to avoid using the database directly for this in any way so i'm hoping another idea could be proposed?

As for the reverse, i'm capable of capturing and saving the zone ID when those are created so that is less of a problem....

abeeson

oh i should also say, this question probably applies equally to the get_nameserver_list and get_user_list as well, though in this case it doesnt affect me.

It seems those should return everything when not supplied with anything (or better yet, when supplied with "all" or something similar, -1 maybe?)

EDIT: A quick fix for this would be the addition of some simple API calls (something like get_*_ids) for nameserver, zone and user that returned just basic summary data, name and ID would be fine i would imagine.

matt

I believe what you're looking for is get_group_zones. Call that with a set of search parameters and you can find your zones ID.

matt

Also, you might want to have a look at the scripts in the server/api/contrib directory, such as DNS.pm that encapsulates the API calls into higher level functions.

abeeson

Cheers matt that is exactly what i was looking for :)