module Database.IAVL.RPC where

import           Data.ProtoLens.Message       (defMessage)
import           Network.GRPC.Client          (RawReply)
import           Network.GRPC.Client.Helpers  (GrpcClient, rawUnary)
import           Network.GRPC.HTTP2.ProtoLens (RPC (..))
import           Network.HTTP2.Client         (ClientIO, TooMuchConcurrency)

import qualified Proto.Google.Protobuf.Empty  as PT (Empty)
import qualified Proto.Iavl.Api               as Api


--------------------------------------------------------------------------------
-- | get
--------------------------------------------------------------------------------
get
  :: GrpcClient
  -> Api.GetRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.GetResponse))
get :: GrpcClient
-> GetRequest
-> ClientIO (Either TooMuchConcurrency (RawReply GetResponse))
get = RPC IAVLService "get"
-> GrpcClient
-> GetRequest
-> ClientIO (Either TooMuchConcurrency (RawReply GetResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "get"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "get")

--------------------------------------------------------------------------------
-- | getVersioned
--------------------------------------------------------------------------------
getVersioned
  :: GrpcClient
  -> Api.GetVersionedRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.GetResponse))
getVersioned :: GrpcClient
-> GetVersionedRequest
-> ClientIO (Either TooMuchConcurrency (RawReply GetResponse))
getVersioned = RPC IAVLService "getVersioned"
-> GrpcClient
-> GetVersionedRequest
-> ClientIO (Either TooMuchConcurrency (RawReply GetResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "getVersioned"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "getVersioned")

--------------------------------------------------------------------------------
-- | getVersionededWithProof
--------------------------------------------------------------------------------
getVersionedWithProof
  :: GrpcClient
  -> Api.GetVersionedRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.GetWithProofResponse))
getVersionedWithProof :: GrpcClient
-> GetVersionedRequest
-> ClientIO
     (Either TooMuchConcurrency (RawReply GetWithProofResponse))
getVersionedWithProof = RPC IAVLService "getVersionedWithProof"
-> GrpcClient
-> GetVersionedRequest
-> ClientIO
     (Either TooMuchConcurrency (RawReply GetWithProofResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "getVersionedWithProof"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "getVersionedWithProof")

--------------------------------------------------------------------------------
-- | getWithProof
--------------------------------------------------------------------------------
getWithProof
  :: GrpcClient
  -> Api.GetRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.GetWithProofResponse))
getWithProof :: GrpcClient
-> GetRequest
-> ClientIO
     (Either TooMuchConcurrency (RawReply GetWithProofResponse))
getWithProof = RPC IAVLService "getWithProof"
-> GrpcClient
-> GetRequest
-> ClientIO
     (Either TooMuchConcurrency (RawReply GetWithProofResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "getWithProof"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "getWithProof")

--------------------------------------------------------------------------------
-- | set
--------------------------------------------------------------------------------
set
  :: GrpcClient
  -> Api.SetRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.SetResponse))
set :: GrpcClient
-> SetRequest
-> ClientIO (Either TooMuchConcurrency (RawReply SetResponse))
set = RPC IAVLService "set"
-> GrpcClient
-> SetRequest
-> ClientIO (Either TooMuchConcurrency (RawReply SetResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "set"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "set")

--------------------------------------------------------------------------------
-- | remove
--------------------------------------------------------------------------------
remove
  :: GrpcClient
  -> Api.RemoveRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.RemoveResponse))
remove :: GrpcClient
-> RemoveRequest
-> ClientIO (Either TooMuchConcurrency (RawReply RemoveResponse))
remove = RPC IAVLService "remove"
-> GrpcClient
-> RemoveRequest
-> ClientIO (Either TooMuchConcurrency (RawReply RemoveResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "remove"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "remove")

--------------------------------------------------------------------------------
-- | saveVersion
--------------------------------------------------------------------------------
saveVersion
  :: GrpcClient
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.SaveVersionResponse))
saveVersion :: GrpcClient
-> ClientIO
     (Either TooMuchConcurrency (RawReply SaveVersionResponse))
saveVersion gc :: GrpcClient
gc = RPC IAVLService "saveVersion"
-> GrpcClient
-> Empty
-> ClientIO
     (Either TooMuchConcurrency (RawReply SaveVersionResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "saveVersion"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "saveVersion") GrpcClient
gc Empty
forall msg. Message msg => msg
defMessage

--------------------------------------------------------------------------------
-- | deleteVersion
--------------------------------------------------------------------------------
deleteVersion
  :: GrpcClient
  -> Api.DeleteVersionRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.DeleteVersionResponse))
deleteVersion :: GrpcClient
-> DeleteVersionRequest
-> ClientIO
     (Either TooMuchConcurrency (RawReply DeleteVersionResponse))
deleteVersion = RPC IAVLService "deleteVersion"
-> GrpcClient
-> DeleteVersionRequest
-> ClientIO
     (Either TooMuchConcurrency (RawReply DeleteVersionResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "deleteVersion"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "deleteVersion")

--------------------------------------------------------------------------------
-- | version
--------------------------------------------------------------------------------
version
  :: GrpcClient
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.VersionResponse))
version :: GrpcClient
-> ClientIO (Either TooMuchConcurrency (RawReply VersionResponse))
version gc :: GrpcClient
gc = RPC IAVLService "version"
-> GrpcClient
-> Empty
-> ClientIO (Either TooMuchConcurrency (RawReply VersionResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "version"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "version") GrpcClient
gc Empty
forall msg. Message msg => msg
defMessage

--------------------------------------------------------------------------------
-- | hash
--------------------------------------------------------------------------------
hash
  :: GrpcClient
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.HashResponse))
hash :: GrpcClient
-> ClientIO (Either TooMuchConcurrency (RawReply HashResponse))
hash gc :: GrpcClient
gc = RPC IAVLService "hash"
-> GrpcClient
-> Empty
-> ClientIO (Either TooMuchConcurrency (RawReply HashResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "hash"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "hash") GrpcClient
gc Empty
forall msg. Message msg => msg
defMessage

--------------------------------------------------------------------------------
-- | versionExists
--------------------------------------------------------------------------------
versionExists
  :: GrpcClient
  -> Api.VersionExistsRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.VersionExistsResponse))
versionExists :: GrpcClient
-> VersionExistsRequest
-> ClientIO
     (Either TooMuchConcurrency (RawReply VersionExistsResponse))
versionExists = RPC IAVLService "versionExists"
-> GrpcClient
-> VersionExistsRequest
-> ClientIO
     (Either TooMuchConcurrency (RawReply VersionExistsResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "versionExists"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "versionExists")

--------------------------------------------------------------------------------
-- | verify
--------------------------------------------------------------------------------
verify
  :: GrpcClient
  -> Api.VerifyRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply PT.Empty))
verify :: GrpcClient
-> VerifyRequest
-> ClientIO (Either TooMuchConcurrency (RawReply Empty))
verify = RPC IAVLService "verify"
-> GrpcClient
-> VerifyRequest
-> ClientIO (Either TooMuchConcurrency (RawReply Empty))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "verify"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "verify")

--------------------------------------------------------------------------------
-- | verifyItem
--------------------------------------------------------------------------------
verifyItem
  :: GrpcClient
  -> Api.VerifyItemRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply PT.Empty))
verifyItem :: GrpcClient
-> VerifyItemRequest
-> ClientIO (Either TooMuchConcurrency (RawReply Empty))
verifyItem = RPC IAVLService "verifyItem"
-> GrpcClient
-> VerifyItemRequest
-> ClientIO (Either TooMuchConcurrency (RawReply Empty))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "verifyItem"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "verifyItem")

--------------------------------------------------------------------------------
-- | verifyAbsence
--------------------------------------------------------------------------------
verifyAbsence
  :: GrpcClient
  -> Api.VerifyAbsenceRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply PT.Empty))
verifyAbsence :: GrpcClient
-> VerifyAbsenceRequest
-> ClientIO (Either TooMuchConcurrency (RawReply Empty))
verifyAbsence = RPC IAVLService "verifyAbsence"
-> GrpcClient
-> VerifyAbsenceRequest
-> ClientIO (Either TooMuchConcurrency (RawReply Empty))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "verifyAbsence"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "verifyAbsence")

--------------------------------------------------------------------------------
-- | rollback
--------------------------------------------------------------------------------
rollback
  :: GrpcClient
  -> ClientIO (Either TooMuchConcurrency (RawReply PT.Empty))
rollback :: GrpcClient -> ClientIO (Either TooMuchConcurrency (RawReply Empty))
rollback gc :: GrpcClient
gc = RPC IAVLService "rollback"
-> GrpcClient
-> Empty
-> ClientIO (Either TooMuchConcurrency (RawReply Empty))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "rollback"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "rollback") GrpcClient
gc Empty
forall msg. Message msg => msg
defMessage

--------------------------------------------------------------------------------
-- | has
--------------------------------------------------------------------------------
has
  :: GrpcClient
  -> Api.HasRequest
  -> ClientIO (Either TooMuchConcurrency (RawReply Api.HasResponse))
has :: GrpcClient
-> HasRequest
-> ClientIO (Either TooMuchConcurrency (RawReply HasResponse))
has = RPC IAVLService "has"
-> GrpcClient
-> HasRequest
-> ClientIO (Either TooMuchConcurrency (RawReply HasResponse))
forall r i o.
(GRPCInput r i, GRPCOutput r o) =>
r
-> GrpcClient
-> i
-> ClientIO (Either TooMuchConcurrency (RawReply o))
rawUnary (RPC IAVLService "has"
forall s (m :: Symbol). RPC s m
RPC :: RPC Api.IAVLService "has")