         p12-file (get-p12 instance-id auth-token)]
     (get-filtered-surveys {:host host
                            :iam-account iam-account
-                           :p12-path (.getAbsolutePath p12-file)
-                           }
+                           :p12-path (.getAbsolutePath p12-file)}
                           email
                           "24109115"))
+
+  (def auth-token (System/getenv "GITHUB_API_KEY"))
+  (def instance-map (get-instance-map auth-token))
+
+  (remote-api-spec instance-map "akvoflow-uat1")
+  (with-remote-api (remote-api-spec instance-map "akvoflow-uat1")
+    (get-survey-definition "" "31929121"))
+
+  )

(defn to-iso-8601 [date]
  (.format date-format (.toInstant date)))


(defn get-filtered-folders [spec email parent-id]
  (with-remote-api spec


      (->> user-surveys
           (map (fn [survey]
                  {:id (str (id survey))
                   :name (.getName survey)
                   :folder-id (str (.getParentId survey))
                   :created-at (created-at survey)
                   :modified-at (modified-at survey)}))
           (filter #(= (:folder-id %) folder-id))))))

(defn ->question [question]
  {:id (str (id question))
   :name (.getText question)
   :type (str (.getType question))
   :order (.getOrder question)
   :created-at (created-at question)
   :modified-at (modified-at question)})



(defn question-group-definition [question-group questions]
  (let [qs (sort-by :order (map ->question questions))]
    {:id (str (id question-group))
     :name (.getName question-group)
     :repeatable? (.getRepeatable question-group)
     :questions qs
     :created-at (created-at question-group)
     :modified-at (modified-at question-group)}))

(defn get-form-definition [email form-id]
  (let [form-dao (com.gallatinsystems.survey.dao.SurveyDAO.)
        ;; Includes question groups, but contrary to docstring does not contain questions
        form (.loadFullSurvey form-dao form-id)
        question-dao (com.gallatinsystems.survey.dao.QuestionDao.)
        questions (group-by #(.getQuestionGroupId %)
                            (.listQuestionsBySurvey question-dao form-id))]
    {:id (str (id form))
     :name (.getName form)
     :question-groups (mapv (fn [question-group]
                              (question-group-definition question-group
                                                         (get questions
                                                              (id question-group))))
                            (.values (.getQuestionGroupMap form)))
     :created-at (created-at form)
     :modified-at (modified-at form)}))

(defn get-survey-definition [email survey-id]
  (let [user-dao (UserDao.)
        user (.findUserByEmail user-dao email)
        survey-dao (com.gallatinsystems.survey.dao.SurveyGroupDAO.)
        survey (.getByKey survey-dao (Long/parseLong survey-id))
        form-dao (com.gallatinsystems.survey.dao.SurveyDAO.)
        forms (.filterByUserAuthorizationObjectId form-dao
                                                  (.listSurveysByGroup form-dao (Long/parseLong survey-id))
                                                  (id user))]
    {:id survey-id
     :name (.getName survey)
     :forms (mapv #(get-form-definition email (id %))
                  forms)
     :created-at (created-at survey)
     :modified-at (modified-at survey)}))

(defn contents-url [path]
  (format "https://api.github.com/repos/akvo/akvo-flow-server-config/contents%s" path))
