mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-06-04 11:57:48 +02:00
118 lines
2.9 KiB
Rust
118 lines
2.9 KiB
Rust
use actix_web::{delete, get, post, put};
|
|
use actix_web::{web, HttpResponse};
|
|
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::Data;
|
|
use crate::error::ResponseError;
|
|
use crate::helpers::Authentication;
|
|
use crate::routes::IndexParam;
|
|
|
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
|
cfg.service(list_indexes)
|
|
.service(get_index)
|
|
.service(create_index)
|
|
.service(update_index)
|
|
.service(delete_index)
|
|
.service(get_update_status)
|
|
.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!()
|
|
}
|
|
|
|
#[get("/indexes/{index_uid}", wrap = "Authentication::Private")]
|
|
async fn get_index(
|
|
_data: web::Data<Data>,
|
|
_path: web::Path<IndexParam>,
|
|
) -> Result<HttpResponse, ResponseError> {
|
|
todo!()
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
|
struct IndexCreateRequest {
|
|
name: Option<String>,
|
|
uid: Option<String>,
|
|
primary_key: Option<String>,
|
|
}
|
|
|
|
#[post("/indexes", wrap = "Authentication::Private")]
|
|
async fn create_index(
|
|
_data: web::Data<Data>,
|
|
_body: web::Json<IndexCreateRequest>,
|
|
) -> Result<HttpResponse, ResponseError> {
|
|
todo!()
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
|
struct UpdateIndexRequest {
|
|
name: Option<String>,
|
|
primary_key: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
struct UpdateIndexResponse {
|
|
name: String,
|
|
uid: String,
|
|
created_at: DateTime<Utc>,
|
|
updated_at: DateTime<Utc>,
|
|
primary_key: Option<String>,
|
|
}
|
|
|
|
#[put("/indexes/{index_uid}", wrap = "Authentication::Private")]
|
|
async fn update_index(
|
|
_data: web::Data<Data>,
|
|
_path: web::Path<IndexParam>,
|
|
_body: web::Json<IndexCreateRequest>,
|
|
) -> Result<HttpResponse, ResponseError> {
|
|
todo!()
|
|
}
|
|
|
|
#[delete("/indexes/{index_uid}", wrap = "Authentication::Private")]
|
|
async fn delete_index(
|
|
_data: web::Data<Data>,
|
|
_path: web::Path<IndexParam>,
|
|
) -> Result<HttpResponse, ResponseError> {
|
|
todo!()
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
struct UpdateParam {
|
|
_index_uid: String,
|
|
_update_id: u64,
|
|
}
|
|
|
|
#[get(
|
|
"/indexes/{index_uid}/updates/{update_id}",
|
|
wrap = "Authentication::Private"
|
|
)]
|
|
async fn get_update_status(
|
|
_data: web::Data<Data>,
|
|
_path: web::Path<UpdateParam>,
|
|
) -> Result<HttpResponse, ResponseError> {
|
|
todo!()
|
|
}
|
|
|
|
#[get("/indexes/{index_uid}/updates", wrap = "Authentication::Private")]
|
|
async fn get_all_updates_status(
|
|
_data: web::Data<Data>,
|
|
_path: web::Path<IndexParam>,
|
|
) -> Result<HttpResponse, ResponseError> {
|
|
todo!()
|
|
}
|