-- |
-- Module      :  Network.Ipfs.Api.Bootstrap
-- Copyright   :  Aleksandr Krupenkin 2016-2021
-- License     :  Apache-2.0
--
-- Maintainer  :  mail@akru.me
-- Stability   :  experimental
-- Portability :  unknown
--
-- Api calls with `bootstrap` prefix.
--

module Network.Ipfs.Api.Bootstrap where

import           Control.Monad.IO.Class         (MonadIO)
import           Data.Text                      (Text)

import           Network.Ipfs.Api.Internal      (_bootstrapAdd, _bootstrapList,
                                                 _bootstrapRM)
import           Network.Ipfs.Api.Internal.Call (call)
import           Network.Ipfs.Api.Types         (BootstrapObj)
import           Network.Ipfs.Client            (IpfsT)

-- | Add peers to the bootstrap list.
add :: MonadIO m => Text -> IpfsT m BootstrapObj
add :: Text -> IpfsT m BootstrapObj
add = ClientM BootstrapObj -> IpfsT m BootstrapObj
forall (m :: * -> *) a. MonadIO m => ClientM a -> IpfsT m a
call (ClientM BootstrapObj -> IpfsT m BootstrapObj)
-> (Text -> ClientM BootstrapObj) -> Text -> IpfsT m BootstrapObj
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> ClientM BootstrapObj
_bootstrapAdd (Maybe Text -> ClientM BootstrapObj)
-> (Text -> Maybe Text) -> Text -> ClientM BootstrapObj
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe Text
forall a. a -> Maybe a
Just

-- | Show peers in the bootstrap list.
list :: MonadIO m => IpfsT m BootstrapObj
list :: IpfsT m BootstrapObj
list = ClientM BootstrapObj -> IpfsT m BootstrapObj
forall (m :: * -> *) a. MonadIO m => ClientM a -> IpfsT m a
call ClientM BootstrapObj
_bootstrapList

-- | Remove peers from the bootstrap list.
rm :: MonadIO m => Text -> IpfsT m BootstrapObj
rm :: Text -> IpfsT m BootstrapObj
rm = ClientM BootstrapObj -> IpfsT m BootstrapObj
forall (m :: * -> *) a. MonadIO m => ClientM a -> IpfsT m a
call (ClientM BootstrapObj -> IpfsT m BootstrapObj)
-> (Text -> ClientM BootstrapObj) -> Text -> IpfsT m BootstrapObj
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> ClientM BootstrapObj
_bootstrapRM (Maybe Text -> ClientM BootstrapObj)
-> (Text -> Maybe Text) -> Text -> ClientM BootstrapObj
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe Text
forall a. a -> Maybe a
Just