-- | This module has type class and types which implements the Metadata Storage Abstraction
module Hasura.Metadata.Class
  ( SchemaSyncEventProcessResult (..),
    MonadMetadataStorage (..),
    MonadEECredentialsStorage (..),
    createOneOffScheduledEvent,
    createCronEvents,
    dropFutureCronEvents,
    deleteActionData,
    fetchScheduledEventInvocations,
    fetchScheduledEvents,
    dropEvent,
    fetchCatalogState,
    updateCatalogState,
  )
where

import Control.Monad.Trans.Extended
import Control.Monad.Trans.Managed
import Data.Aeson
import Hasura.Base.Error
import Hasura.Eventing.ScheduledTrigger.Types
import Hasura.Prelude
import Hasura.RQL.Types.Action
import Hasura.RQL.Types.EECredentials
import Hasura.RQL.Types.EventTrigger
import Hasura.RQL.Types.Eventing
import Hasura.RQL.Types.Metadata
import Hasura.RQL.Types.ScheduledTrigger
import Hasura.RQL.Types.SchemaCache
import Hasura.RQL.Types.SchemaCache.Build
import Hasura.Server.Types
import Hasura.Session
import Network.HTTP.Types qualified as HTTP

data SchemaSyncEventProcessResult = SchemaSyncEventProcessResult
  { SchemaSyncEventProcessResult -> Bool
_sseprShouldReload :: !Bool,
    SchemaSyncEventProcessResult -> CacheInvalidations
_sseprCacheInvalidations :: !CacheInvalidations
  }

{- Note [Todo: Common interface for eventing sub-system]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Postgres tables' event triggers and scheduled event triggers are similar in the
core logic. But currently, their implementation is completely isolated and do not
share a common schema in Postgres. We're having a plan to simplify them via a
common 'event storage and retrieval' interface (maybe via a Postgres extension?).
This will potentially reduce number of interactions made to database and schema foot print.

TODO: Reference to open issue or rfc?
-}

-- | Metadata storage abstraction via a type class.
--
-- This type class enables storing and managing Hasura metadata in an isolated
-- database which will not interfere with user's database where tables/functions
-- are defined. Hence, it'll enable support for databases of multiple backends
-- like MSSQL etc.
--
-- Error-handling is handled explicitly, with every function returning an
-- `Either QErr`. This is inelegant, but is required: we want the caller to
-- explictly deal with errors, rather than letting them surface to a "lower"
-- monad, because we want to implement this as a "Service", on the base monad,
-- so that different implementations of the engine can choose how to implement
-- it; and those base monads do not include error handling, all error handling
-- must be done at the endpoint level. As a result, we choose to make the errors
-- explicit in the return type rather than making assumptions about the stack.
--
-- This class has functions broadly related to:
--
-- 1. Metadata Management
-- ----------------------
-- Basic metadata management functions such as retrieving metadata from storage
-- database and replacing the given metadata.
-- TODO: Console specific operations
--
-- 2. Scheduled Triggers
-- ---------------------
-- Eventing sub-system for scheduled triggers is implemented via metadata storage.
-- For more details, refer description in 'Hasura.Eventing.ScheduledTrigger' module.
--
-- TODO: Functions need to be added to the type class
-- - Retrieving invocation logs from storage (console requirement)
-- - Deleting an scheduled event
-- - Creating an one-off scheduled event
--
-- 3. Async Actions
-- ----------------
-- Operations to implement async actions sub-system. This includes recording an
-- async action event and retreiving the details of action delivery to the webhook.
-- For more details see Note [Async action architecture] in 'Hasura.GraphQL.Execute.Action' module.
--
-- It is believed that all the above three are implemented in a single storage
-- system (ex: a Postgres database). We can split the functions into appropriate and
-- specific type classes in future iterations if required.
class (Monad m) => MonadMetadataStorage m where
  -- Metadata
  fetchMetadataResourceVersion :: m (Either QErr MetadataResourceVersion)
  fetchMetadata :: m (Either QErr MetadataWithResourceVersion)
  fetchMetadataNotifications :: MetadataResourceVersion -> InstanceId -> m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
  setMetadata :: MetadataResourceVersion -> Metadata -> m (Either QErr MetadataResourceVersion)
  notifySchemaCacheSync :: MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m (Either QErr ())
  getCatalogState :: m (Either QErr CatalogState)

  -- the `setCatalogState` function is used by the console and CLI to store its state
  -- it is disabled when maintenance mode is on
  setCatalogState :: CatalogStateType -> Value -> m (Either QErr ())

  -- methods for storing and retrieving source introspection which is stored in
  -- "stored introspection" db. See 'StoredIntrospection'.
  -- This returns a @Maybe StoredIntrospection@ as in some distributions
  -- fetching of source introspection may not be available
  fetchSourceIntrospection :: MetadataResourceVersion -> m (Either QErr (Maybe StoredIntrospection))
  storeSourceIntrospection :: StoredIntrospection -> MetadataResourceVersion -> m (Either QErr ())

  -- get the @db_uuid@ that we store in the database.
  getMetadataDbUid :: m (Either QErr MetadataDbId)
  checkMetadataStorageHealth :: m (Either QErr ())

  -- Scheduled triggers
  -- TODO:-
  -- Ideally we would've liked to avoid having functions that are specific to
  -- scheduled/cron triggers and instead have functions that provide a generic
  -- 'event storage and retrieval' interface but we'll have to change a lot of
  -- existing code for scheduled and cron triggers. We can get to this after the
  -- multi-source work is done. See Note [Todo: Common interface for eventing sub-system]
  getDeprivedCronTriggerStats :: [TriggerName] -> m (Either QErr [CronTriggerStats])
  getScheduledEventsForDelivery :: [TriggerName] -> m (Either QErr ([CronEvent], [OneOffScheduledEvent]))
  insertCronEvents :: [CronEventSeed] -> m (Either QErr ())
  insertOneOffScheduledEvent :: OneOffEvent -> m (Either QErr EventId)
  insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> m (Either QErr ())
  setScheduledEventOp :: ScheduledEventId -> ScheduledEventOp -> ScheduledEventType -> m (Either QErr ())
  unlockScheduledEvents :: ScheduledEventType -> [ScheduledEventId] -> m (Either QErr Int)
  unlockAllLockedScheduledEvents :: m (Either QErr ())
  clearFutureCronEvents :: ClearCronEvents -> m (Either QErr ())

  -- Console API requirements
  getOneOffScheduledEvents :: ScheduledEventPagination -> [ScheduledEventStatus] -> RowsCountOption -> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
  getCronEvents :: TriggerName -> ScheduledEventPagination -> [ScheduledEventStatus] -> RowsCountOption -> m (Either QErr (WithOptionalTotalCount [CronEvent]))
  getScheduledEventInvocations :: GetScheduledEventInvocations -> m (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
  deleteScheduledEvent :: ScheduledEventId -> ScheduledEventType -> m (Either QErr ())

  -- Async actions
  insertAction ::
    ActionName ->
    SessionVariables ->
    [HTTP.Header] ->
    Value ->
    m (Either QErr ActionId)
  fetchUndeliveredActionEvents :: m (Either QErr [ActionLogItem])
  setActionStatus :: ActionId -> AsyncActionStatus -> m (Either QErr ())
  fetchActionResponse :: ActionId -> m (Either QErr ActionLogResponse)
  clearActionData :: ActionName -> m (Either QErr ())
  setProcessingActionLogsToPending :: LockedActionIdArray -> m (Either QErr ())

instance (MonadMetadataStorage m, MonadTrans t, Monad (t m)) => MonadMetadataStorage (TransT t m) where
  fetchMetadataResourceVersion :: TransT t m (Either QErr MetadataResourceVersion)
fetchMetadataResourceVersion = m (Either QErr MetadataResourceVersion)
-> TransT t m (Either QErr MetadataResourceVersion)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Either QErr MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Either QErr MetadataResourceVersion)
fetchMetadataResourceVersion
  fetchMetadata :: TransT t m (Either QErr MetadataWithResourceVersion)
fetchMetadata = m (Either QErr MetadataWithResourceVersion)
-> TransT t m (Either QErr MetadataWithResourceVersion)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Either QErr MetadataWithResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Either QErr MetadataWithResourceVersion)
fetchMetadata
  fetchMetadataNotifications :: MetadataResourceVersion
-> InstanceId
-> TransT
     t m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b = m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
-> TransT
     t m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
 -> TransT
      t m (Either QErr [(MetadataResourceVersion, CacheInvalidations)]))
-> m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
-> TransT
     t m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId
-> m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId
-> m (Either QErr [(MetadataResourceVersion, CacheInvalidations)])
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b
  setMetadata :: MetadataResourceVersion
-> Metadata -> TransT t m (Either QErr MetadataResourceVersion)
setMetadata MetadataResourceVersion
r = m (Either QErr MetadataResourceVersion)
-> TransT t m (Either QErr MetadataResourceVersion)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr MetadataResourceVersion)
 -> TransT t m (Either QErr MetadataResourceVersion))
-> (Metadata -> m (Either QErr MetadataResourceVersion))
-> Metadata
-> TransT t m (Either QErr MetadataResourceVersion)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion
-> Metadata -> m (Either QErr MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> Metadata -> m (Either QErr MetadataResourceVersion)
setMetadata MetadataResourceVersion
r
  notifySchemaCacheSync :: MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> TransT t m (Either QErr ())
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> m (Either QErr ())
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c
  getCatalogState :: TransT t m (Either QErr CatalogState)
getCatalogState = m (Either QErr CatalogState)
-> TransT t m (Either QErr CatalogState)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Either QErr CatalogState)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Either QErr CatalogState)
getCatalogState
  setCatalogState :: CatalogStateType -> Value -> TransT t m (Either QErr ())
setCatalogState CatalogStateType
a Value
b = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ CatalogStateType -> Value -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m (Either QErr ())
setCatalogState CatalogStateType
a Value
b

  fetchSourceIntrospection :: MetadataResourceVersion
-> TransT t m (Either QErr (Maybe StoredIntrospection))
fetchSourceIntrospection = m (Either QErr (Maybe StoredIntrospection))
-> TransT t m (Either QErr (Maybe StoredIntrospection))
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr (Maybe StoredIntrospection))
 -> TransT t m (Either QErr (Maybe StoredIntrospection)))
-> (MetadataResourceVersion
    -> m (Either QErr (Maybe StoredIntrospection)))
-> MetadataResourceVersion
-> TransT t m (Either QErr (Maybe StoredIntrospection))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion
-> m (Either QErr (Maybe StoredIntrospection))
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> m (Either QErr (Maybe StoredIntrospection))
fetchSourceIntrospection
  storeSourceIntrospection :: StoredIntrospection
-> MetadataResourceVersion -> TransT t m (Either QErr ())
storeSourceIntrospection StoredIntrospection
a MetadataResourceVersion
b = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ StoredIntrospection
-> MetadataResourceVersion -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
StoredIntrospection
-> MetadataResourceVersion -> m (Either QErr ())
storeSourceIntrospection StoredIntrospection
a MetadataResourceVersion
b

  getMetadataDbUid :: TransT t m (Either QErr MetadataDbId)
getMetadataDbUid = m (Either QErr MetadataDbId)
-> TransT t m (Either QErr MetadataDbId)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Either QErr MetadataDbId)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Either QErr MetadataDbId)
getMetadataDbUid
  checkMetadataStorageHealth :: TransT t m (Either QErr ())
checkMetadataStorageHealth = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Either QErr ())
forall (m :: * -> *). MonadMetadataStorage m => m (Either QErr ())
checkMetadataStorageHealth

  getDeprivedCronTriggerStats :: [TriggerName] -> TransT t m (Either QErr [CronTriggerStats])
getDeprivedCronTriggerStats = m (Either QErr [CronTriggerStats])
-> TransT t m (Either QErr [CronTriggerStats])
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr [CronTriggerStats])
 -> TransT t m (Either QErr [CronTriggerStats]))
-> ([TriggerName] -> m (Either QErr [CronTriggerStats]))
-> [TriggerName]
-> TransT t m (Either QErr [CronTriggerStats])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName] -> m (Either QErr [CronTriggerStats])
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName] -> m (Either QErr [CronTriggerStats])
getDeprivedCronTriggerStats
  getScheduledEventsForDelivery :: [TriggerName]
-> TransT t m (Either QErr ([CronEvent], [OneOffScheduledEvent]))
getScheduledEventsForDelivery = m (Either QErr ([CronEvent], [OneOffScheduledEvent]))
-> TransT t m (Either QErr ([CronEvent], [OneOffScheduledEvent]))
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ([CronEvent], [OneOffScheduledEvent]))
 -> TransT t m (Either QErr ([CronEvent], [OneOffScheduledEvent])))
-> ([TriggerName]
    -> m (Either QErr ([CronEvent], [OneOffScheduledEvent])))
-> [TriggerName]
-> TransT t m (Either QErr ([CronEvent], [OneOffScheduledEvent]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName]
-> m (Either QErr ([CronEvent], [OneOffScheduledEvent]))
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName]
-> m (Either QErr ([CronEvent], [OneOffScheduledEvent]))
getScheduledEventsForDelivery
  insertCronEvents :: [CronEventSeed] -> TransT t m (Either QErr ())
insertCronEvents = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> ([CronEventSeed] -> m (Either QErr ()))
-> [CronEventSeed]
-> TransT t m (Either QErr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CronEventSeed] -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m (Either QErr ())
insertCronEvents
  insertOneOffScheduledEvent :: OneOffEvent -> TransT t m (Either QErr EventId)
insertOneOffScheduledEvent = m (Either QErr EventId) -> TransT t m (Either QErr EventId)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr EventId) -> TransT t m (Either QErr EventId))
-> (OneOffEvent -> m (Either QErr EventId))
-> OneOffEvent
-> TransT t m (Either QErr EventId)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OneOffEvent -> m (Either QErr EventId)
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m (Either QErr EventId)
insertOneOffScheduledEvent
  insertScheduledEventInvocation :: Invocation 'ScheduledType
-> ScheduledEventType -> TransT t m (Either QErr ())
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ Invocation 'ScheduledType
-> ScheduledEventType -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
Invocation 'ScheduledType
-> ScheduledEventType -> m (Either QErr ())
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b
  setScheduledEventOp :: EventId
-> ScheduledEventOp
-> ScheduledEventType
-> TransT t m (Either QErr ())
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ EventId
-> ScheduledEventOp -> ScheduledEventType -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId
-> ScheduledEventOp -> ScheduledEventType -> m (Either QErr ())
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c
  unlockScheduledEvents :: ScheduledEventType -> [EventId] -> TransT t m (Either QErr Int)
unlockScheduledEvents ScheduledEventType
a [EventId]
b = m (Either QErr Int) -> TransT t m (Either QErr Int)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr Int) -> TransT t m (Either QErr Int))
-> m (Either QErr Int) -> TransT t m (Either QErr Int)
forall a b. (a -> b) -> a -> b
$ ScheduledEventType -> [EventId] -> m (Either QErr Int)
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventType -> [EventId] -> m (Either QErr Int)
unlockScheduledEvents ScheduledEventType
a [EventId]
b
  unlockAllLockedScheduledEvents :: TransT t m (Either QErr ())
unlockAllLockedScheduledEvents = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ m (Either QErr ())
forall (m :: * -> *). MonadMetadataStorage m => m (Either QErr ())
unlockAllLockedScheduledEvents
  clearFutureCronEvents :: ClearCronEvents -> TransT t m (Either QErr ())
clearFutureCronEvents = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> (ClearCronEvents -> m (Either QErr ()))
-> ClearCronEvents
-> TransT t m (Either QErr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClearCronEvents -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m (Either QErr ())
clearFutureCronEvents
  getOneOffScheduledEvents :: ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> TransT
     t m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b RowsCountOption
c = m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
-> TransT
     t m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
 -> TransT
      t m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent])))
-> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
-> TransT
     t m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b RowsCountOption
c
  getCronEvents :: TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> TransT t m (Either QErr (WithOptionalTotalCount [CronEvent]))
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c RowsCountOption
d = m (Either QErr (WithOptionalTotalCount [CronEvent]))
-> TransT t m (Either QErr (WithOptionalTotalCount [CronEvent]))
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr (WithOptionalTotalCount [CronEvent]))
 -> TransT t m (Either QErr (WithOptionalTotalCount [CronEvent])))
-> m (Either QErr (WithOptionalTotalCount [CronEvent]))
-> TransT t m (Either QErr (WithOptionalTotalCount [CronEvent]))
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> m (Either QErr (WithOptionalTotalCount [CronEvent]))
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> m (Either QErr (WithOptionalTotalCount [CronEvent]))
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c RowsCountOption
d
  getScheduledEventInvocations :: GetScheduledEventInvocations
-> TransT
     t
     m
     (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
getScheduledEventInvocations GetScheduledEventInvocations
a = m (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
-> TransT
     t
     m
     (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either
      QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
 -> TransT
      t
      m
      (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation])))
-> m (Either
        QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
-> TransT
     t
     m
     (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
forall a b. (a -> b) -> a -> b
$ GetScheduledEventInvocations
-> m (Either
        QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
forall (m :: * -> *).
MonadMetadataStorage m =>
GetScheduledEventInvocations
-> m (Either
        QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
getScheduledEventInvocations GetScheduledEventInvocations
a
  deleteScheduledEvent :: EventId -> ScheduledEventType -> TransT t m (Either QErr ())
deleteScheduledEvent EventId
a ScheduledEventType
b = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventType -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m (Either QErr ())
deleteScheduledEvent EventId
a ScheduledEventType
b

  insertAction :: ActionName
-> SessionVariables
-> [Header]
-> Value
-> TransT t m (Either QErr ActionId)
insertAction ActionName
a SessionVariables
b [Header]
c Value
d = m (Either QErr ActionId) -> TransT t m (Either QErr ActionId)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ActionId) -> TransT t m (Either QErr ActionId))
-> m (Either QErr ActionId) -> TransT t m (Either QErr ActionId)
forall a b. (a -> b) -> a -> b
$ ActionName
-> SessionVariables
-> [Header]
-> Value
-> m (Either QErr ActionId)
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName
-> SessionVariables
-> [Header]
-> Value
-> m (Either QErr ActionId)
insertAction ActionName
a SessionVariables
b [Header]
c Value
d
  fetchUndeliveredActionEvents :: TransT t m (Either QErr [ActionLogItem])
fetchUndeliveredActionEvents = m (Either QErr [ActionLogItem])
-> TransT t m (Either QErr [ActionLogItem])
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Either QErr [ActionLogItem])
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Either QErr [ActionLogItem])
fetchUndeliveredActionEvents
  setActionStatus :: ActionId -> AsyncActionStatus -> TransT t m (Either QErr ())
setActionStatus ActionId
a AsyncActionStatus
b = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ ActionId -> AsyncActionStatus -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> AsyncActionStatus -> m (Either QErr ())
setActionStatus ActionId
a AsyncActionStatus
b
  fetchActionResponse :: ActionId -> TransT t m (Either QErr ActionLogResponse)
fetchActionResponse = m (Either QErr ActionLogResponse)
-> TransT t m (Either QErr ActionLogResponse)
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ActionLogResponse)
 -> TransT t m (Either QErr ActionLogResponse))
-> (ActionId -> m (Either QErr ActionLogResponse))
-> ActionId
-> TransT t m (Either QErr ActionLogResponse)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionId -> m (Either QErr ActionLogResponse)
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> m (Either QErr ActionLogResponse)
fetchActionResponse
  clearActionData :: ActionName -> TransT t m (Either QErr ())
clearActionData = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> (ActionName -> m (Either QErr ()))
-> ActionName
-> TransT t m (Either QErr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionName -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> m (Either QErr ())
clearActionData
  setProcessingActionLogsToPending :: LockedActionIdArray -> TransT t m (Either QErr ())
setProcessingActionLogsToPending = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> (LockedActionIdArray -> m (Either QErr ()))
-> LockedActionIdArray
-> TransT t m (Either QErr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LockedActionIdArray -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
LockedActionIdArray -> m (Either QErr ())
setProcessingActionLogsToPending

deriving via (TransT (ReaderT r) m) instance (MonadMetadataStorage m) => MonadMetadataStorage (ReaderT r m)

deriving via (TransT (StateT s) m) instance (MonadMetadataStorage m) => MonadMetadataStorage (StateT s m)

deriving via (TransT (ExceptT e) m) instance (MonadMetadataStorage m) => MonadMetadataStorage (ExceptT e m)

deriving via (TransT MetadataT m) instance (MonadMetadataStorage m) => MonadMetadataStorage (MetadataT m)

deriving via (TransT ManagedT m) instance (MonadMetadataStorage m) => MonadMetadataStorage (ManagedT m)

-- | Record a one-off event
createOneOffScheduledEvent :: (MonadMetadataStorage m) => OneOffEvent -> m (Either QErr EventId)
createOneOffScheduledEvent :: forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m (Either QErr EventId)
createOneOffScheduledEvent = OneOffEvent -> m (Either QErr EventId)
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m (Either QErr EventId)
insertOneOffScheduledEvent

-- | Record a cron event
createCronEvents :: (MonadMetadataStorage m) => [CronEventSeed] -> m (Either QErr ())
createCronEvents :: forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m (Either QErr ())
createCronEvents = [CronEventSeed] -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m (Either QErr ())
insertCronEvents

-- | Clear cron events
dropFutureCronEvents :: (MonadMetadataStorage m) => ClearCronEvents -> m (Either QErr ())
dropFutureCronEvents :: forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m (Either QErr ())
dropFutureCronEvents = ClearCronEvents -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m (Either QErr ())
clearFutureCronEvents

-- | Delete async action logs
deleteActionData :: (MonadMetadataStorage m) => ActionName -> m (Either QErr ())
deleteActionData :: forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> m (Either QErr ())
deleteActionData = ActionName -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> m (Either QErr ())
clearActionData

-- | Fetch cron/oneoff scheduled event invocations
fetchScheduledEventInvocations ::
  (MonadMetadataStorage m) =>
  GetScheduledEventInvocations ->
  m (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
fetchScheduledEventInvocations :: forall (m :: * -> *).
MonadMetadataStorage m =>
GetScheduledEventInvocations
-> m (Either
        QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
fetchScheduledEventInvocations = GetScheduledEventInvocations
-> m (Either
        QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
forall (m :: * -> *).
MonadMetadataStorage m =>
GetScheduledEventInvocations
-> m (Either
        QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
getScheduledEventInvocations

-- | Fetch cron/oneoff scheduled events
fetchScheduledEvents :: (MonadMetadataStorage m) => GetScheduledEvents -> m (Either QErr Value)
fetchScheduledEvents :: forall (m :: * -> *).
MonadMetadataStorage m =>
GetScheduledEvents -> m (Either QErr Value)
fetchScheduledEvents GetScheduledEvents {[ScheduledEventStatus]
RowsCountOption
ScheduledEventPagination
ScheduledEvent
_gseScheduledEvent :: ScheduledEvent
_gsePagination :: ScheduledEventPagination
_gseStatus :: [ScheduledEventStatus]
_gseGetRowsCount :: RowsCountOption
_gseScheduledEvent :: GetScheduledEvents -> ScheduledEvent
_gsePagination :: GetScheduledEvents -> ScheduledEventPagination
_gseStatus :: GetScheduledEvents -> [ScheduledEventStatus]
_gseGetRowsCount :: GetScheduledEvents -> RowsCountOption
..} = do
  let totalCountToJSON :: WithOptionalTotalCount v -> Value
totalCountToJSON WithOptionalTotalCount {v
Maybe Int
_wtcCount :: Maybe Int
_wtcData :: v
_wtcCount :: forall a. WithOptionalTotalCount a -> Maybe Int
_wtcData :: forall a. WithOptionalTotalCount a -> a
..} =
        [Pair] -> Value
object
          ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ (Key
"events" Key -> v -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
.= v
_wtcData)
          Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: ([Pair] -> (Int -> [Pair]) -> Maybe Int -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [Pair]
forall a. Monoid a => a
mempty (\Int
count -> [Key
"count" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
.= Int
count]) Maybe Int
_wtcCount)
  case ScheduledEvent
_gseScheduledEvent of
    ScheduledEvent
SEOneOff -> ((Either QErr (WithOptionalTotalCount [OneOffScheduledEvent])
 -> Either QErr Value)
-> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
-> m (Either QErr Value)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Either QErr (WithOptionalTotalCount [OneOffScheduledEvent])
  -> Either QErr Value)
 -> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
 -> m (Either QErr Value))
-> ((WithOptionalTotalCount [OneOffScheduledEvent] -> Value)
    -> Either QErr (WithOptionalTotalCount [OneOffScheduledEvent])
    -> Either QErr Value)
-> (WithOptionalTotalCount [OneOffScheduledEvent] -> Value)
-> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
-> m (Either QErr Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WithOptionalTotalCount [OneOffScheduledEvent] -> Value)
-> Either QErr (WithOptionalTotalCount [OneOffScheduledEvent])
-> Either QErr Value
forall a b. (a -> b) -> Either QErr a -> Either QErr b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap) WithOptionalTotalCount [OneOffScheduledEvent] -> Value
forall {v}. ToJSON v => WithOptionalTotalCount v -> Value
totalCountToJSON (m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
 -> m (Either QErr Value))
-> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
-> m (Either QErr Value)
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent]))
getOneOffScheduledEvents ScheduledEventPagination
_gsePagination [ScheduledEventStatus]
_gseStatus RowsCountOption
_gseGetRowsCount
    SECron TriggerName
name -> ((Either QErr (WithOptionalTotalCount [CronEvent])
 -> Either QErr Value)
-> m (Either QErr (WithOptionalTotalCount [CronEvent]))
-> m (Either QErr Value)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Either QErr (WithOptionalTotalCount [CronEvent])
  -> Either QErr Value)
 -> m (Either QErr (WithOptionalTotalCount [CronEvent]))
 -> m (Either QErr Value))
-> ((WithOptionalTotalCount [CronEvent] -> Value)
    -> Either QErr (WithOptionalTotalCount [CronEvent])
    -> Either QErr Value)
-> (WithOptionalTotalCount [CronEvent] -> Value)
-> m (Either QErr (WithOptionalTotalCount [CronEvent]))
-> m (Either QErr Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WithOptionalTotalCount [CronEvent] -> Value)
-> Either QErr (WithOptionalTotalCount [CronEvent])
-> Either QErr Value
forall a b. (a -> b) -> Either QErr a -> Either QErr b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap) WithOptionalTotalCount [CronEvent] -> Value
forall {v}. ToJSON v => WithOptionalTotalCount v -> Value
totalCountToJSON (m (Either QErr (WithOptionalTotalCount [CronEvent]))
 -> m (Either QErr Value))
-> m (Either QErr (WithOptionalTotalCount [CronEvent]))
-> m (Either QErr Value)
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> m (Either QErr (WithOptionalTotalCount [CronEvent]))
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> RowsCountOption
-> m (Either QErr (WithOptionalTotalCount [CronEvent]))
getCronEvents TriggerName
name ScheduledEventPagination
_gsePagination [ScheduledEventStatus]
_gseStatus RowsCountOption
_gseGetRowsCount

-- | Drop a cron/oneoff scheduled event
dropEvent :: (MonadMetadataStorage m) => ScheduledEventId -> ScheduledEventType -> m (Either QErr ())
dropEvent :: forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m (Either QErr ())
dropEvent = EventId -> ScheduledEventType -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m (Either QErr ())
deleteScheduledEvent

-- | Retrieve the state from metadata storage catalog
fetchCatalogState :: (MonadMetadataStorage m) => m (Either QErr CatalogState)
fetchCatalogState :: forall (m :: * -> *).
MonadMetadataStorage m =>
m (Either QErr CatalogState)
fetchCatalogState = m (Either QErr CatalogState)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Either QErr CatalogState)
getCatalogState

-- | Update the state from metadata storage catalog
updateCatalogState :: (MonadMetadataStorage m) => CatalogStateType -> Value -> m (Either QErr ())
updateCatalogState :: forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m (Either QErr ())
updateCatalogState = CatalogStateType -> Value -> m (Either QErr ())
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m (Either QErr ())
setCatalogState

-- | Metadata database operations for EE credentials storage.
--
-- This class is only necessary because we haven't written an implementation
-- for storing EE credentials in Cloud.
class (Monad m) => MonadEECredentialsStorage m where
  getEEClientCredentials :: m (Either QErr (Maybe EEClientCredentials))
  setEEClientCredentials :: EEClientCredentials -> m (Either QErr ())

instance (MonadEECredentialsStorage m, MonadTrans t, Monad (t m)) => MonadEECredentialsStorage (TransT t m) where
  getEEClientCredentials :: TransT t m (Either QErr (Maybe EEClientCredentials))
getEEClientCredentials = m (Either QErr (Maybe EEClientCredentials))
-> TransT t m (Either QErr (Maybe EEClientCredentials))
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Either QErr (Maybe EEClientCredentials))
forall (m :: * -> *).
MonadEECredentialsStorage m =>
m (Either QErr (Maybe EEClientCredentials))
getEEClientCredentials
  setEEClientCredentials :: EEClientCredentials -> TransT t m (Either QErr ())
setEEClientCredentials EEClientCredentials
a = m (Either QErr ()) -> TransT t m (Either QErr ())
forall (m :: * -> *) a. Monad m => m a -> TransT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either QErr ()) -> TransT t m (Either QErr ()))
-> m (Either QErr ()) -> TransT t m (Either QErr ())
forall a b. (a -> b) -> a -> b
$ EEClientCredentials -> m (Either QErr ())
forall (m :: * -> *).
MonadEECredentialsStorage m =>
EEClientCredentials -> m (Either QErr ())
setEEClientCredentials EEClientCredentials
a

deriving via (TransT (ReaderT r) m) instance (MonadEECredentialsStorage m) => MonadEECredentialsStorage (ReaderT r m)

deriving via (TransT (StateT s) m) instance (MonadEECredentialsStorage m) => MonadEECredentialsStorage (StateT s m)

deriving via (TransT (ExceptT e) m) instance (MonadEECredentialsStorage m) => MonadEECredentialsStorage (ExceptT e m)

deriving via (TransT MetadataT m) instance (MonadEECredentialsStorage m) => MonadEECredentialsStorage (MetadataT m)

deriving via (TransT ManagedT m) instance (MonadEECredentialsStorage m) => MonadEECredentialsStorage (ManagedT m)