11use crate :: server_state:: ServerState ;
2- use aruna_core:: structs:: Status ;
32use axum:: extract:: State ;
43use axum:: http:: StatusCode ;
54use axum:: routing:: get;
@@ -60,8 +59,31 @@ pub struct TimeoutConfig {
6059
6160#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , ToSchema ) ]
6261pub struct InterfaceStatus {
63- pub s3_status : String ,
64- pub rest_status : String ,
62+ pub rest : RestInterfaceStatus ,
63+ pub s3 : S3InterfaceStatus ,
64+ }
65+
66+ #[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , ToSchema ) ]
67+ #[ serde( tag = "status" ) ]
68+ pub enum RestInterfaceStatus {
69+ Available {
70+ bind_address : String ,
71+ base_url : String ,
72+ api_base_url : String ,
73+ info_url : String ,
74+ swagger_ui_url : String ,
75+ } ,
76+ Unavailable ,
77+ }
78+
79+ #[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , ToSchema ) ]
80+ #[ serde( tag = "status" ) ]
81+ pub enum S3InterfaceStatus {
82+ Available {
83+ bind_address : String ,
84+ base_url : String ,
85+ } ,
86+ Unavailable ,
6587}
6688
6789#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize , ToSchema ) ]
@@ -138,12 +160,25 @@ pub async fn get_info(State(state): State<Arc<ServerState>>) -> (StatusCode, Jso
138160 }
139161 None => BlobStatus :: Unavailable ,
140162 } ;
141- // TODO:
142- // - Replace hardcoded values
143- // - Add s3 interface address
163+ let interface_runtime = state. interface_state ( ) . await ;
144164 let interface_status = InterfaceStatus {
145- s3_status : Status :: Available . to_string ( ) ,
146- rest_status : Status :: Available . to_string ( ) ,
165+ rest : match interface_runtime. rest {
166+ Some ( rest) => RestInterfaceStatus :: Available {
167+ bind_address : rest. bind_address . to_string ( ) ,
168+ base_url : rest. base_url ,
169+ api_base_url : rest. api_base_url ,
170+ info_url : rest. info_url ,
171+ swagger_ui_url : rest. swagger_ui_url ,
172+ } ,
173+ None => RestInterfaceStatus :: Unavailable ,
174+ } ,
175+ s3 : match interface_runtime. s3 {
176+ Some ( s3) => S3InterfaceStatus :: Available {
177+ bind_address : s3. bind_address . to_string ( ) ,
178+ base_url : s3. base_url ,
179+ } ,
180+ None => S3InterfaceStatus :: Unavailable ,
181+ } ,
147182 } ;
148183 let storage_metrics = state. get_ctx ( ) . storage_handle . snapshot_metrics ( ) ;
149184 let database_status = DatabaseStatus {
@@ -169,11 +204,14 @@ pub async fn get_info(State(state): State<Arc<ServerState>>) -> (StatusCode, Jso
169204
170205#[ cfg( test) ]
171206mod tests {
172- use super :: { BlobStatus , InfoResponse , InterfaceStatus , NetStatus , DatabaseStatus , get_info} ;
207+ use super :: {
208+ BlobStatus , DatabaseStatus , InfoResponse , InterfaceStatus , NetStatus ,
209+ RestInterfaceStatus , S3InterfaceStatus , get_info,
210+ } ;
173211 use crate :: openapi:: ApiDoc ;
174212 use crate :: server_state:: ServerState ;
175213 use aruna_core:: effects:: StorageEffect ;
176- use aruna_core:: structs:: { NodeCapabilities , RealmId , Status } ;
214+ use aruna_core:: structs:: { NodeCapabilities , RealmId } ;
177215 use aruna_operations:: driver:: DriverContext ;
178216 use aruna_storage:: storage;
179217 use axum:: Json ;
@@ -229,8 +267,8 @@ mod tests {
229267 net_state: NetStatus :: Unavailable ,
230268 blob_status: BlobStatus :: Unavailable ,
231269 interface_status: InterfaceStatus {
232- s3_status : Status :: Available . to_string ( ) ,
233- rest_status : Status :: Available . to_string ( ) ,
270+ rest : RestInterfaceStatus :: Unavailable ,
271+ s3 : S3InterfaceStatus :: Unavailable ,
234272 } ,
235273 database_status: DatabaseStatus {
236274 requests_total: baseline. requests_total,
@@ -246,6 +284,40 @@ mod tests {
246284 ) ;
247285 }
248286
287+ #[ tokio:: test]
288+ async fn get_info_reports_registered_interface_paths ( ) {
289+ let ( state, _tempdir) = setup_state ( ) . await ;
290+ state
291+ . register_rest_interface ( "0.0.0.0:3000" . parse ( ) . unwrap ( ) )
292+ . await ;
293+ state
294+ . register_s3_interface (
295+ "0.0.0.0:1337" . parse ( ) . unwrap ( ) ,
296+ "http://localhost:1337" . to_string ( ) ,
297+ )
298+ . await ;
299+
300+ let ( status, Json ( response) ) = get_info ( State ( state) ) . await ;
301+
302+ assert_eq ! ( status, StatusCode :: OK ) ;
303+ assert_eq ! (
304+ response. interface_status,
305+ InterfaceStatus {
306+ rest: RestInterfaceStatus :: Available {
307+ bind_address: "0.0.0.0:3000" . to_string( ) ,
308+ base_url: "http://127.0.0.1:3000" . to_string( ) ,
309+ api_base_url: "http://127.0.0.1:3000/api/v1" . to_string( ) ,
310+ info_url: "http://127.0.0.1:3000/api/v1/info" . to_string( ) ,
311+ swagger_ui_url: "http://127.0.0.1:3000/swagger-ui" . to_string( ) ,
312+ } ,
313+ s3: S3InterfaceStatus :: Available {
314+ bind_address: "0.0.0.0:1337" . to_string( ) ,
315+ base_url: "http://localhost:1337" . to_string( ) ,
316+ } ,
317+ }
318+ ) ;
319+ }
320+
249321 #[ tokio:: test]
250322 async fn get_info_reports_storage_error_metrics ( ) {
251323 let ( state, _tempdir) = setup_state ( ) . await ;
0 commit comments