diff options
author | John Keiser <john@johnkeiser.com> | 2016-01-15 10:44:34 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-01-15 13:31:44 -0800 |
commit | 33ad78efb84af54cb5d7dae0bee8b491dbc394a7 (patch) | |
tree | 85a1f9e48d133b1547b92313146f142c0ed2ae99 /lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb | |
parent | aa1f0797f90c322c8ebec640a798f82c95d7e558 (diff) | |
download | chef-zero-33ad78efb84af54cb5d7dae0bee8b491dbc394a7.tar.gz |
Rename cookbook artifacts
Diffstat (limited to 'lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb')
-rw-r--r-- | lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb b/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb new file mode 100644 index 0000000..e17fea2 --- /dev/null +++ b/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb @@ -0,0 +1,24 @@ +require 'chef_zero/chef_data/data_normalizer' + +module ChefZero + module Endpoints + class CookbookArtifactEndpoint < RestBase + # GET /organizations/ORG/cookbook_artifacts/COOKBOOK + def get(request) + cookbook_name = request.rest_path.last + cookbook_url = build_uri(request.base_uri, request.rest_path) + response_data = {} + versions = [] + + list_data(request).each do |identifier| + artifact_url = build_uri(request.base_uri, request.rest_path + [cookbook_name, identifier]) + versions << { url: artifact_url, identifier: identifier } + end + + response_data[cookbook_name] = { url: cookbook_url, versions: versions } + + return json_response(200, response_data) + end + end + end +end |