{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}

-- | Response types for the Arbiter REST API.
module Arbiter.Servant.Types
  ( module Arbiter.Servant.Types
  , CronScheduleRow (..)
  , CronScheduleUpdate (..)
  , QueueOverview (..)
  , QueueRow (..)
  , WorkerRow (..)
  , RateLimitPolicyView (..)
  , RateLimitBucketView (..)
  , RateLimitPolicyUpdate (..)
  , ConcurrencyPolicyView (..)
  , ConcurrencyKeyView (..)
  , ConcurrencyPolicyUpdate (..)
  , PgDbHealth (..)
  ) where

import Arbiter.Core.Concurrency.Stats
  ( ConcurrencyKeyView (..)
  , ConcurrencyPolicyUpdate (..)
  , ConcurrencyPolicyView (..)
  )
import Arbiter.Core.CronSchedule (CronScheduleRow (..), CronScheduleUpdate (..))
import Arbiter.Core.Health (PgDbHealth (..))
import Arbiter.Core.Job.Archive qualified as Archive
import Arbiter.Core.Job.DLQ qualified as DLQ
import Arbiter.Core.Job.Types
  ( JobRead
  , JobStatus
  , JobWrite
  , isRollup
  , traceparent
  , tracestate
  )
import Arbiter.Core.Job.Types qualified as Arb
import Arbiter.Core.Operations (QueueOverview (..), QueueStats)
import Arbiter.Core.Queues (QueueRow (..))
import Arbiter.Core.RateLimit.Stats
  ( RateLimitBucketView (..)
  , RateLimitPolicyUpdate (..)
  , RateLimitPolicyView (..)
  )
import Arbiter.Core.Worker (WorkerRow (..))
import Data.Aeson
  ( FromJSON (..)
  , ToJSON (..)
  , Value (Object)
  , object
  , withObject
  , withText
  , (.!=)
  , (.:)
  , (.:!)
  , (.:?)
  , (.=)
  )
import Data.Aeson.KeyMap qualified as KM
import Data.Aeson.Types (Pair)
import Data.Int (Int64)
import Data.Map.Strict (Map)
import Data.Text (Text)
import Data.Time.Clock (UTCTime)
import Data.UUID.Types (UUID)
import GHC.Generics (Generic)

-- | A job in its JSON wire shape.
newtype ApiJob payload = ApiJob {forall payload. ApiJob payload -> JobRead payload
unApiJob :: JobRead payload}
  deriving stock (ApiJob payload -> ApiJob payload -> Bool
(ApiJob payload -> ApiJob payload -> Bool)
-> (ApiJob payload -> ApiJob payload -> Bool)
-> Eq (ApiJob payload)
forall payload.
Eq payload =>
ApiJob payload -> ApiJob payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
ApiJob payload -> ApiJob payload -> Bool
== :: ApiJob payload -> ApiJob payload -> Bool
$c/= :: forall payload.
Eq payload =>
ApiJob payload -> ApiJob payload -> Bool
/= :: ApiJob payload -> ApiJob payload -> Bool
Eq, Int -> ApiJob payload -> ShowS
[ApiJob payload] -> ShowS
ApiJob payload -> String
(Int -> ApiJob payload -> ShowS)
-> (ApiJob payload -> String)
-> ([ApiJob payload] -> ShowS)
-> Show (ApiJob payload)
forall payload. Show payload => Int -> ApiJob payload -> ShowS
forall payload. Show payload => [ApiJob payload] -> ShowS
forall payload. Show payload => ApiJob payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload. Show payload => Int -> ApiJob payload -> ShowS
showsPrec :: Int -> ApiJob payload -> ShowS
$cshow :: forall payload. Show payload => ApiJob payload -> String
show :: ApiJob payload -> String
$cshowList :: forall payload. Show payload => [ApiJob payload] -> ShowS
showList :: [ApiJob payload] -> ShowS
Show)

-- | A job row plus its SQL-derived status, for the list endpoint.
data ApiJobWithStatus payload = ApiJobWithStatus
  { forall payload. ApiJobWithStatus payload -> JobRead payload
ajwsJob :: JobRead payload
  , forall payload. ApiJobWithStatus payload -> JobStatus
ajwsStatus :: JobStatus
  }
  deriving stock (ApiJobWithStatus payload -> ApiJobWithStatus payload -> Bool
(ApiJobWithStatus payload -> ApiJobWithStatus payload -> Bool)
-> (ApiJobWithStatus payload -> ApiJobWithStatus payload -> Bool)
-> Eq (ApiJobWithStatus payload)
forall payload.
Eq payload =>
ApiJobWithStatus payload -> ApiJobWithStatus payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
ApiJobWithStatus payload -> ApiJobWithStatus payload -> Bool
== :: ApiJobWithStatus payload -> ApiJobWithStatus payload -> Bool
$c/= :: forall payload.
Eq payload =>
ApiJobWithStatus payload -> ApiJobWithStatus payload -> Bool
/= :: ApiJobWithStatus payload -> ApiJobWithStatus payload -> Bool
Eq, Int -> ApiJobWithStatus payload -> ShowS
[ApiJobWithStatus payload] -> ShowS
ApiJobWithStatus payload -> String
(Int -> ApiJobWithStatus payload -> ShowS)
-> (ApiJobWithStatus payload -> String)
-> ([ApiJobWithStatus payload] -> ShowS)
-> Show (ApiJobWithStatus payload)
forall payload.
Show payload =>
Int -> ApiJobWithStatus payload -> ShowS
forall payload. Show payload => [ApiJobWithStatus payload] -> ShowS
forall payload. Show payload => ApiJobWithStatus payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload.
Show payload =>
Int -> ApiJobWithStatus payload -> ShowS
showsPrec :: Int -> ApiJobWithStatus payload -> ShowS
$cshow :: forall payload. Show payload => ApiJobWithStatus payload -> String
show :: ApiJobWithStatus payload -> String
$cshowList :: forall payload. Show payload => [ApiJobWithStatus payload] -> ShowS
showList :: [ApiJobWithStatus payload] -> ShowS
Show)

-- | Write-side job type for REST API insertion.
--
-- Accepts @payload@, @groupKey@, @priority@, @notVisibleUntil@, @dedupKey@,
-- and @maxAttempts@. Fields like @parentId@, @parentState@, and @suspended@
-- are managed internally and cannot be set through the REST API.
newtype ApiJobWrite payload = ApiJobWrite {forall payload. ApiJobWrite payload -> JobWrite payload
unApiJobWrite :: JobWrite payload}
  deriving newtype (ApiJobWrite payload -> ApiJobWrite payload -> Bool
(ApiJobWrite payload -> ApiJobWrite payload -> Bool)
-> (ApiJobWrite payload -> ApiJobWrite payload -> Bool)
-> Eq (ApiJobWrite payload)
forall payload.
Eq payload =>
ApiJobWrite payload -> ApiJobWrite payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
ApiJobWrite payload -> ApiJobWrite payload -> Bool
== :: ApiJobWrite payload -> ApiJobWrite payload -> Bool
$c/= :: forall payload.
Eq payload =>
ApiJobWrite payload -> ApiJobWrite payload -> Bool
/= :: ApiJobWrite payload -> ApiJobWrite payload -> Bool
Eq, Int -> ApiJobWrite payload -> ShowS
[ApiJobWrite payload] -> ShowS
ApiJobWrite payload -> String
(Int -> ApiJobWrite payload -> ShowS)
-> (ApiJobWrite payload -> String)
-> ([ApiJobWrite payload] -> ShowS)
-> Show (ApiJobWrite payload)
forall payload. Show payload => Int -> ApiJobWrite payload -> ShowS
forall payload. Show payload => [ApiJobWrite payload] -> ShowS
forall payload. Show payload => ApiJobWrite payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload. Show payload => Int -> ApiJobWrite payload -> ShowS
showsPrec :: Int -> ApiJobWrite payload -> ShowS
$cshow :: forall payload. Show payload => ApiJobWrite payload -> String
show :: ApiJobWrite payload -> String
$cshowList :: forall payload. Show payload => [ApiJobWrite payload] -> ShowS
showList :: [ApiJobWrite payload] -> ShowS
Show)

-- | Shared JSON field list for a job row. 'ApiJobWithStatus' appends @status@.
apiJobPairs :: (ToJSON payload) => JobRead payload -> [Pair]
apiJobPairs :: forall payload. ToJSON payload => JobRead payload -> [Pair]
apiJobPairs JobRead payload
job =
  [ Key
"primaryKey" Key -> Int64 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Int64
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> key
Arb.primaryKey JobRead payload
job
  , Key
"payload" Key -> payload -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> payload
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> payload
Arb.payload JobRead payload
job
  , Key
"queueName" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Text
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> q
Arb.queueName JobRead payload
job
  , Key
"groupKey" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe Text
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe Text
Arb.groupKey JobRead payload
job
  , Key
"insertedAt" Key -> UTCTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> UTCTime
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> insertedAt
Arb.insertedAt JobRead payload
job
  , Key
"updatedAt" Key -> Maybe UTCTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe UTCTime
forall payload q insertedAt adm.
JobRecord payload Int64 q insertedAt adm -> Maybe UTCTime
Arb.updatedAt JobRead payload
job
  , Key
"attempts" Key -> Int32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Int32
forall payload q insertedAt adm.
JobRecord payload Int64 q insertedAt adm -> Int32
Arb.attempts JobRead payload
job
  , Key
"lastError" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe Text
forall payload q insertedAt adm.
JobRecord payload Int64 q insertedAt adm -> Maybe Text
Arb.lastError JobRead payload
job
  , Key
"priority" Key -> Int32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Int32
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Int32
Arb.priority JobRead payload
job
  , Key
"lastAttemptedAt" Key -> Maybe UTCTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe UTCTime
forall payload q insertedAt adm.
JobRecord payload Int64 q insertedAt adm -> Maybe UTCTime
Arb.lastAttemptedAt JobRead payload
job
  , Key
"notVisibleUntil" Key -> Maybe UTCTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe UTCTime
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe UTCTime
Arb.notVisibleUntil JobRead payload
job
  , Key
"dedupKey" Key -> Maybe DedupKey -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe DedupKey
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe DedupKey
Arb.dedupKey JobRead payload
job
  , Key
"maxAttempts" Key -> Maybe Int32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe Int32
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe Int32
Arb.maxAttempts JobRead payload
job
  , Key
"parentId" Key -> Maybe Int64 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe Int64
forall payload q insertedAt adm.
JobRecord payload Int64 q insertedAt adm -> Maybe Int64
Arb.parentId JobRead payload
job
  , Key
"parentState" Key -> Maybe Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe Value
forall payload q insertedAt adm.
JobRecord payload Int64 q insertedAt adm -> Maybe Value
Arb.parentState JobRead payload
job
  , Key
"isRollup" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Bool
forall p q t adm. Job p Int64 q t adm -> Bool
isRollup JobRead payload
job
  , Key
"traceparent" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (TraceContext -> Text
traceparent (TraceContext -> Text) -> Maybe TraceContext -> Maybe Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> JobRead payload -> Maybe TraceContext
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe TraceContext
Arb.traceContext JobRead payload
job)
  , Key
"tracestate" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (TraceContext -> Maybe Text
tracestate (TraceContext -> Maybe Text) -> Maybe TraceContext -> Maybe Text
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< JobRead payload -> Maybe TraceContext
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe TraceContext
Arb.traceContext JobRead payload
job)
  , Key
"suspended" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Bool
forall p q t adm. Job p Int64 q t adm -> Bool
Arb.suspended JobRead payload
job
  , Key
"claimedBy" Key -> Maybe UUID -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe UUID
forall payload q insertedAt adm.
JobRecord payload Int64 q insertedAt adm -> Maybe UUID
Arb.claimedBy JobRead payload
job
  , Key
"claimSeq" Key -> Int64 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Int64
forall payload q insertedAt adm.
JobRecord payload Int64 q insertedAt adm -> Int64
Arb.claimSeq JobRead payload
job
  , Key
"archiveFor" Key -> Maybe Int32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> Maybe Int32
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe Int32
Arb.archiveFor JobRead payload
job
  , Key
"kind" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= PayloadKeys -> Maybe Text
Arb.jobKind (JobRead payload -> PayloadKeys
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> adm
Arb.payloadKeys JobRead payload
job)
  , Key
"rateLimit" Key -> Maybe RateLimitKey -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= PayloadKeys -> Maybe RateLimitKey
Arb.jobRateLimitKey (JobRead payload -> PayloadKeys
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> adm
Arb.payloadKeys JobRead payload
job)
  , Key
"concurrency" Key -> Maybe ConcurrencyKey -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= PayloadKeys -> Maybe ConcurrencyKey
Arb.jobConcurrencyKey (JobRead payload -> PayloadKeys
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> adm
Arb.payloadKeys JobRead payload
job)
  ]

instance (ToJSON payload) => ToJSON (ApiJob payload) where
  toJSON :: ApiJob payload -> Value
toJSON (ApiJob JobRead payload
job) = [Pair] -> Value
object (JobRead payload -> [Pair]
forall payload. ToJSON payload => JobRead payload -> [Pair]
apiJobPairs JobRead payload
job)

instance (ToJSON payload) => ToJSON (ApiJobWithStatus payload) where
  toJSON :: ApiJobWithStatus payload -> Value
toJSON (ApiJobWithStatus JobRead payload
job JobStatus
status) = [Pair] -> Value
object (JobRead payload -> [Pair]
forall payload. ToJSON payload => JobRead payload -> [Pair]
apiJobPairs JobRead payload
job [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Key
"status" Key -> JobStatus -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobStatus
status])

instance (FromJSON payload) => FromJSON (ApiJob payload) where
  parseJSON :: Value -> Parser (ApiJob payload)
parseJSON Value
value = JobRead payload -> ApiJob payload
forall payload. JobRead payload -> ApiJob payload
ApiJob (JobRead payload -> ApiJob payload)
-> Parser (JobRead payload) -> Parser (ApiJob payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (JobRead payload)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
value

instance (FromJSON payload) => FromJSON (ApiJobWithStatus payload) where
  parseJSON :: Value -> Parser (ApiJobWithStatus payload)
parseJSON Value
value = do
    ApiJob job <- Value -> Parser (ApiJob payload)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
value
    status <- withObject "JobWithStatus" (.: "status") value
    pure $ ApiJobWithStatus job status

instance (ToJSON payload) => ToJSON (ApiJobWrite payload) where
  toJSON :: ApiJobWrite payload -> Value
toJSON (ApiJobWrite JobWrite payload
job) =
    [Pair] -> Value
object
      [ Key
"payload" Key -> payload -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobWrite payload -> payload
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> payload
Arb.payload JobWrite payload
job
      , Key
"groupKey" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobWrite payload -> Maybe Text
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe Text
Arb.groupKey JobWrite payload
job
      , Key
"priority" Key -> Int32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobWrite payload -> Int32
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Int32
Arb.priority JobWrite payload
job
      , Key
"notVisibleUntil" Key -> Maybe UTCTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobWrite payload -> Maybe UTCTime
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe UTCTime
Arb.notVisibleUntil JobWrite payload
job
      , Key
"dedupKey" Key -> Maybe DedupKey -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobWrite payload -> Maybe DedupKey
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe DedupKey
Arb.dedupKey JobWrite payload
job
      , Key
"maxAttempts" Key -> Maybe Int32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobWrite payload -> Maybe Int32
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe Int32
Arb.maxAttempts JobWrite payload
job
      , Key
"archiveFor" Key -> Maybe Int32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobWrite payload -> Maybe Int32
forall payload key q insertedAt adm.
JobRecord payload key q insertedAt adm -> Maybe Int32
Arb.archiveFor JobWrite payload
job
      ]

instance (FromJSON payload) => FromJSON (ApiJobWrite payload) where
  parseJSON :: Value -> Parser (ApiJobWrite payload)
parseJSON = String
-> (Object -> Parser (ApiJobWrite payload))
-> Value
-> Parser (ApiJobWrite payload)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"JobWrite" ((Object -> Parser (ApiJobWrite payload))
 -> Value -> Parser (ApiJobWrite payload))
-> (Object -> Parser (ApiJobWrite payload))
-> Value
-> Parser (ApiJobWrite payload)
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
    payload <- Object
obj Object -> Key -> Parser payload
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"payload"
    group <- obj .:? "groupKey"
    priority <- obj .:? "priority" .!= 0
    visibleAt <- obj .:? "notVisibleUntil"
    dedup <- obj .:? "dedupKey"
    attempts <- obj .:? "maxAttempts"
    retention <- obj .:! "archiveFor" .!= Nothing
    pure . ApiJobWrite
      $ Arb.setArchiveFor retention
      $ Arb.setMaxAttempts attempts
      $ Arb.setDedupKey dedup
      $ Arb.setNotVisibleUntil visibleAt
      $ Arb.setPriority priority
      $ Arb.setGroupKey group
      $ Arb.defaultJob payload

-- | A DLQ entry in its JSON wire shape.
newtype ApiDLQJob payload = ApiDLQJob {forall payload. ApiDLQJob payload -> DLQJob payload
unApiDLQJob :: DLQ.DLQJob payload}
  deriving stock (ApiDLQJob payload -> ApiDLQJob payload -> Bool
(ApiDLQJob payload -> ApiDLQJob payload -> Bool)
-> (ApiDLQJob payload -> ApiDLQJob payload -> Bool)
-> Eq (ApiDLQJob payload)
forall payload.
Eq payload =>
ApiDLQJob payload -> ApiDLQJob payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
ApiDLQJob payload -> ApiDLQJob payload -> Bool
== :: ApiDLQJob payload -> ApiDLQJob payload -> Bool
$c/= :: forall payload.
Eq payload =>
ApiDLQJob payload -> ApiDLQJob payload -> Bool
/= :: ApiDLQJob payload -> ApiDLQJob payload -> Bool
Eq, Int -> ApiDLQJob payload -> ShowS
[ApiDLQJob payload] -> ShowS
ApiDLQJob payload -> String
(Int -> ApiDLQJob payload -> ShowS)
-> (ApiDLQJob payload -> String)
-> ([ApiDLQJob payload] -> ShowS)
-> Show (ApiDLQJob payload)
forall payload. Show payload => Int -> ApiDLQJob payload -> ShowS
forall payload. Show payload => [ApiDLQJob payload] -> ShowS
forall payload. Show payload => ApiDLQJob payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload. Show payload => Int -> ApiDLQJob payload -> ShowS
showsPrec :: Int -> ApiDLQJob payload -> ShowS
$cshow :: forall payload. Show payload => ApiDLQJob payload -> String
show :: ApiDLQJob payload -> String
$cshowList :: forall payload. Show payload => [ApiDLQJob payload] -> ShowS
showList :: [ApiDLQJob payload] -> ShowS
Show)

instance (ToJSON payload) => ToJSON (ApiDLQJob payload) where
  toJSON :: ApiDLQJob payload -> Value
toJSON (ApiDLQJob DLQJob payload
dlq) =
    [Pair] -> Value
object
      [ Key
"dlqPrimaryKey" Key -> Int64 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DLQJob payload -> Int64
forall payload. DLQJob payload -> Int64
DLQ.dlqPrimaryKey DLQJob payload
dlq
      , Key
"failedAt" Key -> UTCTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DLQJob payload -> UTCTime
forall payload. DLQJob payload -> UTCTime
DLQ.failedAt DLQJob payload
dlq
      , Key
"jobSnapshot" Key -> ApiJob payload -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> ApiJob payload
forall payload. JobRead payload -> ApiJob payload
ApiJob (DLQJob payload -> JobRead payload
forall payload. DLQJob payload -> JobSnapshot payload
DLQ.jobSnapshot DLQJob payload
dlq)
      ]

instance (FromJSON payload) => FromJSON (ApiDLQJob payload) where
  parseJSON :: Value -> Parser (ApiDLQJob payload)
parseJSON = String
-> (Object -> Parser (ApiDLQJob payload))
-> Value
-> Parser (ApiDLQJob payload)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"DLQJob" ((Object -> Parser (ApiDLQJob payload))
 -> Value -> Parser (ApiDLQJob payload))
-> (Object -> Parser (ApiDLQJob payload))
-> Value
-> Parser (ApiDLQJob payload)
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
    apiJob <- Object
obj Object -> Key -> Parser (ApiJob payload)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"jobSnapshot"
    dlq <-
      DLQ.DLQJob
        <$> obj .: "dlqPrimaryKey"
        <*> obj .: "failedAt"
        <*> pure (unApiJob apiJob)
    pure $ ApiDLQJob dlq

-- | An archived job in its JSON wire shape.
newtype ApiArchiveJob payload = ApiArchiveJob {forall payload. ApiArchiveJob payload -> ArchiveJob payload
unApiArchiveJob :: Archive.ArchiveJob payload}
  deriving stock (ApiArchiveJob payload -> ApiArchiveJob payload -> Bool
(ApiArchiveJob payload -> ApiArchiveJob payload -> Bool)
-> (ApiArchiveJob payload -> ApiArchiveJob payload -> Bool)
-> Eq (ApiArchiveJob payload)
forall payload.
Eq payload =>
ApiArchiveJob payload -> ApiArchiveJob payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
ApiArchiveJob payload -> ApiArchiveJob payload -> Bool
== :: ApiArchiveJob payload -> ApiArchiveJob payload -> Bool
$c/= :: forall payload.
Eq payload =>
ApiArchiveJob payload -> ApiArchiveJob payload -> Bool
/= :: ApiArchiveJob payload -> ApiArchiveJob payload -> Bool
Eq, Int -> ApiArchiveJob payload -> ShowS
[ApiArchiveJob payload] -> ShowS
ApiArchiveJob payload -> String
(Int -> ApiArchiveJob payload -> ShowS)
-> (ApiArchiveJob payload -> String)
-> ([ApiArchiveJob payload] -> ShowS)
-> Show (ApiArchiveJob payload)
forall payload.
Show payload =>
Int -> ApiArchiveJob payload -> ShowS
forall payload. Show payload => [ApiArchiveJob payload] -> ShowS
forall payload. Show payload => ApiArchiveJob payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload.
Show payload =>
Int -> ApiArchiveJob payload -> ShowS
showsPrec :: Int -> ApiArchiveJob payload -> ShowS
$cshow :: forall payload. Show payload => ApiArchiveJob payload -> String
show :: ApiArchiveJob payload -> String
$cshowList :: forall payload. Show payload => [ApiArchiveJob payload] -> ShowS
showList :: [ApiArchiveJob payload] -> ShowS
Show)

instance (ToJSON payload) => ToJSON (ApiArchiveJob payload) where
  toJSON :: ApiArchiveJob payload -> Value
toJSON (ApiArchiveJob ArchiveJob payload
archived) =
    [Pair] -> Value
object
      [ Key
"archivePrimaryKey" Key -> Int64 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ArchiveJob payload -> Int64
forall payload. ArchiveJob payload -> Int64
Archive.archivePrimaryKey ArchiveJob payload
archived
      , Key
"completedAt" Key -> UTCTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ArchiveJob payload -> UTCTime
forall payload. ArchiveJob payload -> UTCTime
Archive.completedAt ArchiveJob payload
archived
      , Key
"jobSnapshot" Key -> ApiJob payload -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobRead payload -> ApiJob payload
forall payload. JobRead payload -> ApiJob payload
ApiJob (ArchiveJob payload -> JobRead payload
forall payload. ArchiveJob payload -> JobSnapshot payload
Archive.jobSnapshot ArchiveJob payload
archived)
      , Key
"result" Key -> Maybe Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ArchiveJob payload -> Maybe Value
forall payload. ArchiveJob payload -> Maybe Value
Archive.archivedResult ArchiveJob payload
archived
      ]

instance (FromJSON payload) => FromJSON (ApiArchiveJob payload) where
  parseJSON :: Value -> Parser (ApiArchiveJob payload)
parseJSON = String
-> (Object -> Parser (ApiArchiveJob payload))
-> Value
-> Parser (ApiArchiveJob payload)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ArchiveJob" ((Object -> Parser (ApiArchiveJob payload))
 -> Value -> Parser (ApiArchiveJob payload))
-> (Object -> Parser (ApiArchiveJob payload))
-> Value
-> Parser (ApiArchiveJob payload)
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
    apiJob <- Object
obj Object -> Key -> Parser (ApiJob payload)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"jobSnapshot"
    archived <-
      Archive.ArchiveJob
        <$> obj .: "archivePrimaryKey"
        <*> obj .: "completedAt"
        <*> pure (unApiJob apiJob)
        <*> obj .:? "result"
    pure $ ApiArchiveJob archived

-- | Response wrapper for archived jobs.
data ArchiveResponse payload = ArchiveResponse
  { forall payload. ArchiveResponse payload -> [ApiArchiveJob payload]
archiveJobs :: [ApiArchiveJob payload]
  , forall payload. ArchiveResponse payload -> Int
archiveTotal :: Int
  , forall payload. ArchiveResponse payload -> Int
archiveOffset :: Int
  , forall payload. ArchiveResponse payload -> Int
archiveLimit :: Int
  }
  deriving stock (ArchiveResponse payload -> ArchiveResponse payload -> Bool
(ArchiveResponse payload -> ArchiveResponse payload -> Bool)
-> (ArchiveResponse payload -> ArchiveResponse payload -> Bool)
-> Eq (ArchiveResponse payload)
forall payload.
Eq payload =>
ArchiveResponse payload -> ArchiveResponse payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
ArchiveResponse payload -> ArchiveResponse payload -> Bool
== :: ArchiveResponse payload -> ArchiveResponse payload -> Bool
$c/= :: forall payload.
Eq payload =>
ArchiveResponse payload -> ArchiveResponse payload -> Bool
/= :: ArchiveResponse payload -> ArchiveResponse payload -> Bool
Eq, (forall x.
 ArchiveResponse payload -> Rep (ArchiveResponse payload) x)
-> (forall x.
    Rep (ArchiveResponse payload) x -> ArchiveResponse payload)
-> Generic (ArchiveResponse payload)
forall x.
Rep (ArchiveResponse payload) x -> ArchiveResponse payload
forall x.
ArchiveResponse payload -> Rep (ArchiveResponse payload) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall payload x.
Rep (ArchiveResponse payload) x -> ArchiveResponse payload
forall payload x.
ArchiveResponse payload -> Rep (ArchiveResponse payload) x
$cfrom :: forall payload x.
ArchiveResponse payload -> Rep (ArchiveResponse payload) x
from :: forall x.
ArchiveResponse payload -> Rep (ArchiveResponse payload) x
$cto :: forall payload x.
Rep (ArchiveResponse payload) x -> ArchiveResponse payload
to :: forall x.
Rep (ArchiveResponse payload) x -> ArchiveResponse payload
Generic, Int -> ArchiveResponse payload -> ShowS
[ArchiveResponse payload] -> ShowS
ArchiveResponse payload -> String
(Int -> ArchiveResponse payload -> ShowS)
-> (ArchiveResponse payload -> String)
-> ([ArchiveResponse payload] -> ShowS)
-> Show (ArchiveResponse payload)
forall payload.
Show payload =>
Int -> ArchiveResponse payload -> ShowS
forall payload. Show payload => [ArchiveResponse payload] -> ShowS
forall payload. Show payload => ArchiveResponse payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload.
Show payload =>
Int -> ArchiveResponse payload -> ShowS
showsPrec :: Int -> ArchiveResponse payload -> ShowS
$cshow :: forall payload. Show payload => ArchiveResponse payload -> String
show :: ArchiveResponse payload -> String
$cshowList :: forall payload. Show payload => [ArchiveResponse payload] -> ShowS
showList :: [ArchiveResponse payload] -> ShowS
Show)
  deriving anyclass (Maybe (ArchiveResponse payload)
Value -> Parser [ArchiveResponse payload]
Value -> Parser (ArchiveResponse payload)
(Value -> Parser (ArchiveResponse payload))
-> (Value -> Parser [ArchiveResponse payload])
-> Maybe (ArchiveResponse payload)
-> FromJSON (ArchiveResponse payload)
forall payload. FromJSON payload => Maybe (ArchiveResponse payload)
forall payload.
FromJSON payload =>
Value -> Parser [ArchiveResponse payload]
forall payload.
FromJSON payload =>
Value -> Parser (ArchiveResponse payload)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: forall payload.
FromJSON payload =>
Value -> Parser (ArchiveResponse payload)
parseJSON :: Value -> Parser (ArchiveResponse payload)
$cparseJSONList :: forall payload.
FromJSON payload =>
Value -> Parser [ArchiveResponse payload]
parseJSONList :: Value -> Parser [ArchiveResponse payload]
$comittedField :: forall payload. FromJSON payload => Maybe (ArchiveResponse payload)
omittedField :: Maybe (ArchiveResponse payload)
FromJSON, [ArchiveResponse payload] -> Value
[ArchiveResponse payload] -> Encoding
ArchiveResponse payload -> Bool
ArchiveResponse payload -> Value
ArchiveResponse payload -> Encoding
(ArchiveResponse payload -> Value)
-> (ArchiveResponse payload -> Encoding)
-> ([ArchiveResponse payload] -> Value)
-> ([ArchiveResponse payload] -> Encoding)
-> (ArchiveResponse payload -> Bool)
-> ToJSON (ArchiveResponse payload)
forall payload.
ToJSON payload =>
[ArchiveResponse payload] -> Value
forall payload.
ToJSON payload =>
[ArchiveResponse payload] -> Encoding
forall payload. ToJSON payload => ArchiveResponse payload -> Bool
forall payload. ToJSON payload => ArchiveResponse payload -> Value
forall payload.
ToJSON payload =>
ArchiveResponse payload -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: forall payload. ToJSON payload => ArchiveResponse payload -> Value
toJSON :: ArchiveResponse payload -> Value
$ctoEncoding :: forall payload.
ToJSON payload =>
ArchiveResponse payload -> Encoding
toEncoding :: ArchiveResponse payload -> Encoding
$ctoJSONList :: forall payload.
ToJSON payload =>
[ArchiveResponse payload] -> Value
toJSONList :: [ArchiveResponse payload] -> Value
$ctoEncodingList :: forall payload.
ToJSON payload =>
[ArchiveResponse payload] -> Encoding
toEncodingList :: [ArchiveResponse payload] -> Encoding
$comitField :: forall payload. ToJSON payload => ArchiveResponse payload -> Bool
omitField :: ArchiveResponse payload -> Bool
ToJSON)

-- | Single-job response envelope, parameterized over the job representation
-- ('ApiJob' for insert, 'ApiJobWithStatus' for the detail endpoint).
newtype JobResponse a = JobResponse
  { forall a. JobResponse a -> a
job :: a
  }
  deriving stock (JobResponse a -> JobResponse a -> Bool
(JobResponse a -> JobResponse a -> Bool)
-> (JobResponse a -> JobResponse a -> Bool) -> Eq (JobResponse a)
forall a. Eq a => JobResponse a -> JobResponse a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => JobResponse a -> JobResponse a -> Bool
== :: JobResponse a -> JobResponse a -> Bool
$c/= :: forall a. Eq a => JobResponse a -> JobResponse a -> Bool
/= :: JobResponse a -> JobResponse a -> Bool
Eq, (forall x. JobResponse a -> Rep (JobResponse a) x)
-> (forall x. Rep (JobResponse a) x -> JobResponse a)
-> Generic (JobResponse a)
forall x. Rep (JobResponse a) x -> JobResponse a
forall x. JobResponse a -> Rep (JobResponse a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (JobResponse a) x -> JobResponse a
forall a x. JobResponse a -> Rep (JobResponse a) x
$cfrom :: forall a x. JobResponse a -> Rep (JobResponse a) x
from :: forall x. JobResponse a -> Rep (JobResponse a) x
$cto :: forall a x. Rep (JobResponse a) x -> JobResponse a
to :: forall x. Rep (JobResponse a) x -> JobResponse a
Generic, Int -> JobResponse a -> ShowS
[JobResponse a] -> ShowS
JobResponse a -> String
(Int -> JobResponse a -> ShowS)
-> (JobResponse a -> String)
-> ([JobResponse a] -> ShowS)
-> Show (JobResponse a)
forall a. Show a => Int -> JobResponse a -> ShowS
forall a. Show a => [JobResponse a] -> ShowS
forall a. Show a => JobResponse a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> JobResponse a -> ShowS
showsPrec :: Int -> JobResponse a -> ShowS
$cshow :: forall a. Show a => JobResponse a -> String
show :: JobResponse a -> String
$cshowList :: forall a. Show a => [JobResponse a] -> ShowS
showList :: [JobResponse a] -> ShowS
Show)
  deriving anyclass (Maybe (JobResponse a)
Value -> Parser [JobResponse a]
Value -> Parser (JobResponse a)
(Value -> Parser (JobResponse a))
-> (Value -> Parser [JobResponse a])
-> Maybe (JobResponse a)
-> FromJSON (JobResponse a)
forall a. FromJSON a => Maybe (JobResponse a)
forall a. FromJSON a => Value -> Parser [JobResponse a]
forall a. FromJSON a => Value -> Parser (JobResponse a)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: forall a. FromJSON a => Value -> Parser (JobResponse a)
parseJSON :: Value -> Parser (JobResponse a)
$cparseJSONList :: forall a. FromJSON a => Value -> Parser [JobResponse a]
parseJSONList :: Value -> Parser [JobResponse a]
$comittedField :: forall a. FromJSON a => Maybe (JobResponse a)
omittedField :: Maybe (JobResponse a)
FromJSON, [JobResponse a] -> Value
[JobResponse a] -> Encoding
JobResponse a -> Bool
JobResponse a -> Value
JobResponse a -> Encoding
(JobResponse a -> Value)
-> (JobResponse a -> Encoding)
-> ([JobResponse a] -> Value)
-> ([JobResponse a] -> Encoding)
-> (JobResponse a -> Bool)
-> ToJSON (JobResponse a)
forall a. ToJSON a => [JobResponse a] -> Value
forall a. ToJSON a => [JobResponse a] -> Encoding
forall a. ToJSON a => JobResponse a -> Bool
forall a. ToJSON a => JobResponse a -> Value
forall a. ToJSON a => JobResponse a -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: forall a. ToJSON a => JobResponse a -> Value
toJSON :: JobResponse a -> Value
$ctoEncoding :: forall a. ToJSON a => JobResponse a -> Encoding
toEncoding :: JobResponse a -> Encoding
$ctoJSONList :: forall a. ToJSON a => [JobResponse a] -> Value
toJSONList :: [JobResponse a] -> Value
$ctoEncodingList :: forall a. ToJSON a => [JobResponse a] -> Encoding
toEncodingList :: [JobResponse a] -> Encoding
$comitField :: forall a. ToJSON a => JobResponse a -> Bool
omitField :: JobResponse a -> Bool
ToJSON)

-- | Response wrapper for multiple jobs.
data JobsResponse payload = JobsResponse
  { forall payload. JobsResponse payload -> [ApiJobWithStatus payload]
jobs :: [ApiJobWithStatus payload]
  , forall payload. JobsResponse payload -> Int
jobsTotal :: Int
  , forall payload. JobsResponse payload -> Int
jobsOffset :: Int
  , forall payload. JobsResponse payload -> Int
jobsLimit :: Int
  , forall payload. JobsResponse payload -> Map Int64 Int64
childCounts :: Map Int64 Int64
  , forall payload. JobsResponse payload -> [Int64]
pausedParents :: [Int64]
  , forall payload. JobsResponse payload -> Map Int64 Int64
dlqChildCounts :: Map Int64 Int64
  }
  deriving stock (JobsResponse payload -> JobsResponse payload -> Bool
(JobsResponse payload -> JobsResponse payload -> Bool)
-> (JobsResponse payload -> JobsResponse payload -> Bool)
-> Eq (JobsResponse payload)
forall payload.
Eq payload =>
JobsResponse payload -> JobsResponse payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
JobsResponse payload -> JobsResponse payload -> Bool
== :: JobsResponse payload -> JobsResponse payload -> Bool
$c/= :: forall payload.
Eq payload =>
JobsResponse payload -> JobsResponse payload -> Bool
/= :: JobsResponse payload -> JobsResponse payload -> Bool
Eq, (forall x. JobsResponse payload -> Rep (JobsResponse payload) x)
-> (forall x. Rep (JobsResponse payload) x -> JobsResponse payload)
-> Generic (JobsResponse payload)
forall x. Rep (JobsResponse payload) x -> JobsResponse payload
forall x. JobsResponse payload -> Rep (JobsResponse payload) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall payload x.
Rep (JobsResponse payload) x -> JobsResponse payload
forall payload x.
JobsResponse payload -> Rep (JobsResponse payload) x
$cfrom :: forall payload x.
JobsResponse payload -> Rep (JobsResponse payload) x
from :: forall x. JobsResponse payload -> Rep (JobsResponse payload) x
$cto :: forall payload x.
Rep (JobsResponse payload) x -> JobsResponse payload
to :: forall x. Rep (JobsResponse payload) x -> JobsResponse payload
Generic, Int -> JobsResponse payload -> ShowS
[JobsResponse payload] -> ShowS
JobsResponse payload -> String
(Int -> JobsResponse payload -> ShowS)
-> (JobsResponse payload -> String)
-> ([JobsResponse payload] -> ShowS)
-> Show (JobsResponse payload)
forall payload.
Show payload =>
Int -> JobsResponse payload -> ShowS
forall payload. Show payload => [JobsResponse payload] -> ShowS
forall payload. Show payload => JobsResponse payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload.
Show payload =>
Int -> JobsResponse payload -> ShowS
showsPrec :: Int -> JobsResponse payload -> ShowS
$cshow :: forall payload. Show payload => JobsResponse payload -> String
show :: JobsResponse payload -> String
$cshowList :: forall payload. Show payload => [JobsResponse payload] -> ShowS
showList :: [JobsResponse payload] -> ShowS
Show)
  deriving anyclass (Maybe (JobsResponse payload)
Value -> Parser [JobsResponse payload]
Value -> Parser (JobsResponse payload)
(Value -> Parser (JobsResponse payload))
-> (Value -> Parser [JobsResponse payload])
-> Maybe (JobsResponse payload)
-> FromJSON (JobsResponse payload)
forall payload. FromJSON payload => Maybe (JobsResponse payload)
forall payload.
FromJSON payload =>
Value -> Parser [JobsResponse payload]
forall payload.
FromJSON payload =>
Value -> Parser (JobsResponse payload)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: forall payload.
FromJSON payload =>
Value -> Parser (JobsResponse payload)
parseJSON :: Value -> Parser (JobsResponse payload)
$cparseJSONList :: forall payload.
FromJSON payload =>
Value -> Parser [JobsResponse payload]
parseJSONList :: Value -> Parser [JobsResponse payload]
$comittedField :: forall payload. FromJSON payload => Maybe (JobsResponse payload)
omittedField :: Maybe (JobsResponse payload)
FromJSON, [JobsResponse payload] -> Value
[JobsResponse payload] -> Encoding
JobsResponse payload -> Bool
JobsResponse payload -> Value
JobsResponse payload -> Encoding
(JobsResponse payload -> Value)
-> (JobsResponse payload -> Encoding)
-> ([JobsResponse payload] -> Value)
-> ([JobsResponse payload] -> Encoding)
-> (JobsResponse payload -> Bool)
-> ToJSON (JobsResponse payload)
forall payload. ToJSON payload => [JobsResponse payload] -> Value
forall payload.
ToJSON payload =>
[JobsResponse payload] -> Encoding
forall payload. ToJSON payload => JobsResponse payload -> Bool
forall payload. ToJSON payload => JobsResponse payload -> Value
forall payload. ToJSON payload => JobsResponse payload -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: forall payload. ToJSON payload => JobsResponse payload -> Value
toJSON :: JobsResponse payload -> Value
$ctoEncoding :: forall payload. ToJSON payload => JobsResponse payload -> Encoding
toEncoding :: JobsResponse payload -> Encoding
$ctoJSONList :: forall payload. ToJSON payload => [JobsResponse payload] -> Value
toJSONList :: [JobsResponse payload] -> Value
$ctoEncodingList :: forall payload.
ToJSON payload =>
[JobsResponse payload] -> Encoding
toEncodingList :: [JobsResponse payload] -> Encoding
$comitField :: forall payload. ToJSON payload => JobsResponse payload -> Bool
omitField :: JobsResponse payload -> Bool
ToJSON)

-- | A consumer's request to lease visible jobs.
data ClaimRequest = ClaimRequest
  { ClaimRequest -> Maybe Int
crMaxJobs :: Maybe Int
  , ClaimRequest -> Maybe Double
crLeaseSeconds :: Maybe Double
  }
  deriving stock (ClaimRequest -> ClaimRequest -> Bool
(ClaimRequest -> ClaimRequest -> Bool)
-> (ClaimRequest -> ClaimRequest -> Bool) -> Eq ClaimRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClaimRequest -> ClaimRequest -> Bool
== :: ClaimRequest -> ClaimRequest -> Bool
$c/= :: ClaimRequest -> ClaimRequest -> Bool
/= :: ClaimRequest -> ClaimRequest -> Bool
Eq, Int -> ClaimRequest -> ShowS
[ClaimRequest] -> ShowS
ClaimRequest -> String
(Int -> ClaimRequest -> ShowS)
-> (ClaimRequest -> String)
-> ([ClaimRequest] -> ShowS)
-> Show ClaimRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClaimRequest -> ShowS
showsPrec :: Int -> ClaimRequest -> ShowS
$cshow :: ClaimRequest -> String
show :: ClaimRequest -> String
$cshowList :: [ClaimRequest] -> ShowS
showList :: [ClaimRequest] -> ShowS
Show)

instance FromJSON ClaimRequest where
  parseJSON :: Value -> Parser ClaimRequest
parseJSON = String
-> (Object -> Parser ClaimRequest) -> Value -> Parser ClaimRequest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ClaimRequest" ((Object -> Parser ClaimRequest) -> Value -> Parser ClaimRequest)
-> (Object -> Parser ClaimRequest) -> Value -> Parser ClaimRequest
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
    Maybe Int -> Maybe Double -> ClaimRequest
ClaimRequest (Maybe Int -> Maybe Double -> ClaimRequest)
-> Parser (Maybe Int) -> Parser (Maybe Double -> ClaimRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"maxJobs" Parser (Maybe Double -> ClaimRequest)
-> Parser (Maybe Double) -> Parser ClaimRequest
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"leaseSeconds"

instance ToJSON ClaimRequest where
  toJSON :: ClaimRequest -> Value
toJSON ClaimRequest
req = [Pair] -> Value
object [Key
"maxJobs" Key -> Maybe Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ClaimRequest -> Maybe Int
crMaxJobs ClaimRequest
req, Key
"leaseSeconds" Key -> Maybe Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ClaimRequest -> Maybe Double
crLeaseSeconds ClaimRequest
req]

-- | Jobs returned by one claim. Each job contains the lease fields required for
-- finalization.
newtype ClaimResponse payload = ClaimResponse {forall payload. ClaimResponse payload -> [ApiJob payload]
claimedJobs :: [ApiJob payload]}
  deriving stock (ClaimResponse payload -> ClaimResponse payload -> Bool
(ClaimResponse payload -> ClaimResponse payload -> Bool)
-> (ClaimResponse payload -> ClaimResponse payload -> Bool)
-> Eq (ClaimResponse payload)
forall payload.
Eq payload =>
ClaimResponse payload -> ClaimResponse payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
ClaimResponse payload -> ClaimResponse payload -> Bool
== :: ClaimResponse payload -> ClaimResponse payload -> Bool
$c/= :: forall payload.
Eq payload =>
ClaimResponse payload -> ClaimResponse payload -> Bool
/= :: ClaimResponse payload -> ClaimResponse payload -> Bool
Eq, Int -> ClaimResponse payload -> ShowS
[ClaimResponse payload] -> ShowS
ClaimResponse payload -> String
(Int -> ClaimResponse payload -> ShowS)
-> (ClaimResponse payload -> String)
-> ([ClaimResponse payload] -> ShowS)
-> Show (ClaimResponse payload)
forall payload.
Show payload =>
Int -> ClaimResponse payload -> ShowS
forall payload. Show payload => [ClaimResponse payload] -> ShowS
forall payload. Show payload => ClaimResponse payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload.
Show payload =>
Int -> ClaimResponse payload -> ShowS
showsPrec :: Int -> ClaimResponse payload -> ShowS
$cshow :: forall payload. Show payload => ClaimResponse payload -> String
show :: ClaimResponse payload -> String
$cshowList :: forall payload. Show payload => [ClaimResponse payload] -> ShowS
showList :: [ClaimResponse payload] -> ShowS
Show)

instance (ToJSON payload) => ToJSON (ClaimResponse payload) where
  toJSON :: ClaimResponse payload -> Value
toJSON (ClaimResponse [ApiJob payload]
claimed) = [Pair] -> Value
object [Key
"jobs" Key -> [ApiJob payload] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [ApiJob payload]
claimed]

instance (FromJSON payload) => FromJSON (ClaimResponse payload) where
  parseJSON :: Value -> Parser (ClaimResponse payload)
parseJSON = String
-> (Object -> Parser (ClaimResponse payload))
-> Value
-> Parser (ClaimResponse payload)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ClaimResponse" ((Object -> Parser (ClaimResponse payload))
 -> Value -> Parser (ClaimResponse payload))
-> (Object -> Parser (ClaimResponse payload))
-> Value
-> Parser (ClaimResponse payload)
forall a b. (a -> b) -> a -> b
$ \Object
obj -> [ApiJob payload] -> ClaimResponse payload
forall payload. [ApiJob payload] -> ClaimResponse payload
ClaimResponse ([ApiJob payload] -> ClaimResponse payload)
-> Parser [ApiJob payload] -> Parser (ClaimResponse payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Key -> Parser [ApiJob payload]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"jobs"

-- | Proof that the caller still holds a claimed job.
data JobLease = JobLease
  { JobLease -> Int64
jlClaimSeq :: Int64
  , JobLease -> UUID
jlClaimedBy :: UUID
  }
  deriving stock (JobLease -> JobLease -> Bool
(JobLease -> JobLease -> Bool)
-> (JobLease -> JobLease -> Bool) -> Eq JobLease
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: JobLease -> JobLease -> Bool
== :: JobLease -> JobLease -> Bool
$c/= :: JobLease -> JobLease -> Bool
/= :: JobLease -> JobLease -> Bool
Eq, Int -> JobLease -> ShowS
[JobLease] -> ShowS
JobLease -> String
(Int -> JobLease -> ShowS)
-> (JobLease -> String) -> ([JobLease] -> ShowS) -> Show JobLease
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JobLease -> ShowS
showsPrec :: Int -> JobLease -> ShowS
$cshow :: JobLease -> String
show :: JobLease -> String
$cshowList :: [JobLease] -> ShowS
showList :: [JobLease] -> ShowS
Show)

instance FromJSON JobLease where
  parseJSON :: Value -> Parser JobLease
parseJSON = String -> (Object -> Parser JobLease) -> Value -> Parser JobLease
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"JobLease" ((Object -> Parser JobLease) -> Value -> Parser JobLease)
-> (Object -> Parser JobLease) -> Value -> Parser JobLease
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
    Int64 -> UUID -> JobLease
JobLease (Int64 -> UUID -> JobLease)
-> Parser Int64 -> Parser (UUID -> JobLease)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Key -> Parser Int64
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"claimSeq" Parser (UUID -> JobLease) -> Parser UUID -> Parser JobLease
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser UUID
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"claimedBy"

-- | Shared JSON fields for a lease. Request encoders append request-specific fields.
jobLeasePairs :: JobLease -> [Pair]
jobLeasePairs :: JobLease -> [Pair]
jobLeasePairs JobLease
lease = [Key
"claimSeq" Key -> Int64 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobLease -> Int64
jlClaimSeq JobLease
lease, Key
"claimedBy" Key -> UUID -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobLease -> UUID
jlClaimedBy JobLease
lease]

instance ToJSON JobLease where
  toJSON :: JobLease -> Value
toJSON = [Pair] -> Value
object ([Pair] -> Value) -> (JobLease -> [Pair]) -> JobLease -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JobLease -> [Pair]
jobLeasePairs

-- | A lease and an optional stored result. An absent result performs a plain ack.
data AckRequest result = AckRequest
  { forall result. AckRequest result -> JobLease
arLease :: JobLease
  , forall result. AckRequest result -> Maybe result
arResult :: Maybe result
  }
  deriving stock (AckRequest result -> AckRequest result -> Bool
(AckRequest result -> AckRequest result -> Bool)
-> (AckRequest result -> AckRequest result -> Bool)
-> Eq (AckRequest result)
forall result.
Eq result =>
AckRequest result -> AckRequest result -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall result.
Eq result =>
AckRequest result -> AckRequest result -> Bool
== :: AckRequest result -> AckRequest result -> Bool
$c/= :: forall result.
Eq result =>
AckRequest result -> AckRequest result -> Bool
/= :: AckRequest result -> AckRequest result -> Bool
Eq, Int -> AckRequest result -> ShowS
[AckRequest result] -> ShowS
AckRequest result -> String
(Int -> AckRequest result -> ShowS)
-> (AckRequest result -> String)
-> ([AckRequest result] -> ShowS)
-> Show (AckRequest result)
forall result. Show result => Int -> AckRequest result -> ShowS
forall result. Show result => [AckRequest result] -> ShowS
forall result. Show result => AckRequest result -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall result. Show result => Int -> AckRequest result -> ShowS
showsPrec :: Int -> AckRequest result -> ShowS
$cshow :: forall result. Show result => AckRequest result -> String
show :: AckRequest result -> String
$cshowList :: forall result. Show result => [AckRequest result] -> ShowS
showList :: [AckRequest result] -> ShowS
Show)

instance (FromJSON result) => FromJSON (AckRequest result) where
  parseJSON :: Value -> Parser (AckRequest result)
parseJSON = String
-> (Object -> Parser (AckRequest result))
-> Value
-> Parser (AckRequest result)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"AckRequest" ((Object -> Parser (AckRequest result))
 -> Value -> Parser (AckRequest result))
-> (Object -> Parser (AckRequest result))
-> Value
-> Parser (AckRequest result)
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
    JobLease -> Maybe result -> AckRequest result
forall result. JobLease -> Maybe result -> AckRequest result
AckRequest (JobLease -> Maybe result -> AckRequest result)
-> Parser JobLease -> Parser (Maybe result -> AckRequest result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser JobLease
forall a. FromJSON a => Value -> Parser a
parseJSON (Object -> Value
Object Object
obj) Parser (Maybe result -> AckRequest result)
-> Parser (Maybe result) -> Parser (AckRequest result)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser (Maybe result)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"result"

instance (ToJSON result) => ToJSON (AckRequest result) where
  toJSON :: AckRequest result -> Value
toJSON AckRequest result
req = [Pair] -> Value
object (JobLease -> [Pair]
jobLeasePairs (AckRequest result -> JobLease
forall result. AckRequest result -> JobLease
arLease AckRequest result
req) [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> (result -> [Pair]) -> Maybe result -> [Pair]
forall m a. Monoid m => (a -> m) -> Maybe a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (\result
stored -> [Key
"result" Key -> result -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= result
stored]) (AckRequest result -> Maybe result
forall result. AckRequest result -> Maybe result
arResult AckRequest result
req))

-- | A lease plus the window to hide the job for, counted from now.
data ExtendRequest = ExtendRequest
  { ExtendRequest -> JobLease
erLease :: JobLease
  , ExtendRequest -> Double
erSeconds :: Double
  }
  deriving stock (ExtendRequest -> ExtendRequest -> Bool
(ExtendRequest -> ExtendRequest -> Bool)
-> (ExtendRequest -> ExtendRequest -> Bool) -> Eq ExtendRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExtendRequest -> ExtendRequest -> Bool
== :: ExtendRequest -> ExtendRequest -> Bool
$c/= :: ExtendRequest -> ExtendRequest -> Bool
/= :: ExtendRequest -> ExtendRequest -> Bool
Eq, Int -> ExtendRequest -> ShowS
[ExtendRequest] -> ShowS
ExtendRequest -> String
(Int -> ExtendRequest -> ShowS)
-> (ExtendRequest -> String)
-> ([ExtendRequest] -> ShowS)
-> Show ExtendRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExtendRequest -> ShowS
showsPrec :: Int -> ExtendRequest -> ShowS
$cshow :: ExtendRequest -> String
show :: ExtendRequest -> String
$cshowList :: [ExtendRequest] -> ShowS
showList :: [ExtendRequest] -> ShowS
Show)

instance FromJSON ExtendRequest where
  parseJSON :: Value -> Parser ExtendRequest
parseJSON = String
-> (Object -> Parser ExtendRequest)
-> Value
-> Parser ExtendRequest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ExtendRequest" ((Object -> Parser ExtendRequest) -> Value -> Parser ExtendRequest)
-> (Object -> Parser ExtendRequest)
-> Value
-> Parser ExtendRequest
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
    JobLease -> Double -> ExtendRequest
ExtendRequest (JobLease -> Double -> ExtendRequest)
-> Parser JobLease -> Parser (Double -> ExtendRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser JobLease
forall a. FromJSON a => Value -> Parser a
parseJSON (Object -> Value
Object Object
obj) Parser (Double -> ExtendRequest)
-> Parser Double -> Parser ExtendRequest
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"seconds"

instance ToJSON ExtendRequest where
  toJSON :: ExtendRequest -> Value
toJSON ExtendRequest
req = [Pair] -> Value
object (JobLease -> [Pair]
jobLeasePairs (ExtendRequest -> JobLease
erLease ExtendRequest
req) [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Key
"seconds" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ExtendRequest -> Double
erSeconds ExtendRequest
req])

-- | Rows each maintenance operation touched, and the operations that raised. An
-- operation in neither was skipped.
data MaintenanceResponse = MaintenanceResponse
  { MaintenanceResponse -> Map Text Int64
maintenanceOps :: Map Text Int64
  , MaintenanceResponse -> [Text]
maintenanceFailed :: [Text]
  }
  deriving stock (MaintenanceResponse -> MaintenanceResponse -> Bool
(MaintenanceResponse -> MaintenanceResponse -> Bool)
-> (MaintenanceResponse -> MaintenanceResponse -> Bool)
-> Eq MaintenanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MaintenanceResponse -> MaintenanceResponse -> Bool
== :: MaintenanceResponse -> MaintenanceResponse -> Bool
$c/= :: MaintenanceResponse -> MaintenanceResponse -> Bool
/= :: MaintenanceResponse -> MaintenanceResponse -> Bool
Eq, Int -> MaintenanceResponse -> ShowS
[MaintenanceResponse] -> ShowS
MaintenanceResponse -> String
(Int -> MaintenanceResponse -> ShowS)
-> (MaintenanceResponse -> String)
-> ([MaintenanceResponse] -> ShowS)
-> Show MaintenanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MaintenanceResponse -> ShowS
showsPrec :: Int -> MaintenanceResponse -> ShowS
$cshow :: MaintenanceResponse -> String
show :: MaintenanceResponse -> String
$cshowList :: [MaintenanceResponse] -> ShowS
showList :: [MaintenanceResponse] -> ShowS
Show)

instance ToJSON MaintenanceResponse where
  toJSON :: MaintenanceResponse -> Value
toJSON (MaintenanceResponse Map Text Int64
ops [Text]
failed) = [Pair] -> Value
object [Key
"ops" Key -> Map Text Int64 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Map Text Int64
ops, Key
"failed" Key -> [Text] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Text]
failed]

instance FromJSON MaintenanceResponse where
  parseJSON :: Value -> Parser MaintenanceResponse
parseJSON = String
-> (Object -> Parser MaintenanceResponse)
-> Value
-> Parser MaintenanceResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"MaintenanceResponse" ((Object -> Parser MaintenanceResponse)
 -> Value -> Parser MaintenanceResponse)
-> (Object -> Parser MaintenanceResponse)
-> Value
-> Parser MaintenanceResponse
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
    Map Text Int64 -> [Text] -> MaintenanceResponse
MaintenanceResponse (Map Text Int64 -> [Text] -> MaintenanceResponse)
-> Parser (Map Text Int64)
-> Parser ([Text] -> MaintenanceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Key -> Parser (Map Text Int64)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"ops" Parser ([Text] -> MaintenanceResponse)
-> Parser [Text] -> Parser MaintenanceResponse
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"failed" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
.!= []

-- | Response wrapper for DLQ jobs.
data DLQResponse payload = DLQResponse
  { forall payload. DLQResponse payload -> [ApiDLQJob payload]
dlqJobs :: [ApiDLQJob payload]
  , forall payload. DLQResponse payload -> Int
dlqTotal :: Int
  , forall payload. DLQResponse payload -> Int
dlqOffset :: Int
  , forall payload. DLQResponse payload -> Int
dlqLimit :: Int
  }
  deriving stock (DLQResponse payload -> DLQResponse payload -> Bool
(DLQResponse payload -> DLQResponse payload -> Bool)
-> (DLQResponse payload -> DLQResponse payload -> Bool)
-> Eq (DLQResponse payload)
forall payload.
Eq payload =>
DLQResponse payload -> DLQResponse payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
DLQResponse payload -> DLQResponse payload -> Bool
== :: DLQResponse payload -> DLQResponse payload -> Bool
$c/= :: forall payload.
Eq payload =>
DLQResponse payload -> DLQResponse payload -> Bool
/= :: DLQResponse payload -> DLQResponse payload -> Bool
Eq, (forall x. DLQResponse payload -> Rep (DLQResponse payload) x)
-> (forall x. Rep (DLQResponse payload) x -> DLQResponse payload)
-> Generic (DLQResponse payload)
forall x. Rep (DLQResponse payload) x -> DLQResponse payload
forall x. DLQResponse payload -> Rep (DLQResponse payload) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall payload x.
Rep (DLQResponse payload) x -> DLQResponse payload
forall payload x.
DLQResponse payload -> Rep (DLQResponse payload) x
$cfrom :: forall payload x.
DLQResponse payload -> Rep (DLQResponse payload) x
from :: forall x. DLQResponse payload -> Rep (DLQResponse payload) x
$cto :: forall payload x.
Rep (DLQResponse payload) x -> DLQResponse payload
to :: forall x. Rep (DLQResponse payload) x -> DLQResponse payload
Generic, Int -> DLQResponse payload -> ShowS
[DLQResponse payload] -> ShowS
DLQResponse payload -> String
(Int -> DLQResponse payload -> ShowS)
-> (DLQResponse payload -> String)
-> ([DLQResponse payload] -> ShowS)
-> Show (DLQResponse payload)
forall payload. Show payload => Int -> DLQResponse payload -> ShowS
forall payload. Show payload => [DLQResponse payload] -> ShowS
forall payload. Show payload => DLQResponse payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload. Show payload => Int -> DLQResponse payload -> ShowS
showsPrec :: Int -> DLQResponse payload -> ShowS
$cshow :: forall payload. Show payload => DLQResponse payload -> String
show :: DLQResponse payload -> String
$cshowList :: forall payload. Show payload => [DLQResponse payload] -> ShowS
showList :: [DLQResponse payload] -> ShowS
Show)
  deriving anyclass (Maybe (DLQResponse payload)
Value -> Parser [DLQResponse payload]
Value -> Parser (DLQResponse payload)
(Value -> Parser (DLQResponse payload))
-> (Value -> Parser [DLQResponse payload])
-> Maybe (DLQResponse payload)
-> FromJSON (DLQResponse payload)
forall payload. FromJSON payload => Maybe (DLQResponse payload)
forall payload.
FromJSON payload =>
Value -> Parser [DLQResponse payload]
forall payload.
FromJSON payload =>
Value -> Parser (DLQResponse payload)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: forall payload.
FromJSON payload =>
Value -> Parser (DLQResponse payload)
parseJSON :: Value -> Parser (DLQResponse payload)
$cparseJSONList :: forall payload.
FromJSON payload =>
Value -> Parser [DLQResponse payload]
parseJSONList :: Value -> Parser [DLQResponse payload]
$comittedField :: forall payload. FromJSON payload => Maybe (DLQResponse payload)
omittedField :: Maybe (DLQResponse payload)
FromJSON, [DLQResponse payload] -> Value
[DLQResponse payload] -> Encoding
DLQResponse payload -> Bool
DLQResponse payload -> Value
DLQResponse payload -> Encoding
(DLQResponse payload -> Value)
-> (DLQResponse payload -> Encoding)
-> ([DLQResponse payload] -> Value)
-> ([DLQResponse payload] -> Encoding)
-> (DLQResponse payload -> Bool)
-> ToJSON (DLQResponse payload)
forall payload. ToJSON payload => [DLQResponse payload] -> Value
forall payload. ToJSON payload => [DLQResponse payload] -> Encoding
forall payload. ToJSON payload => DLQResponse payload -> Bool
forall payload. ToJSON payload => DLQResponse payload -> Value
forall payload. ToJSON payload => DLQResponse payload -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: forall payload. ToJSON payload => DLQResponse payload -> Value
toJSON :: DLQResponse payload -> Value
$ctoEncoding :: forall payload. ToJSON payload => DLQResponse payload -> Encoding
toEncoding :: DLQResponse payload -> Encoding
$ctoJSONList :: forall payload. ToJSON payload => [DLQResponse payload] -> Value
toJSONList :: [DLQResponse payload] -> Value
$ctoEncodingList :: forall payload. ToJSON payload => [DLQResponse payload] -> Encoding
toEncodingList :: [DLQResponse payload] -> Encoding
$comitField :: forall payload. ToJSON payload => DLQResponse payload -> Bool
omitField :: DLQResponse payload -> Bool
ToJSON)

-- | Queue statistics response.
data StatsResponse = StatsResponse
  { StatsResponse -> QueueStats
stats :: QueueStats
  , StatsResponse -> Text
timestamp :: Text
  }
  deriving stock (StatsResponse -> StatsResponse -> Bool
(StatsResponse -> StatsResponse -> Bool)
-> (StatsResponse -> StatsResponse -> Bool) -> Eq StatsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StatsResponse -> StatsResponse -> Bool
== :: StatsResponse -> StatsResponse -> Bool
$c/= :: StatsResponse -> StatsResponse -> Bool
/= :: StatsResponse -> StatsResponse -> Bool
Eq, (forall x. StatsResponse -> Rep StatsResponse x)
-> (forall x. Rep StatsResponse x -> StatsResponse)
-> Generic StatsResponse
forall x. Rep StatsResponse x -> StatsResponse
forall x. StatsResponse -> Rep StatsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. StatsResponse -> Rep StatsResponse x
from :: forall x. StatsResponse -> Rep StatsResponse x
$cto :: forall x. Rep StatsResponse x -> StatsResponse
to :: forall x. Rep StatsResponse x -> StatsResponse
Generic, Int -> StatsResponse -> ShowS
[StatsResponse] -> ShowS
StatsResponse -> String
(Int -> StatsResponse -> ShowS)
-> (StatsResponse -> String)
-> ([StatsResponse] -> ShowS)
-> Show StatsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StatsResponse -> ShowS
showsPrec :: Int -> StatsResponse -> ShowS
$cshow :: StatsResponse -> String
show :: StatsResponse -> String
$cshowList :: [StatsResponse] -> ShowS
showList :: [StatsResponse] -> ShowS
Show)
  deriving anyclass (Maybe StatsResponse
Value -> Parser [StatsResponse]
Value -> Parser StatsResponse
(Value -> Parser StatsResponse)
-> (Value -> Parser [StatsResponse])
-> Maybe StatsResponse
-> FromJSON StatsResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser StatsResponse
parseJSON :: Value -> Parser StatsResponse
$cparseJSONList :: Value -> Parser [StatsResponse]
parseJSONList :: Value -> Parser [StatsResponse]
$comittedField :: Maybe StatsResponse
omittedField :: Maybe StatsResponse
FromJSON, [StatsResponse] -> Value
[StatsResponse] -> Encoding
StatsResponse -> Bool
StatsResponse -> Value
StatsResponse -> Encoding
(StatsResponse -> Value)
-> (StatsResponse -> Encoding)
-> ([StatsResponse] -> Value)
-> ([StatsResponse] -> Encoding)
-> (StatsResponse -> Bool)
-> ToJSON StatsResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: StatsResponse -> Value
toJSON :: StatsResponse -> Value
$ctoEncoding :: StatsResponse -> Encoding
toEncoding :: StatsResponse -> Encoding
$ctoJSONList :: [StatsResponse] -> Value
toJSONList :: [StatsResponse] -> Value
$ctoEncodingList :: [StatsResponse] -> Encoding
toEncodingList :: [StatsResponse] -> Encoding
$comitField :: StatsResponse -> Bool
omitField :: StatsResponse -> Bool
ToJSON)

-- | Every queue's stats, for the landing overview.
data AllStatsResponse = AllStatsResponse
  { AllStatsResponse -> [QueueOverview]
queues :: [QueueOverview]
  }
  deriving stock (AllStatsResponse -> AllStatsResponse -> Bool
(AllStatsResponse -> AllStatsResponse -> Bool)
-> (AllStatsResponse -> AllStatsResponse -> Bool)
-> Eq AllStatsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AllStatsResponse -> AllStatsResponse -> Bool
== :: AllStatsResponse -> AllStatsResponse -> Bool
$c/= :: AllStatsResponse -> AllStatsResponse -> Bool
/= :: AllStatsResponse -> AllStatsResponse -> Bool
Eq, (forall x. AllStatsResponse -> Rep AllStatsResponse x)
-> (forall x. Rep AllStatsResponse x -> AllStatsResponse)
-> Generic AllStatsResponse
forall x. Rep AllStatsResponse x -> AllStatsResponse
forall x. AllStatsResponse -> Rep AllStatsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AllStatsResponse -> Rep AllStatsResponse x
from :: forall x. AllStatsResponse -> Rep AllStatsResponse x
$cto :: forall x. Rep AllStatsResponse x -> AllStatsResponse
to :: forall x. Rep AllStatsResponse x -> AllStatsResponse
Generic, Int -> AllStatsResponse -> ShowS
[AllStatsResponse] -> ShowS
AllStatsResponse -> String
(Int -> AllStatsResponse -> ShowS)
-> (AllStatsResponse -> String)
-> ([AllStatsResponse] -> ShowS)
-> Show AllStatsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AllStatsResponse -> ShowS
showsPrec :: Int -> AllStatsResponse -> ShowS
$cshow :: AllStatsResponse -> String
show :: AllStatsResponse -> String
$cshowList :: [AllStatsResponse] -> ShowS
showList :: [AllStatsResponse] -> ShowS
Show)
  deriving anyclass (Maybe AllStatsResponse
Value -> Parser [AllStatsResponse]
Value -> Parser AllStatsResponse
(Value -> Parser AllStatsResponse)
-> (Value -> Parser [AllStatsResponse])
-> Maybe AllStatsResponse
-> FromJSON AllStatsResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser AllStatsResponse
parseJSON :: Value -> Parser AllStatsResponse
$cparseJSONList :: Value -> Parser [AllStatsResponse]
parseJSONList :: Value -> Parser [AllStatsResponse]
$comittedField :: Maybe AllStatsResponse
omittedField :: Maybe AllStatsResponse
FromJSON, [AllStatsResponse] -> Value
[AllStatsResponse] -> Encoding
AllStatsResponse -> Bool
AllStatsResponse -> Value
AllStatsResponse -> Encoding
(AllStatsResponse -> Value)
-> (AllStatsResponse -> Encoding)
-> ([AllStatsResponse] -> Value)
-> ([AllStatsResponse] -> Encoding)
-> (AllStatsResponse -> Bool)
-> ToJSON AllStatsResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: AllStatsResponse -> Value
toJSON :: AllStatsResponse -> Value
$ctoEncoding :: AllStatsResponse -> Encoding
toEncoding :: AllStatsResponse -> Encoding
$ctoJSONList :: [AllStatsResponse] -> Value
toJSONList :: [AllStatsResponse] -> Value
$ctoEncodingList :: [AllStatsResponse] -> Encoding
toEncodingList :: [AllStatsResponse] -> Encoding
$comitField :: AllStatsResponse -> Bool
omitField :: AllStatsResponse -> Bool
ToJSON)

-- | Queues list response.
data QueuesResponse = QueuesResponse
  { QueuesResponse -> [Text]
queues :: [Text]
  }
  deriving stock (QueuesResponse -> QueuesResponse -> Bool
(QueuesResponse -> QueuesResponse -> Bool)
-> (QueuesResponse -> QueuesResponse -> Bool) -> Eq QueuesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: QueuesResponse -> QueuesResponse -> Bool
== :: QueuesResponse -> QueuesResponse -> Bool
$c/= :: QueuesResponse -> QueuesResponse -> Bool
/= :: QueuesResponse -> QueuesResponse -> Bool
Eq, (forall x. QueuesResponse -> Rep QueuesResponse x)
-> (forall x. Rep QueuesResponse x -> QueuesResponse)
-> Generic QueuesResponse
forall x. Rep QueuesResponse x -> QueuesResponse
forall x. QueuesResponse -> Rep QueuesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. QueuesResponse -> Rep QueuesResponse x
from :: forall x. QueuesResponse -> Rep QueuesResponse x
$cto :: forall x. Rep QueuesResponse x -> QueuesResponse
to :: forall x. Rep QueuesResponse x -> QueuesResponse
Generic, Int -> QueuesResponse -> ShowS
[QueuesResponse] -> ShowS
QueuesResponse -> String
(Int -> QueuesResponse -> ShowS)
-> (QueuesResponse -> String)
-> ([QueuesResponse] -> ShowS)
-> Show QueuesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> QueuesResponse -> ShowS
showsPrec :: Int -> QueuesResponse -> ShowS
$cshow :: QueuesResponse -> String
show :: QueuesResponse -> String
$cshowList :: [QueuesResponse] -> ShowS
showList :: [QueuesResponse] -> ShowS
Show)
  deriving anyclass (Maybe QueuesResponse
Value -> Parser [QueuesResponse]
Value -> Parser QueuesResponse
(Value -> Parser QueuesResponse)
-> (Value -> Parser [QueuesResponse])
-> Maybe QueuesResponse
-> FromJSON QueuesResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser QueuesResponse
parseJSON :: Value -> Parser QueuesResponse
$cparseJSONList :: Value -> Parser [QueuesResponse]
parseJSONList :: Value -> Parser [QueuesResponse]
$comittedField :: Maybe QueuesResponse
omittedField :: Maybe QueuesResponse
FromJSON, [QueuesResponse] -> Value
[QueuesResponse] -> Encoding
QueuesResponse -> Bool
QueuesResponse -> Value
QueuesResponse -> Encoding
(QueuesResponse -> Value)
-> (QueuesResponse -> Encoding)
-> ([QueuesResponse] -> Value)
-> ([QueuesResponse] -> Encoding)
-> (QueuesResponse -> Bool)
-> ToJSON QueuesResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: QueuesResponse -> Value
toJSON :: QueuesResponse -> Value
$ctoEncoding :: QueuesResponse -> Encoding
toEncoding :: QueuesResponse -> Encoding
$ctoJSONList :: [QueuesResponse] -> Value
toJSONList :: [QueuesResponse] -> Value
$ctoEncodingList :: [QueuesResponse] -> Encoding
toEncodingList :: [QueuesResponse] -> Encoding
$comitField :: QueuesResponse -> Bool
omitField :: QueuesResponse -> Bool
ToJSON)

-- | Request body for batch job insert.
newtype BatchInsertRequest payload = BatchInsertRequest
  { forall payload. BatchInsertRequest payload -> [ApiJobWrite payload]
jobWrites :: [ApiJobWrite payload]
  }
  deriving stock (BatchInsertRequest payload -> BatchInsertRequest payload -> Bool
(BatchInsertRequest payload -> BatchInsertRequest payload -> Bool)
-> (BatchInsertRequest payload
    -> BatchInsertRequest payload -> Bool)
-> Eq (BatchInsertRequest payload)
forall payload.
Eq payload =>
BatchInsertRequest payload -> BatchInsertRequest payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
BatchInsertRequest payload -> BatchInsertRequest payload -> Bool
== :: BatchInsertRequest payload -> BatchInsertRequest payload -> Bool
$c/= :: forall payload.
Eq payload =>
BatchInsertRequest payload -> BatchInsertRequest payload -> Bool
/= :: BatchInsertRequest payload -> BatchInsertRequest payload -> Bool
Eq, (forall x.
 BatchInsertRequest payload -> Rep (BatchInsertRequest payload) x)
-> (forall x.
    Rep (BatchInsertRequest payload) x -> BatchInsertRequest payload)
-> Generic (BatchInsertRequest payload)
forall x.
Rep (BatchInsertRequest payload) x -> BatchInsertRequest payload
forall x.
BatchInsertRequest payload -> Rep (BatchInsertRequest payload) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall payload x.
Rep (BatchInsertRequest payload) x -> BatchInsertRequest payload
forall payload x.
BatchInsertRequest payload -> Rep (BatchInsertRequest payload) x
$cfrom :: forall payload x.
BatchInsertRequest payload -> Rep (BatchInsertRequest payload) x
from :: forall x.
BatchInsertRequest payload -> Rep (BatchInsertRequest payload) x
$cto :: forall payload x.
Rep (BatchInsertRequest payload) x -> BatchInsertRequest payload
to :: forall x.
Rep (BatchInsertRequest payload) x -> BatchInsertRequest payload
Generic, Int -> BatchInsertRequest payload -> ShowS
[BatchInsertRequest payload] -> ShowS
BatchInsertRequest payload -> String
(Int -> BatchInsertRequest payload -> ShowS)
-> (BatchInsertRequest payload -> String)
-> ([BatchInsertRequest payload] -> ShowS)
-> Show (BatchInsertRequest payload)
forall payload.
Show payload =>
Int -> BatchInsertRequest payload -> ShowS
forall payload.
Show payload =>
[BatchInsertRequest payload] -> ShowS
forall payload.
Show payload =>
BatchInsertRequest payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload.
Show payload =>
Int -> BatchInsertRequest payload -> ShowS
showsPrec :: Int -> BatchInsertRequest payload -> ShowS
$cshow :: forall payload.
Show payload =>
BatchInsertRequest payload -> String
show :: BatchInsertRequest payload -> String
$cshowList :: forall payload.
Show payload =>
[BatchInsertRequest payload] -> ShowS
showList :: [BatchInsertRequest payload] -> ShowS
Show)
  deriving anyclass (Maybe (BatchInsertRequest payload)
Value -> Parser [BatchInsertRequest payload]
Value -> Parser (BatchInsertRequest payload)
(Value -> Parser (BatchInsertRequest payload))
-> (Value -> Parser [BatchInsertRequest payload])
-> Maybe (BatchInsertRequest payload)
-> FromJSON (BatchInsertRequest payload)
forall payload.
FromJSON payload =>
Maybe (BatchInsertRequest payload)
forall payload.
FromJSON payload =>
Value -> Parser [BatchInsertRequest payload]
forall payload.
FromJSON payload =>
Value -> Parser (BatchInsertRequest payload)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: forall payload.
FromJSON payload =>
Value -> Parser (BatchInsertRequest payload)
parseJSON :: Value -> Parser (BatchInsertRequest payload)
$cparseJSONList :: forall payload.
FromJSON payload =>
Value -> Parser [BatchInsertRequest payload]
parseJSONList :: Value -> Parser [BatchInsertRequest payload]
$comittedField :: forall payload.
FromJSON payload =>
Maybe (BatchInsertRequest payload)
omittedField :: Maybe (BatchInsertRequest payload)
FromJSON, [BatchInsertRequest payload] -> Value
[BatchInsertRequest payload] -> Encoding
BatchInsertRequest payload -> Bool
BatchInsertRequest payload -> Value
BatchInsertRequest payload -> Encoding
(BatchInsertRequest payload -> Value)
-> (BatchInsertRequest payload -> Encoding)
-> ([BatchInsertRequest payload] -> Value)
-> ([BatchInsertRequest payload] -> Encoding)
-> (BatchInsertRequest payload -> Bool)
-> ToJSON (BatchInsertRequest payload)
forall payload.
ToJSON payload =>
[BatchInsertRequest payload] -> Value
forall payload.
ToJSON payload =>
[BatchInsertRequest payload] -> Encoding
forall payload.
ToJSON payload =>
BatchInsertRequest payload -> Bool
forall payload.
ToJSON payload =>
BatchInsertRequest payload -> Value
forall payload.
ToJSON payload =>
BatchInsertRequest payload -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: forall payload.
ToJSON payload =>
BatchInsertRequest payload -> Value
toJSON :: BatchInsertRequest payload -> Value
$ctoEncoding :: forall payload.
ToJSON payload =>
BatchInsertRequest payload -> Encoding
toEncoding :: BatchInsertRequest payload -> Encoding
$ctoJSONList :: forall payload.
ToJSON payload =>
[BatchInsertRequest payload] -> Value
toJSONList :: [BatchInsertRequest payload] -> Value
$ctoEncodingList :: forall payload.
ToJSON payload =>
[BatchInsertRequest payload] -> Encoding
toEncodingList :: [BatchInsertRequest payload] -> Encoding
$comitField :: forall payload.
ToJSON payload =>
BatchInsertRequest payload -> Bool
omitField :: BatchInsertRequest payload -> Bool
ToJSON)

-- | Response body for batch job insert.
data BatchInsertResponse payload = BatchInsertResponse
  { forall payload. BatchInsertResponse payload -> [ApiJob payload]
inserted :: [ApiJob payload]
  , forall payload. BatchInsertResponse payload -> Int
insertedCount :: Int
  }
  deriving stock (BatchInsertResponse payload -> BatchInsertResponse payload -> Bool
(BatchInsertResponse payload
 -> BatchInsertResponse payload -> Bool)
-> (BatchInsertResponse payload
    -> BatchInsertResponse payload -> Bool)
-> Eq (BatchInsertResponse payload)
forall payload.
Eq payload =>
BatchInsertResponse payload -> BatchInsertResponse payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
BatchInsertResponse payload -> BatchInsertResponse payload -> Bool
== :: BatchInsertResponse payload -> BatchInsertResponse payload -> Bool
$c/= :: forall payload.
Eq payload =>
BatchInsertResponse payload -> BatchInsertResponse payload -> Bool
/= :: BatchInsertResponse payload -> BatchInsertResponse payload -> Bool
Eq, (forall x.
 BatchInsertResponse payload -> Rep (BatchInsertResponse payload) x)
-> (forall x.
    Rep (BatchInsertResponse payload) x -> BatchInsertResponse payload)
-> Generic (BatchInsertResponse payload)
forall x.
Rep (BatchInsertResponse payload) x -> BatchInsertResponse payload
forall x.
BatchInsertResponse payload -> Rep (BatchInsertResponse payload) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall payload x.
Rep (BatchInsertResponse payload) x -> BatchInsertResponse payload
forall payload x.
BatchInsertResponse payload -> Rep (BatchInsertResponse payload) x
$cfrom :: forall payload x.
BatchInsertResponse payload -> Rep (BatchInsertResponse payload) x
from :: forall x.
BatchInsertResponse payload -> Rep (BatchInsertResponse payload) x
$cto :: forall payload x.
Rep (BatchInsertResponse payload) x -> BatchInsertResponse payload
to :: forall x.
Rep (BatchInsertResponse payload) x -> BatchInsertResponse payload
Generic, Int -> BatchInsertResponse payload -> ShowS
[BatchInsertResponse payload] -> ShowS
BatchInsertResponse payload -> String
(Int -> BatchInsertResponse payload -> ShowS)
-> (BatchInsertResponse payload -> String)
-> ([BatchInsertResponse payload] -> ShowS)
-> Show (BatchInsertResponse payload)
forall payload.
Show payload =>
Int -> BatchInsertResponse payload -> ShowS
forall payload.
Show payload =>
[BatchInsertResponse payload] -> ShowS
forall payload.
Show payload =>
BatchInsertResponse payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload.
Show payload =>
Int -> BatchInsertResponse payload -> ShowS
showsPrec :: Int -> BatchInsertResponse payload -> ShowS
$cshow :: forall payload.
Show payload =>
BatchInsertResponse payload -> String
show :: BatchInsertResponse payload -> String
$cshowList :: forall payload.
Show payload =>
[BatchInsertResponse payload] -> ShowS
showList :: [BatchInsertResponse payload] -> ShowS
Show)
  deriving anyclass (Maybe (BatchInsertResponse payload)
Value -> Parser [BatchInsertResponse payload]
Value -> Parser (BatchInsertResponse payload)
(Value -> Parser (BatchInsertResponse payload))
-> (Value -> Parser [BatchInsertResponse payload])
-> Maybe (BatchInsertResponse payload)
-> FromJSON (BatchInsertResponse payload)
forall payload.
FromJSON payload =>
Maybe (BatchInsertResponse payload)
forall payload.
FromJSON payload =>
Value -> Parser [BatchInsertResponse payload]
forall payload.
FromJSON payload =>
Value -> Parser (BatchInsertResponse payload)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: forall payload.
FromJSON payload =>
Value -> Parser (BatchInsertResponse payload)
parseJSON :: Value -> Parser (BatchInsertResponse payload)
$cparseJSONList :: forall payload.
FromJSON payload =>
Value -> Parser [BatchInsertResponse payload]
parseJSONList :: Value -> Parser [BatchInsertResponse payload]
$comittedField :: forall payload.
FromJSON payload =>
Maybe (BatchInsertResponse payload)
omittedField :: Maybe (BatchInsertResponse payload)
FromJSON, [BatchInsertResponse payload] -> Value
[BatchInsertResponse payload] -> Encoding
BatchInsertResponse payload -> Bool
BatchInsertResponse payload -> Value
BatchInsertResponse payload -> Encoding
(BatchInsertResponse payload -> Value)
-> (BatchInsertResponse payload -> Encoding)
-> ([BatchInsertResponse payload] -> Value)
-> ([BatchInsertResponse payload] -> Encoding)
-> (BatchInsertResponse payload -> Bool)
-> ToJSON (BatchInsertResponse payload)
forall payload.
ToJSON payload =>
[BatchInsertResponse payload] -> Value
forall payload.
ToJSON payload =>
[BatchInsertResponse payload] -> Encoding
forall payload.
ToJSON payload =>
BatchInsertResponse payload -> Bool
forall payload.
ToJSON payload =>
BatchInsertResponse payload -> Value
forall payload.
ToJSON payload =>
BatchInsertResponse payload -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: forall payload.
ToJSON payload =>
BatchInsertResponse payload -> Value
toJSON :: BatchInsertResponse payload -> Value
$ctoEncoding :: forall payload.
ToJSON payload =>
BatchInsertResponse payload -> Encoding
toEncoding :: BatchInsertResponse payload -> Encoding
$ctoJSONList :: forall payload.
ToJSON payload =>
[BatchInsertResponse payload] -> Value
toJSONList :: [BatchInsertResponse payload] -> Value
$ctoEncodingList :: forall payload.
ToJSON payload =>
[BatchInsertResponse payload] -> Encoding
toEncodingList :: [BatchInsertResponse payload] -> Encoding
$comitField :: forall payload.
ToJSON payload =>
BatchInsertResponse payload -> Bool
omitField :: BatchInsertResponse payload -> Bool
ToJSON)

-- | Request body for batch DLQ delete.
data BatchDeleteRequest = BatchDeleteRequest
  { BatchDeleteRequest -> [Int64]
ids :: [Int64]
  }
  deriving stock (BatchDeleteRequest -> BatchDeleteRequest -> Bool
(BatchDeleteRequest -> BatchDeleteRequest -> Bool)
-> (BatchDeleteRequest -> BatchDeleteRequest -> Bool)
-> Eq BatchDeleteRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BatchDeleteRequest -> BatchDeleteRequest -> Bool
== :: BatchDeleteRequest -> BatchDeleteRequest -> Bool
$c/= :: BatchDeleteRequest -> BatchDeleteRequest -> Bool
/= :: BatchDeleteRequest -> BatchDeleteRequest -> Bool
Eq, (forall x. BatchDeleteRequest -> Rep BatchDeleteRequest x)
-> (forall x. Rep BatchDeleteRequest x -> BatchDeleteRequest)
-> Generic BatchDeleteRequest
forall x. Rep BatchDeleteRequest x -> BatchDeleteRequest
forall x. BatchDeleteRequest -> Rep BatchDeleteRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BatchDeleteRequest -> Rep BatchDeleteRequest x
from :: forall x. BatchDeleteRequest -> Rep BatchDeleteRequest x
$cto :: forall x. Rep BatchDeleteRequest x -> BatchDeleteRequest
to :: forall x. Rep BatchDeleteRequest x -> BatchDeleteRequest
Generic, Int -> BatchDeleteRequest -> ShowS
[BatchDeleteRequest] -> ShowS
BatchDeleteRequest -> String
(Int -> BatchDeleteRequest -> ShowS)
-> (BatchDeleteRequest -> String)
-> ([BatchDeleteRequest] -> ShowS)
-> Show BatchDeleteRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BatchDeleteRequest -> ShowS
showsPrec :: Int -> BatchDeleteRequest -> ShowS
$cshow :: BatchDeleteRequest -> String
show :: BatchDeleteRequest -> String
$cshowList :: [BatchDeleteRequest] -> ShowS
showList :: [BatchDeleteRequest] -> ShowS
Show)
  deriving anyclass (Maybe BatchDeleteRequest
Value -> Parser [BatchDeleteRequest]
Value -> Parser BatchDeleteRequest
(Value -> Parser BatchDeleteRequest)
-> (Value -> Parser [BatchDeleteRequest])
-> Maybe BatchDeleteRequest
-> FromJSON BatchDeleteRequest
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser BatchDeleteRequest
parseJSON :: Value -> Parser BatchDeleteRequest
$cparseJSONList :: Value -> Parser [BatchDeleteRequest]
parseJSONList :: Value -> Parser [BatchDeleteRequest]
$comittedField :: Maybe BatchDeleteRequest
omittedField :: Maybe BatchDeleteRequest
FromJSON, [BatchDeleteRequest] -> Value
[BatchDeleteRequest] -> Encoding
BatchDeleteRequest -> Bool
BatchDeleteRequest -> Value
BatchDeleteRequest -> Encoding
(BatchDeleteRequest -> Value)
-> (BatchDeleteRequest -> Encoding)
-> ([BatchDeleteRequest] -> Value)
-> ([BatchDeleteRequest] -> Encoding)
-> (BatchDeleteRequest -> Bool)
-> ToJSON BatchDeleteRequest
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: BatchDeleteRequest -> Value
toJSON :: BatchDeleteRequest -> Value
$ctoEncoding :: BatchDeleteRequest -> Encoding
toEncoding :: BatchDeleteRequest -> Encoding
$ctoJSONList :: [BatchDeleteRequest] -> Value
toJSONList :: [BatchDeleteRequest] -> Value
$ctoEncodingList :: [BatchDeleteRequest] -> Encoding
toEncodingList :: [BatchDeleteRequest] -> Encoding
$comitField :: BatchDeleteRequest -> Bool
omitField :: BatchDeleteRequest -> Bool
ToJSON)

-- | Response body for batch DLQ delete.
data BatchDeleteResponse = BatchDeleteResponse
  { BatchDeleteResponse -> Int64
deleted :: Int64
  }
  deriving stock (BatchDeleteResponse -> BatchDeleteResponse -> Bool
(BatchDeleteResponse -> BatchDeleteResponse -> Bool)
-> (BatchDeleteResponse -> BatchDeleteResponse -> Bool)
-> Eq BatchDeleteResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BatchDeleteResponse -> BatchDeleteResponse -> Bool
== :: BatchDeleteResponse -> BatchDeleteResponse -> Bool
$c/= :: BatchDeleteResponse -> BatchDeleteResponse -> Bool
/= :: BatchDeleteResponse -> BatchDeleteResponse -> Bool
Eq, (forall x. BatchDeleteResponse -> Rep BatchDeleteResponse x)
-> (forall x. Rep BatchDeleteResponse x -> BatchDeleteResponse)
-> Generic BatchDeleteResponse
forall x. Rep BatchDeleteResponse x -> BatchDeleteResponse
forall x. BatchDeleteResponse -> Rep BatchDeleteResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BatchDeleteResponse -> Rep BatchDeleteResponse x
from :: forall x. BatchDeleteResponse -> Rep BatchDeleteResponse x
$cto :: forall x. Rep BatchDeleteResponse x -> BatchDeleteResponse
to :: forall x. Rep BatchDeleteResponse x -> BatchDeleteResponse
Generic, Int -> BatchDeleteResponse -> ShowS
[BatchDeleteResponse] -> ShowS
BatchDeleteResponse -> String
(Int -> BatchDeleteResponse -> ShowS)
-> (BatchDeleteResponse -> String)
-> ([BatchDeleteResponse] -> ShowS)
-> Show BatchDeleteResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BatchDeleteResponse -> ShowS
showsPrec :: Int -> BatchDeleteResponse -> ShowS
$cshow :: BatchDeleteResponse -> String
show :: BatchDeleteResponse -> String
$cshowList :: [BatchDeleteResponse] -> ShowS
showList :: [BatchDeleteResponse] -> ShowS
Show)
  deriving anyclass (Maybe BatchDeleteResponse
Value -> Parser [BatchDeleteResponse]
Value -> Parser BatchDeleteResponse
(Value -> Parser BatchDeleteResponse)
-> (Value -> Parser [BatchDeleteResponse])
-> Maybe BatchDeleteResponse
-> FromJSON BatchDeleteResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser BatchDeleteResponse
parseJSON :: Value -> Parser BatchDeleteResponse
$cparseJSONList :: Value -> Parser [BatchDeleteResponse]
parseJSONList :: Value -> Parser [BatchDeleteResponse]
$comittedField :: Maybe BatchDeleteResponse
omittedField :: Maybe BatchDeleteResponse
FromJSON, [BatchDeleteResponse] -> Value
[BatchDeleteResponse] -> Encoding
BatchDeleteResponse -> Bool
BatchDeleteResponse -> Value
BatchDeleteResponse -> Encoding
(BatchDeleteResponse -> Value)
-> (BatchDeleteResponse -> Encoding)
-> ([BatchDeleteResponse] -> Value)
-> ([BatchDeleteResponse] -> Encoding)
-> (BatchDeleteResponse -> Bool)
-> ToJSON BatchDeleteResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: BatchDeleteResponse -> Value
toJSON :: BatchDeleteResponse -> Value
$ctoEncoding :: BatchDeleteResponse -> Encoding
toEncoding :: BatchDeleteResponse -> Encoding
$ctoJSONList :: [BatchDeleteResponse] -> Value
toJSONList :: [BatchDeleteResponse] -> Value
$ctoEncodingList :: [BatchDeleteResponse] -> Encoding
toEncodingList :: [BatchDeleteResponse] -> Encoding
$comitField :: BatchDeleteResponse -> Bool
omitField :: BatchDeleteResponse -> Bool
ToJSON)

-- | A cron schedule row plus the next tick its effective expression fires at.
-- An expression that never fires again, or one the server cannot parse, has none.
data CronScheduleView = CronScheduleView
  { CronScheduleView -> CronScheduleRow
schedule :: CronScheduleRow
  , CronScheduleView -> Maybe UTCTime
nextRunAt :: Maybe UTCTime
  }
  deriving stock (CronScheduleView -> CronScheduleView -> Bool
(CronScheduleView -> CronScheduleView -> Bool)
-> (CronScheduleView -> CronScheduleView -> Bool)
-> Eq CronScheduleView
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CronScheduleView -> CronScheduleView -> Bool
== :: CronScheduleView -> CronScheduleView -> Bool
$c/= :: CronScheduleView -> CronScheduleView -> Bool
/= :: CronScheduleView -> CronScheduleView -> Bool
Eq, (forall x. CronScheduleView -> Rep CronScheduleView x)
-> (forall x. Rep CronScheduleView x -> CronScheduleView)
-> Generic CronScheduleView
forall x. Rep CronScheduleView x -> CronScheduleView
forall x. CronScheduleView -> Rep CronScheduleView x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CronScheduleView -> Rep CronScheduleView x
from :: forall x. CronScheduleView -> Rep CronScheduleView x
$cto :: forall x. Rep CronScheduleView x -> CronScheduleView
to :: forall x. Rep CronScheduleView x -> CronScheduleView
Generic, Int -> CronScheduleView -> ShowS
[CronScheduleView] -> ShowS
CronScheduleView -> String
(Int -> CronScheduleView -> ShowS)
-> (CronScheduleView -> String)
-> ([CronScheduleView] -> ShowS)
-> Show CronScheduleView
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CronScheduleView -> ShowS
showsPrec :: Int -> CronScheduleView -> ShowS
$cshow :: CronScheduleView -> String
show :: CronScheduleView -> String
$cshowList :: [CronScheduleView] -> ShowS
showList :: [CronScheduleView] -> ShowS
Show)

-- | The row's own fields, with @nextRunAt@ alongside them.
instance ToJSON CronScheduleView where
  toJSON :: CronScheduleView -> Value
toJSON CronScheduleView
view = case CronScheduleRow -> Value
forall a. ToJSON a => a -> Value
toJSON (CronScheduleView -> CronScheduleRow
schedule CronScheduleView
view) of
    Object Object
obj -> Object -> Value
Object (Key -> Value -> Object -> Object
forall v. Key -> v -> KeyMap v -> KeyMap v
KM.insert Key
"nextRunAt" (Maybe UTCTime -> Value
forall a. ToJSON a => a -> Value
toJSON (CronScheduleView -> Maybe UTCTime
nextRunAt CronScheduleView
view)) Object
obj)
    Value
other -> Value
other

instance FromJSON CronScheduleView where
  parseJSON :: Value -> Parser CronScheduleView
parseJSON = String
-> (Object -> Parser CronScheduleView)
-> Value
-> Parser CronScheduleView
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"CronScheduleView" ((Object -> Parser CronScheduleView)
 -> Value -> Parser CronScheduleView)
-> (Object -> Parser CronScheduleView)
-> Value
-> Parser CronScheduleView
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
    CronScheduleRow -> Maybe UTCTime -> CronScheduleView
CronScheduleView (CronScheduleRow -> Maybe UTCTime -> CronScheduleView)
-> Parser CronScheduleRow
-> Parser (Maybe UTCTime -> CronScheduleView)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser CronScheduleRow
forall a. FromJSON a => Value -> Parser a
parseJSON (Object -> Value
Object Object
obj) Parser (Maybe UTCTime -> CronScheduleView)
-> Parser (Maybe UTCTime) -> Parser CronScheduleView
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser (Maybe UTCTime)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"nextRunAt"

-- | Cron schedules response.
data CronSchedulesResponse = CronSchedulesResponse
  { CronSchedulesResponse -> [CronScheduleView]
cronSchedules :: [CronScheduleView]
  }
  deriving stock (CronSchedulesResponse -> CronSchedulesResponse -> Bool
(CronSchedulesResponse -> CronSchedulesResponse -> Bool)
-> (CronSchedulesResponse -> CronSchedulesResponse -> Bool)
-> Eq CronSchedulesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CronSchedulesResponse -> CronSchedulesResponse -> Bool
== :: CronSchedulesResponse -> CronSchedulesResponse -> Bool
$c/= :: CronSchedulesResponse -> CronSchedulesResponse -> Bool
/= :: CronSchedulesResponse -> CronSchedulesResponse -> Bool
Eq, (forall x. CronSchedulesResponse -> Rep CronSchedulesResponse x)
-> (forall x. Rep CronSchedulesResponse x -> CronSchedulesResponse)
-> Generic CronSchedulesResponse
forall x. Rep CronSchedulesResponse x -> CronSchedulesResponse
forall x. CronSchedulesResponse -> Rep CronSchedulesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CronSchedulesResponse -> Rep CronSchedulesResponse x
from :: forall x. CronSchedulesResponse -> Rep CronSchedulesResponse x
$cto :: forall x. Rep CronSchedulesResponse x -> CronSchedulesResponse
to :: forall x. Rep CronSchedulesResponse x -> CronSchedulesResponse
Generic, Int -> CronSchedulesResponse -> ShowS
[CronSchedulesResponse] -> ShowS
CronSchedulesResponse -> String
(Int -> CronSchedulesResponse -> ShowS)
-> (CronSchedulesResponse -> String)
-> ([CronSchedulesResponse] -> ShowS)
-> Show CronSchedulesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CronSchedulesResponse -> ShowS
showsPrec :: Int -> CronSchedulesResponse -> ShowS
$cshow :: CronSchedulesResponse -> String
show :: CronSchedulesResponse -> String
$cshowList :: [CronSchedulesResponse] -> ShowS
showList :: [CronSchedulesResponse] -> ShowS
Show)
  deriving anyclass (Maybe CronSchedulesResponse
Value -> Parser [CronSchedulesResponse]
Value -> Parser CronSchedulesResponse
(Value -> Parser CronSchedulesResponse)
-> (Value -> Parser [CronSchedulesResponse])
-> Maybe CronSchedulesResponse
-> FromJSON CronSchedulesResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser CronSchedulesResponse
parseJSON :: Value -> Parser CronSchedulesResponse
$cparseJSONList :: Value -> Parser [CronSchedulesResponse]
parseJSONList :: Value -> Parser [CronSchedulesResponse]
$comittedField :: Maybe CronSchedulesResponse
omittedField :: Maybe CronSchedulesResponse
FromJSON, [CronSchedulesResponse] -> Value
[CronSchedulesResponse] -> Encoding
CronSchedulesResponse -> Bool
CronSchedulesResponse -> Value
CronSchedulesResponse -> Encoding
(CronSchedulesResponse -> Value)
-> (CronSchedulesResponse -> Encoding)
-> ([CronSchedulesResponse] -> Value)
-> ([CronSchedulesResponse] -> Encoding)
-> (CronSchedulesResponse -> Bool)
-> ToJSON CronSchedulesResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: CronSchedulesResponse -> Value
toJSON :: CronSchedulesResponse -> Value
$ctoEncoding :: CronSchedulesResponse -> Encoding
toEncoding :: CronSchedulesResponse -> Encoding
$ctoJSONList :: [CronSchedulesResponse] -> Value
toJSONList :: [CronSchedulesResponse] -> Value
$ctoEncodingList :: [CronSchedulesResponse] -> Encoding
toEncodingList :: [CronSchedulesResponse] -> Encoding
$comitField :: CronSchedulesResponse -> Bool
omitField :: CronSchedulesResponse -> Bool
ToJSON)

-- | Worker registry response.
data WorkersResponse = WorkersResponse
  { WorkersResponse -> [WorkerRow]
workers :: [WorkerRow]
  }
  deriving stock (WorkersResponse -> WorkersResponse -> Bool
(WorkersResponse -> WorkersResponse -> Bool)
-> (WorkersResponse -> WorkersResponse -> Bool)
-> Eq WorkersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WorkersResponse -> WorkersResponse -> Bool
== :: WorkersResponse -> WorkersResponse -> Bool
$c/= :: WorkersResponse -> WorkersResponse -> Bool
/= :: WorkersResponse -> WorkersResponse -> Bool
Eq, (forall x. WorkersResponse -> Rep WorkersResponse x)
-> (forall x. Rep WorkersResponse x -> WorkersResponse)
-> Generic WorkersResponse
forall x. Rep WorkersResponse x -> WorkersResponse
forall x. WorkersResponse -> Rep WorkersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. WorkersResponse -> Rep WorkersResponse x
from :: forall x. WorkersResponse -> Rep WorkersResponse x
$cto :: forall x. Rep WorkersResponse x -> WorkersResponse
to :: forall x. Rep WorkersResponse x -> WorkersResponse
Generic, Int -> WorkersResponse -> ShowS
[WorkersResponse] -> ShowS
WorkersResponse -> String
(Int -> WorkersResponse -> ShowS)
-> (WorkersResponse -> String)
-> ([WorkersResponse] -> ShowS)
-> Show WorkersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WorkersResponse -> ShowS
showsPrec :: Int -> WorkersResponse -> ShowS
$cshow :: WorkersResponse -> String
show :: WorkersResponse -> String
$cshowList :: [WorkersResponse] -> ShowS
showList :: [WorkersResponse] -> ShowS
Show)
  deriving anyclass (Maybe WorkersResponse
Value -> Parser [WorkersResponse]
Value -> Parser WorkersResponse
(Value -> Parser WorkersResponse)
-> (Value -> Parser [WorkersResponse])
-> Maybe WorkersResponse
-> FromJSON WorkersResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser WorkersResponse
parseJSON :: Value -> Parser WorkersResponse
$cparseJSONList :: Value -> Parser [WorkersResponse]
parseJSONList :: Value -> Parser [WorkersResponse]
$comittedField :: Maybe WorkersResponse
omittedField :: Maybe WorkersResponse
FromJSON, [WorkersResponse] -> Value
[WorkersResponse] -> Encoding
WorkersResponse -> Bool
WorkersResponse -> Value
WorkersResponse -> Encoding
(WorkersResponse -> Value)
-> (WorkersResponse -> Encoding)
-> ([WorkersResponse] -> Value)
-> ([WorkersResponse] -> Encoding)
-> (WorkersResponse -> Bool)
-> ToJSON WorkersResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: WorkersResponse -> Value
toJSON :: WorkersResponse -> Value
$ctoEncoding :: WorkersResponse -> Encoding
toEncoding :: WorkersResponse -> Encoding
$ctoJSONList :: [WorkersResponse] -> Value
toJSONList :: [WorkersResponse] -> Value
$ctoEncodingList :: [WorkersResponse] -> Encoding
toEncodingList :: [WorkersResponse] -> Encoding
$comitField :: WorkersResponse -> Bool
omitField :: WorkersResponse -> Bool
ToJSON)

-- | Rate-limit policies response.
data RateLimitPoliciesResponse = RateLimitPoliciesResponse
  { RateLimitPoliciesResponse -> [RateLimitPolicyView]
policies :: [RateLimitPolicyView]
  }
  deriving stock (RateLimitPoliciesResponse -> RateLimitPoliciesResponse -> Bool
(RateLimitPoliciesResponse -> RateLimitPoliciesResponse -> Bool)
-> (RateLimitPoliciesResponse -> RateLimitPoliciesResponse -> Bool)
-> Eq RateLimitPoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RateLimitPoliciesResponse -> RateLimitPoliciesResponse -> Bool
== :: RateLimitPoliciesResponse -> RateLimitPoliciesResponse -> Bool
$c/= :: RateLimitPoliciesResponse -> RateLimitPoliciesResponse -> Bool
/= :: RateLimitPoliciesResponse -> RateLimitPoliciesResponse -> Bool
Eq, (forall x.
 RateLimitPoliciesResponse -> Rep RateLimitPoliciesResponse x)
-> (forall x.
    Rep RateLimitPoliciesResponse x -> RateLimitPoliciesResponse)
-> Generic RateLimitPoliciesResponse
forall x.
Rep RateLimitPoliciesResponse x -> RateLimitPoliciesResponse
forall x.
RateLimitPoliciesResponse -> Rep RateLimitPoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
RateLimitPoliciesResponse -> Rep RateLimitPoliciesResponse x
from :: forall x.
RateLimitPoliciesResponse -> Rep RateLimitPoliciesResponse x
$cto :: forall x.
Rep RateLimitPoliciesResponse x -> RateLimitPoliciesResponse
to :: forall x.
Rep RateLimitPoliciesResponse x -> RateLimitPoliciesResponse
Generic, Int -> RateLimitPoliciesResponse -> ShowS
[RateLimitPoliciesResponse] -> ShowS
RateLimitPoliciesResponse -> String
(Int -> RateLimitPoliciesResponse -> ShowS)
-> (RateLimitPoliciesResponse -> String)
-> ([RateLimitPoliciesResponse] -> ShowS)
-> Show RateLimitPoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RateLimitPoliciesResponse -> ShowS
showsPrec :: Int -> RateLimitPoliciesResponse -> ShowS
$cshow :: RateLimitPoliciesResponse -> String
show :: RateLimitPoliciesResponse -> String
$cshowList :: [RateLimitPoliciesResponse] -> ShowS
showList :: [RateLimitPoliciesResponse] -> ShowS
Show)
  deriving anyclass (Maybe RateLimitPoliciesResponse
Value -> Parser [RateLimitPoliciesResponse]
Value -> Parser RateLimitPoliciesResponse
(Value -> Parser RateLimitPoliciesResponse)
-> (Value -> Parser [RateLimitPoliciesResponse])
-> Maybe RateLimitPoliciesResponse
-> FromJSON RateLimitPoliciesResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser RateLimitPoliciesResponse
parseJSON :: Value -> Parser RateLimitPoliciesResponse
$cparseJSONList :: Value -> Parser [RateLimitPoliciesResponse]
parseJSONList :: Value -> Parser [RateLimitPoliciesResponse]
$comittedField :: Maybe RateLimitPoliciesResponse
omittedField :: Maybe RateLimitPoliciesResponse
FromJSON, [RateLimitPoliciesResponse] -> Value
[RateLimitPoliciesResponse] -> Encoding
RateLimitPoliciesResponse -> Bool
RateLimitPoliciesResponse -> Value
RateLimitPoliciesResponse -> Encoding
(RateLimitPoliciesResponse -> Value)
-> (RateLimitPoliciesResponse -> Encoding)
-> ([RateLimitPoliciesResponse] -> Value)
-> ([RateLimitPoliciesResponse] -> Encoding)
-> (RateLimitPoliciesResponse -> Bool)
-> ToJSON RateLimitPoliciesResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: RateLimitPoliciesResponse -> Value
toJSON :: RateLimitPoliciesResponse -> Value
$ctoEncoding :: RateLimitPoliciesResponse -> Encoding
toEncoding :: RateLimitPoliciesResponse -> Encoding
$ctoJSONList :: [RateLimitPoliciesResponse] -> Value
toJSONList :: [RateLimitPoliciesResponse] -> Value
$ctoEncodingList :: [RateLimitPoliciesResponse] -> Encoding
toEncodingList :: [RateLimitPoliciesResponse] -> Encoding
$comitField :: RateLimitPoliciesResponse -> Bool
omitField :: RateLimitPoliciesResponse -> Bool
ToJSON)

-- | Rate-limit buckets response (one prefix's keys).
data RateLimitBucketsResponse = RateLimitBucketsResponse
  { RateLimitBucketsResponse -> [RateLimitBucketView]
buckets :: [RateLimitBucketView]
  }
  deriving stock (RateLimitBucketsResponse -> RateLimitBucketsResponse -> Bool
(RateLimitBucketsResponse -> RateLimitBucketsResponse -> Bool)
-> (RateLimitBucketsResponse -> RateLimitBucketsResponse -> Bool)
-> Eq RateLimitBucketsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RateLimitBucketsResponse -> RateLimitBucketsResponse -> Bool
== :: RateLimitBucketsResponse -> RateLimitBucketsResponse -> Bool
$c/= :: RateLimitBucketsResponse -> RateLimitBucketsResponse -> Bool
/= :: RateLimitBucketsResponse -> RateLimitBucketsResponse -> Bool
Eq, (forall x.
 RateLimitBucketsResponse -> Rep RateLimitBucketsResponse x)
-> (forall x.
    Rep RateLimitBucketsResponse x -> RateLimitBucketsResponse)
-> Generic RateLimitBucketsResponse
forall x.
Rep RateLimitBucketsResponse x -> RateLimitBucketsResponse
forall x.
RateLimitBucketsResponse -> Rep RateLimitBucketsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
RateLimitBucketsResponse -> Rep RateLimitBucketsResponse x
from :: forall x.
RateLimitBucketsResponse -> Rep RateLimitBucketsResponse x
$cto :: forall x.
Rep RateLimitBucketsResponse x -> RateLimitBucketsResponse
to :: forall x.
Rep RateLimitBucketsResponse x -> RateLimitBucketsResponse
Generic, Int -> RateLimitBucketsResponse -> ShowS
[RateLimitBucketsResponse] -> ShowS
RateLimitBucketsResponse -> String
(Int -> RateLimitBucketsResponse -> ShowS)
-> (RateLimitBucketsResponse -> String)
-> ([RateLimitBucketsResponse] -> ShowS)
-> Show RateLimitBucketsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RateLimitBucketsResponse -> ShowS
showsPrec :: Int -> RateLimitBucketsResponse -> ShowS
$cshow :: RateLimitBucketsResponse -> String
show :: RateLimitBucketsResponse -> String
$cshowList :: [RateLimitBucketsResponse] -> ShowS
showList :: [RateLimitBucketsResponse] -> ShowS
Show)
  deriving anyclass (Maybe RateLimitBucketsResponse
Value -> Parser [RateLimitBucketsResponse]
Value -> Parser RateLimitBucketsResponse
(Value -> Parser RateLimitBucketsResponse)
-> (Value -> Parser [RateLimitBucketsResponse])
-> Maybe RateLimitBucketsResponse
-> FromJSON RateLimitBucketsResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser RateLimitBucketsResponse
parseJSON :: Value -> Parser RateLimitBucketsResponse
$cparseJSONList :: Value -> Parser [RateLimitBucketsResponse]
parseJSONList :: Value -> Parser [RateLimitBucketsResponse]
$comittedField :: Maybe RateLimitBucketsResponse
omittedField :: Maybe RateLimitBucketsResponse
FromJSON, [RateLimitBucketsResponse] -> Value
[RateLimitBucketsResponse] -> Encoding
RateLimitBucketsResponse -> Bool
RateLimitBucketsResponse -> Value
RateLimitBucketsResponse -> Encoding
(RateLimitBucketsResponse -> Value)
-> (RateLimitBucketsResponse -> Encoding)
-> ([RateLimitBucketsResponse] -> Value)
-> ([RateLimitBucketsResponse] -> Encoding)
-> (RateLimitBucketsResponse -> Bool)
-> ToJSON RateLimitBucketsResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: RateLimitBucketsResponse -> Value
toJSON :: RateLimitBucketsResponse -> Value
$ctoEncoding :: RateLimitBucketsResponse -> Encoding
toEncoding :: RateLimitBucketsResponse -> Encoding
$ctoJSONList :: [RateLimitBucketsResponse] -> Value
toJSONList :: [RateLimitBucketsResponse] -> Value
$ctoEncodingList :: [RateLimitBucketsResponse] -> Encoding
toEncodingList :: [RateLimitBucketsResponse] -> Encoding
$comitField :: RateLimitBucketsResponse -> Bool
omitField :: RateLimitBucketsResponse -> Bool
ToJSON)

-- | Number of buckets cleared by a reset.
data RateLimitResetResponse = RateLimitResetResponse
  { RateLimitResetResponse -> Int64
reset :: Int64
  }
  deriving stock (RateLimitResetResponse -> RateLimitResetResponse -> Bool
(RateLimitResetResponse -> RateLimitResetResponse -> Bool)
-> (RateLimitResetResponse -> RateLimitResetResponse -> Bool)
-> Eq RateLimitResetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RateLimitResetResponse -> RateLimitResetResponse -> Bool
== :: RateLimitResetResponse -> RateLimitResetResponse -> Bool
$c/= :: RateLimitResetResponse -> RateLimitResetResponse -> Bool
/= :: RateLimitResetResponse -> RateLimitResetResponse -> Bool
Eq, (forall x. RateLimitResetResponse -> Rep RateLimitResetResponse x)
-> (forall x.
    Rep RateLimitResetResponse x -> RateLimitResetResponse)
-> Generic RateLimitResetResponse
forall x. Rep RateLimitResetResponse x -> RateLimitResetResponse
forall x. RateLimitResetResponse -> Rep RateLimitResetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RateLimitResetResponse -> Rep RateLimitResetResponse x
from :: forall x. RateLimitResetResponse -> Rep RateLimitResetResponse x
$cto :: forall x. Rep RateLimitResetResponse x -> RateLimitResetResponse
to :: forall x. Rep RateLimitResetResponse x -> RateLimitResetResponse
Generic, Int -> RateLimitResetResponse -> ShowS
[RateLimitResetResponse] -> ShowS
RateLimitResetResponse -> String
(Int -> RateLimitResetResponse -> ShowS)
-> (RateLimitResetResponse -> String)
-> ([RateLimitResetResponse] -> ShowS)
-> Show RateLimitResetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RateLimitResetResponse -> ShowS
showsPrec :: Int -> RateLimitResetResponse -> ShowS
$cshow :: RateLimitResetResponse -> String
show :: RateLimitResetResponse -> String
$cshowList :: [RateLimitResetResponse] -> ShowS
showList :: [RateLimitResetResponse] -> ShowS
Show)
  deriving anyclass (Maybe RateLimitResetResponse
Value -> Parser [RateLimitResetResponse]
Value -> Parser RateLimitResetResponse
(Value -> Parser RateLimitResetResponse)
-> (Value -> Parser [RateLimitResetResponse])
-> Maybe RateLimitResetResponse
-> FromJSON RateLimitResetResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser RateLimitResetResponse
parseJSON :: Value -> Parser RateLimitResetResponse
$cparseJSONList :: Value -> Parser [RateLimitResetResponse]
parseJSONList :: Value -> Parser [RateLimitResetResponse]
$comittedField :: Maybe RateLimitResetResponse
omittedField :: Maybe RateLimitResetResponse
FromJSON, [RateLimitResetResponse] -> Value
[RateLimitResetResponse] -> Encoding
RateLimitResetResponse -> Bool
RateLimitResetResponse -> Value
RateLimitResetResponse -> Encoding
(RateLimitResetResponse -> Value)
-> (RateLimitResetResponse -> Encoding)
-> ([RateLimitResetResponse] -> Value)
-> ([RateLimitResetResponse] -> Encoding)
-> (RateLimitResetResponse -> Bool)
-> ToJSON RateLimitResetResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: RateLimitResetResponse -> Value
toJSON :: RateLimitResetResponse -> Value
$ctoEncoding :: RateLimitResetResponse -> Encoding
toEncoding :: RateLimitResetResponse -> Encoding
$ctoJSONList :: [RateLimitResetResponse] -> Value
toJSONList :: [RateLimitResetResponse] -> Value
$ctoEncodingList :: [RateLimitResetResponse] -> Encoding
toEncodingList :: [RateLimitResetResponse] -> Encoding
$comitField :: RateLimitResetResponse -> Bool
omitField :: RateLimitResetResponse -> Bool
ToJSON)

-- | Concurrency pools response.
data ConcurrencyPoliciesResponse = ConcurrencyPoliciesResponse
  { ConcurrencyPoliciesResponse -> [ConcurrencyPolicyView]
policies :: [ConcurrencyPolicyView]
  }
  deriving stock (ConcurrencyPoliciesResponse -> ConcurrencyPoliciesResponse -> Bool
(ConcurrencyPoliciesResponse
 -> ConcurrencyPoliciesResponse -> Bool)
-> (ConcurrencyPoliciesResponse
    -> ConcurrencyPoliciesResponse -> Bool)
-> Eq ConcurrencyPoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConcurrencyPoliciesResponse -> ConcurrencyPoliciesResponse -> Bool
== :: ConcurrencyPoliciesResponse -> ConcurrencyPoliciesResponse -> Bool
$c/= :: ConcurrencyPoliciesResponse -> ConcurrencyPoliciesResponse -> Bool
/= :: ConcurrencyPoliciesResponse -> ConcurrencyPoliciesResponse -> Bool
Eq, (forall x.
 ConcurrencyPoliciesResponse -> Rep ConcurrencyPoliciesResponse x)
-> (forall x.
    Rep ConcurrencyPoliciesResponse x -> ConcurrencyPoliciesResponse)
-> Generic ConcurrencyPoliciesResponse
forall x.
Rep ConcurrencyPoliciesResponse x -> ConcurrencyPoliciesResponse
forall x.
ConcurrencyPoliciesResponse -> Rep ConcurrencyPoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
ConcurrencyPoliciesResponse -> Rep ConcurrencyPoliciesResponse x
from :: forall x.
ConcurrencyPoliciesResponse -> Rep ConcurrencyPoliciesResponse x
$cto :: forall x.
Rep ConcurrencyPoliciesResponse x -> ConcurrencyPoliciesResponse
to :: forall x.
Rep ConcurrencyPoliciesResponse x -> ConcurrencyPoliciesResponse
Generic, Int -> ConcurrencyPoliciesResponse -> ShowS
[ConcurrencyPoliciesResponse] -> ShowS
ConcurrencyPoliciesResponse -> String
(Int -> ConcurrencyPoliciesResponse -> ShowS)
-> (ConcurrencyPoliciesResponse -> String)
-> ([ConcurrencyPoliciesResponse] -> ShowS)
-> Show ConcurrencyPoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConcurrencyPoliciesResponse -> ShowS
showsPrec :: Int -> ConcurrencyPoliciesResponse -> ShowS
$cshow :: ConcurrencyPoliciesResponse -> String
show :: ConcurrencyPoliciesResponse -> String
$cshowList :: [ConcurrencyPoliciesResponse] -> ShowS
showList :: [ConcurrencyPoliciesResponse] -> ShowS
Show)
  deriving anyclass (Maybe ConcurrencyPoliciesResponse
Value -> Parser [ConcurrencyPoliciesResponse]
Value -> Parser ConcurrencyPoliciesResponse
(Value -> Parser ConcurrencyPoliciesResponse)
-> (Value -> Parser [ConcurrencyPoliciesResponse])
-> Maybe ConcurrencyPoliciesResponse
-> FromJSON ConcurrencyPoliciesResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ConcurrencyPoliciesResponse
parseJSON :: Value -> Parser ConcurrencyPoliciesResponse
$cparseJSONList :: Value -> Parser [ConcurrencyPoliciesResponse]
parseJSONList :: Value -> Parser [ConcurrencyPoliciesResponse]
$comittedField :: Maybe ConcurrencyPoliciesResponse
omittedField :: Maybe ConcurrencyPoliciesResponse
FromJSON, [ConcurrencyPoliciesResponse] -> Value
[ConcurrencyPoliciesResponse] -> Encoding
ConcurrencyPoliciesResponse -> Bool
ConcurrencyPoliciesResponse -> Value
ConcurrencyPoliciesResponse -> Encoding
(ConcurrencyPoliciesResponse -> Value)
-> (ConcurrencyPoliciesResponse -> Encoding)
-> ([ConcurrencyPoliciesResponse] -> Value)
-> ([ConcurrencyPoliciesResponse] -> Encoding)
-> (ConcurrencyPoliciesResponse -> Bool)
-> ToJSON ConcurrencyPoliciesResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ConcurrencyPoliciesResponse -> Value
toJSON :: ConcurrencyPoliciesResponse -> Value
$ctoEncoding :: ConcurrencyPoliciesResponse -> Encoding
toEncoding :: ConcurrencyPoliciesResponse -> Encoding
$ctoJSONList :: [ConcurrencyPoliciesResponse] -> Value
toJSONList :: [ConcurrencyPoliciesResponse] -> Value
$ctoEncodingList :: [ConcurrencyPoliciesResponse] -> Encoding
toEncodingList :: [ConcurrencyPoliciesResponse] -> Encoding
$comitField :: ConcurrencyPoliciesResponse -> Bool
omitField :: ConcurrencyPoliciesResponse -> Bool
ToJSON)

-- | Concurrency keys response (one prefix's keys).
data ConcurrencyKeysResponse = ConcurrencyKeysResponse
  { ConcurrencyKeysResponse -> [ConcurrencyKeyView]
keys :: [ConcurrencyKeyView]
  }
  deriving stock (ConcurrencyKeysResponse -> ConcurrencyKeysResponse -> Bool
(ConcurrencyKeysResponse -> ConcurrencyKeysResponse -> Bool)
-> (ConcurrencyKeysResponse -> ConcurrencyKeysResponse -> Bool)
-> Eq ConcurrencyKeysResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConcurrencyKeysResponse -> ConcurrencyKeysResponse -> Bool
== :: ConcurrencyKeysResponse -> ConcurrencyKeysResponse -> Bool
$c/= :: ConcurrencyKeysResponse -> ConcurrencyKeysResponse -> Bool
/= :: ConcurrencyKeysResponse -> ConcurrencyKeysResponse -> Bool
Eq, (forall x.
 ConcurrencyKeysResponse -> Rep ConcurrencyKeysResponse x)
-> (forall x.
    Rep ConcurrencyKeysResponse x -> ConcurrencyKeysResponse)
-> Generic ConcurrencyKeysResponse
forall x. Rep ConcurrencyKeysResponse x -> ConcurrencyKeysResponse
forall x. ConcurrencyKeysResponse -> Rep ConcurrencyKeysResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConcurrencyKeysResponse -> Rep ConcurrencyKeysResponse x
from :: forall x. ConcurrencyKeysResponse -> Rep ConcurrencyKeysResponse x
$cto :: forall x. Rep ConcurrencyKeysResponse x -> ConcurrencyKeysResponse
to :: forall x. Rep ConcurrencyKeysResponse x -> ConcurrencyKeysResponse
Generic, Int -> ConcurrencyKeysResponse -> ShowS
[ConcurrencyKeysResponse] -> ShowS
ConcurrencyKeysResponse -> String
(Int -> ConcurrencyKeysResponse -> ShowS)
-> (ConcurrencyKeysResponse -> String)
-> ([ConcurrencyKeysResponse] -> ShowS)
-> Show ConcurrencyKeysResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConcurrencyKeysResponse -> ShowS
showsPrec :: Int -> ConcurrencyKeysResponse -> ShowS
$cshow :: ConcurrencyKeysResponse -> String
show :: ConcurrencyKeysResponse -> String
$cshowList :: [ConcurrencyKeysResponse] -> ShowS
showList :: [ConcurrencyKeysResponse] -> ShowS
Show)
  deriving anyclass (Maybe ConcurrencyKeysResponse
Value -> Parser [ConcurrencyKeysResponse]
Value -> Parser ConcurrencyKeysResponse
(Value -> Parser ConcurrencyKeysResponse)
-> (Value -> Parser [ConcurrencyKeysResponse])
-> Maybe ConcurrencyKeysResponse
-> FromJSON ConcurrencyKeysResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ConcurrencyKeysResponse
parseJSON :: Value -> Parser ConcurrencyKeysResponse
$cparseJSONList :: Value -> Parser [ConcurrencyKeysResponse]
parseJSONList :: Value -> Parser [ConcurrencyKeysResponse]
$comittedField :: Maybe ConcurrencyKeysResponse
omittedField :: Maybe ConcurrencyKeysResponse
FromJSON, [ConcurrencyKeysResponse] -> Value
[ConcurrencyKeysResponse] -> Encoding
ConcurrencyKeysResponse -> Bool
ConcurrencyKeysResponse -> Value
ConcurrencyKeysResponse -> Encoding
(ConcurrencyKeysResponse -> Value)
-> (ConcurrencyKeysResponse -> Encoding)
-> ([ConcurrencyKeysResponse] -> Value)
-> ([ConcurrencyKeysResponse] -> Encoding)
-> (ConcurrencyKeysResponse -> Bool)
-> ToJSON ConcurrencyKeysResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ConcurrencyKeysResponse -> Value
toJSON :: ConcurrencyKeysResponse -> Value
$ctoEncoding :: ConcurrencyKeysResponse -> Encoding
toEncoding :: ConcurrencyKeysResponse -> Encoding
$ctoJSONList :: [ConcurrencyKeysResponse] -> Value
toJSONList :: [ConcurrencyKeysResponse] -> Value
$ctoEncodingList :: [ConcurrencyKeysResponse] -> Encoding
toEncodingList :: [ConcurrencyKeysResponse] -> Encoding
$comitField :: ConcurrencyKeysResponse -> Bool
omitField :: ConcurrencyKeysResponse -> Bool
ToJSON)

-- | Number of count rows repaired from live jobs.
data ConcurrencyReconcileResponse = ConcurrencyReconcileResponse
  { ConcurrencyReconcileResponse -> Int64
reconciled :: Int64
  }
  deriving stock (ConcurrencyReconcileResponse
-> ConcurrencyReconcileResponse -> Bool
(ConcurrencyReconcileResponse
 -> ConcurrencyReconcileResponse -> Bool)
-> (ConcurrencyReconcileResponse
    -> ConcurrencyReconcileResponse -> Bool)
-> Eq ConcurrencyReconcileResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConcurrencyReconcileResponse
-> ConcurrencyReconcileResponse -> Bool
== :: ConcurrencyReconcileResponse
-> ConcurrencyReconcileResponse -> Bool
$c/= :: ConcurrencyReconcileResponse
-> ConcurrencyReconcileResponse -> Bool
/= :: ConcurrencyReconcileResponse
-> ConcurrencyReconcileResponse -> Bool
Eq, (forall x.
 ConcurrencyReconcileResponse -> Rep ConcurrencyReconcileResponse x)
-> (forall x.
    Rep ConcurrencyReconcileResponse x -> ConcurrencyReconcileResponse)
-> Generic ConcurrencyReconcileResponse
forall x.
Rep ConcurrencyReconcileResponse x -> ConcurrencyReconcileResponse
forall x.
ConcurrencyReconcileResponse -> Rep ConcurrencyReconcileResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
ConcurrencyReconcileResponse -> Rep ConcurrencyReconcileResponse x
from :: forall x.
ConcurrencyReconcileResponse -> Rep ConcurrencyReconcileResponse x
$cto :: forall x.
Rep ConcurrencyReconcileResponse x -> ConcurrencyReconcileResponse
to :: forall x.
Rep ConcurrencyReconcileResponse x -> ConcurrencyReconcileResponse
Generic, Int -> ConcurrencyReconcileResponse -> ShowS
[ConcurrencyReconcileResponse] -> ShowS
ConcurrencyReconcileResponse -> String
(Int -> ConcurrencyReconcileResponse -> ShowS)
-> (ConcurrencyReconcileResponse -> String)
-> ([ConcurrencyReconcileResponse] -> ShowS)
-> Show ConcurrencyReconcileResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConcurrencyReconcileResponse -> ShowS
showsPrec :: Int -> ConcurrencyReconcileResponse -> ShowS
$cshow :: ConcurrencyReconcileResponse -> String
show :: ConcurrencyReconcileResponse -> String
$cshowList :: [ConcurrencyReconcileResponse] -> ShowS
showList :: [ConcurrencyReconcileResponse] -> ShowS
Show)
  deriving anyclass (Maybe ConcurrencyReconcileResponse
Value -> Parser [ConcurrencyReconcileResponse]
Value -> Parser ConcurrencyReconcileResponse
(Value -> Parser ConcurrencyReconcileResponse)
-> (Value -> Parser [ConcurrencyReconcileResponse])
-> Maybe ConcurrencyReconcileResponse
-> FromJSON ConcurrencyReconcileResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ConcurrencyReconcileResponse
parseJSON :: Value -> Parser ConcurrencyReconcileResponse
$cparseJSONList :: Value -> Parser [ConcurrencyReconcileResponse]
parseJSONList :: Value -> Parser [ConcurrencyReconcileResponse]
$comittedField :: Maybe ConcurrencyReconcileResponse
omittedField :: Maybe ConcurrencyReconcileResponse
FromJSON, [ConcurrencyReconcileResponse] -> Value
[ConcurrencyReconcileResponse] -> Encoding
ConcurrencyReconcileResponse -> Bool
ConcurrencyReconcileResponse -> Value
ConcurrencyReconcileResponse -> Encoding
(ConcurrencyReconcileResponse -> Value)
-> (ConcurrencyReconcileResponse -> Encoding)
-> ([ConcurrencyReconcileResponse] -> Value)
-> ([ConcurrencyReconcileResponse] -> Encoding)
-> (ConcurrencyReconcileResponse -> Bool)
-> ToJSON ConcurrencyReconcileResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ConcurrencyReconcileResponse -> Value
toJSON :: ConcurrencyReconcileResponse -> Value
$ctoEncoding :: ConcurrencyReconcileResponse -> Encoding
toEncoding :: ConcurrencyReconcileResponse -> Encoding
$ctoJSONList :: [ConcurrencyReconcileResponse] -> Value
toJSONList :: [ConcurrencyReconcileResponse] -> Value
$ctoEncodingList :: [ConcurrencyReconcileResponse] -> Encoding
toEncodingList :: [ConcurrencyReconcileResponse] -> Encoding
$comitField :: ConcurrencyReconcileResponse -> Bool
omitField :: ConcurrencyReconcileResponse -> Bool
ToJSON)

-- | Whether the API can reach its database.
data HealthStatus = Ok | Down
  deriving stock (HealthStatus -> HealthStatus -> Bool
(HealthStatus -> HealthStatus -> Bool)
-> (HealthStatus -> HealthStatus -> Bool) -> Eq HealthStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HealthStatus -> HealthStatus -> Bool
== :: HealthStatus -> HealthStatus -> Bool
$c/= :: HealthStatus -> HealthStatus -> Bool
/= :: HealthStatus -> HealthStatus -> Bool
Eq, (forall x. HealthStatus -> Rep HealthStatus x)
-> (forall x. Rep HealthStatus x -> HealthStatus)
-> Generic HealthStatus
forall x. Rep HealthStatus x -> HealthStatus
forall x. HealthStatus -> Rep HealthStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HealthStatus -> Rep HealthStatus x
from :: forall x. HealthStatus -> Rep HealthStatus x
$cto :: forall x. Rep HealthStatus x -> HealthStatus
to :: forall x. Rep HealthStatus x -> HealthStatus
Generic, Int -> HealthStatus -> ShowS
[HealthStatus] -> ShowS
HealthStatus -> String
(Int -> HealthStatus -> ShowS)
-> (HealthStatus -> String)
-> ([HealthStatus] -> ShowS)
-> Show HealthStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HealthStatus -> ShowS
showsPrec :: Int -> HealthStatus -> ShowS
$cshow :: HealthStatus -> String
show :: HealthStatus -> String
$cshowList :: [HealthStatus] -> ShowS
showList :: [HealthStatus] -> ShowS
Show)

instance ToJSON HealthStatus where
  toJSON :: HealthStatus -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (HealthStatus -> Text) -> HealthStatus -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HealthStatus -> Text
healthStatusToText

instance FromJSON HealthStatus where
  parseJSON :: Value -> Parser HealthStatus
parseJSON = String
-> (Text -> Parser HealthStatus) -> Value -> Parser HealthStatus
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"HealthStatus" ((Text -> Parser HealthStatus) -> Value -> Parser HealthStatus)
-> (Text -> Parser HealthStatus) -> Value -> Parser HealthStatus
forall a b. (a -> b) -> a -> b
$ \Text
txt -> case Text
txt of
    Text
"ok" -> HealthStatus -> Parser HealthStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HealthStatus
Ok
    Text
"down" -> HealthStatus -> Parser HealthStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HealthStatus
Down
    Text
_ -> String -> Parser HealthStatus
forall a. HasCallStack => String -> Parser a
forall (m :: * -> *) a.
(MonadFail m, HasCallStack) =>
String -> m a
fail String
"expected ok or down"

healthStatusToText :: HealthStatus -> Text
healthStatusToText :: HealthStatus -> Text
healthStatusToText = \case
  HealthStatus
Ok -> Text
"ok"
  HealthStatus
Down -> Text
"down"

-- | Readiness of the API and the database behind it.
data HealthResponse = HealthResponse
  { HealthResponse -> HealthStatus
status :: HealthStatus
  , HealthResponse -> Text
schemaName :: Text
  , HealthResponse -> UTCTime
checkedAt :: UTCTime
  , HealthResponse -> Maybe Double
dbLatencyMs :: Maybe Double
  -- ^ Nothing when the database could not be reached.
  , HealthResponse -> Maybe PgDbHealth
db :: Maybe PgDbHealth
  -- ^ Connection and age counters, absent when the database is unreachable.
  }
  deriving stock (HealthResponse -> HealthResponse -> Bool
(HealthResponse -> HealthResponse -> Bool)
-> (HealthResponse -> HealthResponse -> Bool) -> Eq HealthResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HealthResponse -> HealthResponse -> Bool
== :: HealthResponse -> HealthResponse -> Bool
$c/= :: HealthResponse -> HealthResponse -> Bool
/= :: HealthResponse -> HealthResponse -> Bool
Eq, (forall x. HealthResponse -> Rep HealthResponse x)
-> (forall x. Rep HealthResponse x -> HealthResponse)
-> Generic HealthResponse
forall x. Rep HealthResponse x -> HealthResponse
forall x. HealthResponse -> Rep HealthResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HealthResponse -> Rep HealthResponse x
from :: forall x. HealthResponse -> Rep HealthResponse x
$cto :: forall x. Rep HealthResponse x -> HealthResponse
to :: forall x. Rep HealthResponse x -> HealthResponse
Generic, Int -> HealthResponse -> ShowS
[HealthResponse] -> ShowS
HealthResponse -> String
(Int -> HealthResponse -> ShowS)
-> (HealthResponse -> String)
-> ([HealthResponse] -> ShowS)
-> Show HealthResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HealthResponse -> ShowS
showsPrec :: Int -> HealthResponse -> ShowS
$cshow :: HealthResponse -> String
show :: HealthResponse -> String
$cshowList :: [HealthResponse] -> ShowS
showList :: [HealthResponse] -> ShowS
Show)
  deriving anyclass (Maybe HealthResponse
Value -> Parser [HealthResponse]
Value -> Parser HealthResponse
(Value -> Parser HealthResponse)
-> (Value -> Parser [HealthResponse])
-> Maybe HealthResponse
-> FromJSON HealthResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser HealthResponse
parseJSON :: Value -> Parser HealthResponse
$cparseJSONList :: Value -> Parser [HealthResponse]
parseJSONList :: Value -> Parser [HealthResponse]
$comittedField :: Maybe HealthResponse
omittedField :: Maybe HealthResponse
FromJSON, [HealthResponse] -> Value
[HealthResponse] -> Encoding
HealthResponse -> Bool
HealthResponse -> Value
HealthResponse -> Encoding
(HealthResponse -> Value)
-> (HealthResponse -> Encoding)
-> ([HealthResponse] -> Value)
-> ([HealthResponse] -> Encoding)
-> (HealthResponse -> Bool)
-> ToJSON HealthResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: HealthResponse -> Value
toJSON :: HealthResponse -> Value
$ctoEncoding :: HealthResponse -> Encoding
toEncoding :: HealthResponse -> Encoding
$ctoJSONList :: [HealthResponse] -> Value
toJSONList :: [HealthResponse] -> Value
$ctoEncodingList :: [HealthResponse] -> Encoding
toEncodingList :: [HealthResponse] -> Encoding
$comitField :: HealthResponse -> Bool
omitField :: HealthResponse -> Bool
ToJSON)

-- | The process is running. Answered without touching the database.
data LivenessResponse = LivenessResponse
  { LivenessResponse -> Bool
alive :: Bool
  }
  deriving stock (LivenessResponse -> LivenessResponse -> Bool
(LivenessResponse -> LivenessResponse -> Bool)
-> (LivenessResponse -> LivenessResponse -> Bool)
-> Eq LivenessResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LivenessResponse -> LivenessResponse -> Bool
== :: LivenessResponse -> LivenessResponse -> Bool
$c/= :: LivenessResponse -> LivenessResponse -> Bool
/= :: LivenessResponse -> LivenessResponse -> Bool
Eq, (forall x. LivenessResponse -> Rep LivenessResponse x)
-> (forall x. Rep LivenessResponse x -> LivenessResponse)
-> Generic LivenessResponse
forall x. Rep LivenessResponse x -> LivenessResponse
forall x. LivenessResponse -> Rep LivenessResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LivenessResponse -> Rep LivenessResponse x
from :: forall x. LivenessResponse -> Rep LivenessResponse x
$cto :: forall x. Rep LivenessResponse x -> LivenessResponse
to :: forall x. Rep LivenessResponse x -> LivenessResponse
Generic, Int -> LivenessResponse -> ShowS
[LivenessResponse] -> ShowS
LivenessResponse -> String
(Int -> LivenessResponse -> ShowS)
-> (LivenessResponse -> String)
-> ([LivenessResponse] -> ShowS)
-> Show LivenessResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LivenessResponse -> ShowS
showsPrec :: Int -> LivenessResponse -> ShowS
$cshow :: LivenessResponse -> String
show :: LivenessResponse -> String
$cshowList :: [LivenessResponse] -> ShowS
showList :: [LivenessResponse] -> ShowS
Show)
  deriving anyclass (Maybe LivenessResponse
Value -> Parser [LivenessResponse]
Value -> Parser LivenessResponse
(Value -> Parser LivenessResponse)
-> (Value -> Parser [LivenessResponse])
-> Maybe LivenessResponse
-> FromJSON LivenessResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser LivenessResponse
parseJSON :: Value -> Parser LivenessResponse
$cparseJSONList :: Value -> Parser [LivenessResponse]
parseJSONList :: Value -> Parser [LivenessResponse]
$comittedField :: Maybe LivenessResponse
omittedField :: Maybe LivenessResponse
FromJSON, [LivenessResponse] -> Value
[LivenessResponse] -> Encoding
LivenessResponse -> Bool
LivenessResponse -> Value
LivenessResponse -> Encoding
(LivenessResponse -> Value)
-> (LivenessResponse -> Encoding)
-> ([LivenessResponse] -> Value)
-> ([LivenessResponse] -> Encoding)
-> (LivenessResponse -> Bool)
-> ToJSON LivenessResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: LivenessResponse -> Value
toJSON :: LivenessResponse -> Value
$ctoEncoding :: LivenessResponse -> Encoding
toEncoding :: LivenessResponse -> Encoding
$ctoJSONList :: [LivenessResponse] -> Value
toJSONList :: [LivenessResponse] -> Value
$ctoEncodingList :: [LivenessResponse] -> Encoding
toEncodingList :: [LivenessResponse] -> Encoding
$comitField :: LivenessResponse -> Bool
omitField :: LivenessResponse -> Bool
ToJSON)