fix: list_resources returns data (config+metadata); register source code resource
This commit is contained in:
@@ -668,7 +668,7 @@ pub struct RegisterResourceRequest {
|
|||||||
pub struct ResourceResponse {
|
pub struct ResourceResponse {
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Option<ResourceItem>,
|
pub data: Option<Vec<ResourceItem>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
@@ -677,6 +677,8 @@ pub struct ResourceItem {
|
|||||||
pub resource_type: String,
|
pub resource_type: String,
|
||||||
pub category: String,
|
pub category: String,
|
||||||
pub capabilities: Option<serde_json::Value>,
|
pub capabilities: Option<serde_json::Value>,
|
||||||
|
pub config: Option<serde_json::Value>,
|
||||||
|
pub metadata: Option<serde_json::Value>,
|
||||||
pub status: String,
|
pub status: String,
|
||||||
pub last_heartbeat: Option<chrono::DateTime<chrono::Utc>>,
|
pub last_heartbeat: Option<chrono::DateTime<chrono::Utc>>,
|
||||||
}
|
}
|
||||||
@@ -743,22 +745,24 @@ async fn list_resources(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
||||||
|
|
||||||
let data: Vec<ResourceItem> = records
|
let data: Vec<ResourceItem> = records
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|r| ResourceItem {
|
.map(|r| ResourceItem {
|
||||||
resource_id: r.resource_id,
|
resource_id: r.resource_id,
|
||||||
resource_type: r.resource_type,
|
resource_type: r.resource_type,
|
||||||
category: r.category,
|
category: r.category,
|
||||||
capabilities: r.capabilities,
|
capabilities: r.capabilities,
|
||||||
status: r.status,
|
config: r.config,
|
||||||
last_heartbeat: r.last_heartbeat,
|
metadata: r.metadata,
|
||||||
})
|
status: r.status,
|
||||||
.collect();
|
last_heartbeat: r.last_heartbeat,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
Ok(Json(ResourceResponse {
|
Ok(Json(ResourceResponse {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Resources listed".to_string(),
|
message: "Resources listed".to_string(),
|
||||||
data: None,
|
data: Some(data),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user