{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}

-- | Request and response types for the Arbiter REST API.
module Arbiter.Servant.Types
  ( -- * Jobs
    ApiJobWithStatus (..)
  , ApiJobWrite (..)
  , JobResponse (..)
  , JobsResponse (..)
  , RescheduleRequest (..)
  , DLQRetentionRequest (..)
  , BatchInsertRequest (..)
  , BatchInsertResponse (..)

    -- * DLQ and archive
  , PayloadEdit (..)
  , OptionalJSON
  , BatchDeleteRequest (..)
  , BatchDeleteResponse (..)
  , BatchRetryRequest (..)
  , BatchRetryResponse (..)

    -- * Pages
  , Page (..)
  , PageSize (..)
  , PageLimit
  , KeyPageLimit
  , pageSizeDefault
  , pageLimitRange
  , Items (..)
  , ArchiveResponse
  , DLQResponse
  , GroupsResponse

    -- * Leases
  , ClaimRequest (..)
  , claimJobsRange
  , defaultClaimJobs
  , leaseSecondsRange
  , defaultLeaseSeconds
  , ClaimResponse (..)
  , JobLease (..)
  , AckRequest (..)
  , ExtendRequest (..)

    -- * Queues and stats
  , StatsResponse (..)
  , AllStatsResponse (..)
  , QueuesResponse (..)

    -- * Maintenance
  , MaintenanceResponse (..)

    -- * Cron and workers
  , CronScheduleView (..)
  , CronSchedulesResponse (..)
  , WorkersResponse (..)

    -- * Admission policies
  , RateLimitPoliciesResponse (..)
  , RateLimitBucketsResponse
  , RateLimitResetResponse (..)
  , AddTokensRequest (..)
  , AddTokensResponse (..)
  , PruneResponse (..)
  , ConcurrencyPoliciesResponse (..)
  , ConcurrencyKeysResponse
  , ConcurrencyReconcileResponse (..)

    -- * Health
  , HealthStatus (..)
  , healthStatusToText
  , HealthResponse (..)
  , LivenessResponse (..)

    -- * Re-exported core types
  , CronScheduleRow (..)
  , CronScheduleUpdate (..)
  , QueueOverview (..)
  , QueueStats (..)
  , QueueRow (..)
  , WorkerRow (..)
  , RateLimitPolicyView (..)
  , RateLimitBucketView (..)
  , RateLimitPolicyUpdate (..)
  , ConcurrencyPolicyView (..)
  , ConcurrencyKeyView (..)
  , ConcurrencyPolicyUpdate (..)
  , PgDbHealth (..)
  , GroupSummary (..)
  ) where

import Arbiter.Core.Concurrency.Stats
  ( ConcurrencyKeyView (..)
  , ConcurrencyPolicyUpdate (..)
  , ConcurrencyPolicyView (..)
  )
import Arbiter.Core.CronSchedule (CronScheduleRow (..), CronScheduleUpdate (..))
import Arbiter.Core.Enum (enumFromText)
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, Stored, jobReadPairs, jobReadSeries)
import Arbiter.Core.Job.Types qualified as Arb
import Arbiter.Core.Operations (GroupSummary (..), QueueOverview (..), QueueStats (..))
import Arbiter.Core.Queues (QueueRow (..))
import Arbiter.Core.RateLimit.Stats
  ( RateLimitBucketView (..)
  , RateLimitPolicyUpdate (..)
  , RateLimitPolicyView (..)
  )
import Arbiter.Core.Worker (WorkerRow (..))
import Data.Aeson
  ( FromJSON (..)
  , KeyValue
  , ToJSON (..)
  , Value (Object)
  , eitherDecode
  , encode
  , object
  , pairs
  , withObject
  , withText
  , (.!=)
  , (.:)
  , (.:!)
  , (.:?)
  , (.=)
  )
import Data.Aeson.KeyMap qualified as KM
import Data.Aeson.Types (Object, Pair, Parser)
import Data.ByteString.Lazy.Char8 qualified as LBS8
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.Map.Strict (Map)
import Data.Proxy (Proxy (..))
import Data.String (IsString)
import Data.Text (Text, unpack)
import Data.Time.Clock (UTCTime)
import Data.UUID.Types (UUID)
import GHC.Generics (Generic, Generically (..))
import GHC.TypeLits (KnownNat, Nat, natVal)
import Servant.API (Accept (..), FromHttpApiData, JSON, MimeRender (..), MimeUnrender (..), ToHttpApiData)

-- | A job row plus its SQL-derived status, for the list and detail endpoints.
data ApiJobWithStatus payload = ApiJobWithStatus
  { forall payload. ApiJobWithStatus payload -> JobRead payload
ajwsJob :: JobRead payload
  -- ^ The job. Its fields are flattened into the object.
  , 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 for REST insertion. Lineage, suspension and trace fields are not settable.
newtype ApiJobWrite payload = ApiJobWrite
  { forall payload. ApiJobWrite payload -> JobWrite payload
unApiJobWrite :: JobWrite payload
  -- ^ The job to insert. Its settable fields are flattened into the object.
  }
  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)

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]
jobReadPairs 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])
  toEncoding :: ApiJobWithStatus payload -> Encoding
toEncoding (ApiJobWithStatus JobRead payload
job JobStatus
status) = Series -> Encoding
pairs (JobRead payload -> Series
forall payload. ToJSON payload => JobRead payload -> Series
jobReadSeries JobRead payload
job Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> Key
"status" Key -> JobStatus -> Series
forall v. ToJSON v => Key -> v -> Series
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobStatus
status)

instance (FromJSON payload) => FromJSON (ApiJobWithStatus payload) where
  parseJSON :: Value -> Parser (ApiJobWithStatus payload)
parseJSON Value
value = JobRead payload -> JobStatus -> ApiJobWithStatus payload
forall payload.
JobRead payload -> JobStatus -> ApiJobWithStatus payload
ApiJobWithStatus (JobRead payload -> JobStatus -> ApiJobWithStatus payload)
-> Parser (JobRead payload)
-> Parser (JobStatus -> ApiJobWithStatus 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 Parser (JobStatus -> ApiJobWithStatus payload)
-> Parser JobStatus -> Parser (ApiJobWithStatus payload)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> String -> (Object -> Parser JobStatus) -> Value -> Parser JobStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"JobWithStatus" (Object -> Key -> Parser JobStatus
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"status") Value
value

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.
Job 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.
Job 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.
Job 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.
Job 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.
Job 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.
Job 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.
Job 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"
    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
      $ maybe id Arb.setPriority priority
      $ Arb.setGroupKey group
      $ Arb.defaultJob payload

-- | Page size of a listing, with the size it takes when the request omits it.
newtype PageSize (def :: Nat) = PageSize {forall (def :: Nat). PageSize def -> Int
unPageSize :: Int}
  deriving newtype (PageSize def -> PageSize def -> Bool
(PageSize def -> PageSize def -> Bool)
-> (PageSize def -> PageSize def -> Bool) -> Eq (PageSize def)
forall (def :: Nat). PageSize def -> PageSize def -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall (def :: Nat). PageSize def -> PageSize def -> Bool
== :: PageSize def -> PageSize def -> Bool
$c/= :: forall (def :: Nat). PageSize def -> PageSize def -> Bool
/= :: PageSize def -> PageSize def -> Bool
Eq, Text -> Either Text (PageSize def)
ByteString -> Either Text (PageSize def)
(Text -> Either Text (PageSize def))
-> (ByteString -> Either Text (PageSize def))
-> (Text -> Either Text (PageSize def))
-> FromHttpApiData (PageSize def)
forall (def :: Nat). Text -> Either Text (PageSize def)
forall (def :: Nat). ByteString -> Either Text (PageSize def)
forall a.
(Text -> Either Text a)
-> (ByteString -> Either Text a)
-> (Text -> Either Text a)
-> FromHttpApiData a
$cparseUrlPiece :: forall (def :: Nat). Text -> Either Text (PageSize def)
parseUrlPiece :: Text -> Either Text (PageSize def)
$cparseHeader :: forall (def :: Nat). ByteString -> Either Text (PageSize def)
parseHeader :: ByteString -> Either Text (PageSize def)
$cparseQueryParam :: forall (def :: Nat). Text -> Either Text (PageSize def)
parseQueryParam :: Text -> Either Text (PageSize def)
FromHttpApiData, Int -> PageSize def -> ShowS
[PageSize def] -> ShowS
PageSize def -> String
(Int -> PageSize def -> ShowS)
-> (PageSize def -> String)
-> ([PageSize def] -> ShowS)
-> Show (PageSize def)
forall (def :: Nat). Int -> PageSize def -> ShowS
forall (def :: Nat). [PageSize def] -> ShowS
forall (def :: Nat). PageSize def -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall (def :: Nat). Int -> PageSize def -> ShowS
showsPrec :: Int -> PageSize def -> ShowS
$cshow :: forall (def :: Nat). PageSize def -> String
show :: PageSize def -> String
$cshowList :: forall (def :: Nat). [PageSize def] -> ShowS
showList :: [PageSize def] -> ShowS
Show, PageSize def -> Text
PageSize def -> ByteString
PageSize def -> Builder
(PageSize def -> Text)
-> (PageSize def -> Builder)
-> (PageSize def -> ByteString)
-> (PageSize def -> Text)
-> (PageSize def -> Builder)
-> ToHttpApiData (PageSize def)
forall (def :: Nat). PageSize def -> Text
forall (def :: Nat). PageSize def -> ByteString
forall (def :: Nat). PageSize def -> Builder
forall a.
(a -> Text)
-> (a -> Builder)
-> (a -> ByteString)
-> (a -> Text)
-> (a -> Builder)
-> ToHttpApiData a
$ctoUrlPiece :: forall (def :: Nat). PageSize def -> Text
toUrlPiece :: PageSize def -> Text
$ctoEncodedUrlPiece :: forall (def :: Nat). PageSize def -> Builder
toEncodedUrlPiece :: PageSize def -> Builder
$ctoHeader :: forall (def :: Nat). PageSize def -> ByteString
toHeader :: PageSize def -> ByteString
$ctoQueryParam :: forall (def :: Nat). PageSize def -> Text
toQueryParam :: PageSize def -> Text
$ctoEncodedQueryParam :: forall (def :: Nat). PageSize def -> Builder
toEncodedQueryParam :: PageSize def -> Builder
ToHttpApiData)

-- | Page size of a job, DLQ, archive or group listing.
type PageLimit = PageSize 50

-- | Page size of a bucket or key listing.
type KeyPageLimit = PageSize 100

-- | Bounds on page size.
pageLimitRange :: (Int, Int)
pageLimitRange :: (Int, Int)
pageLimitRange = (Int
1, Int
1000)

-- | The page size a listing takes when the request omits it.
pageSizeDefault :: (KnownNat def) => proxy def -> Int
pageSizeDefault :: forall (def :: Nat) (proxy :: Nat -> *).
KnownNat def =>
proxy def -> Int
pageSizeDefault = Integer -> Int
forall a. Num a => Integer -> a
fromInteger (Integer -> Int) -> (proxy def -> Integer) -> proxy def -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. proxy def -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal

-- | One page of a list, with the size of the full list.
data Page a = Page
  { forall a. Page a -> [a]
pageItems :: [a]
  , forall a. Page a -> Int
pageTotal :: Int
  -- ^ Rows that match the filters, across all pages.
  , forall a. Page a -> Int
pageOffset :: Int
  , forall a. Page a -> Int
pageLimit :: Int
  -- ^ Page size, clamped to 'pageLimitRange'.
  }
  deriving stock (Page a -> Page a -> Bool
(Page a -> Page a -> Bool)
-> (Page a -> Page a -> Bool) -> Eq (Page a)
forall a. Eq a => Page a -> Page a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Page a -> Page a -> Bool
== :: Page a -> Page a -> Bool
$c/= :: forall a. Eq a => Page a -> Page a -> Bool
/= :: Page a -> Page a -> Bool
Eq, Int -> Page a -> ShowS
[Page a] -> ShowS
Page a -> String
(Int -> Page a -> ShowS)
-> (Page a -> String) -> ([Page a] -> ShowS) -> Show (Page a)
forall a. Show a => Int -> Page a -> ShowS
forall a. Show a => [Page a] -> ShowS
forall a. Show a => Page a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Page a -> ShowS
showsPrec :: Int -> Page a -> ShowS
$cshow :: forall a. Show a => Page a -> String
show :: Page a -> String
$cshowList :: forall a. Show a => [Page a] -> ShowS
showList :: [Page a] -> ShowS
Show)

instance (ToJSON a) => ToJSON (Page a) where
  toJSON :: Page a -> Value
toJSON = [Pair] -> Value
object ([Pair] -> Value) -> (Page a -> [Pair]) -> Page a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Page a -> [Pair]
forall e kv a. (KeyValue e kv, ToJSON a) => Page a -> [kv]
pageKeys
  toEncoding :: Page a -> Encoding
toEncoding = Series -> Encoding
pairs (Series -> Encoding) -> (Page a -> Series) -> Page a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Series] -> Series
forall a. Monoid a => [a] -> a
mconcat ([Series] -> Series) -> (Page a -> [Series]) -> Page a -> Series
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Page a -> [Series]
forall e kv a. (KeyValue e kv, ToJSON a) => Page a -> [kv]
pageKeys

pageKeys :: (KeyValue e kv, ToJSON a) => Page a -> [kv]
pageKeys :: forall e kv a. (KeyValue e kv, ToJSON a) => Page a -> [kv]
pageKeys Page a
p = [Key
"items" Key -> [a] -> kv
forall v. ToJSON v => Key -> v -> kv
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Page a -> [a]
forall a. Page a -> [a]
pageItems Page a
p, Key
"total" Key -> Int -> kv
forall v. ToJSON v => Key -> v -> kv
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Page a -> Int
forall a. Page a -> Int
pageTotal Page a
p, Key
"offset" Key -> Int -> kv
forall v. ToJSON v => Key -> v -> kv
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Page a -> Int
forall a. Page a -> Int
pageOffset Page a
p, Key
"limit" Key -> Int -> kv
forall v. ToJSON v => Key -> v -> kv
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Page a -> Int
forall a. Page a -> Int
pageLimit Page a
p]

instance (FromJSON a) => FromJSON (Page a) where
  parseJSON :: Value -> Parser (Page a)
parseJSON = String -> (Object -> Parser (Page a)) -> Value -> Parser (Page a)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Page" Object -> Parser (Page a)
forall a. FromJSON a => Object -> Parser (Page a)
parsePage

parsePage :: (FromJSON a) => Object -> Parser (Page a)
parsePage :: forall a. FromJSON a => Object -> Parser (Page a)
parsePage Object
obj = [a] -> Int -> Int -> Int -> Page a
forall a. [a] -> Int -> Int -> Int -> Page a
Page ([a] -> Int -> Int -> Int -> Page a)
-> Parser [a] -> Parser (Int -> Int -> Int -> Page a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Key -> Parser [a]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"items" Parser (Int -> Int -> Int -> Page a)
-> Parser Int -> Parser (Int -> Int -> Page a)
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 Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"total" Parser (Int -> Int -> Page a)
-> Parser Int -> Parser (Int -> Page a)
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 Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"offset" Parser (Int -> Page a) -> Parser Int -> Parser (Page a)
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 Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"limit"

-- | A list of rows without a total.
newtype Items a = Items
  { forall a. Items a -> [a]
items :: [a]
  }
  deriving stock (Items a -> Items a -> Bool
(Items a -> Items a -> Bool)
-> (Items a -> Items a -> Bool) -> Eq (Items a)
forall a. Eq a => Items a -> Items a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Items a -> Items a -> Bool
== :: Items a -> Items a -> Bool
$c/= :: forall a. Eq a => Items a -> Items a -> Bool
/= :: Items a -> Items a -> Bool
Eq, (forall x. Items a -> Rep (Items a) x)
-> (forall x. Rep (Items a) x -> Items a) -> Generic (Items a)
forall x. Rep (Items a) x -> Items a
forall x. Items a -> Rep (Items a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Items a) x -> Items a
forall a x. Items a -> Rep (Items a) x
$cfrom :: forall a x. Items a -> Rep (Items a) x
from :: forall x. Items a -> Rep (Items a) x
$cto :: forall a x. Rep (Items a) x -> Items a
to :: forall x. Rep (Items a) x -> Items a
Generic, Int -> Items a -> ShowS
[Items a] -> ShowS
Items a -> String
(Int -> Items a -> ShowS)
-> (Items a -> String) -> ([Items a] -> ShowS) -> Show (Items a)
forall a. Show a => Int -> Items a -> ShowS
forall a. Show a => [Items a] -> ShowS
forall a. Show a => Items a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Items a -> ShowS
showsPrec :: Int -> Items a -> ShowS
$cshow :: forall a. Show a => Items a -> String
show :: Items a -> String
$cshowList :: forall a. Show a => [Items a] -> ShowS
showList :: [Items a] -> ShowS
Show)
  deriving (Maybe (Items a)
Value -> Parser [Items a]
Value -> Parser (Items a)
(Value -> Parser (Items a))
-> (Value -> Parser [Items a])
-> Maybe (Items a)
-> FromJSON (Items a)
forall a. FromJSON a => Maybe (Items a)
forall a. FromJSON a => Value -> Parser [Items a]
forall a. FromJSON a => Value -> Parser (Items a)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: forall a. FromJSON a => Value -> Parser (Items a)
parseJSON :: Value -> Parser (Items a)
$cparseJSONList :: forall a. FromJSON a => Value -> Parser [Items a]
parseJSONList :: Value -> Parser [Items a]
$comittedField :: forall a. FromJSON a => Maybe (Items a)
omittedField :: Maybe (Items a)
FromJSON, [Items a] -> Value
[Items a] -> Encoding
Items a -> Bool
Items a -> Value
Items a -> Encoding
(Items a -> Value)
-> (Items a -> Encoding)
-> ([Items a] -> Value)
-> ([Items a] -> Encoding)
-> (Items a -> Bool)
-> ToJSON (Items a)
forall a. ToJSON a => [Items a] -> Value
forall a. ToJSON a => [Items a] -> Encoding
forall a. ToJSON a => Items a -> Bool
forall a. ToJSON a => Items a -> Value
forall a. ToJSON a => Items a -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: forall a. ToJSON a => Items a -> Value
toJSON :: Items a -> Value
$ctoEncoding :: forall a. ToJSON a => Items a -> Encoding
toEncoding :: Items a -> Encoding
$ctoJSONList :: forall a. ToJSON a => [Items a] -> Value
toJSONList :: [Items a] -> Value
$ctoEncodingList :: forall a. ToJSON a => [Items a] -> Encoding
toEncodingList :: [Items a] -> Encoding
$comitField :: forall a. ToJSON a => Items a -> Bool
omitField :: Items a -> Bool
ToJSON) via Generically (Items a)

-- | A page of archived jobs.
type ArchiveResponse payload = Page (Archive.ArchiveJob (Stored payload))

-- | Single-job response envelope, parameterized over the job representation
-- ('JobRead' 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 (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) via Generically (JobResponse a)

-- | A page of jobs with their tree counts.
data JobsResponse payload = JobsResponse
  { forall payload.
JobsResponse payload -> Page (ApiJobWithStatus (Stored payload))
jobsPage :: Page (ApiJobWithStatus (Stored payload))
  -- ^ The page. Its fields are flattened into the object.
  , forall payload. JobsResponse payload -> Map Int64 Int64
childCounts :: Map Int64 Int64
  -- ^ Child count, keyed by the id of each parent on the page.
  , forall payload. JobsResponse payload -> [Int64]
pausedParents :: [Int64]
  -- ^ Ids of the parents on the page whose children are all paused.
  , forall payload. JobsResponse payload -> Map Int64 Int64
dlqChildCounts :: Map Int64 Int64
  -- ^ DLQ child count, keyed by the id of each parent on the page.
  }
  deriving stock (JobsResponse payload -> JobsResponse payload -> Bool
(JobsResponse payload -> JobsResponse payload -> Bool)
-> (JobsResponse payload -> JobsResponse payload -> Bool)
-> Eq (JobsResponse payload)
forall payload.
JobsResponse payload -> JobsResponse payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
JobsResponse payload -> JobsResponse payload -> Bool
== :: JobsResponse payload -> JobsResponse payload -> Bool
$c/= :: forall payload.
JobsResponse payload -> JobsResponse payload -> Bool
/= :: JobsResponse payload -> JobsResponse payload -> Bool
Eq, 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. Int -> JobsResponse payload -> ShowS
forall payload. [JobsResponse payload] -> ShowS
forall payload. JobsResponse payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload. Int -> JobsResponse payload -> ShowS
showsPrec :: Int -> JobsResponse payload -> ShowS
$cshow :: forall payload. JobsResponse payload -> String
show :: JobsResponse payload -> String
$cshowList :: forall payload. [JobsResponse payload] -> ShowS
showList :: [JobsResponse payload] -> ShowS
Show)

instance ToJSON (JobsResponse payload) where
  toJSON :: JobsResponse payload -> Value
toJSON = [Pair] -> Value
object ([Pair] -> Value)
-> (JobsResponse payload -> [Pair])
-> JobsResponse payload
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JobsResponse payload -> [Pair]
forall e kv payload. KeyValue e kv => JobsResponse payload -> [kv]
jobsResponseKeys
  toEncoding :: JobsResponse payload -> Encoding
toEncoding = Series -> Encoding
pairs (Series -> Encoding)
-> (JobsResponse payload -> Series)
-> JobsResponse payload
-> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Series] -> Series
forall a. Monoid a => [a] -> a
mconcat ([Series] -> Series)
-> (JobsResponse payload -> [Series])
-> JobsResponse payload
-> Series
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JobsResponse payload -> [Series]
forall e kv payload. KeyValue e kv => JobsResponse payload -> [kv]
jobsResponseKeys

jobsResponseKeys :: (KeyValue e kv) => JobsResponse payload -> [kv]
jobsResponseKeys :: forall e kv payload. KeyValue e kv => JobsResponse payload -> [kv]
jobsResponseKeys JobsResponse payload
r =
  Page (ApiJobWithStatus (Stored payload)) -> [kv]
forall e kv a. (KeyValue e kv, ToJSON a) => Page a -> [kv]
pageKeys (JobsResponse payload -> Page (ApiJobWithStatus (Stored payload))
forall payload.
JobsResponse payload -> Page (ApiJobWithStatus (Stored payload))
jobsPage JobsResponse payload
r)
    [kv] -> [kv] -> [kv]
forall a. Semigroup a => a -> a -> a
<> [Key
"childCounts" Key -> Map Int64 Int64 -> kv
forall v. ToJSON v => Key -> v -> kv
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobsResponse payload -> Map Int64 Int64
forall payload. JobsResponse payload -> Map Int64 Int64
childCounts JobsResponse payload
r, Key
"pausedParents" Key -> [Int64] -> kv
forall v. ToJSON v => Key -> v -> kv
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobsResponse payload -> [Int64]
forall payload. JobsResponse payload -> [Int64]
pausedParents JobsResponse payload
r, Key
"dlqChildCounts" Key -> Map Int64 Int64 -> kv
forall v. ToJSON v => Key -> v -> kv
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= JobsResponse payload -> Map Int64 Int64
forall payload. JobsResponse payload -> Map Int64 Int64
dlqChildCounts JobsResponse payload
r]

instance FromJSON (JobsResponse payload) where
  parseJSON :: Value -> Parser (JobsResponse payload)
parseJSON = String
-> (Object -> Parser (JobsResponse payload))
-> Value
-> Parser (JobsResponse payload)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"JobsResponse" ((Object -> Parser (JobsResponse payload))
 -> Value -> Parser (JobsResponse payload))
-> (Object -> Parser (JobsResponse payload))
-> Value
-> Parser (JobsResponse payload)
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
    Page (ApiJobWithStatus (Stored payload))
-> Map Int64 Int64
-> [Int64]
-> Map Int64 Int64
-> JobsResponse payload
forall payload.
Page (ApiJobWithStatus (Stored payload))
-> Map Int64 Int64
-> [Int64]
-> Map Int64 Int64
-> JobsResponse payload
JobsResponse (Page (ApiJobWithStatus (Stored payload))
 -> Map Int64 Int64
 -> [Int64]
 -> Map Int64 Int64
 -> JobsResponse payload)
-> Parser (Page (ApiJobWithStatus (Stored payload)))
-> Parser
     (Map Int64 Int64
      -> [Int64] -> Map Int64 Int64 -> JobsResponse payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object -> Parser (Page (ApiJobWithStatus (Stored payload)))
forall a. FromJSON a => Object -> Parser (Page a)
parsePage Object
obj Parser
  (Map Int64 Int64
   -> [Int64] -> Map Int64 Int64 -> JobsResponse payload)
-> Parser (Map Int64 Int64)
-> Parser ([Int64] -> Map Int64 Int64 -> JobsResponse payload)
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 (Map Int64 Int64)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"childCounts" Parser ([Int64] -> Map Int64 Int64 -> JobsResponse payload)
-> Parser [Int64]
-> Parser (Map Int64 Int64 -> JobsResponse payload)
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 [Int64]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"pausedParents" Parser (Map Int64 Int64 -> JobsResponse payload)
-> Parser (Map Int64 Int64) -> Parser (JobsResponse payload)
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 (Map Int64 Int64)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"dlqChildCounts"

-- | Bounds on jobs per claim.
claimJobsRange :: (Int, Int)
claimJobsRange :: (Int, Int)
claimJobsRange = (Int
1, Int
1000)

-- | Jobs per claim when the request omits it.
defaultClaimJobs :: Int
defaultClaimJobs :: Int
defaultClaimJobs = Int
1

-- | Bounds on lease seconds.
leaseSecondsRange :: (Double, Double)
leaseSecondsRange :: (Double, Double)
leaseSecondsRange = (Double
1, Double
3600)

-- | Lease seconds when the request omits it.
defaultLeaseSeconds :: Double
defaultLeaseSeconds :: Double
defaultLeaseSeconds = Double
60

-- | A consumer's request to lease visible jobs.
data ClaimRequest = ClaimRequest
  { ClaimRequest -> Maybe Int
maxJobs :: Maybe Int
  -- ^ Jobs to claim. See 'defaultClaimJobs' and 'claimJobsRange'.
  , ClaimRequest -> Maybe Double
leaseSeconds :: Maybe Double
  -- ^ Lease length in seconds. See 'defaultLeaseSeconds' and 'leaseSecondsRange'.
  }
  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, (forall x. ClaimRequest -> Rep ClaimRequest x)
-> (forall x. Rep ClaimRequest x -> ClaimRequest)
-> Generic ClaimRequest
forall x. Rep ClaimRequest x -> ClaimRequest
forall x. ClaimRequest -> Rep ClaimRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ClaimRequest -> Rep ClaimRequest x
from :: forall x. ClaimRequest -> Rep ClaimRequest x
$cto :: forall x. Rep ClaimRequest x -> ClaimRequest
to :: forall x. Rep ClaimRequest x -> ClaimRequest
Generic, 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)
  deriving (Maybe ClaimRequest
Value -> Parser [ClaimRequest]
Value -> Parser ClaimRequest
(Value -> Parser ClaimRequest)
-> (Value -> Parser [ClaimRequest])
-> Maybe ClaimRequest
-> FromJSON ClaimRequest
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ClaimRequest
parseJSON :: Value -> Parser ClaimRequest
$cparseJSONList :: Value -> Parser [ClaimRequest]
parseJSONList :: Value -> Parser [ClaimRequest]
$comittedField :: Maybe ClaimRequest
omittedField :: Maybe ClaimRequest
FromJSON, [ClaimRequest] -> Value
[ClaimRequest] -> Encoding
ClaimRequest -> Bool
ClaimRequest -> Value
ClaimRequest -> Encoding
(ClaimRequest -> Value)
-> (ClaimRequest -> Encoding)
-> ([ClaimRequest] -> Value)
-> ([ClaimRequest] -> Encoding)
-> (ClaimRequest -> Bool)
-> ToJSON ClaimRequest
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ClaimRequest -> Value
toJSON :: ClaimRequest -> Value
$ctoEncoding :: ClaimRequest -> Encoding
toEncoding :: ClaimRequest -> Encoding
$ctoJSONList :: [ClaimRequest] -> Value
toJSONList :: [ClaimRequest] -> Value
$ctoEncodingList :: [ClaimRequest] -> Encoding
toEncodingList :: [ClaimRequest] -> Encoding
$comitField :: ClaimRequest -> Bool
omitField :: ClaimRequest -> Bool
ToJSON) via Generically ClaimRequest

-- | Jobs returned by one claim. Each job contains the lease fields required for
-- finalization.
newtype ClaimResponse payload = ClaimResponse
  { forall payload. ClaimResponse payload -> [JobRead payload]
jobs :: [JobRead 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, (forall x. ClaimResponse payload -> Rep (ClaimResponse payload) x)
-> (forall x.
    Rep (ClaimResponse payload) x -> ClaimResponse payload)
-> Generic (ClaimResponse payload)
forall x. Rep (ClaimResponse payload) x -> ClaimResponse payload
forall x. ClaimResponse payload -> Rep (ClaimResponse payload) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall payload x.
Rep (ClaimResponse payload) x -> ClaimResponse payload
forall payload x.
ClaimResponse payload -> Rep (ClaimResponse payload) x
$cfrom :: forall payload x.
ClaimResponse payload -> Rep (ClaimResponse payload) x
from :: forall x. ClaimResponse payload -> Rep (ClaimResponse payload) x
$cto :: forall payload x.
Rep (ClaimResponse payload) x -> ClaimResponse payload
to :: forall x. Rep (ClaimResponse payload) x -> ClaimResponse payload
Generic, 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)
  deriving (Maybe (ClaimResponse payload)
Value -> Parser [ClaimResponse payload]
Value -> Parser (ClaimResponse payload)
(Value -> Parser (ClaimResponse payload))
-> (Value -> Parser [ClaimResponse payload])
-> Maybe (ClaimResponse payload)
-> FromJSON (ClaimResponse payload)
forall payload. FromJSON payload => Maybe (ClaimResponse payload)
forall payload.
FromJSON payload =>
Value -> Parser [ClaimResponse payload]
forall payload.
FromJSON payload =>
Value -> Parser (ClaimResponse payload)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: forall payload.
FromJSON payload =>
Value -> Parser (ClaimResponse payload)
parseJSON :: Value -> Parser (ClaimResponse payload)
$cparseJSONList :: forall payload.
FromJSON payload =>
Value -> Parser [ClaimResponse payload]
parseJSONList :: Value -> Parser [ClaimResponse payload]
$comittedField :: forall payload. FromJSON payload => Maybe (ClaimResponse payload)
omittedField :: Maybe (ClaimResponse payload)
FromJSON, [ClaimResponse payload] -> Value
[ClaimResponse payload] -> Encoding
ClaimResponse payload -> Bool
ClaimResponse payload -> Value
ClaimResponse payload -> Encoding
(ClaimResponse payload -> Value)
-> (ClaimResponse payload -> Encoding)
-> ([ClaimResponse payload] -> Value)
-> ([ClaimResponse payload] -> Encoding)
-> (ClaimResponse payload -> Bool)
-> ToJSON (ClaimResponse payload)
forall payload. ToJSON payload => [ClaimResponse payload] -> Value
forall payload.
ToJSON payload =>
[ClaimResponse payload] -> Encoding
forall payload. ToJSON payload => ClaimResponse payload -> Bool
forall payload. ToJSON payload => ClaimResponse payload -> Value
forall payload. ToJSON payload => ClaimResponse payload -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: forall payload. ToJSON payload => ClaimResponse payload -> Value
toJSON :: ClaimResponse payload -> Value
$ctoEncoding :: forall payload. ToJSON payload => ClaimResponse payload -> Encoding
toEncoding :: ClaimResponse payload -> Encoding
$ctoJSONList :: forall payload. ToJSON payload => [ClaimResponse payload] -> Value
toJSONList :: [ClaimResponse payload] -> Value
$ctoEncodingList :: forall payload.
ToJSON payload =>
[ClaimResponse payload] -> Encoding
toEncodingList :: [ClaimResponse payload] -> Encoding
$comitField :: forall payload. ToJSON payload => ClaimResponse payload -> Bool
omitField :: ClaimResponse payload -> Bool
ToJSON) via Generically (ClaimResponse payload)

-- | 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
  -- ^ The lease. Its fields are flattened into the object.
  , 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
  -- ^ The lease. Its fields are flattened into the object.
  , ExtendRequest -> Double
erSeconds :: Double
  -- ^ Clamped to 'leaseSecondsRange'.
  }
  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
"leaseSeconds"

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
"leaseSeconds" 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
  -- ^ Rows touched, keyed by operation name.
  , MaintenanceResponse -> [Text]
maintenanceFailed :: [Text]
  -- ^ Names of the operations that raised.
  }
  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
.!= []

-- | JSON that a request can leave out. An empty body decodes as 'Nothing'. A request
-- with no content type is read as this type and must have an empty body.
data OptionalJSON

-- | The type Servant gives a request that has no content type.
bodylessContentType :: (IsString s) => s
bodylessContentType :: forall s. IsString s => s
bodylessContentType = s
"application/octet-stream"

instance Accept OptionalJSON where
  contentTypes :: Proxy OptionalJSON -> NonEmpty MediaType
contentTypes Proxy OptionalJSON
_ = Proxy JSON -> NonEmpty MediaType
forall {k} (ctype :: k).
Accept ctype =>
Proxy ctype -> NonEmpty MediaType
contentTypes (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @JSON) NonEmpty MediaType -> NonEmpty MediaType -> NonEmpty MediaType
forall a. Semigroup a => a -> a -> a
<> MediaType -> NonEmpty MediaType
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MediaType
forall s. IsString s => s
bodylessContentType

instance (FromJSON a) => MimeUnrender OptionalJSON (Maybe a) where
  mimeUnrender :: Proxy OptionalJSON -> ByteString -> Either String (Maybe a)
mimeUnrender Proxy OptionalJSON
proxy = Proxy OptionalJSON
-> MediaType -> ByteString -> Either String (Maybe a)
forall {k} (ctype :: k) a.
MimeUnrender ctype a =>
Proxy ctype -> MediaType -> ByteString -> Either String a
mimeUnrenderWithType Proxy OptionalJSON
proxy MediaType
forall s. IsString s => s
bodylessContentType
  mimeUnrenderWithType :: Proxy OptionalJSON
-> MediaType -> ByteString -> Either String (Maybe a)
mimeUnrenderWithType Proxy OptionalJSON
_ MediaType
mediaType ByteString
body
    | (Char -> Bool) -> ByteString -> Bool
LBS8.all Char -> Bool
isSpace ByteString
body = Maybe a -> Either String (Maybe a)
forall a b. b -> Either a b
Right Maybe a
forall a. Maybe a
Nothing
    | MediaType
mediaType MediaType -> MediaType -> Bool
forall a. Eq a => a -> a -> Bool
== MediaType
forall s. IsString s => s
bodylessContentType = String -> Either String (Maybe a)
forall a b. a -> Either a b
Left String
"a request body needs a JSON content type"
    | Bool
otherwise = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> Either String a -> Either String (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String a
forall a. FromJSON a => ByteString -> Either String a
eitherDecode ByteString
body

-- | 'Nothing' renders an empty body.
instance (ToJSON a) => MimeRender OptionalJSON (Maybe a) where
  mimeRender :: Proxy OptionalJSON -> Maybe a -> ByteString
mimeRender Proxy OptionalJSON
_ = ByteString -> (a -> ByteString) -> Maybe a -> ByteString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ByteString
forall a. Monoid a => a
mempty a -> ByteString
forall a. ToJSON a => a -> ByteString
encode

-- | A replacement payload for a retry or a re-enqueue.
newtype PayloadEdit payload = PayloadEdit
  { forall payload. PayloadEdit payload -> payload
editPayload :: payload
  }
  deriving stock (PayloadEdit payload -> PayloadEdit payload -> Bool
(PayloadEdit payload -> PayloadEdit payload -> Bool)
-> (PayloadEdit payload -> PayloadEdit payload -> Bool)
-> Eq (PayloadEdit payload)
forall payload.
Eq payload =>
PayloadEdit payload -> PayloadEdit payload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall payload.
Eq payload =>
PayloadEdit payload -> PayloadEdit payload -> Bool
== :: PayloadEdit payload -> PayloadEdit payload -> Bool
$c/= :: forall payload.
Eq payload =>
PayloadEdit payload -> PayloadEdit payload -> Bool
/= :: PayloadEdit payload -> PayloadEdit payload -> Bool
Eq, Int -> PayloadEdit payload -> ShowS
[PayloadEdit payload] -> ShowS
PayloadEdit payload -> String
(Int -> PayloadEdit payload -> ShowS)
-> (PayloadEdit payload -> String)
-> ([PayloadEdit payload] -> ShowS)
-> Show (PayloadEdit payload)
forall payload. Show payload => Int -> PayloadEdit payload -> ShowS
forall payload. Show payload => [PayloadEdit payload] -> ShowS
forall payload. Show payload => PayloadEdit payload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall payload. Show payload => Int -> PayloadEdit payload -> ShowS
showsPrec :: Int -> PayloadEdit payload -> ShowS
$cshow :: forall payload. Show payload => PayloadEdit payload -> String
show :: PayloadEdit payload -> String
$cshowList :: forall payload. Show payload => [PayloadEdit payload] -> ShowS
showList :: [PayloadEdit payload] -> ShowS
Show)

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

instance (ToJSON payload) => ToJSON (PayloadEdit payload) where
  toJSON :: PayloadEdit payload -> Value
toJSON PayloadEdit payload
edit = [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
.= PayloadEdit payload -> payload
forall payload. PayloadEdit payload -> payload
editPayload PayloadEdit payload
edit]

-- | When a rescheduled job becomes visible.
newtype RescheduleRequest = RescheduleRequest
  { RescheduleRequest -> UTCTime
runAt :: UTCTime
  }
  deriving stock (RescheduleRequest -> RescheduleRequest -> Bool
(RescheduleRequest -> RescheduleRequest -> Bool)
-> (RescheduleRequest -> RescheduleRequest -> Bool)
-> Eq RescheduleRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RescheduleRequest -> RescheduleRequest -> Bool
== :: RescheduleRequest -> RescheduleRequest -> Bool
$c/= :: RescheduleRequest -> RescheduleRequest -> Bool
/= :: RescheduleRequest -> RescheduleRequest -> Bool
Eq, (forall x. RescheduleRequest -> Rep RescheduleRequest x)
-> (forall x. Rep RescheduleRequest x -> RescheduleRequest)
-> Generic RescheduleRequest
forall x. Rep RescheduleRequest x -> RescheduleRequest
forall x. RescheduleRequest -> Rep RescheduleRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RescheduleRequest -> Rep RescheduleRequest x
from :: forall x. RescheduleRequest -> Rep RescheduleRequest x
$cto :: forall x. Rep RescheduleRequest x -> RescheduleRequest
to :: forall x. Rep RescheduleRequest x -> RescheduleRequest
Generic, Int -> RescheduleRequest -> ShowS
[RescheduleRequest] -> ShowS
RescheduleRequest -> String
(Int -> RescheduleRequest -> ShowS)
-> (RescheduleRequest -> String)
-> ([RescheduleRequest] -> ShowS)
-> Show RescheduleRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RescheduleRequest -> ShowS
showsPrec :: Int -> RescheduleRequest -> ShowS
$cshow :: RescheduleRequest -> String
show :: RescheduleRequest -> String
$cshowList :: [RescheduleRequest] -> ShowS
showList :: [RescheduleRequest] -> ShowS
Show)
  deriving (Maybe RescheduleRequest
Value -> Parser [RescheduleRequest]
Value -> Parser RescheduleRequest
(Value -> Parser RescheduleRequest)
-> (Value -> Parser [RescheduleRequest])
-> Maybe RescheduleRequest
-> FromJSON RescheduleRequest
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser RescheduleRequest
parseJSON :: Value -> Parser RescheduleRequest
$cparseJSONList :: Value -> Parser [RescheduleRequest]
parseJSONList :: Value -> Parser [RescheduleRequest]
$comittedField :: Maybe RescheduleRequest
omittedField :: Maybe RescheduleRequest
FromJSON, [RescheduleRequest] -> Value
[RescheduleRequest] -> Encoding
RescheduleRequest -> Bool
RescheduleRequest -> Value
RescheduleRequest -> Encoding
(RescheduleRequest -> Value)
-> (RescheduleRequest -> Encoding)
-> ([RescheduleRequest] -> Value)
-> ([RescheduleRequest] -> Encoding)
-> (RescheduleRequest -> Bool)
-> ToJSON RescheduleRequest
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: RescheduleRequest -> Value
toJSON :: RescheduleRequest -> Value
$ctoEncoding :: RescheduleRequest -> Encoding
toEncoding :: RescheduleRequest -> Encoding
$ctoJSONList :: [RescheduleRequest] -> Value
toJSONList :: [RescheduleRequest] -> Value
$ctoEncodingList :: [RescheduleRequest] -> Encoding
toEncodingList :: [RescheduleRequest] -> Encoding
$comitField :: RescheduleRequest -> Bool
omitField :: RescheduleRequest -> Bool
ToJSON) via Generically RescheduleRequest

-- | Request body for setting a queue's DLQ retention.
newtype DLQRetentionRequest = DLQRetentionRequest
  { DLQRetentionRequest -> Maybe Double
retentionSeconds :: Maybe Double
  }
  deriving stock (DLQRetentionRequest -> DLQRetentionRequest -> Bool
(DLQRetentionRequest -> DLQRetentionRequest -> Bool)
-> (DLQRetentionRequest -> DLQRetentionRequest -> Bool)
-> Eq DLQRetentionRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DLQRetentionRequest -> DLQRetentionRequest -> Bool
== :: DLQRetentionRequest -> DLQRetentionRequest -> Bool
$c/= :: DLQRetentionRequest -> DLQRetentionRequest -> Bool
/= :: DLQRetentionRequest -> DLQRetentionRequest -> Bool
Eq, (forall x. DLQRetentionRequest -> Rep DLQRetentionRequest x)
-> (forall x. Rep DLQRetentionRequest x -> DLQRetentionRequest)
-> Generic DLQRetentionRequest
forall x. Rep DLQRetentionRequest x -> DLQRetentionRequest
forall x. DLQRetentionRequest -> Rep DLQRetentionRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DLQRetentionRequest -> Rep DLQRetentionRequest x
from :: forall x. DLQRetentionRequest -> Rep DLQRetentionRequest x
$cto :: forall x. Rep DLQRetentionRequest x -> DLQRetentionRequest
to :: forall x. Rep DLQRetentionRequest x -> DLQRetentionRequest
Generic, Int -> DLQRetentionRequest -> ShowS
[DLQRetentionRequest] -> ShowS
DLQRetentionRequest -> String
(Int -> DLQRetentionRequest -> ShowS)
-> (DLQRetentionRequest -> String)
-> ([DLQRetentionRequest] -> ShowS)
-> Show DLQRetentionRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DLQRetentionRequest -> ShowS
showsPrec :: Int -> DLQRetentionRequest -> ShowS
$cshow :: DLQRetentionRequest -> String
show :: DLQRetentionRequest -> String
$cshowList :: [DLQRetentionRequest] -> ShowS
showList :: [DLQRetentionRequest] -> ShowS
Show)
  deriving (Maybe DLQRetentionRequest
Value -> Parser [DLQRetentionRequest]
Value -> Parser DLQRetentionRequest
(Value -> Parser DLQRetentionRequest)
-> (Value -> Parser [DLQRetentionRequest])
-> Maybe DLQRetentionRequest
-> FromJSON DLQRetentionRequest
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser DLQRetentionRequest
parseJSON :: Value -> Parser DLQRetentionRequest
$cparseJSONList :: Value -> Parser [DLQRetentionRequest]
parseJSONList :: Value -> Parser [DLQRetentionRequest]
$comittedField :: Maybe DLQRetentionRequest
omittedField :: Maybe DLQRetentionRequest
FromJSON, [DLQRetentionRequest] -> Value
[DLQRetentionRequest] -> Encoding
DLQRetentionRequest -> Bool
DLQRetentionRequest -> Value
DLQRetentionRequest -> Encoding
(DLQRetentionRequest -> Value)
-> (DLQRetentionRequest -> Encoding)
-> ([DLQRetentionRequest] -> Value)
-> ([DLQRetentionRequest] -> Encoding)
-> (DLQRetentionRequest -> Bool)
-> ToJSON DLQRetentionRequest
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: DLQRetentionRequest -> Value
toJSON :: DLQRetentionRequest -> Value
$ctoEncoding :: DLQRetentionRequest -> Encoding
toEncoding :: DLQRetentionRequest -> Encoding
$ctoJSONList :: [DLQRetentionRequest] -> Value
toJSONList :: [DLQRetentionRequest] -> Value
$ctoEncodingList :: [DLQRetentionRequest] -> Encoding
toEncodingList :: [DLQRetentionRequest] -> Encoding
$comitField :: DLQRetentionRequest -> Bool
omitField :: DLQRetentionRequest -> Bool
ToJSON) via Generically DLQRetentionRequest

-- | Tokens to add to one rate-limit bucket.
newtype AddTokensRequest = AddTokensRequest
  { AddTokensRequest -> Double
addedTokens :: Double
  }
  deriving stock (AddTokensRequest -> AddTokensRequest -> Bool
(AddTokensRequest -> AddTokensRequest -> Bool)
-> (AddTokensRequest -> AddTokensRequest -> Bool)
-> Eq AddTokensRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddTokensRequest -> AddTokensRequest -> Bool
== :: AddTokensRequest -> AddTokensRequest -> Bool
$c/= :: AddTokensRequest -> AddTokensRequest -> Bool
/= :: AddTokensRequest -> AddTokensRequest -> Bool
Eq, Int -> AddTokensRequest -> ShowS
[AddTokensRequest] -> ShowS
AddTokensRequest -> String
(Int -> AddTokensRequest -> ShowS)
-> (AddTokensRequest -> String)
-> ([AddTokensRequest] -> ShowS)
-> Show AddTokensRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddTokensRequest -> ShowS
showsPrec :: Int -> AddTokensRequest -> ShowS
$cshow :: AddTokensRequest -> String
show :: AddTokensRequest -> String
$cshowList :: [AddTokensRequest] -> ShowS
showList :: [AddTokensRequest] -> ShowS
Show)

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

instance ToJSON AddTokensRequest where
  toJSON :: AddTokensRequest -> Value
toJSON AddTokensRequest
request = [Pair] -> Value
object [Key
"tokens" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AddTokensRequest -> Double
addedTokens AddTokensRequest
request]

-- | Jobs a token grant made claimable again.
newtype AddTokensResponse = AddTokensResponse
  { AddTokensResponse -> Int64
woken :: Int64
  }
  deriving stock (AddTokensResponse -> AddTokensResponse -> Bool
(AddTokensResponse -> AddTokensResponse -> Bool)
-> (AddTokensResponse -> AddTokensResponse -> Bool)
-> Eq AddTokensResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddTokensResponse -> AddTokensResponse -> Bool
== :: AddTokensResponse -> AddTokensResponse -> Bool
$c/= :: AddTokensResponse -> AddTokensResponse -> Bool
/= :: AddTokensResponse -> AddTokensResponse -> Bool
Eq, (forall x. AddTokensResponse -> Rep AddTokensResponse x)
-> (forall x. Rep AddTokensResponse x -> AddTokensResponse)
-> Generic AddTokensResponse
forall x. Rep AddTokensResponse x -> AddTokensResponse
forall x. AddTokensResponse -> Rep AddTokensResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddTokensResponse -> Rep AddTokensResponse x
from :: forall x. AddTokensResponse -> Rep AddTokensResponse x
$cto :: forall x. Rep AddTokensResponse x -> AddTokensResponse
to :: forall x. Rep AddTokensResponse x -> AddTokensResponse
Generic, Int -> AddTokensResponse -> ShowS
[AddTokensResponse] -> ShowS
AddTokensResponse -> String
(Int -> AddTokensResponse -> ShowS)
-> (AddTokensResponse -> String)
-> ([AddTokensResponse] -> ShowS)
-> Show AddTokensResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddTokensResponse -> ShowS
showsPrec :: Int -> AddTokensResponse -> ShowS
$cshow :: AddTokensResponse -> String
show :: AddTokensResponse -> String
$cshowList :: [AddTokensResponse] -> ShowS
showList :: [AddTokensResponse] -> ShowS
Show)
  deriving (Maybe AddTokensResponse
Value -> Parser [AddTokensResponse]
Value -> Parser AddTokensResponse
(Value -> Parser AddTokensResponse)
-> (Value -> Parser [AddTokensResponse])
-> Maybe AddTokensResponse
-> FromJSON AddTokensResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser AddTokensResponse
parseJSON :: Value -> Parser AddTokensResponse
$cparseJSONList :: Value -> Parser [AddTokensResponse]
parseJSONList :: Value -> Parser [AddTokensResponse]
$comittedField :: Maybe AddTokensResponse
omittedField :: Maybe AddTokensResponse
FromJSON, [AddTokensResponse] -> Value
[AddTokensResponse] -> Encoding
AddTokensResponse -> Bool
AddTokensResponse -> Value
AddTokensResponse -> Encoding
(AddTokensResponse -> Value)
-> (AddTokensResponse -> Encoding)
-> ([AddTokensResponse] -> Value)
-> ([AddTokensResponse] -> Encoding)
-> (AddTokensResponse -> Bool)
-> ToJSON AddTokensResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: AddTokensResponse -> Value
toJSON :: AddTokensResponse -> Value
$ctoEncoding :: AddTokensResponse -> Encoding
toEncoding :: AddTokensResponse -> Encoding
$ctoJSONList :: [AddTokensResponse] -> Value
toJSONList :: [AddTokensResponse] -> Value
$ctoEncodingList :: [AddTokensResponse] -> Encoding
toEncodingList :: [AddTokensResponse] -> Encoding
$comitField :: AddTokensResponse -> Bool
omitField :: AddTokensResponse -> Bool
ToJSON) via Generically AddTokensResponse

-- | Rows a prune deleted.
newtype PruneResponse = PruneResponse
  { PruneResponse -> Int64
pruned :: Int64
  }
  deriving stock (PruneResponse -> PruneResponse -> Bool
(PruneResponse -> PruneResponse -> Bool)
-> (PruneResponse -> PruneResponse -> Bool) -> Eq PruneResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PruneResponse -> PruneResponse -> Bool
== :: PruneResponse -> PruneResponse -> Bool
$c/= :: PruneResponse -> PruneResponse -> Bool
/= :: PruneResponse -> PruneResponse -> Bool
Eq, (forall x. PruneResponse -> Rep PruneResponse x)
-> (forall x. Rep PruneResponse x -> PruneResponse)
-> Generic PruneResponse
forall x. Rep PruneResponse x -> PruneResponse
forall x. PruneResponse -> Rep PruneResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PruneResponse -> Rep PruneResponse x
from :: forall x. PruneResponse -> Rep PruneResponse x
$cto :: forall x. Rep PruneResponse x -> PruneResponse
to :: forall x. Rep PruneResponse x -> PruneResponse
Generic, Int -> PruneResponse -> ShowS
[PruneResponse] -> ShowS
PruneResponse -> String
(Int -> PruneResponse -> ShowS)
-> (PruneResponse -> String)
-> ([PruneResponse] -> ShowS)
-> Show PruneResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PruneResponse -> ShowS
showsPrec :: Int -> PruneResponse -> ShowS
$cshow :: PruneResponse -> String
show :: PruneResponse -> String
$cshowList :: [PruneResponse] -> ShowS
showList :: [PruneResponse] -> ShowS
Show)
  deriving (Maybe PruneResponse
Value -> Parser [PruneResponse]
Value -> Parser PruneResponse
(Value -> Parser PruneResponse)
-> (Value -> Parser [PruneResponse])
-> Maybe PruneResponse
-> FromJSON PruneResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser PruneResponse
parseJSON :: Value -> Parser PruneResponse
$cparseJSONList :: Value -> Parser [PruneResponse]
parseJSONList :: Value -> Parser [PruneResponse]
$comittedField :: Maybe PruneResponse
omittedField :: Maybe PruneResponse
FromJSON, [PruneResponse] -> Value
[PruneResponse] -> Encoding
PruneResponse -> Bool
PruneResponse -> Value
PruneResponse -> Encoding
(PruneResponse -> Value)
-> (PruneResponse -> Encoding)
-> ([PruneResponse] -> Value)
-> ([PruneResponse] -> Encoding)
-> (PruneResponse -> Bool)
-> ToJSON PruneResponse
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: PruneResponse -> Value
toJSON :: PruneResponse -> Value
$ctoEncoding :: PruneResponse -> Encoding
toEncoding :: PruneResponse -> Encoding
$ctoJSONList :: [PruneResponse] -> Value
toJSONList :: [PruneResponse] -> Value
$ctoEncodingList :: [PruneResponse] -> Encoding
toEncodingList :: [PruneResponse] -> Encoding
$comitField :: PruneResponse -> Bool
omitField :: PruneResponse -> Bool
ToJSON) via Generically PruneResponse

-- | A page of a queue's open groups.
type GroupsResponse = Page GroupSummary

-- | A page of DLQ jobs.
type DLQResponse payload = Page (DLQ.DLQJob (Stored payload))

-- | Queue statistics response.
data StatsResponse = StatsResponse
  { StatsResponse -> QueueStats
stats :: QueueStats
  , StatsResponse -> UTCTime
timestamp :: UTCTime
  -- ^ When the stats were read.
  }
  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 (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) via Generically StatsResponse

-- | Every queue's stats, for the landing overview.
newtype 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 (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) via Generically AllStatsResponse

-- | Queues list response.
newtype QueuesResponse = QueuesResponse
  { QueuesResponse -> [Text]
queues :: [Text]
  -- ^ Registry queue names.
  }
  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 (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) via Generically QueuesResponse

-- | Request body for batch job insert.
newtype BatchInsertRequest payload = BatchInsertRequest
  { forall payload. BatchInsertRequest payload -> [ApiJobWrite payload]
jobs :: [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 (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) via Generically (BatchInsertRequest payload)

-- | Response body for batch job insert.
data BatchInsertResponse payload = BatchInsertResponse
  { forall payload. BatchInsertResponse payload -> [JobRead payload]
inserted :: [JobRead 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 (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) via Generically (BatchInsertResponse payload)

-- | Request body for a batch DLQ or archive delete.
newtype 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 (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) via Generically BatchDeleteRequest

-- | Response body for a batch DLQ or archive delete.
newtype 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 (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) via Generically BatchDeleteResponse

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

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

-- | A cron schedule row plus the next tick its effective expression fires at.
-- A disabled schedule, an expression that never fires again, or one the server
-- cannot parse has none.
data CronScheduleView = CronScheduleView
  { CronScheduleView -> CronScheduleRow
schedule :: CronScheduleRow
  -- ^ The row. Its fields are flattened into the object.
  , 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.
newtype CronSchedulesResponse = CronSchedulesResponse
  { CronSchedulesResponse -> [CronScheduleView]
schedules :: [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 (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) via Generically CronSchedulesResponse

-- | Worker registry response.
newtype 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 (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) via Generically WorkersResponse

-- | Rate-limit policies response.
newtype 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 (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) via Generically RateLimitPoliciesResponse

-- | Rate-limit buckets response (one prefix's keys).
type RateLimitBucketsResponse = Items RateLimitBucketView

-- | Number of buckets a reset refilled to full.
newtype 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 (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) via Generically RateLimitResetResponse

-- | Concurrency policies response.
newtype 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 (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) via Generically ConcurrencyPoliciesResponse

-- | Concurrency keys response (one prefix's keys).
type ConcurrencyKeysResponse = Items ConcurrencyKeyView

-- | Number of count rows repaired from live jobs.
newtype 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 (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) via Generically ConcurrencyReconcileResponse

-- | Whether the API can reach its database.
data HealthStatus
  = -- | The database answered.
    Ok
  | -- | The database did not answer.
    Down
  deriving stock (HealthStatus
HealthStatus -> HealthStatus -> Bounded HealthStatus
forall a. a -> a -> Bounded a
$cminBound :: HealthStatus
minBound :: HealthStatus
$cmaxBound :: HealthStatus
maxBound :: HealthStatus
Bounded, Int -> HealthStatus
HealthStatus -> Int
HealthStatus -> [HealthStatus]
HealthStatus -> HealthStatus
HealthStatus -> HealthStatus -> [HealthStatus]
HealthStatus -> HealthStatus -> HealthStatus -> [HealthStatus]
(HealthStatus -> HealthStatus)
-> (HealthStatus -> HealthStatus)
-> (Int -> HealthStatus)
-> (HealthStatus -> Int)
-> (HealthStatus -> [HealthStatus])
-> (HealthStatus -> HealthStatus -> [HealthStatus])
-> (HealthStatus -> HealthStatus -> [HealthStatus])
-> (HealthStatus -> HealthStatus -> HealthStatus -> [HealthStatus])
-> Enum HealthStatus
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: HealthStatus -> HealthStatus
succ :: HealthStatus -> HealthStatus
$cpred :: HealthStatus -> HealthStatus
pred :: HealthStatus -> HealthStatus
$ctoEnum :: Int -> HealthStatus
toEnum :: Int -> HealthStatus
$cfromEnum :: HealthStatus -> Int
fromEnum :: HealthStatus -> Int
$cenumFrom :: HealthStatus -> [HealthStatus]
enumFrom :: HealthStatus -> [HealthStatus]
$cenumFromThen :: HealthStatus -> HealthStatus -> [HealthStatus]
enumFromThen :: HealthStatus -> HealthStatus -> [HealthStatus]
$cenumFromTo :: HealthStatus -> HealthStatus -> [HealthStatus]
enumFromTo :: HealthStatus -> HealthStatus -> [HealthStatus]
$cenumFromThenTo :: HealthStatus -> HealthStatus -> HealthStatus -> [HealthStatus]
enumFromThenTo :: HealthStatus -> HealthStatus -> HealthStatus -> [HealthStatus]
Enum, 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 -> Parser HealthStatus)
-> (HealthStatus -> Parser HealthStatus)
-> Either Text HealthStatus
-> Parser HealthStatus
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (String -> Parser HealthStatus
forall a. HasCallStack => String -> Parser a
forall (m :: * -> *) a.
(MonadFail m, HasCallStack) =>
String -> m a
fail (String -> Parser HealthStatus)
-> (Text -> String) -> Text -> Parser HealthStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
unpack) HealthStatus -> Parser HealthStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either Text HealthStatus -> Parser HealthStatus)
-> (Text -> Either Text HealthStatus)
-> Text
-> Parser HealthStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (HealthStatus -> Text) -> Text -> Either Text HealthStatus
forall a.
(Bounded a, Enum a) =>
Text -> (a -> Text) -> Text -> Either Text a
enumFromText Text
"health status" HealthStatus -> Text
healthStatusToText

-- | The JSON text of a status: @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
  -- ^ The schema the API serves.
  , HealthResponse -> UTCTime
checkedAt :: UTCTime
  -- ^ When the probe finished.
  , HealthResponse -> Maybe Double
dbLatencyMs :: Maybe Double
  -- ^ Null when the database could not be reached.
  , HealthResponse -> Maybe PgDbHealth
db :: Maybe PgDbHealth
  -- ^ Connection and age counters. Null when the database is unreachable or reports no row.
  }
  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 (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) via Generically HealthResponse

-- | The process is running. Answered without touching the database.
newtype 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 (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) via Generically LivenessResponse