summaryrefslogtreecommitdiff
path: root/lib/chef_zero/endpoints/data_bag_item_endpoint.rb
diff options
context:
space:
mode:
authorjkeiser <jkeiser@opscode.com>2012-12-19 23:22:54 -0800
committerjkeiser <jkeiser@opscode.com>2012-12-19 23:23:21 -0800
commit666374b272a8851a2c57530a71a6183d4d06a648 (patch)
treeb53efd8134aa36ab0d459f3e4e87e1a6bbd1fe21 /lib/chef_zero/endpoints/data_bag_item_endpoint.rb
downloadchef-zero-666374b272a8851a2c57530a71a6183d4d06a648.tar.gz
Initial commit (moved/split up from jk/tiny-chef-server branch of jkeiser/chef)
Diffstat (limited to 'lib/chef_zero/endpoints/data_bag_item_endpoint.rb')
-rw-r--r--lib/chef_zero/endpoints/data_bag_item_endpoint.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/chef_zero/endpoints/data_bag_item_endpoint.rb b/lib/chef_zero/endpoints/data_bag_item_endpoint.rb
new file mode 100644
index 0000000..9c084a3
--- /dev/null
+++ b/lib/chef_zero/endpoints/data_bag_item_endpoint.rb
@@ -0,0 +1,25 @@
+require 'json'
+require 'chef_zero/endpoints/rest_object_endpoint'
+require 'chef_zero/endpoints/data_bag_item_endpoint'
+require 'chef_zero/data_normalizer'
+
+module ChefZero
+ module Endpoints
+ # /data/NAME/NAME
+ class DataBagItemEndpoint < RestObjectEndpoint
+ def initialize(server)
+ super(server, 'id')
+ end
+
+ def populate_defaults(request, response_json)
+ DataBagItemEndpoint::populate_defaults(request, response_json, request.rest_path[1], request.rest_path[2])
+ end
+
+ def self.populate_defaults(request, response_json, data_bag, data_bag_item)
+ response = JSON.parse(response_json, :create_additions => false)
+ response = DataNormalizer.normalize_data_bag_item(response, data_bag, data_bag_item, request.method)
+ JSON.pretty_generate(response)
+ end
+ end
+ end
+end