implement list indexes

This commit is contained in:
mpostma 2021-02-03 17:44:20 +01:00
parent 482f734e53
commit d43dc4824c
No known key found for this signature in database
GPG key ID: CBC8A7C1D7A28C3A
6 changed files with 120 additions and 26 deletions

View file

@ -19,19 +19,20 @@ pub fn services(cfg: &mut web::ServiceConfig) {
.service(get_all_updates_status);
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct IndexResponse {
pub name: String,
pub uid: String,
created_at: DateTime<Utc>,
updated_at: DateTime<Utc>,
pub primary_key: Option<String>,
}
#[get("/indexes", wrap = "Authentication::Private")]
async fn list_indexes(_data: web::Data<Data>) -> Result<HttpResponse, ResponseError> {
todo!()
async fn list_indexes(data: web::Data<Data>) -> Result<HttpResponse, ResponseError> {
match data.list_indexes() {
Ok(indexes) => {
let json = serde_json::to_string(&indexes).unwrap();
Ok(HttpResponse::Ok().body(&json))
}
Err(e) => {
error!("error listing indexes: {}", e);
unimplemented!()
}
}
}
#[get("/indexes/{index_uid}", wrap = "Authentication::Private")]