lexicon icon indicating copy to clipboard operation
lexicon copied to clipboard

Add upsert command

Open iwan-aucamp-cs opened this issue 6 years ago • 2 comments
trafficstars

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

iwan-aucamp-cs avatar Feb 12 '19 11:02 iwan-aucamp-cs

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.

aucampia avatar Feb 13 '19 12:02 aucampia

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.

AnalogJ avatar Feb 25 '19 23:02 AnalogJ