add implementation and tests

Signed-off-by: Victor Vieux <vieux@docker.com>
update api

Signed-off-by: Victor Vieux <vieux@docker.com>