aboutsummaryrefslogtreecommitdiff
path: root/lib/API.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/API.hs')
-rw-r--r--lib/API.hs23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/API.hs b/lib/API.hs
index 416f71e..12d5ba6 100644
--- a/lib/API.hs
+++ b/lib/API.hs
@@ -54,7 +54,7 @@ import Servant.API.ContentTypes (Accept (..))
-- | a bare ping as sent by a tracker device
data SentPing = SentPing
- { sentPingToken :: TrackerId
+ { sentPingTrackerId :: TrackerId
, sentPingGeopos :: Geopos
, sentPingTimestamp :: UTCTime
} deriving (Generic)
@@ -66,24 +66,25 @@ instance FromJSON SentPing where
type API =
-- ingress API (put this behind BasicAuth?)
-- TODO: perhaps require a first ping for registration?
- "tracker" :> "register" :> ReqBody '[JSON] RegisterJson :> Post '[JSON] Token
+ "tracker" :> "register" :> ReqBody '[JSON] RegisterJson :> Post '[JSON] TrackerId
:<|> "tracker" :> "ping" :> ReqBody '[JSON] SentPing :> Post '[JSON] (Maybe TrainAnchor)
:<|> "tracker" :> "ping" :> "ws" :> WebSocket
:<|> "ticker" :> "current" :> Get '[JSON] Value
:<|> "ticket" :> "subscribe" :> Capture "Ticket Id" UUID :> WebSocket
- :<|> "debug" :> "pings" :> Get '[JSON] (Map Token [TrainPing])
- :<|> "debug" :> "pings" :> Capture "Ticket Id" UUID :> Get '[JSON] [TrainPing]
+ :<|> "debug" :> "pings" :> Get '[JSON] (Map UUID [Ping])
+ :<|> "debug" :> "pings" :> Capture "Ticket Id" UUID :> Get '[JSON] [Ping]
:<|> "gtfs.zip" :> Get '[OctetStream] GTFSFile
:<|> "gtfs" :> GtfsRealtimeAPI
-type GtfsRealtimeAPI = "servicealerts" :> Get '[Proto] FeedMessage
- :<|> "tripupdates" :> Get '[Proto] FeedMessage
- :<|> "vehiclepositions" :> Get '[Proto] FeedMessage
+type GtfsRealtimeAPI = "servicealerts" :> QueryFlag "force" :> Get '[Proto] FeedMessage
+ :<|> "tripupdates" :> QueryFlag "force" :> Get '[Proto] FeedMessage
+ :<|> "vehiclepositions" :> QueryFlag "force" :> Get '[Proto] FeedMessage
+
type CompleteAPI =
- "api" :> "openapi" :> Get '[JSON] Swagger
- :<|> "api" :> API
+ {- "api" :> "openapi" :> Get '[JSON] Swagger
+ :<|> -} "api" :> "v1" :> API
:<|> "metrics" :> Get '[PlainText] Text
:<|> "assets" :> Raw
:<|> Raw -- hook for yesod frontend
@@ -107,7 +108,7 @@ instance ToSchema Value where
declareNamedSchema _ = pure $ NamedSchema (Just "json") $ mempty
& type_ ?~ SwaggerObject
instance ToSchema SentPing where
- declareNamedSchema = genericDeclareNamedSchema (GTFS.swaggerOptions "trainPing")
+ declareNamedSchema = genericDeclareNamedSchema (GTFS.swaggerOptions "ping")
@@ -117,7 +118,7 @@ instance HasSwagger WebSocket where
{ _swaggerPaths = singleton "/" $ mempty
{ _pathItemGet = Just $ mempty
{ _operationSummary = Just "this is a websocket endpoint!"
- , _operationDescription = Just "this is a websocket endpoint meant for continious operations, e.g. sending many trainPings one after the other. Unfortunately OpenAPI 2.0 is not suitable to thoroughly model it (hence this text)."
+ , _operationDescription = Just "this is a websocket endpoint meant for continious operations, e.g. sending many pings one after the other. Unfortunately OpenAPI 2.0 is not suitable to thoroughly model it (hence this text)."
, _operationSchemes = Just [ Wss ]
, _operationConsumes = Just $ MimeList [ "application/json" ]
, _operationProduces = Just $ MimeList [ "application/json" ]