summaryrefslogtreecommitdiff
path: root/lib/chef_zero/endpoints/container_endpoint.rb
blob: bf0a184a238194a32a063b451a33fb62886cda15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'ffi_yajl'
require 'chef_zero/endpoints/rest_object_endpoint'
require 'chef_zero/chef_data/data_normalizer'

module ChefZero
  module Endpoints
    # /organizations/ORG/containers/NAME
    class ContainerEndpoint < RestObjectEndpoint
      def initialize(server)
        super(server, %w(id containername))
      end

      undef_method(:put)

      def populate_defaults(request, response_json)
        container = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
        container = ChefData::DataNormalizer.normalize_container(container, request.rest_path[3])
        FFI_Yajl::Encoder.encode(container, :pretty => true)
      end
    end
  end
end