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
  }
class (Monad m) => MonadMetadataStorage m where
  
  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)
  
  
  setCatalogState :: CatalogStateType -> Value -> m (Either QErr ())
  
  
  
  
  fetchSourceIntrospection :: MetadataResourceVersion -> m (Either QErr (Maybe StoredIntrospection))
  storeSourceIntrospection :: StoredIntrospection -> MetadataResourceVersion -> m (Either QErr ())
  
  getMetadataDbUid :: m (Either QErr MetadataDbId)
  checkMetadataStorageHealth :: m (Either QErr ())
  
  
  
  
  
  
  
  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 ())
  
  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 ())
  
  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)
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
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
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
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
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
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
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
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
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
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)