Closed phunehehe closed 9 years ago
The difference between create
and update
commands is that update
takes record identifying information as well: the ID and the last modified date. For cases where search only returns one record, we can automatically derive this API call but what shall we do for cases where multiple records are found for single subdomain? I can't think of anything sane except printing the found candidates (just dumping JSON) and exiting with error code. Do we also print out a message saying what happened or do we go for the machine-friendly output instead? Maybe we should have --human
flag which alters output. Hm.
update
is exposed but error reporting needs to be improved.
@phunehehe I wonder if update
ing an existing record is a valid approach and in what cases do we do it: is it the case that we never want more than one record for same subdomain? The API (and the site itself) is actually lenient here and allows you to create two identical records, modulo ID and the created/modified date. In real use, I imagine one might be active and one not active and people switch between records.
EDIT: the update
at the top said delete
which was a mistake, I was thinking about something else.
I didn't think about multiple records of the same name when I created this ticket. We are using that for load balancing in Rackspace, thought I don't think the plan is to do that for Eris (because we use ELB - cc @proger). I think that use case can be skipped for now.
For single records, update
makes more sense than delete
+ create
, as it doesn't create a time span when the record doesn't exist. For this same use case, patching create
to automatically update
is convenient too. Maybe add a smart-create
command that "does the right thing" and leave create
alone?
Anyway, if update
is available, that's enough for me now. Thanks :)
Maybe add a smart-create command that "does the right thing" and leave create alone?
Sounds reasonable. I don't want to let create
do this because technically calling create
with same arguments twice will produce two records and this is something we may want. I'll do smart-create
tomorrow.
$ myrapi --access-key blahblahblah --secret-key blahblahblah update --domain zalora.com --subdomain dynstatic01-ec-id.zalora.com --value wpc.10280.edgecastcdn.net. --id 62604 --modified 2015-03-27T06:52:56+0100 --ttl 300 --type CNAME --active
ERROR: Failed with "HTTP POST request failed with status: 200 - OK"
This looks like #6 so I'm closing this issue. smart-create
is not needed for now (unless you are almost done with it, of course).
For the error codes thing you need newer servant-client. They are actually making a release very soon I believe which should include these anyway and make for easy packaging.
smart-create
is actually rather trivial to implement because it's just a search followed by a possible create, both of which are already done. I'm going to mess with README a bit later and hand it off so I might put it in then.
As
create
ing a subdomain that already exists doesn't do "the right thing" (update the existing DNS record - see also #2),update
is needed to simulate a "correct"create
command, e.g. search (#3) for abc.zalora.com, if that doesn't exist, create it, otherwise update it to the supplied values.