[openstack-dev] [api][neutron] question on putting an existing tag

Akihiro Motoki amotoki at gmail.com
Fri Feb 26 17:24:42 UTC 2016

2016-02-27 1:02 GMT+09:00 Sean Dague <sean at dague.net>:
> On 02/26/2016 10:52 AM, Chris Dent wrote:
>> On Fri, 26 Feb 2016, Jay Pipes wrote:
>>> On 02/26/2016 09:02 AM, Akihiro Motoki wrote:
>>>> We can create a tag by PUT'ing an individual tag:
>>>> What status code should be returned if a requested tag already exists?
>>>> PUT /servers/1234567890/tags/qux
>>>> The guideline defines 201 (+ Location header) on success.
>>>> In the current neutron implementation proposed, 409 is returned
>>>> when a requested tag already exists.
>>> 409 Conflict.
>> /me gets some paint
>> Stricly speaking, PUT should be idempotent so every time you put a
>> qux tag on 123456789 it should return (the same) 2xx.
>> In the real world things get messy and some implementations return
>> 201 on create and some other 2xx when it is already there. It
>> shouldn't be an error though.
>> The time a 409 might be reasonable is if via a header, like an ETag,
>> we have declared that qux must have a certain state before we accept
>> a PUT of it.
>> In some implementations things like 'Etag: 0' are used to say "Only
>> let this PUT happen if it is a create." That's a bit of a hack but
>> is useful.
> Agree. PUT is an update. The should be no issue updating an existing
> tag. That should be success

Thanks. I agree PUT should be success in general.
Honestly I am confused with a situation that a tag is created by PUT
(not by POST)
and applied the semantics around POST to PUT case.

> Adding a tag should really be semantically:
> POST /servers/1234567890/tags
> to create tags and
> PUT /servers/1234567890/tags/qux to update them

The above combination of POST and PUT is really easy to understand to me.

Do we need to use POST to create a new tag,
or can we keep using PUT to create a tag?

If we keep using PUT, what status code should be returned?
201 Created is now returned for PUT operation.
Is it okay to return 201 even when a tag already exists?

> You should not PUT to any url that you can't GET. And it looks like GET
> /servers/1234567890/tags/qux would be a 404 here.

Yes, I totally agree.


>         -Sean
> --
> Sean Dague
> http://dague.net
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

More information about the OpenStack-dev mailing list