lexicon
lexicon copied to clipboard
Add upsert command
I want to create a record, and if it exists update it. I can do this via some wrappers around dns-lexicon but it would be much nicer to have it in one command.
Have
lexicon cloudflare upsert example.com A --name 'foof.example.com' --content=127.2.3.4 --ttl 1
So if the record exists it will do:
lexicon cloudflare update example.com A --name 'foof.example.com' --identifier ... --content=127.2.3.4 --ttl 1
Otherwise:
lexicon cloudflare create example.com A --name 'foof.example.com' --content=127.2.3.4 --ttl 1
I'm thinking this can be implemented in https://github.com/AnalogJ/lexicon/blob/master/lexicon/providers/base.py#L118 with calls to list followed by create or update - would appreciate some feelback if this would be acceptable.
Conceptually I like the idea, however it would need to be record-set aware.
I think the biggest hurdle here is adding a new test suite and updating existing provider recordings to support this feature.
TBH I'm not sure if its really worth that effort when its fairly easy to do in a wrapper script. It doesn't really need to be a feature built into lexicon.