   OpenShift provided admin credentials for zero conf deployment."
   (str (System/getenv "OPENSHIFT_MONGODB_DB_URL") db-name))
 
+;-- Jelastic
+
+(defn is-jelastic? []
+  (= "jelastic" (str (System/getenv "environment"))))
+
+(defn jelastic-uri [uid pwd]
+  "Get Jelastic MongoDB URI. 'uid' and 'pwd' are ignored, defined in
+  jelastic environemnt configuration file."
+  (str (System/getenv "mongo_url")))
+
 ;-- Heroku
 
 (defn is-heroku? []

(ns notes.paas
  (:require
   [clojure.java.io :as io]
   [clojure.data.json :as json]))

(def db-name "notes")


  autogenerated"
  (System/getenv "MONGOHQ_URL"))

;-- CloudFoundry

(defn is-cloudfoundry? []
  true)
;  (System/getenv "VCAP_APPLICATION"))

(defn cloudfoundry-uri [uid pwd]
  "Get Heroku/MongoHQ MongoDB URI. 'uid' and 'pwd' are ignored, instead uses
  Heroku provided admin credentials for zero conf deployment. DB name is
  autogenerated"
  ;  (get-in (System/getenv "VCAP_SERVICES") ["mongolab-n/a" 0 "credentials" "uri"])
  "mongodb://CloudFoundry_5nac5lb1_sjp9n8un_ht7pj0dj:1W0hC969Q4IuTOFhc-epBTW0jA4zMa6H@ds039778.mongolab.com:39778/CloudFoundry_5nac5lb1_sjp9n8un")

(defn mongo-connection-uri [uid pwd]
  "Try to figure out runtime environment and resolve associated MongoDB
connection URI. Defaults to localhost and standard port"
  (cond (is-dotcloud?) (dotcloud-uri uid pwd)
    (is-open-shift?) (open-shift-uri uid pwd)
    (is-jelastic?) (jelastic-uri uid pwd)
    (is-heroku?) (heroku-uri uid pwd)
    (is-cloudfoundry?) (cloudfoundry-uri uid pwd)
    :else (localhost-uri uid pwd)))

;{"mongolab-n/a":
;  [
;      { "name":"mongolab-97f12",
;        "label":"mongolab-n/a",
;         "tags":[],
;        "plan":"sandbox",
;          "credentials":{"uri":"mongodb://CloudFoundry_5nac5lb1_sjp9n8un_g25hk2k0:U83Fy9e-FYByBMJBIlpHLzjM7fm3n8ey@ds039778.mongolab.com:39778/CloudFoundry_5nac5lb1_sjp9n8un"}}]}
;;Roadmap:
;Jelastic
;AWS Beanstalk
