File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -329,6 +329,10 @@ pub struct TypedQueryResponse<T> {
329329 pub page_info : PageInfo ,
330330}
331331
332+ /// Healthcheck request for http api
333+ #[ derive( Serialize ) ]
334+ pub struct HealthcheckRequest { }
335+
332336#[ cfg( test) ]
333337mod tests {
334338 use super :: * ;
Original file line number Diff line number Diff line change @@ -66,6 +66,11 @@ impl<S: Signer> CeramicHttpClient<S> {
6666 "/api/v0/admin/modelData"
6767 }
6868
69+ /// Get the healthcheck endpoint
70+ pub fn healthcheck_endpoint ( & self ) -> & ' static str {
71+ "/api/v0/node/healthcheck"
72+ }
73+
6974 /// Create a serde compatible request for model creation
7075 pub async fn create_model_request (
7176 & self ,
@@ -239,6 +244,11 @@ impl<S: Signer> CeramicHttpClient<S> {
239244 pagination,
240245 } )
241246 }
247+
248+ /// Create a serde compatible request to check node health
249+ pub async fn create_healthcheck_request ( & self ) -> anyhow:: Result < api:: HealthcheckRequest > {
250+ Ok ( api:: HealthcheckRequest { } )
251+ }
242252}
243253
244254/// Remote HTTP Functionality
@@ -463,6 +473,20 @@ pub mod remote {
463473 page_info : resp. page_info ,
464474 } )
465475 }
476+
477+ /// Check Ceramic node health
478+ pub async fn healthcheck ( & self ) -> anyhow:: Result < String > {
479+ let req = self . cli . create_healthcheck_request ( ) . await ?;
480+ let resp = self
481+ . remote
482+ . get ( self . url_for_path ( self . cli . healthcheck_endpoint ( ) ) ?)
483+ . json ( & req)
484+ . send ( )
485+ . await ?
486+ . text ( )
487+ . await ?;
488+ Ok ( resp)
489+ }
466490 }
467491}
468492
You can’t perform that action at this time.
0 commit comments