@hackage / syncthing-hs

Haskell bindings for the Syncthing REST API

Latest0.3.0.0

About

Metadata

  • Last updated , by JensThomas
  • License BSD-3-Clause
  • Categories Network Development
  • Maintained by: jetho@gmx.de

  • Lottery factor: 0

Links

Installation

Readme

syncthing-hs

Hackage Build Status

Haskell bindings for the Syncthing REST API.

Tutorial

A short tutorial is available at: http://jetho.org/posts/2015-03-07-syncthing-hs-tutorial.html

Installation

cabal update
cabal install syncthing-hs

Usage Example

{-# LANGUAGE OverloadedStrings #-}

import Control.Lens ((&), (.~), (?~))
import Control.Monad (liftM2)
import qualified Network.Wreq as Wreq
import Network.Syncthing
import qualified Network.Syncthing.Get as Get

-- A single Syncthing request.
single = syncthing defaultConfig Get.ping

-- Connection sharing for multiple Syncthing requests.
multiple1 = withManager $ \cfg ->
    syncthing cfg $ do
        p <- Get.ping
        v <- Get.version
        return (p, v)

-- Multiple Syncthing requests with connection sharing and customized configuration.
multiple2 = withManager $ \cfg -> do
    let cfg' = cfg & pServer .~ "192.168.0.10:8080"
                   & pHttps  .~ True
                   & pAuth   ?~ Wreq.basicAuth "user" "pass"
    syncthing cfg' $ liftM2 (,) Get.ping Get.version