blob: 8a4220fd133616c1223a820fa1ab7696c96779f0 (
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
25
|
require 'ffi_yajl'
require 'chef_zero/endpoints/rest_list_endpoint'
module ChefZero
module Endpoints
# /organizations/ORG/containers
class ContainersEndpoint < RestListEndpoint
def initialize(server)
super(server, %w(id containername))
end
# create a container.
# input: {"containername"=>"new-container", "containerpath"=>"/"}
def post(request)
data = parse_json(request.body)
# if they don't match, id wins.
container_name = data["id"] || data["containername"]
container_path_suffix = data["containerpath"].split("/").reject { |o| o.empty? }
create_data(request, request.rest_path, container_name, to_json({}), :create_dir)
json_response(201, { uri: build_uri(request.base_uri, request.rest_path + container_path_suffix + [container_name]) })
end
end
end
end
|