File tree Expand file tree Collapse file tree 3 files changed +34
-3
lines changed
Expand file tree Collapse file tree 3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,16 @@ impl TiledClient {
6969 self . request ( & format ! ( "api/v1/search/{}" , path) , headers, Some ( query) )
7070 . await
7171 }
72+
73+ pub async fn metadata (
74+ & self ,
75+ id : String ,
76+ headers : Option < HeaderMap > ,
77+ ) -> ClientResult < node:: Metadata > {
78+ self . request ( & format ! ( "api/v1/metadata/{id}" ) , headers, None )
79+ . await
80+ }
81+
7282 pub async fn table_full (
7383 & self ,
7484 path : & str ,
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use serde_json::Value;
1313use tracing:: { info, instrument} ;
1414
1515use crate :: RootAddress ;
16- use crate :: clients:: TiledClient ;
16+ use crate :: clients:: { ClientError , TiledClient } ;
1717use crate :: handlers:: AuthHeader ;
1818use crate :: model:: node:: NodeAttributes ;
1919
@@ -29,6 +29,18 @@ impl TiledQuery {
2929 async fn instrument_session ( & self , name : String ) -> InstrumentSession {
3030 InstrumentSession { name }
3131 }
32+
33+ async fn run ( & self , ctx : & Context < ' _ > , id : String ) -> Result < Option < Run > > {
34+ let auth = ctx. data :: < Option < AuthHeader > > ( ) ?;
35+ let headers = auth. as_ref ( ) . map ( AuthHeader :: as_header_map) ;
36+ match ctx. data :: < TiledClient > ( ) ?. metadata ( id, headers) . await {
37+ Ok ( run) => Ok ( Some ( Run {
38+ data : run. into_data ( ) ,
39+ } ) ) ,
40+ Err ( ClientError :: TiledRequest ( 404 , _) ) => Ok ( None ) ,
41+ Err ( other) => Err ( other. into ( ) ) ,
42+ }
43+ }
3244}
3345
3446struct InstrumentSession {
Original file line number Diff line number Diff line change @@ -6,9 +6,12 @@ use serde_json::Value;
66
77use crate :: model:: { array, container, table} ;
88
9+ pub type Root = Response < Vec < DataOption > > ;
10+ pub type Metadata = Response < Data > ;
11+
912#[ derive( Debug , PartialEq , Serialize , Deserialize ) ]
10- pub struct Root {
11- data : Vec < DataOption > ,
13+ pub struct Response < D > {
14+ data : D ,
1215 pub error : Value ,
1316 pub links : Option < Links > ,
1417 pub meta : Value ,
@@ -23,6 +26,12 @@ impl Root {
2326 }
2427}
2528
29+ impl Metadata {
30+ pub fn into_data ( self ) -> Data {
31+ self . data
32+ }
33+ }
34+
2635#[ derive( Debug , PartialEq , Serialize , Deserialize ) ]
2736#[ serde( untagged) ]
2837pub enum DataOption {
You can’t perform that action at this time.
0 commit comments