summaryrefslogtreecommitdiff
path: root/lib/chef_zero/rest_base.rb
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-07-02 15:40:26 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-07-07 11:17:12 -0700
commit955ab1ceaa678782d63a6153d352dc6428f9f364 (patch)
treefa936289c190685fcda4de792ffd59f1f8bf67fe /lib/chef_zero/rest_base.rb
parentb7deb4aa11789f53506686742fe4b32deb31dad2 (diff)
downloadchef-zero-955ab1ceaa678782d63a6153d352dc6428f9f364.tar.gz
Add /organizations, /organizations/NAME, /organizations/NAME/_validator_key
Diffstat (limited to 'lib/chef_zero/rest_base.rb')
-rw-r--r--lib/chef_zero/rest_base.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef_zero/rest_base.rb b/lib/chef_zero/rest_base.rb
index f01950f..9e0ed30 100644
--- a/lib/chef_zero/rest_base.rb
+++ b/lib/chef_zero/rest_base.rb
@@ -80,12 +80,23 @@ module ChefZero
def set_data(request, rest_path, data, *options)
rest_path ||= request.rest_path
begin
- data_store.set(rest_path, request.body, *options)
+ data_store.set(rest_path, data, *options)
rescue DataStore::DataNotFoundError
raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
end
end
+ def create_data_dir(request, rest_path, name, *options)
+ rest_path ||= request.rest_path
+ begin
+ data_store.create_dir(rest_path, name, *options)
+ rescue DataStore::DataNotFoundError
+ raise RestErrorResponse.new(404, "Parent not found: #{build_uri(request.base_uri, request.rest_path)}")
+ rescue DataStore::DataAlreadyExistsError
+ raise RestErrorResponse.new(409, "Object already exists: #{build_uri(request.base_uri, request.rest_path + [name])}")
+ end
+ end
+
def create_data(request, rest_path, name, data, *options)
rest_path ||= request.rest_path
begin