summaryrefslogtreecommitdiff
path: root/lib/chef_zero/endpoints/policy_endpoint.rb
blob: 6d1357504b4b14ce221aa9afdd281223e60274ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require_relative "../chef_data/data_normalizer"

module ChefZero
  module Endpoints
    # /organizations/ORG/policies/NAME
    class PolicyEndpoint < RestBase
      # GET /organizations/ORG/policies/NAME
      def get(request)
        revisions = list_data(request, request.rest_path + ["revisions"])
        data = { revisions: hashify_list(revisions) }
        json_response(200, data)
      end

      # DELETE /organizations/ORG/policies/NAME
      def delete(request)
        revisions = list_data(request, request.rest_path + ["revisions"])
        data = { revisions: hashify_list(revisions) }

        delete_data_dir(request, nil, :recursive)
        json_response(200, data)
      end
    end
  end
end