[katello-devel] How should we post objects
Dmitri Dolguikh
dmitri at redhat.com
Fri Jul 13 15:07:54 UTC 2012
The difference between creating a new object and updating an existing
one is (in the context of this discussion) in idempotency: repeated
calls to create an object may return a new object every time, while
making the same change over and over again should result in the same
state of the object. So: POST is for creation, PUT is for updates.
To create a new object it is necessary to pass in a set of attributes
that allows a creation of the object in a valid state.
Until we have support for PATCH, I'm thinking all updates should be
treated as partials, with optimistic locking via ETAGS (we don't have
the latter bit yet).
Cheers,
-d
On 13/07/12 05:46 PM, Lukas Zapletal wrote:
> We already discussed this some time ago. There are no big
> (dis)advantages for any of these. It's just about what we decide to go
> for.
>
> I am for having the wrapper "person" dictionary there.
>
> LZ
>
> On Thu, Jul 12, 2012 at 11:49:10AM -0400, Bryan Kearney wrote:
>> The API Conventions Document
>> (https://fedorahosted.org/katello/wiki/APIConventions) says that
>> objects should be fully qualified. So, if we return a person object
>> the json should be:
>>
>>
>> {
>> person: {
>> name: "JarJar Binks",
>> id: "1"
>> }
>> }
>>
>> My question is, if I want to create or update a person, what should
>> the body of the html messgae be? Should it be:
>>
>> POST /people
>> {
>> person: {
>> name: "Anakin Skywalker",
>> }
>> }
>>
>> POST /people/1
>> {
>> person: {
>> name: "Jar Jar Binkage",
>> }
>> }
>>
>>
>> OR
>>
>> POST /people
>> {
>> name: "Anakin Skywalker",
>> }
>>
>> POST /people/1
>> {
>> name: "Jar Jar Binkage",
>> }
>>
>>
>> Opinions? I ask because both are used in the API today :)
>>
>> -- bk
>>
>>
>>
>> _______________________________________________
>> katello-devel mailing list
>> katello-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/katello-devel
More information about the katello-devel
mailing list