ncdapi icon indicating copy to clipboard operation
ncdapi copied to clipboard

Get id of record

Open eehmke opened this issue 6 years ago • 2 comments

To delete a record, the ID is needed. However, the only way to get that ID is to use the -g option, which retrieves all records. For script usage, it would be useful for retrieve the ID of an individual record like -G Get ID ncdapi.sh -G HOST DOMAIN RECORDTYPE DESTINATION But is the ID really needed for deletion? I would prefer a command like -D DEL Record ncdapi.sh -D HOST DOMAIN RECORDTYPE DESTINATION

eehmke avatar Nov 28 '18 18:11 eehmke

I wrote a small python script to provide the correct parameter to the -D option. Maybe it can be integrated into the project or can be used independantly. Hope it to be useful, works for me. delDNSEntry.py.zip

eehmke avatar Dec 28 '18 10:12 eehmke

for using letsencrypt, I need the ID of the DNS record I created as a challenge respond to delete it afterwards.

I just added this at the borromt of the addRecord() function of ncdapi.sh.

echo $(echo "$tmp" | jq --arg host "$1" --arg type "$3" --arg dest "$dest" '.responsedata.dnsrecords[] | select(.hostname==$host and .type==$type and .destination==$dest) .id' | tr -d \")

I then pipe the output of ncdapi.sh -N XXX to a file (or a variable) for processing it later in a script (e.g. dehydrated / lets encrypt).

This yould also be modified by just using ncdapi.sh -g xxx.xxx to find a specific ID.

https://github.com/linux-insideDE/ncdapi/pull/6

basbebe avatar Feb 25 '20 08:02 basbebe