[chef] REST API, data bag items and the "action" key


Chronological Thread 
  • From: Pietro Giorgianni < >
  • To:
  • Subject: [chef] REST API, data bag items and the "action" key
  • Date: Mon, 11 Feb 2013 16:07:51 +0100

Hi,

I'm manipulating data bag items using the REST API through a custom, non-ruby client, as documented here: http://docs.opscode.com/api_chef_server.html

When I try to create or update a data bag item containing the key "action" at the main level, that key is thrown away, and I don't see it in the item.



In practice, I post the following JSON to /data/foo
{
  "id": "bar",
  "key": "value",
  "action": "remove"
}

Then, /data/foo/bar contains this:
{
  "id": "bar",
  "key": "value"
}

Of course, creating a data bag item with the "action" key using knife works fine; I patched the gem to add some logging, and what I found out is that knife sends this body:
{
  "name": "data_bag_item_foo_bar",
  "json_class": "Chef::DataBagItem",
  "chef_type": "data_bag_item",
  "data_bag": "foo",
  "raw_data": {
    "id": "bar",
    "key": "value",
    "action": "remove"
  }
}

I couldn't find any mention of this behavior on the Chef documentation.

I'd be happy to go on and implement my code to act as knife does, but I need to know if this is a well known, stable thing or just a temporary glitch.

Any clues?


pietro



Archive powered by MHonArc 2.6.16.

§