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

module Network.Ipfs.Api.Repo where

import           Control.Monad.IO.Class           (MonadIO)

import           Network.Ipfs.Api.Internal        (_repoFsck, _repoVersion)
import           Network.Ipfs.Api.Internal.Call   (call, streamCall)
import           Network.Ipfs.Api.Internal.Stream (_repoGc, _repoVerify)
import           Network.Ipfs.Api.Types           (RepoFsckObj, RepoVersionObj)
import           Network.Ipfs.Client              (IpfsT)

-- | Show the repo version.
version :: MonadIO m => IpfsT m RepoVersionObj
version :: IpfsT m RepoVersionObj
version = ClientM RepoVersionObj -> IpfsT m RepoVersionObj
forall (m :: * -> *) a. MonadIO m => ClientM a -> IpfsT m a
call ClientM RepoVersionObj
_repoVersion

-- | Remove repo lockfiles.
fsck :: MonadIO m => IpfsT m RepoFsckObj
fsck :: IpfsT m RepoFsckObj
fsck = ClientM RepoFsckObj -> IpfsT m RepoFsckObj
forall (m :: * -> *) a. MonadIO m => ClientM a -> IpfsT m a
call ClientM RepoFsckObj
_repoFsck

-- | Perform a garbage collection sweep on the repo.
gc :: MonadIO m => m ()
gc :: m ()
gc = ClientM (SourceT IO RepoGcObj) -> m ()
forall (m :: * -> *) a.
(MonadIO m, Show a) =>
ClientM (SourceT IO a) -> m ()
streamCall ClientM (SourceT IO RepoGcObj)
_repoGc

-- | Verify all blocks in repo are not corrupted.
repoVerify :: MonadIO m => m ()
repoVerify :: m ()
repoVerify = ClientM (SourceT IO RepoVerifyObj) -> m ()
forall (m :: * -> *) a.
(MonadIO m, Show a) =>
ClientM (SourceT IO a) -> m ()
streamCall ClientM (SourceT IO RepoVerifyObj)
_repoVerify