             [cheshire.core :as json]
             [puppetlabs.http.client.sync :as http-client])
   (:import (java.io File)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Schemas
+
+(def PuppetConfFiles
+  {schema/Str (schema/pred (some-fn string? #(instance? File %)))})
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Default settings

  ([puppet-conf-file]
   (with-puppet-conf puppet-conf-file conf-dir))
  ([puppet-conf-file dest-dir]
   (with-puppet-conf-files {"puppet.conf" puppet-conf-file} dest-dir)))
   ssl-request-options
   {:headers     {"Accept" "pson"}
    :as          :text}))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Internal functions

(schema/defn ^:always-validate get-with-puppet-conf-target-paths :- PuppetConfFiles
  "Helper function that joins the filename onto the dest-dir for each file in
  puppet-conf-files."
  [puppet-conf-files :- PuppetConfFiles
   dest-dir :- schema/Str]
  (reduce
   (fn [acc filename]
     (assoc acc filename (fs/file dest-dir filename)))
   {}
   (keys puppet-conf-files)))

(schema/defn ^:always-validate copy-with-puppet-conf-files-into-place!
  "Copies each file in puppet-conf-files into the corresponding destination in
  target-paths."
  [puppet-conf-files :- PuppetConfFiles
   target-paths :- PuppetConfFiles]
  (doseq [filename (keys puppet-conf-files)]
    (fs/copy+ (get puppet-conf-files filename)
              (get target-paths filename))))

(schema/defn ^:always-validate cleanup-with-puppet-conf-files!
  "Deletes all of the files in the target-paths map."
  [target-paths :- PuppetConfFiles]
  (doseq [target-path (vals target-paths)]
    (fs/delete target-path)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Utilities
