diff options
author | John Keiser <jkeiser@opscode.com> | 2014-07-02 15:40:26 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-07-07 11:17:12 -0700 |
commit | 955ab1ceaa678782d63a6153d352dc6428f9f364 (patch) | |
tree | fa936289c190685fcda4de792ffd59f1f8bf67fe /lib/chef_zero/rest_base.rb | |
parent | b7deb4aa11789f53506686742fe4b32deb31dad2 (diff) | |
download | chef-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.rb | 13 |
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 |