[pve-devel] API Return Values

Adam Krone adam.krone at thirdwavellc.com
Tue Oct 24 19:04:03 CEST 2017


(resending, forgot to remove my signature again...)

>I wonder how terraform handle other crontab like files?

Terraform doesn't need to know about implementation details like crontab
files. If any Terraform providers currently handle crontab files, it's
because the API abstracts that. All Terraform needs to know is how to speak
to the API to manage resources, which involves keeping track of an ID for
future requests on that resource.

We can already get all backup IDs with GET /api2/json/cluster/backup, and
that ID is necessary for any of the /api2/json/cluster/backup/{id} methods,
so it's not like we're exposing information that's not already known.

As long as the API is allowed to be consumed by third parties, this seems
like an important addition in order to support the widest variety of use
cases.

Ignoring the backup situation for a moment, I think it would be a good
addition overall to add the resource's current state to the response of all
non-GET methods, instead of just returning null. Granted, the web GUI
wouldn't need to consume this information, however consider the extra bit
of verification it could provide in pvesh.

When I create a user, for example, pvesh could immediately display the
created user, providing some additional feedback beyond the success status
code. This becomes even more useful in situations where optional parameters
that aren't submitted with the request have default values set by the API.
Perhaps there is a default value that isn't obvious to the user, and having
the immediate feedback might prompt them to update it.

Of course, this also helps out other third party libraries, like the one
I'm working on, as it gives us more information about the resource in fewer
requests. Instead of creating a resource and then issuing a GET in order to
get the most complete picture of its current state, all that information
could be exposed in the initial create request.


More information about the pve-devel mailing list