This repository was archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 631
/
Copy pathAPI.hs
622 lines (512 loc) · 21.6 KB
/
API.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Pos.Node.API where
import Universum
import Control.Lens (At, Index, IxValue, at, ix, makePrisms, (?~))
import Data.Aeson
import qualified Data.Aeson.Options as Aeson
import Data.Aeson.TH as A
import Data.Aeson.Types (Value (..), toJSONKeyText)
import qualified Data.ByteArray as ByteArray
import qualified Data.Char as C
import qualified Data.Map.Strict as Map
import Data.Swagger hiding (Example, example)
import qualified Data.Swagger as S
import Data.Swagger.Declare (Declare, look)
import Data.Swagger.Internal.Schema (GToSchema)
import Data.Swagger.Internal.TypeShape (GenericHasSimpleShape,
GenericShape)
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Version (Version, parseVersion, showVersion)
import Formatting (bprint, build, shown, (%))
import qualified Formatting.Buildable
import GHC.Generics (Generic, Rep)
import qualified Network.Transport as NT
import Node (NodeId (..))
import qualified Prelude
import Servant
import Test.QuickCheck
import Text.ParserCombinators.ReadP (readP_to_S)
import qualified Pos.Chain.Update as Core
import qualified Pos.Core as Core
import Pos.Infra.Diffusion.Subscription.Status
(SubscriptionStatus (..))
import Pos.Infra.Util.LogSafe (BuildableSafeGen (..), SecureLog (..),
deriveSafeBuildable)
import Pos.Util.Example
import Pos.Util.Servant (APIResponse, CustomQueryFlag, Flaggable (..),
HasCustomQueryFlagDescription (..), Tags, ValidJSON)
import Pos.Util.UnitsOfMeasure
import Serokell.Util.Text
-- ToJSON/FromJSON instances for NodeId
import Pos.Infra.Communication.Types.Protocol ()
-- TODO: Stuff that was pulled upstream. Likely to be factored out into other modules.
type IsPropertiesMap m =
(IxValue m ~ Referenced Schema, Index m ~ Text, At m, HasProperties Schema m)
genericSchemaDroppingPrefix
:: forall a m proxy.
( Generic a, ToJSON a, Example a, GToSchema (Rep a), IsPropertiesMap m
, GenericHasSimpleShape
a
"genericDeclareNamedSchemaUnrestricted"
(GenericShape (Rep a))
)
=> String -- ^ Prefix to drop on each constructor tag
-> ((Index m -> Text -> m -> m) -> m -> m) -- ^ Callback update to attach descriptions to underlying properties
-> proxy a -- ^ Underlying data-type proxy
-> Declare (Definitions Schema) NamedSchema
genericSchemaDroppingPrefix prfx extraDoc proxy = do
let opts = defaultSchemaOptions
{ S.fieldLabelModifier = over (ix 0) C.toLower . drop (length prfx) }
s <- genericDeclareNamedSchema opts proxy
defs <- look
pure $ s
& over schema (over properties (extraDoc (addFieldDescription defs)))
& schema . S.example ?~ toJSON (genExample :: a)
where
addFieldDescription defs field desc =
over (at field) (addDescription defs field desc)
addDescription defs field desc ms =
let
rewrap s = Just (Inline (s & description ?~ desc))
err = error ("Unknown field in schema: " <> field <> " " <> desc)
in
case ms of
Just (Inline s) -> rewrap s
Just (Ref ref) -> maybe err rewrap (defs ^. at (getReference ref))
_ -> err
data ForceNtpCheck
= ForceNtpCheck
| NoNtpCheck
deriving (Eq)
instance Flaggable ForceNtpCheck where
toBool ForceNtpCheck = True
toBool NoNtpCheck = False
fromBool True = ForceNtpCheck
fromBool False = NoNtpCheck
deriveSafeBuildable ''ForceNtpCheck
instance BuildableSafeGen ForceNtpCheck where
buildSafeGen _ ForceNtpCheck = "force ntp check"
buildSafeGen _ NoNtpCheck = "no ntp check"
forceNtpCheckDescription :: T.Text
forceNtpCheckDescription =
"In some cases, API Clients need to force a new NTP check as a previous result gets cached. A typical use-case is after asking a user to fix its system clock. If this flag is set, request will block until NTP server responds or it will timout if NTP server is not available within **30** seconds."
-- | The different between the local time and the remote NTP server.
newtype LocalTimeDifference = LocalTimeDifference (MeasuredIn 'Microseconds Integer)
deriving (Show, Eq)
mkLocalTimeDifference :: Integer -> LocalTimeDifference
mkLocalTimeDifference = LocalTimeDifference . MeasuredIn
instance Arbitrary LocalTimeDifference where
arbitrary = mkLocalTimeDifference <$> arbitrary
instance ToJSON LocalTimeDifference where
toJSON (LocalTimeDifference (MeasuredIn w)) =
object [ "quantity" .= toJSON w
, "unit" .= String "microseconds"
]
instance FromJSON LocalTimeDifference where
parseJSON = withObject "LocalTimeDifference" $ \sl -> mkLocalTimeDifference <$> sl .: "quantity"
instance ToSchema LocalTimeDifference where
declareNamedSchema _ =
pure $ NamedSchema (Just "LocalTimeDifference") $ mempty
& type_ .~ SwaggerObject
& required .~ ["quantity"]
& properties .~ (mempty
& at "quantity" ?~ (Inline $ mempty
& type_ .~ SwaggerNumber
)
& at "unit" ?~ (Inline $ mempty
& type_ .~ SwaggerString
& enum_ ?~ ["microseconds"]
)
)
deriveSafeBuildable ''LocalTimeDifference
instance BuildableSafeGen LocalTimeDifference where
buildSafeGen _ (LocalTimeDifference (MeasuredIn w)) =
bprint (build%"μs") w
newtype TimeInfo
= TimeInfo
{ timeDifferenceFromNtpServer :: Maybe LocalTimeDifference
} deriving (Eq, Show, Generic)
instance ToSchema TimeInfo where
declareNamedSchema = genericSchemaDroppingPrefix "time" $ \(--^) p -> p &
"differenceFromNtpServer"
--^ ("The difference in microseconds between the node time and the NTP "
<> "server. This value will be null if the NTP server is "
<> "unavailable.")
instance Arbitrary TimeInfo where
arbitrary = TimeInfo <$> arbitrary
instance Example TimeInfo
deriveSafeBuildable ''TimeInfo
instance BuildableSafeGen TimeInfo where
buildSafeGen _ TimeInfo{..} = bprint ("{"
%" differenceFromNtpServer="%build
%" }")
timeDifferenceFromNtpServer
deriveJSON Aeson.defaultOptions ''TimeInfo
newtype SyncPercentage = SyncPercentage (MeasuredIn 'Percentage100 Word8)
deriving (Show, Eq)
mkSyncPercentage :: Word8 -> SyncPercentage
mkSyncPercentage = SyncPercentage . MeasuredIn
instance Ord SyncPercentage where
compare (SyncPercentage (MeasuredIn p1))
(SyncPercentage (MeasuredIn p2)) = compare p1 p2
instance Arbitrary SyncPercentage where
arbitrary = mkSyncPercentage <$> choose (0, 100)
instance Example SyncPercentage where
example = pure (SyncPercentage (MeasuredIn 14))
instance ToJSON SyncPercentage where
toJSON (SyncPercentage (MeasuredIn w)) =
object [ "quantity" .= toJSON w
, "unit" .= String "percent"
]
instance FromJSON SyncPercentage where
parseJSON = withObject "SyncPercentage" $ \sl -> mkSyncPercentage <$> sl .: "quantity"
instance ToSchema SyncPercentage where
declareNamedSchema _ =
pure $ NamedSchema (Just "SyncPercentage") $ mempty
& type_ .~ SwaggerObject
& required .~ ["quantity", "unit"]
& properties .~ (mempty
& at "quantity" ?~ (Inline $ mempty
& type_ .~ SwaggerNumber
& maximum_ .~ Just 100
& minimum_ .~ Just 0
)
& at "unit" ?~ (Inline $ mempty
& type_ .~ SwaggerString
& enum_ ?~ ["percent"]
)
)
deriveSafeBuildable ''SyncPercentage
instance BuildableSafeGen SyncPercentage where
buildSafeGen _ (SyncPercentage (MeasuredIn w)) =
bprint (build%"%") w
-- | The absolute or relative height of the blockchain, measured in number
-- of blocks.
newtype BlockchainHeight = BlockchainHeight (MeasuredIn 'Blocks Core.BlockCount)
deriving (Show, Eq)
mkBlockchainHeight :: Core.BlockCount -> BlockchainHeight
mkBlockchainHeight = BlockchainHeight . MeasuredIn
instance Arbitrary BlockchainHeight where
arbitrary =
mkBlockchainHeight . Core.BlockCount <$> choose (minBound, maxBound)
instance Example BlockchainHeight
instance ToJSON BlockchainHeight where
toJSON (BlockchainHeight (MeasuredIn w)) =
object
[ "quantity" .= toJSON (Core.getBlockCount w)
, "unit" .= String "blocks"
]
instance FromJSON BlockchainHeight where
parseJSON = withObject "BlockchainHeight" $ \sl ->
mkBlockchainHeight . Core.BlockCount <$> sl .: "quantity"
instance ToSchema BlockchainHeight where
declareNamedSchema _ =
pure $ NamedSchema (Just "BlockchainHeight") $ mempty
& type_ .~ SwaggerObject
& required .~ ["quantity"]
& properties .~ (mempty
& at "quantity" ?~ (Inline $ mempty
& type_ .~ SwaggerNumber
& maximum_ .~ Just (fromIntegral (maxBound :: Word64))
& minimum_ .~ Just (fromIntegral (minBound :: Word64))
)
& at "unit" ?~ (Inline $ mempty
& type_ .~ SwaggerString
& enum_ ?~ ["blocks"]
)
)
deriveSafeBuildable ''BlockchainHeight
instance BuildableSafeGen BlockchainHeight where
buildSafeGen _ (BlockchainHeight (MeasuredIn w)) =
bprint (build%" blocks") w
-- | The @dynamic@ information for this node.
data NodeInfo = NodeInfo {
nfoSyncProgress :: !SyncPercentage
, nfoBlockchainHeight :: !(Maybe BlockchainHeight)
, nfoLocalBlockchainHeight :: !BlockchainHeight
, nfoLocalTimeInformation :: !TimeInfo
, nfoSubscriptionStatus :: Map NodeId SubscriptionStatus
} deriving (Show, Eq, Generic)
deriveJSON Aeson.defaultOptions ''NodeInfo
instance ToSchema NodeInfo where
declareNamedSchema =
genericSchemaDroppingPrefix "nfo" (\(--^) props -> props
& ("syncProgress"
--^ "Syncing progression, in percentage.")
& ("blockchainHeight"
--^ "If known, the current blockchain height, in number of blocks.")
& ("localBlockchainHeight"
--^ "Local blockchain height, in number of blocks.")
& ("localTimeInformation"
--^ "Information about the clock on this node.")
& ("subscriptionStatus"
--^ "Is the node connected to the network?")
)
instance Arbitrary NodeInfo where
arbitrary =
NodeInfo
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
deriveSafeBuildable ''NodeInfo
instance BuildableSafeGen NodeInfo where
buildSafeGen _ NodeInfo{..} = bprint ("{"
%" syncProgress="%build
%" blockchainHeight="%build
%" localBlockchainHeight="%build
%" localTimeDifference="%build
%" subscriptionStatus="%listJson
%" }")
nfoSyncProgress
nfoBlockchainHeight
nfoLocalBlockchainHeight
nfoLocalTimeInformation
(Map.toList nfoSubscriptionStatus)
instance Example NodeInfo where
example = NodeInfo <$> example
<*> example -- NOTE: will produce `Just a`
<*> example
<*> example
<*> example
-- | The sync progress with the blockchain.
availableSubscriptionStatus :: [SubscriptionStatus]
availableSubscriptionStatus = [Subscribed, Subscribing]
deriveSafeBuildable ''SubscriptionStatus
instance BuildableSafeGen SubscriptionStatus where
buildSafeGen _ = \case
Subscribed -> "Subscribed"
Subscribing -> "Subscribing"
deriveJSON Aeson.defaultOptions ''SubscriptionStatus
instance Arbitrary SubscriptionStatus where
arbitrary =
elements availableSubscriptionStatus
instance Example SubscriptionStatus
instance ToSchema SubscriptionStatus where
declareNamedSchema _ = do
let enum = toJSON <$> availableSubscriptionStatus
pure $ NamedSchema (Just "SubscriptionStatus") $ mempty
& type_ .~ SwaggerString
& enum_ ?~ enum
instance Arbitrary NodeId where
arbitrary = do
ipv4 <- genIPv4
port_ <- genPort
idx <- genIdx
return . toNodeId $ ipv4 <> ":" <> port_ <> ":" <> idx
where
toNodeId = NodeId . NT.EndPointAddress . T.encodeUtf8
showT = T.pack . show :: Int -> Text
genIdx = showT <$> choose (0, 9)
genPort = showT <$> choose (1000, 8000)
genIPv4 = T.intercalate "." <$> replicateM 4 (showT <$> choose (0, 255))
instance Example NodeId
instance FromJSONKey NodeId where
fromJSONKey =
FromJSONKeyText (NodeId . NT.EndPointAddress . encodeUtf8)
instance ToJSONKey NodeId where
toJSONKey =
toJSONKeyText (decodeUtf8 . getAddress)
where
getAddress (NodeId (NT.EndPointAddress x)) = x
instance ToSchema NodeId where
declareNamedSchema _ = pure $ NamedSchema (Just "NodeId") $ mempty
& type_ .~ SwaggerString
instance (Buildable a, Buildable b) => Buildable (a, b) where
build (a, b) = bprint ("("%build%", "%build%")") a b
-- Types for the NodeSettings API. TODO: Extract to own module.
-- | How many milliseconds a slot lasts for.
newtype SlotDuration = SlotDuration (MeasuredIn 'Milliseconds Word)
deriving (Show, Eq)
mkSlotDuration :: Word -> SlotDuration
mkSlotDuration = SlotDuration . MeasuredIn
instance Arbitrary SlotDuration where
arbitrary = mkSlotDuration <$> choose (0, 100)
instance ToJSON SlotDuration where
toJSON (SlotDuration (MeasuredIn w)) =
object
[ "quantity" .= toJSON w
, "unit" .= String "milliseconds"
]
instance FromJSON SlotDuration where
parseJSON = withObject "SlotDuration" $ \sl ->
mkSlotDuration <$> sl .: "quantity"
instance ToSchema SlotDuration where
declareNamedSchema _ =
pure $ NamedSchema (Just "SlotDuration") $ mempty
& type_ .~ SwaggerObject
& required .~ ["quantity"]
& properties .~ (mempty
& at "quantity" ?~ (Inline $ mempty
& type_ .~ SwaggerNumber
)
& at "unit" ?~ (Inline $ mempty
& type_ .~ SwaggerString
& enum_ ?~ ["milliseconds"]
)
)
deriveSafeBuildable ''SlotDuration
instance BuildableSafeGen SlotDuration where
buildSafeGen _ (SlotDuration (MeasuredIn w)) =
bprint (build%"ms") w
-- | This deceptively-simple newtype is a wrapper to virtually @all@ the types exposed as
-- part of this API. The reason is twofold:
--
-- 1. We want to version our API, and we want the types to reflect that, without us having
-- to manually write newtype wrappers for all the types.
--
-- 2. Shelter an API from serialisation changes. Across versions of an API types can change,
-- so can they JSON instances. But chances are we might want to reuse most of those for different
-- versions of an API. Think about 'Address' or 'Coin'. Those are core Cardano types we want to
-- probably use for the time being. But their serialisation format can change as it's not defined
-- as part of the API, but in the lower layers of the stack.
--
-- General rules for serialisation:
--
-- 1. Never define an instance on the inner type 'a'. Do it only on 'V1 a'.
newtype V1 a = V1 a deriving (Eq, Ord)
-- | Unwrap the 'V1' newtype to give the underlying type.
unV1 :: V1 a -> a
unV1 (V1 a) = a
makePrisms ''V1
instance Buildable (SecureLog a) => Buildable (SecureLog (V1 a)) where
build (SecureLog (V1 x)) = bprint build (SecureLog x)
--
-- Benign instances
--
instance ByteArray.ByteArrayAccess a => ByteArray.ByteArrayAccess (V1 a) where
length (V1 a) = ByteArray.length a
withByteArray (V1 a) = ByteArray.withByteArray a
instance Enum a => Enum (V1 a) where
toEnum x = V1 (toEnum x)
fromEnum (V1 a) = fromEnum a
instance Bounded a => Bounded (V1 a) where
minBound = V1 $ minBound @a
maxBound = V1 $ maxBound @a
instance Show a => Show (V1 a) where
show (V1 a) = Prelude.show a
instance ToJSON (V1 Core.ApplicationName) where
toJSON (V1 svAppName) = toJSON (Core.getApplicationName svAppName)
instance FromJSON (V1 Core.ApplicationName) where
parseJSON = withText "ApplicationName" $ \svAppName ->
pure (V1 (Core.ApplicationName svAppName))
instance ToJSON (V1 Core.SoftwareVersion) where
toJSON (V1 Core.SoftwareVersion{..}) =
object [ "applicationName" .= toJSON (V1 svAppName)
-- svNumber is just a type alias to Word32
-- so that's fine.
, "version" .= toJSON svNumber
]
instance FromJSON (V1 Core.SoftwareVersion) where
parseJSON = withObject "V1SoftwareVersion" $ \o -> do
V1 svAppName <- o .: "applicationName"
svNumber <- o .: "version"
pure $ V1 Core.SoftwareVersion{..}
instance ToSchema (V1 Core.SoftwareVersion) where
declareNamedSchema _ =
pure $ NamedSchema (Just "V1SoftwareVersion") $ mempty
& type_ .~ SwaggerObject
& properties .~ (mempty
& at "applicationName" ?~ Inline (toSchema (Proxy @Text))
& at "version" ?~ Inline (toSchema (Proxy @Word32))
)
& required .~ ["applicationName", "version"]
instance Arbitrary (V1 Core.SoftwareVersion) where
arbitrary = fmap V1 arbitrary
instance Buildable Version where
build v = bprint shown v
instance ToJSON (V1 Version) where
toJSON (V1 v) = toJSON (showVersion v)
instance FromJSON (V1 Version) where
parseJSON = withText "V1Version" $ \v ->
case readP_to_S parseVersion (T.unpack v) of
(reverse -> ((ver,_):_)) -> pure (V1 ver)
_ -> mempty
instance Arbitrary (V1 Version) where
arbitrary = fmap V1 arbitrary
instance {-# OVERLAPPABLE #-} Buildable a => Buildable (V1 a) where
build (V1 x) = bprint build x
#if !(MIN_VERSION_swagger2(2,2,2))
-- See note [Version Orphan]
instance ToSchema Version where
declareNamedSchema _ =
pure $ NamedSchema (Just "Version") $ mempty
& type_ .~ SwaggerString
-- Note [Version Orphan]
-- I have opened a PR to add an instance of 'Version' to the swagger2
-- library. When the PR is merged, we can delete the instance here and remove the warning from the file.
-- PR: https://github.com/GetShopTV/swagger2/pull/152
#endif
instance ToSchema (V1 Version) where
declareNamedSchema _ =
pure $ NamedSchema (Just "V1Version") $ mempty
& type_ .~ SwaggerString
-- | The @static@ settings for this wallet node. In particular, we could group
-- here protocol-related settings like the slot duration, the transaction max size,
-- the current software version running on the node, etc.
data NodeSettings = NodeSettings
{ setSlotDuration :: !SlotDuration
, setSoftwareInfo :: !(V1 Core.SoftwareVersion)
, setProjectVersion :: !(V1 Version)
, setGitRevision :: !Text
} deriving (Show, Eq, Generic)
deriveJSON Aeson.defaultOptions ''NodeSettings
instance ToSchema NodeSettings where
declareNamedSchema =
genericSchemaDroppingPrefix "set" (\(--^) props -> props
& ("slotDuration" --^ "Duration of a slot.")
& ("softwareInfo" --^ "Various pieces of information about the current software.")
& ("projectVersion" --^ "Current project's version.")
& ("gitRevision" --^ "Git revision of this deployment.")
)
instance Arbitrary NodeSettings where
arbitrary = NodeSettings <$> arbitrary
<*> arbitrary
<*> arbitrary
<*> pure "0e1c9322a"
instance Example NodeSettings
deriveSafeBuildable ''NodeSettings
instance BuildableSafeGen NodeSettings where
buildSafeGen _ NodeSettings{..} = bprint ("{"
%" slotDuration="%build
%" softwareInfo="%build
%" projectRevision="%build
%" gitRevision="%build
%" }")
setSlotDuration
setSoftwareInfo
setProjectVersion
setGitRevision
type SettingsAPI =
Tags '["Settings"]
:> "node-settings"
:> Summary "Retrieves the static settings for this node."
:> Get '[ValidJSON] (APIResponse NodeSettings)
type InfoAPI =
Tags '["Info"]
:> "node-info"
:> Summary "Retrieves the dynamic information for this node."
:> CustomQueryFlag "force_ntp_check" ForceNtpCheck
:> Get '[ValidJSON] (APIResponse NodeInfo)
instance HasCustomQueryFlagDescription "force_ntp_check" where
customDescription _ = Just forceNtpCheckDescription
-- The API definition is down here for now due to TH staging restrictions. Will
-- relocate other stuff into it's own module when the extraction is complete.
type API =
SettingsAPI
:<|>
InfoAPI
:<|>
Summary "Version of the next update (404 if none)"
:> "next-update"
:> Get '[ValidJSON] (APIResponse (V1 Core.SoftwareVersion))
:<|>
Summary "Restart the underlying node software."
:> "restart-node"
:> Post '[ValidJSON] NoContent