syncthing-hs-0.2.0.0: Haskell bindings for the Syncthing REST API

Safe HaskellNone
LanguageHaskell2010

Network.Syncthing.Internal

Contents

Description

Internal constructors and helper functions. You should NOT use this module under normal circumstances!

Synopsis

Configuration

data SyncConfig Source

The Syncthing configuration for specifying the Syncthing server, authentication, the API Key etc.

Instances

pServer :: Lens' SyncConfig Server Source

A lens for configuring the server address. Use the ADDRESS:PORT format.

Example:

let cfg = defaultConfig & pServer .~ "192.168.0.10:8080"
syncthing cfg Get.ping

pApiKey :: Lens' SyncConfig (Maybe Text) Source

A lens for specifying the Syncthing API Key.

Example:

let cfg = defaultConfig & pApiKey ?~ "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
syncthing cfg Get.ping

pAuth :: Lens' SyncConfig (Maybe Auth) Source

A lens for configuring request authentication provided by the Wreq package (see Auth).

Example:

import qualified Network.Wreq as Wreq

let cfg = defaultConfig & pHttps .~ True
                        & pAuth  ?~ Wreq.basicAuth "user" "pass"
syncthing cfg Get.ping

pHttps :: Lens' SyncConfig Bool Source

A lens for enabling HTTPS usage.

Example:

let cfg = defaultConfig & pHttps .~ True
syncthing cfg Get.ping

pManager :: Lens' SyncConfig (Either ManagerSettings Manager) Source

A lens for specifying your own ManagerSettings/Manager. For more information, please refer to the Network.HTTP.Client package.

The Syncthing Monad

type SyncResult a = Either SyncError a Source

The result type of Syncthing requests.

newtype SyncM m a Source

The SyncM Monad represents one or multiple Syncthing requests.

Constructors

SyncM 

Instances

Monad m => Monad (SyncM m) 
Monad m => Functor (SyncM m) 
Monad m => Applicative (SyncM m) 

class Monad m => MonadSync m where Source

Instances

MonadSync IO

Use Wreq's getWith and postWith functions when running in IO

runSyncM :: SyncConfig -> SyncM m a -> m (SyncResult a) Source

Run Syncthing requests without error handling.

syncthingM :: MonadCatch m => SyncConfig -> SyncM m a -> m (SyncResult a) Source

Run Syncthing requests with error handling.

liftInner :: Monad m => m a -> SyncM m a Source

liftRight :: Monad m => a -> SyncM m a Source

Requests

type Param = (Text, Text) Source

data HttpMethod Source

Constructors

Get 
Post Value 

Error Handling

Utils

parseAddr :: Server -> Addr Source

Parse server string (SERVER:PORT) into an address type.

encodeAddr :: Addr -> Server Source

Generate server string.

toUTC :: String -> Maybe UTCTime Source

Convert time string to UTCTime type.

fromUTC :: UTCTime -> String Source

Generate time string from UTC.