{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans -Wno-unused-imports #-}
module Arbiter.Servant.OpenApi
(
openApiSpec
, OpenApiAPI
, openApiServer
) where
import Arbiter.Core.Concurrency.Spec (ConcurrencyKey (ConcurrencyKey))
import Arbiter.Core.Concurrency.Stats
( ConcurrencyKeyView
, ConcurrencyPolicyUpdate
, ConcurrencyPolicyView
)
import Arbiter.Core.CronSchedule (CronScheduleRow, CronScheduleUpdate)
import Arbiter.Core.Health (PgDbHealth, PgTableHealth)
import Arbiter.Core.Job.Archive qualified as Archive
import Arbiter.Core.Job.DLQ qualified as DLQ
import Arbiter.Core.Job.Dedup (DedupKey (IgnoreDuplicate))
import Arbiter.Core.Job.TraceContext (toTraceContext)
import Arbiter.Core.Job.Types
( JobRead
, JobStatus
, PayloadKeys (PayloadKeys)
, defaultJob
, jobStatusToText
, setArchiveFor
, setDedupKey
, setGroupKey
, setMaxAttempts
, setNotVisibleUntil
, setPriority
)
import Arbiter.Core.Job.Types.Internal (JobRecord (Job))
import Arbiter.Core.Operations (QueueOverview, QueueStats)
import Arbiter.Core.Queues (QueueRow)
import Arbiter.Core.RateLimit.Spec (RateLimitKey (RateLimitKey))
import Arbiter.Core.RateLimit.Stats
( RateLimitBucketView
, RateLimitPolicyUpdate
, RateLimitPolicyView
)
import Arbiter.Core.Sql.Jobs
( ArchiveSortColumn
, DLQSortColumn
, JobSortColumn
, SortDir
, archiveSortColumnName
, dlqSortColumnName
, jobSortColumnName
, sortDirSql
)
import Arbiter.Core.Worker (WorkerHealth, WorkerRow)
import Arbiter.Servant.API (ArbiterAPI)
import Arbiter.Servant.Types
import Control.Applicative (liftA2)
import Data.Aeson (ToJSON (..), Value)
import Data.HashMap.Strict.InsOrd qualified as InsOrd
import Data.HashSet.InsOrd qualified as InsOrdSet
import Data.Int (Int32, Int64)
import Data.Map.Strict (Map)
import Data.Maybe (fromMaybe, isJust)
import Data.OpenApi
( Definitions
, Info (..)
, MediaTypeObject
, NamedSchema (..)
, OpenApi (..)
, OpenApiType (..)
, Operation (..)
, PathItem (..)
, Referenced (Inline)
, Response (..)
, Responses (..)
, Schema (..)
, Tag (..)
, TagName
, ToParamSchema (..)
, ToSchema (..)
, declareSchemaRef
, defaultSchemaOptions
, genericDeclareNamedSchema
)
import Data.OpenApi qualified as OpenApi
import Data.OpenApi.Declare (Declare)
import Data.OpenApi.Internal.Schema (GToSchema)
import Data.Proxy (Proxy (..))
import Data.Text (Text)
import Data.Text qualified as T
import Data.Time (UTCTime)
import Data.Typeable (Typeable)
import Data.UUID.Types (UUID)
import GHC.Generics (Generic, Rep)
import Servant (Get, JSON, Server, (:>))
import Servant.OpenApi (HasOpenApi, toOpenApi)
type OpenApiAPI = "openapi.json" :> Get '[JSON] Value
openApiServer :: forall registry. (HasOpenApi (ArbiterAPI registry)) => Server OpenApiAPI
openApiServer :: forall (registry :: JobPayloadRegistry).
HasOpenApi (ArbiterAPI registry) =>
Server OpenApiAPI
openApiServer = Value -> Handler Value
forall a. a -> Handler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall (registry :: JobPayloadRegistry).
HasOpenApi (ArbiterAPI registry) =>
Value
openApiSpec @registry)
openApiSpec :: forall registry. (HasOpenApi (ArbiterAPI registry)) => Value
openApiSpec :: forall (registry :: JobPayloadRegistry).
HasOpenApi (ArbiterAPI registry) =>
Value
openApiSpec = OpenApi -> Value
forall a. ToJSON a => a -> Value
toJSON (OpenApi -> OpenApi
sectioned OpenApi
described)
where
described :: OpenApi
described =
(Proxy (ArbiterAPI registry) -> OpenApi
forall {k} (api :: k). HasOpenApi api => Proxy api -> OpenApi
toOpenApi (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @(ArbiterAPI registry)))
{ _openApiInfo =
mempty
{ _infoTitle = "Arbiter"
, _infoVersion = "v1"
, _infoDescription = Just apiDescription
}
}
sectioned :: OpenApi -> OpenApi
sectioned :: OpenApi -> OpenApi
sectioned OpenApi
spec =
OpenApi
spec
{ _openApiPaths = InsOrd.mapWithKey (\String
path -> Text -> PathItem -> PathItem
tagPath (String -> Text
section String
path) (PathItem -> PathItem)
-> (PathItem -> PathItem) -> PathItem -> PathItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathItem -> PathItem
describeRaw) (_openApiPaths spec)
, _openApiTags = InsOrdSet.fromList (map describeSection sections)
}
where
sections :: [Text]
sections = (String -> Text) -> [String] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map String -> Text
section (InsOrdHashMap String PathItem -> [String]
forall k v. InsOrdHashMap k v -> [k]
InsOrd.keys (OpenApi -> InsOrdHashMap String PathItem
_openApiPaths OpenApi
spec))
section :: FilePath -> TagName
section :: String -> Text
section String
path =
case HttpStatusCode -> [Text] -> [Text]
forall a. HttpStatusCode -> [a] -> [a]
drop ([Text] -> HttpStatusCode
forall a. [a] -> HttpStatusCode
forall (t :: * -> *) a. Foldable t => t a -> HttpStatusCode
length [Text]
mountSegments) ((Text -> Bool) -> [Text] -> [Text]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (Text -> Bool) -> Text -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Bool
T.null) (HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
T.splitOn Text
"/" (String -> Text
T.pack String
path))) of
Text
name : [Text]
_ -> Text
name
[] -> Text
"api"
mountSegments :: [Text]
mountSegments :: [Text]
mountSegments = [Text
"api", Text
"v1"]
describeRaw :: PathItem -> PathItem
describeRaw :: PathItem -> PathItem
describeRaw PathItem
item
| ((PathItem -> Bool) -> Bool) -> [PathItem -> Bool] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((PathItem -> Bool) -> PathItem -> Bool
forall a b. (a -> b) -> a -> b
$ PathItem
item) [PathItem -> Bool]
operationFields = PathItem
item
| Bool
otherwise = PathItem
item {_pathItemGet = Just streamOperation}
where
operationFields :: [PathItem -> Bool]
operationFields =
((PathItem -> Maybe Operation) -> PathItem -> Bool)
-> [PathItem -> Maybe Operation] -> [PathItem -> Bool]
forall a b. (a -> b) -> [a] -> [b]
map
(Maybe Operation -> Bool
forall a. Maybe a -> Bool
isJust (Maybe Operation -> Bool)
-> (PathItem -> Maybe Operation) -> PathItem -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
.)
[ PathItem -> Maybe Operation
_pathItemGet
, PathItem -> Maybe Operation
_pathItemPut
, PathItem -> Maybe Operation
_pathItemPost
, PathItem -> Maybe Operation
_pathItemDelete
, PathItem -> Maybe Operation
_pathItemOptions
, PathItem -> Maybe Operation
_pathItemHead
, PathItem -> Maybe Operation
_pathItemPatch
, PathItem -> Maybe Operation
_pathItemTrace
]
streamOperation :: Operation
streamOperation :: Operation
streamOperation =
Operation
forall a. Monoid a => a
mempty
{ _operationSummary = Just "Server-sent stream of job events"
, _operationDescription =
Just
"Streams an event per insert, update, delete and dead-letter, as they happen. \
\Sends a keepalive comment every 15 seconds. A server with streaming switched \
\off answers one \"disabled\" event and closes."
, _operationResponses =
mempty
{ _responsesResponses =
InsOrd.singleton
200
( Inline
mempty
{ _responseDescription = "An event stream."
, _responseContent = InsOrd.singleton "text/event-stream" mempty
}
)
}
}
tagPath :: TagName -> PathItem -> PathItem
tagPath :: Text -> PathItem -> PathItem
tagPath Text
name PathItem
item =
PathItem
item
{ _pathItemGet = tagged (_pathItemGet item)
, _pathItemPut = tagged (_pathItemPut item)
, _pathItemPost = tagged (_pathItemPost item)
, _pathItemDelete = tagged (_pathItemDelete item)
, _pathItemOptions = tagged (_pathItemOptions item)
, _pathItemHead = tagged (_pathItemHead item)
, _pathItemPatch = tagged (_pathItemPatch item)
, _pathItemTrace = tagged (_pathItemTrace item)
}
where
tagged :: Maybe Operation -> Maybe Operation
tagged = (Operation -> Operation) -> Maybe Operation -> Maybe Operation
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Operation
operation -> Operation
operation {_operationTags = InsOrdSet.insert name (_operationTags operation)})
describeSection :: TagName -> Tag
describeSection :: Text -> Tag
describeSection Text
name =
Tag
{ _tagName :: Text
_tagName = Text
name
, _tagDescription :: Maybe Text
_tagDescription = Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe (Text -> Text
forall {a}. (Semigroup a, IsString a) => a -> a
queueDescription Text
name) (Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
name [(Text, Text)]
sectionDescriptions))
, _tagExternalDocs :: Maybe ExternalDocs
_tagExternalDocs = Maybe ExternalDocs
forall a. Maybe a
Nothing
}
where
queueDescription :: a -> a
queueDescription a
queueName = a
"Jobs, dead letters, archive and stats for the " a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
queueName a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
" queue."
sectionDescriptions :: [(TagName, Text)]
sectionDescriptions :: [(Text, Text)]
sectionDescriptions =
[ (Text
"queues", Text
"The registered queues, their counters, and pausing them.")
, (Text
"cron", Text
"Cron schedules, their overrides, and out-of-band runs.")
, (Text
"workers", Text
"The worker registry, and pausing a pool.")
, (Text
"rate-limits", Text
"Token-bucket policies, their live buckets, and overrides.")
, (Text
"concurrency", Text
"Concurrency pools, their live keys, and overrides.")
, (Text
"maintenance", Text
"The sweep a worker pool's reaper runs, on demand.")
, (Text
"events", Text
"A server-sent stream of job events.")
, (Text
"health", Text
"Liveness and readiness.")
]
apiDescription :: Text
apiDescription :: Text
apiDescription =
Text
"The Arbiter job queue over HTTP. Each registered queue has its own section, and a \
\service in any language can use all three sides of it: enqueue jobs, run them by \
\claiming a lease and acking, nacking or extending it, and operate the queue itself. \
\The schema-wide sections cover queues, cron, workers, rate limits, concurrency, \
\maintenance and health.\n\nThe document is derived from the server's own route \
\types. Every payload and result below is the queue's real schema. The server ships \
\no authentication. Put it behind your own."
newtype Fields a = Fields (Declare (Definitions Schema) [(Text, Referenced Schema)])
instance Functor Fields where
fmap :: forall a b. (a -> b) -> Fields a -> Fields b
fmap a -> b
_ (Fields Declare (Definitions Schema) [(Text, Referenced Schema)]
declared) = Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields b
forall {k} (a :: k).
Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields a
Fields Declare (Definitions Schema) [(Text, Referenced Schema)]
declared
instance Applicative Fields where
pure :: forall a. a -> Fields a
pure a
_ = Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields a
forall {k} (a :: k).
Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields a
Fields ([(Text, Referenced Schema)]
-> Declare (Definitions Schema) [(Text, Referenced Schema)]
forall a. a -> DeclareT (Definitions Schema) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [])
Fields Declare (Definitions Schema) [(Text, Referenced Schema)]
left <*> :: forall a b. Fields (a -> b) -> Fields a -> Fields b
<*> Fields Declare (Definitions Schema) [(Text, Referenced Schema)]
right = Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields b
forall {k} (a :: k).
Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields a
Fields (([(Text, Referenced Schema)]
-> [(Text, Referenced Schema)] -> [(Text, Referenced Schema)])
-> Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Declare (Definitions Schema) [(Text, Referenced Schema)]
forall a b c.
(a -> b -> c)
-> DeclareT (Definitions Schema) Identity a
-> DeclareT (Definitions Schema) Identity b
-> DeclareT (Definitions Schema) Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 [(Text, Referenced Schema)]
-> [(Text, Referenced Schema)] -> [(Text, Referenced Schema)]
forall a. Semigroup a => a -> a -> a
(<>) Declare (Definitions Schema) [(Text, Referenced Schema)]
left Declare (Definitions Schema) [(Text, Referenced Schema)]
right)
prop :: forall a. (ToSchema a) => Text -> Fields a
prop :: forall a. ToSchema a => Text -> Fields a
prop Text
name = Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields a
forall {k} (a :: k).
Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields a
Fields ((Text, Referenced Schema) -> [(Text, Referenced Schema)]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Text, Referenced Schema) -> [(Text, Referenced Schema)])
-> (Referenced Schema -> (Text, Referenced Schema))
-> Referenced Schema
-> [(Text, Referenced Schema)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (,) Text
name (Referenced Schema -> [(Text, Referenced Schema)])
-> DeclareT (Definitions Schema) Identity (Referenced Schema)
-> Declare (Definitions Schema) [(Text, Referenced Schema)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Proxy a
-> DeclareT (Definitions Schema) Identity (Referenced Schema)
forall a.
ToSchema a =>
Proxy a
-> DeclareT (Definitions Schema) Identity (Referenced Schema)
declareSchemaRef (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a))
patch :: forall a. (ToSchema a) => Text -> Fields (Maybe (Maybe a))
patch :: forall a. ToSchema a => Text -> Fields (Maybe (Maybe a))
patch Text
name = Maybe a -> Maybe (Maybe a)
forall a. a -> Maybe a
Just (Maybe a -> Maybe (Maybe a))
-> Fields (Maybe a) -> Fields (Maybe (Maybe a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @(Maybe a) Text
name
inlineProp :: forall a. Text -> Schema -> Fields a
inlineProp :: forall {k} (a :: k). Text -> Schema -> Fields a
inlineProp Text
name Schema
schema = Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields a
forall {k} (a :: k).
Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Fields a
Fields ([(Text, Referenced Schema)]
-> Declare (Definitions Schema) [(Text, Referenced Schema)]
forall a. a -> DeclareT (Definitions Schema) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [(Text
name, Schema -> Referenced Schema
forall a. a -> Referenced a
Inline Schema
schema)])
objectSchema :: Text -> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema :: forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema Text
name [Text]
required (Fields Declare (Definitions Schema) [(Text, Referenced Schema)]
declared) =
Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
name) (Schema -> NamedSchema)
-> ([(Text, Referenced Schema)] -> Schema)
-> [(Text, Referenced Schema)]
-> NamedSchema
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> [(Text, Referenced Schema)] -> Schema
schemaOver [Text]
required ([(Text, Referenced Schema)] -> NamedSchema)
-> Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Declare (Definitions Schema) [(Text, Referenced Schema)]
declared
closedSchema :: Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema :: forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
name (Fields Declare (Definitions Schema) [(Text, Referenced Schema)]
declared) = [(Text, Referenced Schema)] -> NamedSchema
named ([(Text, Referenced Schema)] -> NamedSchema)
-> Declare (Definitions Schema) [(Text, Referenced Schema)]
-> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Declare (Definitions Schema) [(Text, Referenced Schema)]
declared
where
named :: [(Text, Referenced Schema)] -> NamedSchema
named [(Text, Referenced Schema)]
props = Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
name) ([Text] -> [(Text, Referenced Schema)] -> Schema
schemaOver (((Text, Referenced Schema) -> Text)
-> [(Text, Referenced Schema)] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text, Referenced Schema) -> Text
forall a b. (a, b) -> a
fst [(Text, Referenced Schema)]
props) [(Text, Referenced Schema)]
props)
schemaOver :: [Text] -> [(Text, Referenced Schema)] -> Schema
schemaOver :: [Text] -> [(Text, Referenced Schema)] -> Schema
schemaOver [Text]
required [(Text, Referenced Schema)]
props =
Schema
forall a. Monoid a => a
mempty
{ _schemaType = Just OpenApiObject
, _schemaProperties = InsOrd.fromList props
, _schemaRequired = required
}
carrying :: forall payload. (ToSchema payload) => Text -> Text
carrying :: forall payload. ToSchema payload => Text -> Text
carrying Text
base = Text -> (Text -> Text) -> Maybe Text -> Text
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
base ((Text
base Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_") Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>) (Proxy payload -> Maybe Text
forall a. ToSchema a => Proxy a -> Maybe Text
OpenApi.schemaName (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @payload))
enumSchema :: forall a p. (Bounded a, Enum a) => (a -> Text) -> p a -> Schema
enumSchema :: forall a (p :: * -> *).
(Bounded a, Enum a) =>
(a -> Text) -> p a -> Schema
enumSchema a -> Text
name p a
_ = [Text] -> Schema
stringEnum [a -> Text
name a
value | a
value <- [a
forall a. Bounded a => a
minBound .. a
forall a. Bounded a => a
maxBound :: a]]
stringEnum :: [Text] -> Schema
stringEnum :: [Text] -> Schema
stringEnum [Text]
values =
Schema
forall a. Monoid a => a
mempty {_schemaType = Just OpenApiString, _schemaEnum = Just (map toJSON values)}
instance ToParamSchema JobStatus where
toParamSchema :: Proxy JobStatus -> Schema
toParamSchema = (JobStatus -> Text) -> Proxy JobStatus -> Schema
forall a (p :: * -> *).
(Bounded a, Enum a) =>
(a -> Text) -> p a -> Schema
enumSchema JobStatus -> Text
jobStatusToText
instance ToParamSchema JobSortColumn where
toParamSchema :: Proxy JobSortColumn -> Schema
toParamSchema = (JobSortColumn -> Text) -> Proxy JobSortColumn -> Schema
forall a (p :: * -> *).
(Bounded a, Enum a) =>
(a -> Text) -> p a -> Schema
enumSchema JobSortColumn -> Text
jobSortColumnName
instance ToParamSchema DLQSortColumn where
toParamSchema :: Proxy DLQSortColumn -> Schema
toParamSchema = (DLQSortColumn -> Text) -> Proxy DLQSortColumn -> Schema
forall a (p :: * -> *).
(Bounded a, Enum a) =>
(a -> Text) -> p a -> Schema
enumSchema DLQSortColumn -> Text
dlqSortColumnName
instance ToParamSchema ArchiveSortColumn where
toParamSchema :: Proxy ArchiveSortColumn -> Schema
toParamSchema = (ArchiveSortColumn -> Text) -> Proxy ArchiveSortColumn -> Schema
forall a (p :: * -> *).
(Bounded a, Enum a) =>
(a -> Text) -> p a -> Schema
enumSchema ArchiveSortColumn -> Text
archiveSortColumnName
instance ToParamSchema SortDir where
toParamSchema :: Proxy SortDir -> Schema
toParamSchema = (SortDir -> Text) -> Proxy SortDir -> Schema
forall a (p :: * -> *).
(Bounded a, Enum a) =>
(a -> Text) -> p a -> Schema
enumSchema SortDir -> Text
sortDirSql
instance ToSchema Value where
declareNamedSchema :: Proxy Value -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy Value
_ =
NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a. a -> DeclareT (Definitions Schema) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> (Schema -> NamedSchema)
-> Schema
-> Declare (Definitions Schema) NamedSchema
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"AnyJson") (Schema -> Declare (Definitions Schema) NamedSchema)
-> Schema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Schema
forall a. Monoid a => a
mempty
{ _schemaType = Just OpenApiObject
, _schemaDescription = Just "Caller-defined JSON."
}
instance ToSchema JobStatus where
declareNamedSchema :: Proxy JobStatus -> Declare (Definitions Schema) NamedSchema
declareNamedSchema = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a. a -> DeclareT (Definitions Schema) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> (Proxy JobStatus -> NamedSchema)
-> Proxy JobStatus
-> Declare (Definitions Schema) NamedSchema
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"JobStatus") (Schema -> NamedSchema)
-> (Proxy JobStatus -> Schema) -> Proxy JobStatus -> NamedSchema
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy JobStatus -> Schema
forall a. ToParamSchema a => Proxy a -> Schema
toParamSchema
instance ToSchema WorkerHealth where
declareNamedSchema :: Proxy WorkerHealth -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy WorkerHealth
_ =
NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a. a -> DeclareT (Definitions Schema) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"WorkerHealth") ([Text] -> Schema
stringEnum [Text
"live", Text
"stale", Text
"draining"]))
instance ToSchema HealthStatus where
declareNamedSchema :: Proxy HealthStatus -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy HealthStatus
_ = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a. a -> DeclareT (Definitions Schema) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"HealthStatus") ([Text] -> Schema
stringEnum [Text
"ok", Text
"down"]))
instance ToSchema DedupKey where
declareNamedSchema :: Proxy DedupKey -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy DedupKey
_ =
Text -> Fields DedupKey -> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
"DedupKey" (Fields DedupKey -> Declare (Definitions Schema) NamedSchema)
-> Fields DedupKey -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
(\Text
key Text
_strategy -> Text -> DedupKey
IgnoreDuplicate Text
key)
(Text -> Text -> DedupKey)
-> Fields Text -> Fields (Text -> DedupKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"key"
Fields (Text -> DedupKey) -> Fields Text -> Fields DedupKey
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Text -> Schema -> Fields a
forall {k} (a :: k). Text -> Schema -> Fields a
inlineProp @Text Text
"strategy" ([Text] -> Schema
stringEnum [Text
"ignore", Text
"replace"])
instance ToSchema RateLimitKey where
declareNamedSchema :: Proxy RateLimitKey -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy RateLimitKey
_ = (Text -> Text -> RateLimitKey)
-> Text -> Declare (Definitions Schema) NamedSchema
forall a.
(Text -> Text -> a)
-> Text -> Declare (Definitions Schema) NamedSchema
admissionKeySchema Text -> Text -> RateLimitKey
RateLimitKey Text
"RateLimitKey"
instance ToSchema ConcurrencyKey where
declareNamedSchema :: Proxy ConcurrencyKey -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy ConcurrencyKey
_ = (Text -> Text -> ConcurrencyKey)
-> Text -> Declare (Definitions Schema) NamedSchema
forall a.
(Text -> Text -> a)
-> Text -> Declare (Definitions Schema) NamedSchema
admissionKeySchema Text -> Text -> ConcurrencyKey
ConcurrencyKey Text
"ConcurrencyKey"
admissionKeySchema
:: (Text -> Text -> a) -> Text -> Declare (Definitions Schema) NamedSchema
admissionKeySchema :: forall a.
(Text -> Text -> a)
-> Text -> Declare (Definitions Schema) NamedSchema
admissionKeySchema Text -> Text -> a
mkKey Text
name =
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
name (Text -> Text -> a
mkKey (Text -> Text -> a) -> Fields Text -> Fields (Text -> a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"prefix" Fields (Text -> a) -> Fields Text -> Fields a
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"suffix")
jobFields :: forall payload. (ToSchema payload) => Fields (JobRead payload)
jobFields :: forall payload. ToSchema payload => Fields (JobRead payload)
jobFields =
Int64
-> payload
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys
forall payload key q insertedAt adm.
key
-> payload
-> q
-> Maybe Text
-> insertedAt
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> adm
-> JobRecord payload key q insertedAt adm
Job
(Int64
-> payload
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields Int64
-> Fields
(payload
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Int64 Text
"primaryKey"
Fields
(payload
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields payload
-> Fields
(Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @payload Text
"payload"
Fields
(Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields Text
-> Fields
(Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"queueName"
Fields
(Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe Text)
-> Fields
(UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Text) Text
"groupKey"
Fields
(UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields UTCTime
-> Fields
(Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @UTCTime Text
"insertedAt"
Fields
(Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe UTCTime)
-> Fields
(Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe UTCTime) Text
"updatedAt"
Fields
(Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields Int32
-> Fields
(Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Int32 Text
"attempts"
Fields
(Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe Text)
-> Fields
(Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Text) Text
"lastError"
Fields
(Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields Int32
-> Fields
(Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Int32 Text
"priority"
Fields
(Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe UTCTime)
-> Fields
(Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe UTCTime) Text
"lastAttemptedAt"
Fields
(Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe UTCTime)
-> Fields
(Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe UTCTime) Text
"notVisibleUntil"
Fields
(Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe DedupKey)
-> Fields
(Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe DedupKey) Text
"dedupKey"
Fields
(Maybe Int32
-> Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe Int32)
-> Fields
(Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Int32) Text
"maxAttempts"
Fields
(Maybe Int64
-> Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe Int64)
-> Fields
(Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Int64) Text
"parentId"
Fields
(Maybe Value
-> Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe Value)
-> Fields
(Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Value) Text
"parentState"
Fields
(Maybe TraceContext
-> Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe TraceContext)
-> Fields
(Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Text -> Maybe Text -> Maybe TraceContext
toTraceContext (Maybe Text -> Maybe Text -> Maybe TraceContext)
-> Fields (Maybe Text) -> Fields (Maybe Text -> Maybe TraceContext)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Text) Text
"traceparent" Fields (Maybe Text -> Maybe TraceContext)
-> Fields (Maybe Text) -> Fields (Maybe TraceContext)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Text) Text
"tracestate")
Fields
(Bool
-> Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields Bool
-> Fields
(Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Bool Text
"suspended"
Fields
(Maybe UUID
-> Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe UUID)
-> Fields
(Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe UUID) Text
"claimedBy"
Fields
(Int64
-> Maybe Int32
-> PayloadKeys
-> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields Int64
-> Fields
(Maybe Int32
-> PayloadKeys -> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Int64 Text
"claimSeq"
Fields
(Maybe Int32
-> PayloadKeys -> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields (Maybe Int32)
-> Fields
(PayloadKeys -> JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Int32) Text
"archiveFor"
Fields
(PayloadKeys -> JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields PayloadKeys
-> Fields (JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( Maybe Text
-> Maybe RateLimitKey -> Maybe ConcurrencyKey -> PayloadKeys
PayloadKeys
(Maybe Text
-> Maybe RateLimitKey -> Maybe ConcurrencyKey -> PayloadKeys)
-> Fields (Maybe Text)
-> Fields
(Maybe RateLimitKey -> Maybe ConcurrencyKey -> PayloadKeys)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Text) Text
"kind"
Fields (Maybe RateLimitKey -> Maybe ConcurrencyKey -> PayloadKeys)
-> Fields (Maybe RateLimitKey)
-> Fields (Maybe ConcurrencyKey -> PayloadKeys)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe RateLimitKey) Text
"rateLimit"
Fields (Maybe ConcurrencyKey -> PayloadKeys)
-> Fields (Maybe ConcurrencyKey) -> Fields PayloadKeys
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe ConcurrencyKey) Text
"concurrency"
)
Fields (JobRecord payload Int64 Text UTCTime PayloadKeys)
-> Fields Bool
-> Fields (JobRecord payload Int64 Text UTCTime PayloadKeys)
forall a b. Fields a -> Fields b -> Fields a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall a. ToSchema a => Text -> Fields a
prop @Bool Text
"isRollup"
instance (ToSchema payload) => ToSchema (ApiJob payload) where
declareNamedSchema :: Proxy (ApiJob payload) -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (ApiJob payload)
_ = Text
-> [Text]
-> Fields (JobRead payload)
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"Job") [] (forall payload. ToSchema payload => Fields (JobRead payload)
jobFields @payload)
instance (ToSchema payload) => ToSchema (ApiJobWithStatus payload) where
declareNamedSchema :: Proxy (ApiJobWithStatus payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (ApiJobWithStatus payload)
_ =
Text
-> [Text]
-> Fields (JobRead payload)
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema
(forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"JobWithStatus")
[]
(forall payload. ToSchema payload => Fields (JobRead payload)
jobFields @payload Fields (JobRead payload)
-> Fields JobStatus -> Fields (JobRead payload)
forall a b. Fields a -> Fields b -> Fields a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall a. ToSchema a => Text -> Fields a
prop @JobStatus Text
"status")
instance (ToSchema payload) => ToSchema (ApiJobWrite payload) where
declareNamedSchema :: Proxy (ApiJobWrite payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (ApiJobWrite payload)
_ =
Text
-> [Text]
-> Fields (JobWrite payload)
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"JobWrite") [Text
"payload"] (Fields (JobWrite payload)
-> Declare (Definitions Schema) NamedSchema)
-> Fields (JobWrite payload)
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
( \payload
value Maybe Text
group Int32
priority Maybe UTCTime
visibleAt Maybe DedupKey
dedup Maybe Int32
attempts Maybe Int32
retention ->
Maybe Int32 -> JobWrite payload -> JobWrite payload
forall payload. Maybe Int32 -> JobWrite payload -> JobWrite payload
setArchiveFor Maybe Int32
retention
(JobWrite payload -> JobWrite payload)
-> (JobWrite payload -> JobWrite payload)
-> JobWrite payload
-> JobWrite payload
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Int32 -> JobWrite payload -> JobWrite payload
forall payload. Maybe Int32 -> JobWrite payload -> JobWrite payload
setMaxAttempts Maybe Int32
attempts
(JobWrite payload -> JobWrite payload)
-> (JobWrite payload -> JobWrite payload)
-> JobWrite payload
-> JobWrite payload
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe DedupKey -> JobWrite payload -> JobWrite payload
forall payload.
Maybe DedupKey -> JobWrite payload -> JobWrite payload
setDedupKey Maybe DedupKey
dedup
(JobWrite payload -> JobWrite payload)
-> (JobWrite payload -> JobWrite payload)
-> JobWrite payload
-> JobWrite payload
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe UTCTime -> JobWrite payload -> JobWrite payload
forall payload.
Maybe UTCTime -> JobWrite payload -> JobWrite payload
setNotVisibleUntil Maybe UTCTime
visibleAt
(JobWrite payload -> JobWrite payload)
-> (JobWrite payload -> JobWrite payload)
-> JobWrite payload
-> JobWrite payload
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int32 -> JobWrite payload -> JobWrite payload
forall payload. Int32 -> JobWrite payload -> JobWrite payload
setPriority Int32
priority
(JobWrite payload -> JobWrite payload)
-> (JobWrite payload -> JobWrite payload)
-> JobWrite payload
-> JobWrite payload
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> JobWrite payload -> JobWrite payload
forall payload. Maybe Text -> JobWrite payload -> JobWrite payload
setGroupKey Maybe Text
group
(JobWrite payload -> JobWrite payload)
-> JobWrite payload -> JobWrite payload
forall a b. (a -> b) -> a -> b
$ payload -> JobWrite payload
forall payload. payload -> JobWrite payload
defaultJob payload
value
)
(payload
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int32
-> JobWrite payload)
-> Fields payload
-> Fields
(Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int32
-> JobWrite payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @payload Text
"payload"
Fields
(Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int32
-> JobWrite payload)
-> Fields (Maybe Text)
-> Fields
(Int32
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int32
-> JobWrite payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Text) Text
"groupKey"
Fields
(Int32
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int32
-> JobWrite payload)
-> Fields Int32
-> Fields
(Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int32
-> JobWrite payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Int32 Text
"priority"
Fields
(Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int32
-> JobWrite payload)
-> Fields (Maybe UTCTime)
-> Fields
(Maybe DedupKey -> Maybe Int32 -> Maybe Int32 -> JobWrite payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe UTCTime) Text
"notVisibleUntil"
Fields
(Maybe DedupKey -> Maybe Int32 -> Maybe Int32 -> JobWrite payload)
-> Fields (Maybe DedupKey)
-> Fields (Maybe Int32 -> Maybe Int32 -> JobWrite payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe DedupKey) Text
"dedupKey"
Fields (Maybe Int32 -> Maybe Int32 -> JobWrite payload)
-> Fields (Maybe Int32) -> Fields (Maybe Int32 -> JobWrite payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Int32) Text
"maxAttempts"
Fields (Maybe Int32 -> JobWrite payload)
-> Fields (Maybe Int32) -> Fields (JobWrite payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Int32) Text
"archiveFor"
instance (ToSchema payload) => ToSchema (ApiDLQJob payload) where
declareNamedSchema :: Proxy (ApiDLQJob payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (ApiDLQJob payload)
_ =
Text
-> Fields (DLQJob payload)
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"DLQEntry") (Fields (DLQJob payload)
-> Declare (Definitions Schema) NamedSchema)
-> Fields (DLQJob payload)
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Int64 -> UTCTime -> JobSnapshot payload -> DLQJob payload
forall payload.
Int64 -> UTCTime -> JobSnapshot payload -> DLQJob payload
DLQ.DLQJob
(Int64 -> UTCTime -> JobSnapshot payload -> DLQJob payload)
-> Fields Int64
-> Fields (UTCTime -> JobSnapshot payload -> DLQJob payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Int64 Text
"dlqPrimaryKey"
Fields (UTCTime -> JobSnapshot payload -> DLQJob payload)
-> Fields UTCTime -> Fields (JobSnapshot payload -> DLQJob payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @UTCTime Text
"failedAt"
Fields (JobSnapshot payload -> DLQJob payload)
-> Fields (JobSnapshot payload) -> Fields (DLQJob payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ApiJob payload -> JobSnapshot payload
forall payload. ApiJob payload -> JobRead payload
unApiJob (ApiJob payload -> JobSnapshot payload)
-> Fields (ApiJob payload) -> Fields (JobSnapshot payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @(ApiJob payload) Text
"jobSnapshot")
instance (ToSchema payload) => ToSchema (ApiArchiveJob payload) where
declareNamedSchema :: Proxy (ApiArchiveJob payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (ApiArchiveJob payload)
_ =
Text
-> [Text]
-> Fields (ArchiveJob payload)
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema
(forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"ArchiveEntry")
[Text
"archivePrimaryKey", Text
"completedAt", Text
"jobSnapshot"]
(Fields (ArchiveJob payload)
-> Declare (Definitions Schema) NamedSchema)
-> Fields (ArchiveJob payload)
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Int64
-> UTCTime
-> JobSnapshot payload
-> Maybe Value
-> ArchiveJob payload
forall payload.
Int64
-> UTCTime
-> JobSnapshot payload
-> Maybe Value
-> ArchiveJob payload
Archive.ArchiveJob
(Int64
-> UTCTime
-> JobSnapshot payload
-> Maybe Value
-> ArchiveJob payload)
-> Fields Int64
-> Fields
(UTCTime
-> JobSnapshot payload -> Maybe Value -> ArchiveJob payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Int64 Text
"archivePrimaryKey"
Fields
(UTCTime
-> JobSnapshot payload -> Maybe Value -> ArchiveJob payload)
-> Fields UTCTime
-> Fields
(JobSnapshot payload -> Maybe Value -> ArchiveJob payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @UTCTime Text
"completedAt"
Fields (JobSnapshot payload -> Maybe Value -> ArchiveJob payload)
-> Fields (JobSnapshot payload)
-> Fields (Maybe Value -> ArchiveJob payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ApiJob payload -> JobSnapshot payload
forall payload. ApiJob payload -> JobRead payload
unApiJob (ApiJob payload -> JobSnapshot payload)
-> Fields (ApiJob payload) -> Fields (JobSnapshot payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @(ApiJob payload) Text
"jobSnapshot")
Fields (Maybe Value -> ArchiveJob payload)
-> Fields (Maybe Value) -> Fields (ArchiveJob payload)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Value) Text
"result"
instance (ToSchema payload) => ToSchema (ClaimResponse payload) where
declareNamedSchema :: Proxy (ClaimResponse payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (ClaimResponse payload)
_ =
Text
-> Fields (ClaimResponse payload)
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"ClaimResponse") (Fields (ClaimResponse payload)
-> Declare (Definitions Schema) NamedSchema)
-> Fields (ClaimResponse payload)
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
[ApiJob payload] -> ClaimResponse payload
forall payload. [ApiJob payload] -> ClaimResponse payload
ClaimResponse ([ApiJob payload] -> ClaimResponse payload)
-> Fields [ApiJob payload] -> Fields (ClaimResponse payload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @[ApiJob payload] Text
"jobs"
instance ToSchema ClaimRequest where
declareNamedSchema :: Proxy ClaimRequest -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy ClaimRequest
_ =
Text
-> [Text]
-> Fields ClaimRequest
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema Text
"ClaimRequest" [] (Fields ClaimRequest -> Declare (Definitions Schema) NamedSchema)
-> Fields ClaimRequest -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Maybe HttpStatusCode -> Maybe Double -> ClaimRequest
ClaimRequest (Maybe HttpStatusCode -> Maybe Double -> ClaimRequest)
-> Fields (Maybe HttpStatusCode)
-> Fields (Maybe Double -> ClaimRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Int) Text
"maxJobs" Fields (Maybe Double -> ClaimRequest)
-> Fields (Maybe Double) -> Fields ClaimRequest
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Double) Text
"leaseSeconds"
instance ToSchema JobLease where
declareNamedSchema :: Proxy JobLease -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy JobLease
_ = Text -> Fields JobLease -> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
"JobLease" Fields JobLease
leaseFields
instance (ToSchema result) => ToSchema (AckRequest result) where
declareNamedSchema :: Proxy (AckRequest result)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (AckRequest result)
_ =
Text
-> [Text]
-> Fields (AckRequest result)
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema
(forall payload. ToSchema payload => Text -> Text
carrying @result Text
"AckRequest")
[Text]
leaseRequired
(JobLease -> Maybe result -> AckRequest result
forall result. JobLease -> Maybe result -> AckRequest result
AckRequest (JobLease -> Maybe result -> AckRequest result)
-> Fields JobLease -> Fields (Maybe result -> AckRequest result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fields JobLease
leaseFields Fields (Maybe result -> AckRequest result)
-> Fields (Maybe result) -> Fields (AckRequest result)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe result) Text
"result")
instance ToSchema ExtendRequest where
declareNamedSchema :: Proxy ExtendRequest -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy ExtendRequest
_ =
Text
-> Fields ExtendRequest -> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
"ExtendRequest" (JobLease -> Double -> ExtendRequest
ExtendRequest (JobLease -> Double -> ExtendRequest)
-> Fields JobLease -> Fields (Double -> ExtendRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fields JobLease
leaseFields Fields (Double -> ExtendRequest)
-> Fields Double -> Fields ExtendRequest
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Double Text
"seconds")
leaseFields :: Fields JobLease
leaseFields :: Fields JobLease
leaseFields = Int64 -> UUID -> JobLease
JobLease (Int64 -> UUID -> JobLease)
-> Fields Int64 -> Fields (UUID -> JobLease)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Int64 Text
"claimSeq" Fields (UUID -> JobLease) -> Fields UUID -> Fields JobLease
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @UUID Text
"claimedBy"
leaseRequired :: [Text]
leaseRequired :: [Text]
leaseRequired = [Text
"claimSeq", Text
"claimedBy"]
instance ToSchema MaintenanceResponse where
declareNamedSchema :: Proxy MaintenanceResponse
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy MaintenanceResponse
_ =
Text
-> Fields MaintenanceResponse
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
"MaintenanceResponse" (Fields MaintenanceResponse
-> Declare (Definitions Schema) NamedSchema)
-> Fields MaintenanceResponse
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Map Text Int64 -> [Text] -> MaintenanceResponse
MaintenanceResponse (Map Text Int64 -> [Text] -> MaintenanceResponse)
-> Fields (Map Text Int64)
-> Fields ([Text] -> MaintenanceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @(Map Text Int64) Text
"ops" Fields ([Text] -> MaintenanceResponse)
-> Fields [Text] -> Fields MaintenanceResponse
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @[Text] Text
"failed"
instance ToSchema CronScheduleView where
declareNamedSchema :: Proxy CronScheduleView -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy CronScheduleView
_ = do
row <- Proxy CronScheduleRow
-> DeclareT (Definitions Schema) Identity (Referenced Schema)
forall a.
ToSchema a =>
Proxy a
-> DeclareT (Definitions Schema) Identity (Referenced Schema)
declareSchemaRef (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @CronScheduleRow)
NamedSchema _ added <- objectSchema "" [] (prop @(Maybe UTCTime) "nextRunAt")
pure . NamedSchema (Just "CronScheduleView") $
mempty
{ _schemaAllOf = Just [row, Inline added]
, _schemaDescription =
Just "A schedule row plus the next tick it fires at, absent when it is disabled."
}
instance ToSchema QueueOverview where
declareNamedSchema :: Proxy QueueOverview -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy QueueOverview
_ =
Text
-> Fields QueueOverview -> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
"QueueOverview" (Fields QueueOverview -> Declare (Definitions Schema) NamedSchema)
-> Fields QueueOverview -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Text -> QueueStats -> Bool -> Int64 -> Int64 -> QueueOverview
QueueOverview
(Text -> QueueStats -> Bool -> Int64 -> Int64 -> QueueOverview)
-> Fields Text
-> Fields (QueueStats -> Bool -> Int64 -> Int64 -> QueueOverview)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"queue"
Fields (QueueStats -> Bool -> Int64 -> Int64 -> QueueOverview)
-> Fields QueueStats
-> Fields (Bool -> Int64 -> Int64 -> QueueOverview)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @QueueStats Text
"stats"
Fields (Bool -> Int64 -> Int64 -> QueueOverview)
-> Fields Bool -> Fields (Int64 -> Int64 -> QueueOverview)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Bool Text
"paused"
Fields (Int64 -> Int64 -> QueueOverview)
-> Fields Int64 -> Fields (Int64 -> QueueOverview)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Int64 Text
"workersLive"
Fields (Int64 -> QueueOverview)
-> Fields Int64 -> Fields QueueOverview
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Int64 Text
"workersPaused"
instance ToSchema RateLimitBucketView where
declareNamedSchema :: Proxy RateLimitBucketView
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy RateLimitBucketView
_ =
Text
-> Fields RateLimitBucketView
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
"RateLimitBucketView" (Fields RateLimitBucketView
-> Declare (Definitions Schema) NamedSchema)
-> Fields RateLimitBucketView
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Text
-> Text
-> Double
-> Double
-> Maybe Double
-> UTCTime
-> RateLimitBucketView
RateLimitBucketView
(Text
-> Text
-> Double
-> Double
-> Maybe Double
-> UTCTime
-> RateLimitBucketView)
-> Fields Text
-> Fields
(Text
-> Double
-> Double
-> Maybe Double
-> UTCTime
-> RateLimitBucketView)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"key"
Fields
(Text
-> Double
-> Double
-> Maybe Double
-> UTCTime
-> RateLimitBucketView)
-> Fields Text
-> Fields
(Double
-> Double -> Maybe Double -> UTCTime -> RateLimitBucketView)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"prefix"
Fields
(Double
-> Double -> Maybe Double -> UTCTime -> RateLimitBucketView)
-> Fields Double
-> Fields
(Double -> Maybe Double -> UTCTime -> RateLimitBucketView)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Double Text
"tokens"
Fields (Double -> Maybe Double -> UTCTime -> RateLimitBucketView)
-> Fields Double
-> Fields (Maybe Double -> UTCTime -> RateLimitBucketView)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Double Text
"maxTokens"
Fields (Maybe Double -> UTCTime -> RateLimitBucketView)
-> Fields (Maybe Double) -> Fields (UTCTime -> RateLimitBucketView)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Double) Text
"fillFraction"
Fields (UTCTime -> RateLimitBucketView)
-> Fields UTCTime -> Fields RateLimitBucketView
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @UTCTime Text
"lastRefill"
instance ToSchema RateLimitPolicyUpdate where
declareNamedSchema :: Proxy RateLimitPolicyUpdate
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy RateLimitPolicyUpdate
_ =
Text
-> [Text]
-> Fields RateLimitPolicyUpdate
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema Text
"RateLimitPolicyUpdate" [] (Fields RateLimitPolicyUpdate
-> Declare (Definitions Schema) NamedSchema)
-> Fields RateLimitPolicyUpdate
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Maybe (Maybe Double)
-> Maybe (Maybe Double)
-> Maybe (Maybe Double)
-> RateLimitPolicyUpdate
RateLimitPolicyUpdate
(Maybe (Maybe Double)
-> Maybe (Maybe Double)
-> Maybe (Maybe Double)
-> RateLimitPolicyUpdate)
-> Fields (Maybe (Maybe Double))
-> Fields
(Maybe (Maybe Double)
-> Maybe (Maybe Double) -> RateLimitPolicyUpdate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields (Maybe (Maybe a))
patch @Double Text
"overrideMaxTokens"
Fields
(Maybe (Maybe Double)
-> Maybe (Maybe Double) -> RateLimitPolicyUpdate)
-> Fields (Maybe (Maybe Double))
-> Fields (Maybe (Maybe Double) -> RateLimitPolicyUpdate)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields (Maybe (Maybe a))
patch @Double Text
"overrideRefillAmount"
Fields (Maybe (Maybe Double) -> RateLimitPolicyUpdate)
-> Fields (Maybe (Maybe Double)) -> Fields RateLimitPolicyUpdate
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields (Maybe (Maybe a))
patch @Double Text
"overrideRefillIntervalSecs"
instance ToSchema ConcurrencyKeyView where
declareNamedSchema :: Proxy ConcurrencyKeyView
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy ConcurrencyKeyView
_ =
Text
-> Fields ConcurrencyKeyView
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text -> Fields a -> Declare (Definitions Schema) NamedSchema
closedSchema Text
"ConcurrencyKeyView" (Fields ConcurrencyKeyView
-> Declare (Definitions Schema) NamedSchema)
-> Fields ConcurrencyKeyView
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Text
-> Text -> Int32 -> Int32 -> Maybe Double -> ConcurrencyKeyView
ConcurrencyKeyView
(Text
-> Text -> Int32 -> Int32 -> Maybe Double -> ConcurrencyKeyView)
-> Fields Text
-> Fields
(Text -> Int32 -> Int32 -> Maybe Double -> ConcurrencyKeyView)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"key"
Fields
(Text -> Int32 -> Int32 -> Maybe Double -> ConcurrencyKeyView)
-> Fields Text
-> Fields (Int32 -> Int32 -> Maybe Double -> ConcurrencyKeyView)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Text Text
"prefix"
Fields (Int32 -> Int32 -> Maybe Double -> ConcurrencyKeyView)
-> Fields Int32
-> Fields (Int32 -> Maybe Double -> ConcurrencyKeyView)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Int32 Text
"inFlight"
Fields (Int32 -> Maybe Double -> ConcurrencyKeyView)
-> Fields Int32 -> Fields (Maybe Double -> ConcurrencyKeyView)
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @Int32 Text
"effectiveLimit"
Fields (Maybe Double -> ConcurrencyKeyView)
-> Fields (Maybe Double) -> Fields ConcurrencyKeyView
forall a b. Fields (a -> b) -> Fields a -> Fields b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. ToSchema a => Text -> Fields a
prop @(Maybe Double) Text
"fillFraction"
instance ToSchema ConcurrencyPolicyUpdate where
declareNamedSchema :: Proxy ConcurrencyPolicyUpdate
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy ConcurrencyPolicyUpdate
_ =
Text
-> [Text]
-> Fields ConcurrencyPolicyUpdate
-> Declare (Definitions Schema) NamedSchema
forall {k} (a :: k).
Text
-> [Text] -> Fields a -> Declare (Definitions Schema) NamedSchema
objectSchema Text
"ConcurrencyPolicyUpdate" [] (Fields ConcurrencyPolicyUpdate
-> Declare (Definitions Schema) NamedSchema)
-> Fields ConcurrencyPolicyUpdate
-> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
Maybe (Maybe Int32) -> ConcurrencyPolicyUpdate
ConcurrencyPolicyUpdate (Maybe (Maybe Int32) -> ConcurrencyPolicyUpdate)
-> Fields (Maybe (Maybe Int32)) -> Fields ConcurrencyPolicyUpdate
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. ToSchema a => Text -> Fields (Maybe (Maybe a))
patch @Int32 Text
"overrideLimit"
renamed
:: forall a
. (GToSchema (Rep a), Generic a, Typeable a)
=> Text
-> Proxy a
-> Declare (Definitions Schema) NamedSchema
renamed :: forall a.
(GToSchema (Rep a), Generic a, Typeable a) =>
Text -> Proxy a -> Declare (Definitions Schema) NamedSchema
renamed Text
name Proxy a
proxy = NamedSchema -> NamedSchema
rename (NamedSchema -> NamedSchema)
-> Declare (Definitions Schema) NamedSchema
-> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SchemaOptions
-> Proxy a -> Declare (Definitions Schema) NamedSchema
forall a.
(Generic a, GToSchema (Rep a), Typeable a) =>
SchemaOptions
-> Proxy a -> Declare (Definitions Schema) NamedSchema
genericDeclareNamedSchema SchemaOptions
defaultSchemaOptions Proxy a
proxy
where
rename :: NamedSchema -> NamedSchema
rename (NamedSchema Maybe Text
_ Schema
schema) = Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
name) Schema
schema
instance ToSchema QueueStats
instance ToSchema QueueRow
instance ToSchema WorkerRow
instance ToSchema CronScheduleRow
instance ToSchema CronScheduleUpdate
instance ToSchema PgDbHealth
instance ToSchema PgTableHealth
instance ToSchema RateLimitPolicyView
instance ToSchema ConcurrencyPolicyView
instance ToSchema BatchDeleteRequest
instance ToSchema BatchDeleteResponse
instance ToSchema StatsResponse
instance ToSchema AllStatsResponse
instance ToSchema QueuesResponse
instance ToSchema CronSchedulesResponse
instance ToSchema WorkersResponse
instance ToSchema RateLimitPoliciesResponse
instance ToSchema RateLimitBucketsResponse
instance ToSchema RateLimitResetResponse
instance ToSchema ConcurrencyPoliciesResponse
instance ToSchema ConcurrencyKeysResponse
instance ToSchema ConcurrencyReconcileResponse
instance ToSchema HealthResponse
instance ToSchema LivenessResponse
instance (ToSchema payload) => ToSchema (JobsResponse payload) where
declareNamedSchema :: Proxy (JobsResponse payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema = Text
-> Proxy (JobsResponse payload)
-> Declare (Definitions Schema) NamedSchema
forall a.
(GToSchema (Rep a), Generic a, Typeable a) =>
Text -> Proxy a -> Declare (Definitions Schema) NamedSchema
renamed (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"JobsResponse")
instance (ToSchema payload) => ToSchema (JobResponse (ApiJob payload)) where
declareNamedSchema :: Proxy (JobResponse (ApiJob payload))
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema = Text
-> Proxy (JobResponse (ApiJob payload))
-> Declare (Definitions Schema) NamedSchema
forall a.
(GToSchema (Rep a), Generic a, Typeable a) =>
Text -> Proxy a -> Declare (Definitions Schema) NamedSchema
renamed (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"JobResponse")
instance (ToSchema payload) => ToSchema (JobResponse (ApiJobWithStatus payload)) where
declareNamedSchema :: Proxy (JobResponse (ApiJobWithStatus payload))
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema = Text
-> Proxy (JobResponse (ApiJobWithStatus payload))
-> Declare (Definitions Schema) NamedSchema
forall a.
(GToSchema (Rep a), Generic a, Typeable a) =>
Text -> Proxy a -> Declare (Definitions Schema) NamedSchema
renamed (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"JobWithStatusResponse")
instance (ToSchema payload) => ToSchema (BatchInsertRequest payload) where
declareNamedSchema :: Proxy (BatchInsertRequest payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema = Text
-> Proxy (BatchInsertRequest payload)
-> Declare (Definitions Schema) NamedSchema
forall a.
(GToSchema (Rep a), Generic a, Typeable a) =>
Text -> Proxy a -> Declare (Definitions Schema) NamedSchema
renamed (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"BatchInsertRequest")
instance (ToSchema payload) => ToSchema (BatchInsertResponse payload) where
declareNamedSchema :: Proxy (BatchInsertResponse payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema = Text
-> Proxy (BatchInsertResponse payload)
-> Declare (Definitions Schema) NamedSchema
forall a.
(GToSchema (Rep a), Generic a, Typeable a) =>
Text -> Proxy a -> Declare (Definitions Schema) NamedSchema
renamed (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"BatchInsertResponse")
instance (ToSchema payload) => ToSchema (DLQResponse payload) where
declareNamedSchema :: Proxy (DLQResponse payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema = Text
-> Proxy (DLQResponse payload)
-> Declare (Definitions Schema) NamedSchema
forall a.
(GToSchema (Rep a), Generic a, Typeable a) =>
Text -> Proxy a -> Declare (Definitions Schema) NamedSchema
renamed (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"DLQResponse")
instance (ToSchema payload) => ToSchema (ArchiveResponse payload) where
declareNamedSchema :: Proxy (ArchiveResponse payload)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema = Text
-> Proxy (ArchiveResponse payload)
-> Declare (Definitions Schema) NamedSchema
forall a.
(GToSchema (Rep a), Generic a, Typeable a) =>
Text -> Proxy a -> Declare (Definitions Schema) NamedSchema
renamed (forall payload. ToSchema payload => Text -> Text
carrying @payload Text
"ArchiveResponse")