-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A library getting the environment when running on Cloud Foundry
--   
--   This is a port of go-cfenv for Golang. The purpose of this library is
--   to assist you in writing Haskell apps that run on Cloud Foundry. It
--   provides convenience functions and structures that map to Cloud
--   Foundry environment variable primitives.
@package cfenv
@version 0.1.0.0


-- | The purpose of this library is to assist you in writing Haskell apps
--   that run on Cloud Foundry. It provides convenience functions and
--   structures that map to Cloud Foundry environment variable primitives.
--   
--   This package is a port of
--   <a>https://github.com/cloudfoundry-community/go-cfenv</a>
module System.CloudFoundry.Environment

-- | Get the current Cloud Foundry environment.
--   
--   Example using <tt>scotty</tt>:
--   
--   <pre>
--   import Data.String (fromString)
--   import Data.Monoid (mconcat)
--   
--   import Web.Scotty
--   
--   import qualified System.CloudFoundry.Environment as CfEnv
--   
--   main = do
--     app &lt;- CfEnv.current
--   
--     scotty (CfEnv.port app) $
--       get "/" $ do
--         html $ mconcat ["&lt;pre&gt;", (fromString (show app)), "&lt;/pre&gt;"]
--   </pre>
current :: IO Application

-- | Detect if the application is running as a Cloud Foundry application.
--   
--   <pre>
--   import System.CloudFoundry.Environment CfEnv
--   
--   main :: IO ()
--   main = do
--       isRunningOnCf &lt;- CfEnv.isRunningOnCf
--   
--       if isRunningOnCf
--           then putStrLn "Running on Cloud Foundry"
--           else putStrLn "Not running on Cloud Foundry"
--   </pre>
isRunningOnCf :: IO Bool

-- | Get the current Cloud Foundry environment and return the result in a
--   Maybe. See <a>current</a>.
lookupCurrent :: IO (Maybe Application)

-- | Get a credential string from a service.
credentialString :: String -> Service -> Maybe String

-- | Get the services by label.
withLabel :: String -> Services -> [Service]

-- | Get the service by name.
withName :: String -> Services -> Maybe Service

-- | Get all services which have the provided tag.
withTag :: String -> Services -> [Service]

-- | Holds information about the current app running on Cloud Foundry. This
--   is returned from <tt>current</tt>.
data Application
Application :: String -> [String] -> String -> String -> String -> String -> Int -> Limits -> String -> String -> String -> Int -> Services -> String -> String -> String -> String -> String -> Application

-- | ID of the application
[appId] :: Application -> String

-- | Application URI of the app
[applicationUris] :: Application -> [String]

-- | URL for the Cloud Foundry API endpoint
[cfApi] :: Application -> String

-- | Root folder for the deployed app
[home] :: Application -> String

-- | Host of the app
[host] :: Application -> String

-- | ID of the instance
[instanceId] :: Application -> String

-- | Index of the app
[index] :: Application -> Int

-- | Limits imposed on this process
[limits] :: Application -> Limits

-- | Maximum amount of memory that each instance of the application can
--   consume
[memoryLimit] :: Application -> String

-- | Name of the app
[appName] :: Application -> String

-- | Present working directory, where the buildpack that processed the
--   application ran
[pwd] :: Application -> String

-- | Port which the app must listen on to receive traffic
[port] :: Application -> Int

-- | Services bound to the app
[services] :: Application -> Services

-- | ID of the space
[spaceId] :: Application -> String

-- | Name of the space
[spaceName] :: Application -> String

-- | Directory location where temporary and staging files are stored
[tmpDir] :: Application -> String

-- | User account under which the app instance runs
[user] :: Application -> String

-- | Version of the app
[version] :: Application -> String
data Limits
Limits :: Int -> Int -> Int -> Limits

-- | Disk limit
[disk] :: Limits -> Int

-- | File descriptors limit
[fds] :: Limits -> Int

-- | Memory limit
[mem] :: Limits -> Int

-- | Description of a bound service. Use <tt>credentialString</tt> to
--   extract the connection details.
data Service
Service :: String -> String -> [String] -> String -> Map String String -> Service
[name] :: Service -> String
[label] :: Service -> String
[tags] :: Service -> [String]
[plan] :: Service -> String
[credentials] :: Service -> Map String String

-- | A collection of <a>Service</a> instances. <tt>withTag</tt>,
--   <tt>withName</tt> and <tt>withLabel</tt> can be used to find the
--   specific services that you want.
newtype Services
Services :: Map String [Service] -> Services

-- | Exceptions which are raised from this package.
data CfEnvError

-- | Thrown when a JSON decode failed for either the VCAP_APPLICATION or
--   VCAP_SERIVCES environment variables.
DecodeError :: String -> String -> CfEnvError

-- | Thrown when an environment variable which is meant to contain an
--   integer contains invalid characters.
NotInteger :: String -> String -> CfEnvError
