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


-- | An HTTP Performance Benchmarker
--   
--   <a>wrecker</a> is a library and executable for creating HTTP
--   benchmarks. It is designed for benchmarking a series of dependent
--   requests. <a>wrecker</a> includes a wrapped version of the <a>wreq</a>
--   Session API , mainly through <a>Network.Wreq.Wrecker</a>. See
--   <a>https://github.com/lorenzo/wrecker#readme</a> for more information.
@package wrecker
@version 1.3.1.0

module Wrecker.Logger
data LogLevel
LevelDebug :: LogLevel
LevelInfo :: LogLevel
LevelWarn :: LogLevel
LevelError :: LogLevel
data LogFormat
PlainText :: LogFormat
Json :: LogFormat
data Logger
Logger :: LogLevel -> LogFormat -> FastLogger -> IO () -> IO FormattedTime -> Logger
[currentLevel] :: Logger -> LogLevel
[logFormat] :: Logger -> LogFormat
[logFunc] :: Logger -> FastLogger
[cleanup] :: Logger -> IO ()
[timeFormatter] :: Logger -> IO FormattedTime

-- | Create a logger using stderr. This is the typical way a logger is
--   created.
newStdErrLogger :: LogLevel -> LogFormat -> IO Logger
writeLogger :: Logger -> LogLevel -> LogStr -> IO ()
formatMsg :: LogFormat -> LogLevel -> FormattedTime -> LogStr -> LogStr
formatLevel :: LogLevel -> LogStr
toLevelCode :: LogLevel -> Int
shutdownLogger :: Logger -> IO ()
logDebug :: ToLogStr msg => Logger -> msg -> IO ()
logInfo :: ToLogStr msg => Logger -> msg -> IO ()
logWarn :: ToLogStr msg => Logger -> msg -> IO ()
logError :: ToLogStr msg => Logger -> msg -> IO ()
instance GHC.Read.Read Wrecker.Logger.LogFormat
instance GHC.Show.Show Wrecker.Logger.LogFormat
instance GHC.Classes.Eq Wrecker.Logger.LogFormat
instance GHC.Read.Read Wrecker.Logger.LogLevel
instance GHC.Classes.Ord Wrecker.Logger.LogLevel
instance GHC.Classes.Eq Wrecker.Logger.LogLevel
instance GHC.Show.Show Wrecker.Logger.LogLevel

module Wrecker.Options

-- | There are two typical ways to invoke <tt>wrecker</tt>. <a>RunCount</a>
--   will execute each a script <tt>n</tt> times on each thread. So a run
--   count of 100 and a concurrency of 10 will run the script a total of
--   1000 times. Alternatively, <tt>wrecker</tt> can run for specified
--   number of seconds with <a>RunTimed</a>.
data RunType
RunCount :: Int -> RunType
RunTimed :: Int -> RunType

-- | <a>DisplayMode</a> controls how results are displayed in the console.
--   The default is <tt>NonInterative</tt> which returns the final results
--   at the end of the program. <a>Interactive</a> will show partial
--   results as the program updates.
data DisplayMode
Interactive :: DisplayMode
NonInteractive :: DisplayMode
data URLDisplay
Path :: URLDisplay
Full :: URLDisplay
data Options
Options :: Int -> Int -> RunType -> Int -> DisplayMode -> LogLevel -> LogFormat -> String -> Maybe Int -> Maybe FilePath -> Bool -> URLDisplay -> Bool -> Bool -> Options

-- | The number of simulatanous connections
[concurrency] :: Options -> Int

-- | The number of bins for the histogram
[binCount] :: Options -> Int

-- | runStyle determines if the <tt>wrecker</tt> runs for a specified time
--   period or for a specified number of runs.
[runStyle] :: Options -> RunType

-- | How long to wait after the first benchmark for the other threads to
--   finish
[timeoutTime] :: Options -> Int

-- | This controls the command line display. It can be either Interactive
--   of NonInteractive
[displayMode] :: Options -> DisplayMode

-- | The log severity to shown in stderr
[logLevel] :: Options -> LogLevel

-- | The log format to use in stderr (either Json or PlainText)
[logFmt] :: Options -> LogFormat

-- | Set this to filter the benchmarks using a pattern
[match] :: Options -> String

-- | Limit the request name column to the given size
[requestNameColumnSize] :: Options -> Maybe Int

-- | Dump the results to JSON file
[outputFilePath] :: Options -> Maybe FilePath

-- | Set <a>silent</a> to true to disable all output.
[silent] :: Options -> Bool

-- | Whether to display short of full URLs in the report
[urlDisplay] :: Options -> URLDisplay

-- | Set <a>recordQuery</a> to consider the query string as a different URL
[recordQuery] :: Options -> Bool

-- | Show the list of exposed test groups, if any
[listTestGroups] :: Options -> Bool

-- | <a>defaultOptions</a> provides sensible default for the <a>Options</a>
--   types
defaultOptions :: Options
data PartialOptions
PartialOptions :: Maybe Int -> Maybe Int -> Maybe RunType -> Maybe Int -> Maybe DisplayMode -> Maybe LogLevel -> Maybe LogFormat -> Maybe String -> Maybe Int -> Maybe FilePath -> Maybe Bool -> Maybe URLDisplay -> Maybe Bool -> Maybe Bool -> PartialOptions
[mConcurrency] :: PartialOptions -> Maybe Int
[mBinCount] :: PartialOptions -> Maybe Int
[mRunStyle] :: PartialOptions -> Maybe RunType
[mTimeoutTime] :: PartialOptions -> Maybe Int
[mDisplayMode] :: PartialOptions -> Maybe DisplayMode
[mLogLevel] :: PartialOptions -> Maybe LogLevel
[mLogFmt] :: PartialOptions -> Maybe LogFormat
[mMatch] :: PartialOptions -> Maybe String
[mRequestNameColumnSize] :: PartialOptions -> Maybe Int
[mOutputFilePath] :: PartialOptions -> Maybe FilePath
[mSilent] :: PartialOptions -> Maybe Bool
[murlDisplay] :: PartialOptions -> Maybe URLDisplay
[mRecordQuery] :: PartialOptions -> Maybe Bool
[mListTestGroups] :: PartialOptions -> Maybe Bool
completeOptions :: PartialOptions -> Maybe Options
optionalOption :: Read a => Mod OptionFields a -> Parser (Maybe a)
optionalStrOption :: Mod OptionFields String -> Parser (Maybe String)
optionalSwitch :: Mod FlagFields Bool -> Parser (Maybe Bool)
pPartialOptions :: Parser PartialOptions

-- | Run the command line parse and return the <a>Options</a>
runParser :: IO Options
instance GHC.Classes.Eq Wrecker.Options.PartialOptions
instance GHC.Show.Show Wrecker.Options.PartialOptions
instance GHC.Classes.Eq Wrecker.Options.Options
instance GHC.Show.Show Wrecker.Options.Options
instance GHC.Read.Read Wrecker.Options.URLDisplay
instance GHC.Classes.Eq Wrecker.Options.URLDisplay
instance GHC.Show.Show Wrecker.Options.URLDisplay
instance GHC.Read.Read Wrecker.Options.DisplayMode
instance GHC.Classes.Eq Wrecker.Options.DisplayMode
instance GHC.Show.Show Wrecker.Options.DisplayMode
instance GHC.Classes.Eq Wrecker.Options.RunType
instance GHC.Show.Show Wrecker.Options.RunType
instance GHC.Base.Monoid Wrecker.Options.PartialOptions

module Wrecker.Recorder
data RunResult
Success :: !Double -> !String -> RunResult
[resultTime] :: RunResult -> !Double
[name] :: RunResult -> !String
ErrorStatus :: !Double -> !Int -> !String -> RunResult
[resultTime] :: RunResult -> !Double
[errorCode] :: RunResult -> !Int
[name] :: RunResult -> !String
Error :: !Double -> !SomeException -> !String -> RunResult
[resultTime] :: RunResult -> !Double
[exception] :: RunResult -> !SomeException
[name] :: RunResult -> !String
RuntimeError :: RunResult
End :: RunResult
data Event
Event :: !Int -> !RunResult -> Event
[eRunIndex] :: Event -> !Int
[eResult] :: Event -> !RunResult

-- | An opaque type for recording actions for profiling. To obtain a
--   <a>Recorder</a> use either <tt>run</tt>, <tt>defaultMain</tt>,
--   <tt>runOne</tt> or <tt>newStandaloneRecorder</tt>.
data Recorder
Recorder :: !Bool -> !Int -> !(TBMQueue Event) -> Recorder
[rWithQuery] :: Recorder -> !Bool
[rRunIndex] :: Recorder -> !Int
[rQueue] :: Recorder -> !(TBMQueue Event)
newtype LogicError
LogicError :: String -> LogicError
newtype HandledError
HandledError :: SomeException -> HandledError
split :: Recorder -> Recorder
newRecorder :: Bool -> Int -> IO Recorder
stopRecorder :: Recorder -> IO ()
addEvent :: Recorder -> RunResult -> IO ()
readEvent :: Recorder -> IO (Maybe Event)

-- | <a>record</a> is a low level function for collecting timing
--   information. Wrap each action of interest in a call to record.
--   
--   <pre>
--   record recorder $ threadDelay 1000000
--   </pre>
--   
--   <a>record</a> measures the elapsed time of the call, and catches
--   <tt>HttpException</tt> in the case of failure. This means failures
--   must be thrown if they are to be properly recorded.
record :: forall a. Recorder -> String -> IO a -> IO a
instance GHC.Show.Show Wrecker.Recorder.HandledError
instance GHC.Show.Show Wrecker.Recorder.Event
instance GHC.Show.Show Wrecker.Recorder.RunResult
instance GHC.Exception.Exception Wrecker.Recorder.HandledError
instance GHC.Show.Show Wrecker.Recorder.LogicError
instance GHC.Exception.Exception Wrecker.Recorder.LogicError

module Wrecker.Statistics

-- | These are the
data Statistics
Statistics :: TDigest 5 -> {-# UNPACK #-} !Double -> Statistics

-- | A histogram of times
[sHistogram] :: Statistics -> TDigest 5

-- | The total time
[sTotal] :: Statistics -> {-# UNPACK #-} !Double

-- | AllStats has all of the ... stats. This type stores all of the
--   information <tt>wrecker</tt> uses to display metrics to the user.
data AllStats
AllStats :: !ResultStatistics -> !ResultStatistics -> !(HashMap Int ResultStatistics) -> !(HashMap String ResultStatistics) -> AllStats

-- | The "total" stats. This computes things like total 2xx and average
--   time Across all requests.
[aRollup] :: AllStats -> !ResultStatistics

-- | This contains statistic for actions that completed entirely
--   successfully. Useful for knowing if a complex action is under some
--   desired total time.
[aCompleteRuns] :: AllStats -> !ResultStatistics

-- | This is an intermediate holding spot for scripts that are still
--   executing.
[aRuns] :: AllStats -> !(HashMap Int ResultStatistics)

-- | This is the per key (URL) statistics.
[aPerUrl] :: AllStats -> !(HashMap String ResultStatistics)

-- | This type includes statistics for all of the result values we can
--   detect. This type is used by AllStats to compute per key (URL)
--   statistics among other uses.
data ResultStatistics
ResultStatistics :: !Statistics -> !Statistics -> !Statistics -> !Statistics -> !Statistics -> !Int -> !Int -> ResultStatistics
[rs2xx] :: ResultStatistics -> !Statistics
[rs4xx] :: ResultStatistics -> !Statistics
[rs5xx] :: ResultStatistics -> !Statistics
[rsFailed] :: ResultStatistics -> !Statistics
[rsRollup] :: ResultStatistics -> !Statistics
[rsTotalTests] :: ResultStatistics -> !Int
[rsTestsFailed] :: ResultStatistics -> !Int
stepAllStats :: AllStats -> Int -> String -> RunResult -> AllStats
emptyAllStats :: AllStats
printStats :: Options -> AllStats -> IO ()
pprStats :: Maybe Int -> URLDisplay -> AllStats -> String
instance GHC.Show.Show Wrecker.Statistics.AllStats
instance GHC.Show.Show Wrecker.Statistics.ResultStatistics
instance GHC.Show.Show Wrecker.Statistics.Statistics
instance Data.Aeson.Types.ToJSON.ToJSON Wrecker.Statistics.AllStats
instance Data.Aeson.Types.ToJSON.ToJSON Wrecker.Statistics.ResultStatistics
instance Data.Aeson.Types.ToJSON.ToJSON Wrecker.Statistics.Statistics

module Wrecker.Runner

-- | The <a>Environment</a> holds state necessary to make and record HTTP
--   calls.
data Environment
Environment :: Recorder -> ConnectionContext -> Logger -> Environment

-- | The <a>Recorder</a> can be used with the <tt>record</tt> function to
--   ... record times.
[recorder] :: Environment -> Recorder

-- | Provided as a convience, this is a shared TLS context to reuse for
--   better performance.
[context] :: Environment -> ConnectionContext
[logger] :: Environment -> Logger

-- | Typically <tt>wrecker</tt> will control benchmarking actions. However
--   in some situations a benchmark might require more control.
--   
--   To facilitate more complex scenarios <tt>wrecker</tt> provide
--   <a>newStandaloneRecorder</a> which provides a <a>Recorder</a> and
--   <tt>Thread</tt> that processes the events, and a reference to the
--   current stats.
newStandaloneRecorder :: IO (NextRef AllStats, Thread, Recorder)
sinkRecorder :: Recorder -> IO (NextRef AllStats, Thread)
updateSampler :: NextRef AllStats -> Event -> IO AllStats
collectEvent :: NextRef AllStats -> Recorder -> IO ()
runAction :: Logger -> Int -> Int -> RunType -> (Environment -> IO ()) -> Environment -> IO ()
runWithNextVar :: Options -> (NextRef AllStats -> IO ()) -> (NextRef AllStats -> IO ()) -> (Environment -> IO ()) -> IO AllStats
printLastSamples :: Options -> NextRef AllStats -> IO ()
runNonInteractive :: Options -> (Environment -> IO ()) -> IO AllStats
printLoop :: Options -> DisplayContext -> Vty -> NextRef AllStats -> IO ()
processInputForCtrlC :: TChan Event -> IO ThreadId
updateUI :: Maybe Int -> URLDisplay -> DisplayContext -> AllStats -> IO ()
runInteractive :: Options -> (Environment -> IO ()) -> IO AllStats

-- | <a>run</a> is the a lower level entry point, compared to
--   <tt>defaultMain</tt>. Unlike <tt>defaultMain</tt> no command line
--   argument parsing is performed. Instead, <a>Options</a> are directly
--   passed in. <a>defaultOptions</a> can be used as a default argument for
--   <a>run</a>.
--   
--   Like <tt>defaultMain</tt>, <a>run</a> creates a <a>Recorder</a> and
--   passes it each benchmark.
run :: Options -> [(String, Environment -> IO ())] -> IO (HashMap String AllStats)
showTestGroups :: [(String, Environment -> IO ())] -> IO ()

-- | Run a single benchmark
runOne :: Options -> (Environment -> IO ()) -> IO AllStats

module Wrecker.Main

-- | <a>defaultMain</a> is typically the main entry point for
--   <tt>wrecker</tt> benchmarks. <a>defaultMain</a> will parse all command
--   line arguments and then call <a>run</a> with the correct
--   <tt>Options</tt>.
--   
--   <pre>
--   import Wrecker
--   import Your.Performance.Scripts (landingPage, purchase)
--   
--   main :: IO ()
--   main = defaultMain
--    [ ("loginReshare", loginReshare)
--    , ("purchase"    , purchase    )
--    ]
--   </pre>
--   
--   To see the options defaultMain can parse call `--help`
--   
--   <pre>
--   $ wrecker-based-app --help
--   
--   wrecker - HTTP stress tester and benchmarker
--   
--   Usage: wreck [--concurrency ARG] [--bin-count ARG] ([--run-count ARG] |
--                [--run-timed ARG]) [--timeout-time ARG] ([--non-interactive] |
--                [--interactive]) [--log-level ARG] [--log-format ARG] [--match ARG]
--                [--request-name-size ARG] [--output-path ARG] [--silent]
--                ([--relative-url-display] | [--absolute-url-display])
--                [--record-query] [--list-test-groups]
--     Welcome to wrecker
--   
--   Available options:
--     -h,--help                Show this help text
--     --concurrency ARG        Number of threads for concurrent requests
--     --bin-count ARG          Number of bins for latency histogram
--     --run-count ARG          number of times to repeat
--     --run-timed ARG          number of seconds to repeat
--     --timeout-time ARG       How long to wait for all requests to finish
--     --log-level ARG          Log to stderr events of criticality greater than the
--                              LOG_LEVEL
--     --log-format ARG         Log format to use
--     --match ARG              Only run tests that match the glob
--     --request-name-size ARG  Request name size for the terminal display
--     --output-path ARG        Save a JSON file of the the statistics to given path
--     --silent                 Disable all output
--     --record-query           Take in consideration the query string for the report
--     --list-test-groups       Shows the list of tests to run and exit
--   </pre>
defaultMain :: [(String, Environment -> IO ())] -> IO ()


-- | <tt>wrecker</tt> is a library and executable for creating HTTP
--   benchmarks. It is designed for benchmarking a series of dependent
--   requests.
--   
--   <tt>wrecker</tt> includes a wrapped version of the <tt>wreq</tt>
--   Session API, mainly through Network.Wreq.Wrecker.
--   
--   import <a>Wrecker</a> to write clients and <tt>Wrecker</tt> to run the
--   them with either <a>defaultMain</a> or <a>run</a>.
--   
--   See <a>https://github.com/lorenzo/wrecker#readme</a> for more
--   information.
module Wrecker

-- | <a>defaultMain</a> is typically the main entry point for
--   <tt>wrecker</tt> benchmarks. <a>defaultMain</a> will parse all command
--   line arguments and then call <a>run</a> with the correct
--   <tt>Options</tt>.
--   
--   <pre>
--   import Wrecker
--   import Your.Performance.Scripts (landingPage, purchase)
--   
--   main :: IO ()
--   main = defaultMain
--    [ ("loginReshare", loginReshare)
--    , ("purchase"    , purchase    )
--    ]
--   </pre>
--   
--   To see the options defaultMain can parse call `--help`
--   
--   <pre>
--   $ wrecker-based-app --help
--   
--   wrecker - HTTP stress tester and benchmarker
--   
--   Usage: wreck [--concurrency ARG] [--bin-count ARG] ([--run-count ARG] |
--                [--run-timed ARG]) [--timeout-time ARG] ([--non-interactive] |
--                [--interactive]) [--log-level ARG] [--log-format ARG] [--match ARG]
--                [--request-name-size ARG] [--output-path ARG] [--silent]
--                ([--relative-url-display] | [--absolute-url-display])
--                [--record-query] [--list-test-groups]
--     Welcome to wrecker
--   
--   Available options:
--     -h,--help                Show this help text
--     --concurrency ARG        Number of threads for concurrent requests
--     --bin-count ARG          Number of bins for latency histogram
--     --run-count ARG          number of times to repeat
--     --run-timed ARG          number of seconds to repeat
--     --timeout-time ARG       How long to wait for all requests to finish
--     --log-level ARG          Log to stderr events of criticality greater than the
--                              LOG_LEVEL
--     --log-format ARG         Log format to use
--     --match ARG              Only run tests that match the glob
--     --request-name-size ARG  Request name size for the terminal display
--     --output-path ARG        Save a JSON file of the the statistics to given path
--     --silent                 Disable all output
--     --record-query           Take in consideration the query string for the report
--     --list-test-groups       Shows the list of tests to run and exit
--   </pre>
defaultMain :: [(String, Environment -> IO ())] -> IO ()

-- | <a>run</a> is the a lower level entry point, compared to
--   <tt>defaultMain</tt>. Unlike <tt>defaultMain</tt> no command line
--   argument parsing is performed. Instead, <a>Options</a> are directly
--   passed in. <a>defaultOptions</a> can be used as a default argument for
--   <a>run</a>.
--   
--   Like <tt>defaultMain</tt>, <a>run</a> creates a <a>Recorder</a> and
--   passes it each benchmark.
run :: Options -> [(String, Environment -> IO ())] -> IO (HashMap String AllStats)

-- | Run a single benchmark
runOne :: Options -> (Environment -> IO ()) -> IO AllStats

-- | The <a>Environment</a> holds state necessary to make and record HTTP
--   calls.
data Environment
Environment :: Recorder -> ConnectionContext -> Logger -> Environment

-- | The <a>Recorder</a> can be used with the <tt>record</tt> function to
--   ... record times.
[recorder] :: Environment -> Recorder

-- | Provided as a convience, this is a shared TLS context to reuse for
--   better performance.
[context] :: Environment -> ConnectionContext
[logger] :: Environment -> Logger

-- | An opaque type for recording actions for profiling. To obtain a
--   <a>Recorder</a> use either <tt>run</tt>, <tt>defaultMain</tt>,
--   <tt>runOne</tt> or <tt>newStandaloneRecorder</tt>.
data Recorder
newtype LogicError
LogicError :: String -> LogicError

-- | <a>record</a> is a low level function for collecting timing
--   information. Wrap each action of interest in a call to record.
--   
--   <pre>
--   record recorder $ threadDelay 1000000
--   </pre>
--   
--   <a>record</a> measures the elapsed time of the call, and catches
--   <tt>HttpException</tt> in the case of failure. This means failures
--   must be thrown if they are to be properly recorded.
record :: forall a. Recorder -> String -> IO a -> IO a
data Options
Options :: Int -> Int -> RunType -> Int -> DisplayMode -> LogLevel -> LogFormat -> String -> Maybe Int -> Maybe FilePath -> Bool -> URLDisplay -> Bool -> Bool -> Options

-- | The number of simulatanous connections
[concurrency] :: Options -> Int

-- | The number of bins for the histogram
[binCount] :: Options -> Int

-- | runStyle determines if the <tt>wrecker</tt> runs for a specified time
--   period or for a specified number of runs.
[runStyle] :: Options -> RunType

-- | How long to wait after the first benchmark for the other threads to
--   finish
[timeoutTime] :: Options -> Int

-- | This controls the command line display. It can be either Interactive
--   of NonInteractive
[displayMode] :: Options -> DisplayMode

-- | The log severity to shown in stderr
[logLevel] :: Options -> LogLevel

-- | The log format to use in stderr (either Json or PlainText)
[logFmt] :: Options -> LogFormat

-- | Set this to filter the benchmarks using a pattern
[match] :: Options -> String

-- | Limit the request name column to the given size
[requestNameColumnSize] :: Options -> Maybe Int

-- | Dump the results to JSON file
[outputFilePath] :: Options -> Maybe FilePath

-- | Set <a>silent</a> to true to disable all output.
[silent] :: Options -> Bool

-- | Whether to display short of full URLs in the report
[urlDisplay] :: Options -> URLDisplay

-- | Set <a>recordQuery</a> to consider the query string as a different URL
[recordQuery] :: Options -> Bool

-- | Show the list of exposed test groups, if any
[listTestGroups] :: Options -> Bool
data URLDisplay
Path :: URLDisplay
Full :: URLDisplay

-- | There are two typical ways to invoke <tt>wrecker</tt>. <a>RunCount</a>
--   will execute each a script <tt>n</tt> times on each thread. So a run
--   count of 100 and a concurrency of 10 will run the script a total of
--   1000 times. Alternatively, <tt>wrecker</tt> can run for specified
--   number of seconds with <a>RunTimed</a>.
data RunType
RunCount :: Int -> RunType
RunTimed :: Int -> RunType

-- | <a>DisplayMode</a> controls how results are displayed in the console.
--   The default is <tt>NonInterative</tt> which returns the final results
--   at the end of the program. <a>Interactive</a> will show partial
--   results as the program updates.
data DisplayMode
Interactive :: DisplayMode
NonInteractive :: DisplayMode

-- | <a>defaultOptions</a> provides sensible default for the <a>Options</a>
--   types
defaultOptions :: Options

-- | AllStats has all of the ... stats. This type stores all of the
--   information <tt>wrecker</tt> uses to display metrics to the user.
data AllStats
AllStats :: !ResultStatistics -> !ResultStatistics -> !(HashMap Int ResultStatistics) -> !(HashMap String ResultStatistics) -> AllStats

-- | The "total" stats. This computes things like total 2xx and average
--   time Across all requests.
[aRollup] :: AllStats -> !ResultStatistics

-- | This contains statistic for actions that completed entirely
--   successfully. Useful for knowing if a complex action is under some
--   desired total time.
[aCompleteRuns] :: AllStats -> !ResultStatistics

-- | This is an intermediate holding spot for scripts that are still
--   executing.
[aRuns] :: AllStats -> !(HashMap Int ResultStatistics)

-- | This is the per key (URL) statistics.
[aPerUrl] :: AllStats -> !(HashMap String ResultStatistics)

-- | This type includes statistics for all of the result values we can
--   detect. This type is used by AllStats to compute per key (URL)
--   statistics among other uses.
data ResultStatistics
ResultStatistics :: !Statistics -> !Statistics -> !Statistics -> !Statistics -> !Statistics -> !Int -> !Int -> ResultStatistics
[rs2xx] :: ResultStatistics -> !Statistics
[rs4xx] :: ResultStatistics -> !Statistics
[rs5xx] :: ResultStatistics -> !Statistics
[rsFailed] :: ResultStatistics -> !Statistics
[rsRollup] :: ResultStatistics -> !Statistics
[rsTotalTests] :: ResultStatistics -> !Int
[rsTestsFailed] :: ResultStatistics -> !Int


-- | This is a copy of the <tt>wreq</tt> <a>Session</a>, but each call is
--   wrapped in <tt>wrecker'</tt>s <a>record</a> function.
--   
--   This file was initially copied from Network.Wreq.Session (c) 2014
--   Bryan O'Sullivan. See the source for the full copy right info.
module Network.Wreq.Wrecker

-- | An opaque type created by <a>withWreq</a>, <a>withWreqNoCookies</a>,
--   or <a>withWreqSettings</a>. All HTTP calls require a <a>Session</a>.
data Session

-- | Create <tt>ManagerSettings</tt> with no timeout using a shared TLS
--   <a>ConnectionContext</a>
defaultManagerSettings :: ConnectionContext -> ManagerSettings

-- | Replaces the record function of the Session with the provided one.
--   
--   This is useful for custom recorder actions, or if you need to catch
--   any exceptions thrown by the IO action and don't wish them to bubble
--   up to the statistics.
withRecordFunction :: (forall a. Recorder -> String -> IO a -> IO a) -> Session -> Session

-- | Create a <a>Session</a> using the <tt>wrecker</tt> <a>Environment</a>,
--   passing it to the given function. The <a>Session</a> will no longer be
--   valid after that function returns.
--   
--   This session manages cookies and uses default session manager
--   configuration.
withWreq :: (Session -> IO a) -> Environment -> IO a

-- | Create a session.
--   
--   This uses the default session manager settings, but does not manage
--   cookies. It is intended for use with REST-like HTTP-based APIs, which
--   typically do not use cookies.
withWreqNoCookies :: (Session -> IO a) -> Environment -> IO a

-- | Create a session, using the given cookie jar and manager settings.
withWreqSettings :: Recorder -> Logger -> Maybe CookieJar -> ManagerSettings -> (Session -> IO a) -> IO a
logDebug :: ToLogStr msg => Session -> msg -> IO ()
logInfo :: ToLogStr msg => Session -> msg -> IO ()
logWarn :: ToLogStr msg => Session -> msg -> IO ()
logError :: ToLogStr msg => Session -> msg -> IO ()
data Logger

-- | <a>Session</a>-specific version of <a>get</a>.
get :: Session -> String -> IO (Response ByteString)

-- | <a>Session</a>-specific version of <a>post</a>.
post :: Postable a => Session -> String -> a -> IO (Response ByteString)

-- | <a>Session</a>-specific version of <a>head_</a>.
head_ :: Session -> String -> IO (Response ())

-- | <a>Session</a>-specific version of <a>options</a>.
options :: Session -> String -> IO (Response ())

-- | <a>Session</a>-specific version of <a>put</a>.
put :: Putable a => Session -> String -> a -> IO (Response ByteString)

-- | <a>Session</a>-specific version of <a>delete</a>.
delete :: Session -> String -> IO (Response ByteString)

-- | <a>Session</a>-specific version of <a>getWith</a>.
getWith :: Options -> Session -> String -> IO (Response ByteString)

-- | <a>Session</a>-specific version of <a>postWith</a>.
postWith :: Postable a => Options -> Session -> String -> a -> IO (Response ByteString)

-- | <a>Session</a>-specific version of <a>headWith</a>.
headWith :: Options -> Session -> String -> IO (Response ())

-- | <a>Session</a>-specific version of <a>optionsWith</a>.
optionsWith :: Options -> Session -> String -> IO (Response ())

-- | <a>Session</a>-specific version of <a>putWith</a>.
putWith :: Putable a => Options -> Session -> String -> a -> IO (Response ByteString)

-- | <a>Session</a>-specific version of <a>deleteWith</a>.
deleteWith :: Options -> Session -> String -> IO (Response ByteString)

-- | <a>Session</a>-specific version of <a>get</a> that expects a JSON
--   response.
getJSON :: FromJSON a => Session -> String -> IO (Response a)

-- | <a>Session</a>-specific version of <a>getWith</a> that expects a JSON
--   response.
getJSONWith :: FromJSON a => Options -> Session -> String -> IO (Response a)

-- | <a>Session</a>-specific version of <a>post</a> that expects a JSON
--   response.
postJSON :: (Postable a, FromJSON b) => Session -> String -> a -> IO (Response b)

-- | <a>Session</a>-specific version of <a>postWith</a> that expects a JSON
--   response.
postJSONWith :: (Postable a, FromJSON b) => Options -> Session -> String -> a -> IO (Response b)

-- | <a>Session</a>-specific version of <a>put</a> that expects a JSON
--   response.
putJSON :: (Putable a, FromJSON b) => Session -> String -> a -> IO (Response b)

-- | <a>Session</a>-specific version of <a>putWith</a> that expects a JSON
--   response.
putJSONWith :: (Putable a, FromJSON b) => Options -> Session -> String -> a -> IO (Response b)

-- | <a>Session</a>-specific version of <a>delete</a> that expects a JSON
--   response.
deleteJSON :: FromJSON a => Session -> String -> IO (Response a)

-- | <a>Session</a>-specific version of <a>deleteWith</a> that expects a
--   JSON response.
deleteJSONWith :: FromJSON a => Options -> Session -> String -> IO (Response a)


-- | This module can be used to describe the operations that can be
--   performed against an external API that uses JSON as its serialization
--   format.
--   
--   It exposes functions tailored to get and post data in the JSON format
--   and to unserialize the responses into types that can be converted form
--   JSON.
--   
--   Use the <a>Ref</a> and <a>RPC</a> types to describe the external API
--   operations.
module Network.Wreq.Wrecker.API

-- | A Ref represents an API resource whose contents can be retrieved with
--   GET
--   
--   We use the phantom type parameter <tt>response</tt> so that we can use
--   this information for understanding what type of data the API resource
--   will return
--   
--   For example, an API endpoint returning a list of User is modelled as
--   follows:
--   
--   <pre>
--   usersRef :: Ref [User]
--   usersRef = Ref "http://localhost:8080/users"
--   </pre>
data Ref response
Ref :: Text -> Ref response
[unRef] :: Ref response -> Text

-- | A Req represents an API resource whose contents can be retrieved with
--   POST
--   
--   We use the phantom type parameter <tt>response</tt> so that we can use
--   this information for understanding what type of data the API resource
--   will return
--   
--   Similarly, the request parameter is used to know what type of data can
--   be posted to the endpoint.
--   
--   For example, an API endpoint that receives a User and returns a list
--   of Friendship is modelled as follows:
--   
--   <pre>
--   newFriendRpc :: User -&gt; RPC [Friendship] User
--   newFriendRpc User { userID } = RPC "http://localhost:8080/users/" &lt;&gt; userID &lt;&gt; "/friendships"
--   </pre>
newtype RPC response request
RPC :: Text -> RPC response request
[rpcUrl] :: RPC response request -> Text

-- | Gets the results form an API endpoint that responds in the JSON
--   format.
--   
--   <pre>
--   users &lt;- get sess usersRef
--   mapM_ (print . userID) users
--   </pre>
get :: FromJSON a => Session -> Ref a -> IO a

-- | Posts some data to an API endpoint in any <a>Postable</a> format and
--   gets the response in JSON format.
--   
--   <pre>
--   Friendships friends &lt;- post sess (newFriendRpc user) user2
--   mapM_ (print . userID) friends
--   </pre>
post :: (Postable req, FromJSON res) => Session -> RPC res req -> req -> IO res

-- | Puts some data to an API endpoint in any <a>Putable</a> format and
--   gets the response in JSON format.
--   
--   <pre>
--   Friendships friends &lt;- put sess (newFriendRpc user) user2
--   mapM_ (print . userID) friends
--   </pre>
put :: (Putable req, FromJSON res) => Session -> RPC res req -> req -> IO res

-- | Posts some data to an API endpoint in any JSON format and gets the
--   response in JSON format.
--   
--   <pre>
--   Friendships friends &lt;- post sess (newFriendRpc user) user2
--   mapM_ (print . userID) friends
--   </pre>
rpc :: (ToJSON req, FromJSON res) => Session -> RPC res req -> req -> IO res

-- | Sends as DELETE request to an API endpoint that responds in the JSON
--   format.
--   
--   <pre>
--   Status { success } &lt;- delete sess usersDeleteRef
--   </pre>
delete :: FromJSON a => Session -> Ref a -> IO a

-- | Gets the results form an API endpoint that responds in the JSON
--   format. This function excepts additional options, such as custom
--   headers
--   
--   <pre>
--   let opts = Network.Wreq.defaults &amp; Network.Wreq.auth ?~ Network.Wreq.basicAuth "user" "pass"
--   users &lt;- getWith opts sess usersRef
--   mapM_ (print . userID) users
--   </pre>
getWith :: FromJSON a => Options -> Session -> Ref a -> IO a

-- | Posts some data to an API endpoint in any <a>Postable</a> format and
--   gets the response in JSON format. This function excepts additional
--   options, such as custom headers
--   
--   <pre>
--   let opts = Network.Wreq.defaults &amp; Network.Wreq.auth ?~ Network.Wreq.basicAuth "user" "pass"
--   Friendships friends &lt;- post sess (newFriendRpc user) user2
--   mapM_ (print . userID) friends
--   </pre>
postWith :: (Postable req, FromJSON res) => Options -> Session -> RPC res req -> req -> IO res

-- | Puts some data to an API endpoint in any <a>Putable</a> format and
--   gets the response in JSON format. This function excepts additional
--   options, such as custom headers
--   
--   <pre>
--   let opts = Network.Wreq.defaults &amp; Network.Wreq.auth ?~ Network.Wreq.basicAuth "user" "pass"
--   Friendships friends &lt;- put sess (newFriendRpc user) user2
--   mapM_ (print . userID) friends
--   </pre>
putWith :: (Putable req, FromJSON res) => Options -> Session -> RPC res req -> req -> IO res

-- | Posts some data to an API endpoint in any JSON format and gets the
--   response in JSON format. This function excepts additional options,
--   such as custom headers
--   
--   <pre>
--   let opts = Network.Wreq.defaults &amp; Network.Wreq.auth ?~ Network.Wreq.basicAuth "user" "pass"
--   Friendships friends &lt;- post sess (newFriendRpc user) user2
--   mapM_ (print . userID) friends
--   </pre>
rpcWith :: (ToJSON req, FromJSON res) => Options -> Session -> RPC res req -> req -> IO res

-- | Sends as DELETE request to an API endpoint that responds in the JSON
--   format. This function excepts additional options, such as custom
--   headers
--   
--   <pre>
--   let opts = Network.Wreq.defaults &amp; Network.Wreq.auth ?~ Network.Wreq.basicAuth "user" "pass"
--   Status { success } &lt;- deleteWith opts sess usersDeleteRef
--   </pre>
deleteWith :: FromJSON a => Options -> Session -> Ref a -> IO a
query :: [(Text, Text)] -> Text
instance GHC.Classes.Eq (Network.Wreq.Wrecker.API.RPC response request)
instance GHC.Show.Show (Network.Wreq.Wrecker.API.RPC response request)
instance GHC.Classes.Eq (Network.Wreq.Wrecker.API.Ref response)
instance GHC.Show.Show (Network.Wreq.Wrecker.API.Ref response)
instance Data.Aeson.Types.FromJSON.FromJSON (Network.Wreq.Wrecker.API.RPC a b)
instance Data.Aeson.Types.FromJSON.FromJSON (Network.Wreq.Wrecker.API.Ref a)
instance Network.Wreq.Internal.Types.Postable [(Data.Text.Internal.Text, Data.Text.Internal.Text)]
instance Network.Wreq.Internal.Types.Postable ()
