Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Config = Config {}
- data HttpstanBackend m = HttpstanBackend {
- v1HealthGet :: m NoContent
- v1ModelsGet :: m V1ModelsGet200Response
- v1ModelsModelIdDelete :: Text -> m NoContent
- v1ModelsModelIdFitsFitIdDelete :: Text -> Text -> m NoContent
- v1ModelsModelIdFitsFitIdGet :: Text -> Text -> m NoContent
- v1ModelsModelIdFitsPost :: Text -> CreateFitRequest -> m Fit
- v1ModelsModelIdLogProbGradPost :: Text -> Bool -> m V1ModelsModelIdLogProbGradPost200Response
- v1ModelsModelIdLogProbPost :: Text -> Bool -> m V1ModelsModelIdLogProbPost200Response
- v1ModelsModelIdParamsPost :: Text -> Value -> m V1ModelsModelIdParamsPost200Response
- v1ModelsModelIdTransformInitsPost :: Text -> Value -> m V1ModelsModelIdTransformInitsPost200Response
- v1ModelsModelIdWriteArrayPost :: Text -> Bool -> m V1ModelsModelIdWriteArrayPost200Response
- v1ModelsPost :: CreateModelRequest -> m Model
- v1OperationsOperationIdGet :: Text -> m Operation
- createHttpstanClient :: HttpstanBackend HttpstanClient
- runHttpstanServer :: (MonadIO m, MonadThrow m) => Config -> HttpstanBackend (ExceptT ServerError IO) -> m ()
- runHttpstanMiddlewareServer :: (MonadIO m, MonadThrow m) => Config -> Middleware -> HttpstanBackend (ExceptT ServerError IO) -> m ()
- runHttpstanClient :: Config -> HttpstanClient a -> ExceptT ClientError IO a
- runHttpstanClientWithManager :: Manager -> Config -> HttpstanClient a -> ExceptT ClientError IO a
- callHttpstan :: (MonadIO m, MonadThrow m) => ClientEnv -> HttpstanClient a -> m a
- data HttpstanClient a
- newtype HttpstanClientError = HttpstanClientError ClientError
- type HttpstanAPI = ("v1" :> ("health" :> Verb 'GET 200 '[JSON] NoContent)) :<|> (("v1" :> ("models" :> Verb 'GET 200 '[JSON] V1ModelsGet200Response)) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> Verb 'DELETE 200 '[JSON] NoContent))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("fits" :> (Capture "fit_id" Text :> Verb 'DELETE 200 '[JSON] NoContent))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("fits" :> (Capture "fit_id" Text :> Verb 'GET 200 '[JSON] NoContent))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("fits" :> (ReqBody '[JSON] CreateFitRequest :> Verb 'POST 201 '[JSON] Fit))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("log_prob_grad" :> (ReqBody '[JSON] Bool :> Verb 'POST 200 '[JSON] V1ModelsModelIdLogProbGradPost200Response))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("log_prob" :> (ReqBody '[JSON] Bool :> Verb 'POST 200 '[JSON] V1ModelsModelIdLogProbPost200Response))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("params" :> (ReqBody '[JSON] Value :> Verb 'POST 200 '[JSON] V1ModelsModelIdParamsPost200Response))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("transform_inits" :> (ReqBody '[JSON] Value :> Verb 'POST 200 '[JSON] V1ModelsModelIdTransformInitsPost200Response))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("write_array" :> (ReqBody '[JSON] Bool :> Verb 'POST 200 '[JSON] V1ModelsModelIdWriteArrayPost200Response))))) :<|> (("v1" :> ("models" :> (ReqBody '[JSON] CreateModelRequest :> Verb 'POST 201 '[JSON] Model))) :<|> (("v1" :> ("operations" :> (Capture "operation_id" Text :> Verb 'GET 200 '[JSON] Operation))) :<|> Raw))))))))))))
- serverWaiApplicationHttpstan :: HttpstanBackend (ExceptT ServerError IO) -> Application
Client and Server
Server or client configuration, specifying the host and port to query or serve on.
Config | |
|
data HttpstanBackend m Source #
Configuration, specifying the full url of the service.
Backend for Httpstan.
The backend can be used both for the client and the server. The client generated from the Httpstan OpenAPI spec
is a backend that executes actions by sending HTTP requests (see createHttpstanClient
). Alternatively, provided
a backend, the API can be served using runHttpstanMiddlewareServer
.
HttpstanBackend | |
|
runHttpstanServer :: (MonadIO m, MonadThrow m) => Config -> HttpstanBackend (ExceptT ServerError IO) -> m () Source #
Run the Httpstan server at the provided host and port.
runHttpstanMiddlewareServer :: (MonadIO m, MonadThrow m) => Config -> Middleware -> HttpstanBackend (ExceptT ServerError IO) -> m () Source #
Run the Httpstan server at the provided host and port.
runHttpstanClient :: Config -> HttpstanClient a -> ExceptT ClientError IO a Source #
Run requests in the HttpstanClient monad.
runHttpstanClientWithManager :: Manager -> Config -> HttpstanClient a -> ExceptT ClientError IO a Source #
Run requests in the HttpstanClient monad using a custom manager.
callHttpstan :: (MonadIO m, MonadThrow m) => ClientEnv -> HttpstanClient a -> m a Source #
Like runClient
, but returns the response or throws
a HttpstanClientError
data HttpstanClient a Source #
Instances
MonadIO HttpstanClient Source # | |
Defined in Httpstan.API liftIO :: IO a -> HttpstanClient a # | |
Applicative HttpstanClient Source # | |
Defined in Httpstan.API pure :: a -> HttpstanClient a # (<*>) :: HttpstanClient (a -> b) -> HttpstanClient a -> HttpstanClient b # liftA2 :: (a -> b -> c) -> HttpstanClient a -> HttpstanClient b -> HttpstanClient c # (*>) :: HttpstanClient a -> HttpstanClient b -> HttpstanClient b # (<*) :: HttpstanClient a -> HttpstanClient b -> HttpstanClient a # | |
Functor HttpstanClient Source # | |
Defined in Httpstan.API fmap :: (a -> b) -> HttpstanClient a -> HttpstanClient b # (<$) :: a -> HttpstanClient b -> HttpstanClient a # | |
Monad HttpstanClient Source # | |
Defined in Httpstan.API (>>=) :: HttpstanClient a -> (a -> HttpstanClient b) -> HttpstanClient b # (>>) :: HttpstanClient a -> HttpstanClient b -> HttpstanClient b # return :: a -> HttpstanClient a # |
newtype HttpstanClientError Source #
Custom exception type for our errors.
Instances
Exception HttpstanClientError Source # | |
Defined in Httpstan.API | |
Show HttpstanClientError Source # | |
Defined in Httpstan.API showsPrec :: Int -> HttpstanClientError -> ShowS # show :: HttpstanClientError -> String # showList :: [HttpstanClientError] -> ShowS # |
Servant
type HttpstanAPI = ("v1" :> ("health" :> Verb 'GET 200 '[JSON] NoContent)) :<|> (("v1" :> ("models" :> Verb 'GET 200 '[JSON] V1ModelsGet200Response)) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> Verb 'DELETE 200 '[JSON] NoContent))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("fits" :> (Capture "fit_id" Text :> Verb 'DELETE 200 '[JSON] NoContent))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("fits" :> (Capture "fit_id" Text :> Verb 'GET 200 '[JSON] NoContent))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("fits" :> (ReqBody '[JSON] CreateFitRequest :> Verb 'POST 201 '[JSON] Fit))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("log_prob_grad" :> (ReqBody '[JSON] Bool :> Verb 'POST 200 '[JSON] V1ModelsModelIdLogProbGradPost200Response))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("log_prob" :> (ReqBody '[JSON] Bool :> Verb 'POST 200 '[JSON] V1ModelsModelIdLogProbPost200Response))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("params" :> (ReqBody '[JSON] Value :> Verb 'POST 200 '[JSON] V1ModelsModelIdParamsPost200Response))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("transform_inits" :> (ReqBody '[JSON] Value :> Verb 'POST 200 '[JSON] V1ModelsModelIdTransformInitsPost200Response))))) :<|> (("v1" :> ("models" :> (Capture "model_id" Text :> ("write_array" :> (ReqBody '[JSON] Bool :> Verb 'POST 200 '[JSON] V1ModelsModelIdWriteArrayPost200Response))))) :<|> (("v1" :> ("models" :> (ReqBody '[JSON] CreateModelRequest :> Verb 'POST 201 '[JSON] Model))) :<|> (("v1" :> ("operations" :> (Capture "operation_id" Text :> Verb 'GET 200 '[JSON] Operation))) :<|> Raw)))))))))))) Source #
Servant type-level API, generated from the OpenAPI spec for Httpstan.
Plain WAI Application
serverWaiApplicationHttpstan :: HttpstanBackend (ExceptT ServerError IO) -> Application Source #
Plain Network.Wai Application for the Httpstan server.
Can be used to implement e.g. tests that call the API without a full webserver.