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


Chronological Thread 
  • From: Erik Hollensbe < >
  • To:
  • Subject: [chef] Re: REST API, data bag items and the "action" key
  • Date: Mon, 11 Feb 2013 08:59:43 -0800

Chef wraps the body of data bag items in an envelope of sorts.

If you look at Chef::DatabagItem's self.json_create method, you can see what it does to transform what you read from disk. This pattern is repeated with other Chef objects like nodes, roles, etc.

HTH!


On Mon, Feb 11, 2013 at 7:07 AM, Pietro Giorgianni < " target="_blank"> > wrote:
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.

§