diff options
Diffstat (limited to 'lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb')
-rw-r--r-- | lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb b/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb new file mode 100644 index 0000000..4bea4c1 --- /dev/null +++ b/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb @@ -0,0 +1,35 @@ +require 'chef_zero/chef_data/data_normalizer' + +module ChefZero + module Endpoints + class CookbookArtifactsCookbookIdentifierEndpoint < RestBase + # GET /organizations/ORG/cookbook_artifacts/COOKBOOK/IDENTIFIER + def get(request) + cookbook_name, identifier = request.rest_path.last(2) + + data = get_data(request) + + return already_json_response(200, data) + end + + # PUT /organizations/ORG/cookbook_artifacts/COOKBOOK/IDENTIFIER + def put(request) + cookbook_name, identifier = request.rest_path.last(2) + + # pedant dictates that we not return the "json_class" element, so let's not store it. + identified_cookbook_json = to_json(parse_json(request.body).tap { |o| o.delete("json_class") }) + + set_data(request, nil, identified_cookbook_json, :create_dir) + + return already_json_response(201, identified_cookbook_json) + end + + # DELETE /organizations/ORG/cookbook_artifacts/COOKBOOK/IDENTIFIER + def delete(request) + delete_data(request) + + return already_json_response(200, "{}") + end + end + end +end |