summaryrefslogtreecommitdiff
path: root/lib/chef_zero/endpoints/role_endpoint.rb
blob: 0325169e4f703d7d415c911af4c1c885c080fe7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'ffi_yajl'
require 'chef_zero/endpoints/rest_object_endpoint'
require 'chef_zero/chef_data/data_normalizer'

module ChefZero
  module Endpoints
    # /roles/NAME
    class RoleEndpoint < RestObjectEndpoint
      def populate_defaults(request, response_json)
        role = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
        role = ChefData::DataNormalizer.normalize_role(role, request.rest_path[3])
        FFI_Yajl::Encoder.encode(role, :pretty => true)
      end
    end
  end
end