benkonrath / transip-api

Python implementation for the TransIP API
https://transip-api.readthedocs.io/en/latest/
MIT License
23 stars 23 forks source link

updating same named entries #22

Closed mkurios closed 6 years ago

mkurios commented 7 years ago

I'd like to update a single DNS entry (@), while we also have other entries with that name (but different content). In my tests an update does not work as it updates (and deletes!?) other records.

Is there any way of specifying exactly which records to update ? an '--entry-current-content' or such ?

Reproducing:
Testing was done with Ubuntu 16.04.3, Python 2.7.11-1 and TransIP-API 0.3.0.

I add 3 TXT records to my DNS of 3600 expire and named 'testing', but with incremented IP as content. After this I ran an update command to another IP. (name & domain name censored)

transip-api  -l bla --domain-name bla-a --entry-name testing --entry-expire 3600 --entry-type TXT --entry-content 127.0.0.0
transip-api  -l bla --domain-name bla-a --entry-name testing --entry-expire 3600 --entry-type TXT --entry-content 127.0.0.1
transip-api  -l bla --domain-name bla-a --entry-name testing --entry-expire 3600 --entry-type TXT --entry-content 127.0.0.2
transip-api  -l bla --domain-name bla -u --entry-name testing --entry-expire 3600 --entry-type TXT --entry-content 127.0.0.3

Result Now looking on the transip DNS page, it shows only two entries left, .1 and .2 If i make 4 entries (.0 .1 .2 .3), and update to .4, i have three entries left .1 .3 .4

benkonrath commented 7 years ago

Just trying to understand the problem. Should the last command be --domain-name bla-a instead of --domain-name bla?

benkonrath commented 7 years ago

Ok, so entry-name and entry-type are used to determine which record to update which is why it's not working for you. I suppose the option you suggested could be added but I think it's better for you to just write a custom python script for your needs; the transip_cli is only intended for testing and basic operations.

You can look at the update_dns method in the cli to see how to make the required calls in python. https://github.com/benkonrath/transip-api/blob/master/transip/transip_cli.py#L33

mkurios commented 7 years ago

Hi Ben,

Yes, I made a typo censoring the domain/name values… thought I wouldn’t mail that after I saw it, which I should have… I’m unfamiliar with sending in bug reports, sorry about that. Goes to show, only send in actually tested lines….

mkurios commented 7 years ago

Hmm.. Is there anyway I should be doing this better ? I know transip has their PHP library but I found that a bit convoluted while your library worked just fine. Is there no way of incorporating fixes like this in your sources, I feel this should be a bugfix that should be in there, especially as currently it seems to delete DNS entries as well. I’m not a PHP programmer and certainly not up to all the unit testing your git requires, but I would like this included. Any way I can help with this ?

Transapi_cli for me is going to be scripted as a SPF record auto updating script, and I have a feeling more people might be interested. I’ve resorted to now just mailing differences and doing stuff manually which is open to human failure, not something you want in SPF or DNS records…sigh..

mkurios commented 7 years ago

And I completely ignored your second remark, sorry for that. I’ll have a look at update_dns as you advised, and I’ll get back on that. I do know some PHP, if I can get any useful updates to the code I’ll upload that.
It not being one of my usual languages I don’t know how useful that code would be :(

benkonrath commented 7 years ago

Ok, I think it make sense to just fix this this project. I'm a bit busy right now so it might take a couple of weeks for me to get to it. You could also try to fix the bug if you're up for it.

foarsitter commented 6 years ago

There is only one endpoint for managing DNS entries: Transip_DomainService::setDnsEntries. Its behavior is documented as following: 'Sets the DnEntries for this Domain, will replace all existing dns entries with the new entries'. So it is not possible to update a single DNS entry since they do not have an unique identifier.

benkonrath commented 6 years ago

@foarsitter Thanks for looking into this. I think it's clear that this issue can't be addressed with the transip api. I'm closing this bug.