Skip to main content

hanzo_client/apis/
index_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`delete_index_indexes_by_uid`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteIndexIndexesByUidError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`delete_index_indexes_by_uid_documents_by_id`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteIndexIndexesByUidDocumentsByIdError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_index_health`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetIndexHealthError {
36    Status503(models::IndexHealth),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`get_index_indexes`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetIndexIndexesError {
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`get_index_indexes_by_uid`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum GetIndexIndexesByUidError {
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`get_index_indexes_by_uid_documents`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum GetIndexIndexesByUidDocumentsError {
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`get_index_indexes_by_uid_documents_by_id`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetIndexIndexesByUidDocumentsByIdError {
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`get_index_indexes_by_uid_settings`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum GetIndexIndexesByUidSettingsError {
72    UnknownValue(serde_json::Value),
73}
74
75/// struct for typed errors of method [`get_index_stats`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum GetIndexStatsError {
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`get_index_tasks_by_uid`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum GetIndexTasksByUidError {
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`get_index_version`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum GetIndexVersionError {
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`patch_index_indexes_by_uid_settings`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum PatchIndexIndexesByUidSettingsError {
100    UnknownValue(serde_json::Value),
101}
102
103/// struct for typed errors of method [`post_index_indexes`]
104#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum PostIndexIndexesError {
107    UnknownValue(serde_json::Value),
108}
109
110/// struct for typed errors of method [`post_index_indexes_by_uid_documents`]
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum PostIndexIndexesByUidDocumentsError {
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`post_index_indexes_by_uid_documents_delete_batch`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum PostIndexIndexesByUidDocumentsDeleteBatchError {
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`post_index_indexes_by_uid_search`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum PostIndexIndexesByUidSearchError {
128    UnknownValue(serde_json::Value),
129}
130
131/// struct for typed errors of method [`put_index_indexes_by_uid_documents`]
132#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum PutIndexIndexesByUidDocumentsError {
135    UnknownValue(serde_json::Value),
136}
137
138
139/// Deletes an index and everything in it.  Drops the index and every document in it from the caller's own org, and answers the dialect's EnqueuedTask. This is the only way to retire an index; without it a mistaken uid is permanent. Deleting an index that is not there succeeds, so a cleanup pass is safe to re-run.  The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the documents are already gone when this answers.
140pub async fn delete_index_indexes_by_uid(configuration: &configuration::Configuration, uid: &str) -> Result<models::IndexEnqueued, Error<DeleteIndexIndexesByUidError>> {
141    // add a prefix to parameters to efficiently prevent name collisions
142    let p_uid = uid;
143
144    let uri_str = format!("{}/v1/index/indexes/{uid}", configuration.base_path, uid=crate::apis::urlencode(p_uid));
145    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
146
147    if let Some(ref user_agent) = configuration.user_agent {
148        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149    }
150    if let Some(ref token) = configuration.bearer_access_token {
151        req_builder = req_builder.bearer_auth(token.to_owned());
152    };
153
154    let req = req_builder.build()?;
155    let resp = configuration.client.execute(req).await?;
156
157    let status = resp.status();
158    let content_type = resp
159        .headers()
160        .get("content-type")
161        .and_then(|v| v.to_str().ok())
162        .unwrap_or("application/octet-stream");
163    let content_type = super::ContentType::from(content_type);
164
165    if !status.is_client_error() && !status.is_server_error() {
166        let content = resp.text().await?;
167        match content_type {
168            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
169            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexEnqueued`"))),
170            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexEnqueued`")))),
171        }
172    } else {
173        let content = resp.text().await?;
174        let entity: Option<DeleteIndexIndexesByUidError> = serde_json::from_str(&content).ok();
175        Err(Error::ResponseError(ResponseContent { status, content, entity }))
176    }
177}
178
179/// Deletes one document by its primary key.  Removes the document from the caller's own org and answers the dialect's EnqueuedTask. Deleting a key that is not there succeeds, so a client reconciling its own corpus can delete without checking first.  The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the document is already gone when this answers.
180pub async fn delete_index_indexes_by_uid_documents_by_id(configuration: &configuration::Configuration, uid: &str, id: &str) -> Result<models::IndexEnqueued, Error<DeleteIndexIndexesByUidDocumentsByIdError>> {
181    // add a prefix to parameters to efficiently prevent name collisions
182    let p_uid = uid;
183    let p_id = id;
184
185    let uri_str = format!("{}/v1/index/indexes/{uid}/documents/{id}", configuration.base_path, uid=crate::apis::urlencode(p_uid), id=crate::apis::urlencode(p_id));
186    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
187
188    if let Some(ref user_agent) = configuration.user_agent {
189        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
190    }
191    if let Some(ref token) = configuration.bearer_access_token {
192        req_builder = req_builder.bearer_auth(token.to_owned());
193    };
194
195    let req = req_builder.build()?;
196    let resp = configuration.client.execute(req).await?;
197
198    let status = resp.status();
199    let content_type = resp
200        .headers()
201        .get("content-type")
202        .and_then(|v| v.to_str().ok())
203        .unwrap_or("application/octet-stream");
204    let content_type = super::ContentType::from(content_type);
205
206    if !status.is_client_error() && !status.is_server_error() {
207        let content = resp.text().await?;
208        match content_type {
209            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
210            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexEnqueued`"))),
211            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexEnqueued`")))),
212        }
213    } else {
214        let content = resp.text().await?;
215        let entity: Option<DeleteIndexIndexesByUidDocumentsByIdError> = serde_json::from_str(&content).ok();
216        Err(Error::ResponseError(ResponseContent { status, content, entity }))
217    }
218}
219
220/// Reports whether the search plane can serve.  Answers the dialect's `{\"status\":\"available\"}` when the index store is readable. It FAILS CLOSED — an unreadable store answers 503 with `{\"status\":\"unavailable\"}` rather than an empty result set, because a Meilisearch client probes this before it will use a server at all and a cheerful 200 over a broken volume turns \"search is down\" into \"nothing matched\". It requires no principal and reads no tenant data.
221pub async fn get_index_health(configuration: &configuration::Configuration, ) -> Result<models::IndexHealth, Error<GetIndexHealthError>> {
222
223    let uri_str = format!("{}/v1/index/health", configuration.base_path);
224    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
225
226    if let Some(ref user_agent) = configuration.user_agent {
227        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
228    }
229    if let Some(ref token) = configuration.bearer_access_token {
230        req_builder = req_builder.bearer_auth(token.to_owned());
231    };
232
233    let req = req_builder.build()?;
234    let resp = configuration.client.execute(req).await?;
235
236    let status = resp.status();
237    let content_type = resp
238        .headers()
239        .get("content-type")
240        .and_then(|v| v.to_str().ok())
241        .unwrap_or("application/octet-stream");
242    let content_type = super::ContentType::from(content_type);
243
244    if !status.is_client_error() && !status.is_server_error() {
245        let content = resp.text().await?;
246        match content_type {
247            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
248            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexHealth`"))),
249            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexHealth`")))),
250        }
251    } else {
252        let content = resp.text().await?;
253        let entity: Option<GetIndexHealthError> = serde_json::from_str(&content).ok();
254        Err(Error::ResponseError(ResponseContent { status, content, entity }))
255    }
256}
257
258/// Lists the indexes your org holds.  Answers every index in the caller's own org with its primary key and timestamps. Without it an index whose uid a caller has forgotten is unreachable — there is no other way to enumerate what an org holds. The page is the whole set: an org's index count is small by construction, so `limit` and `total` both report it.  The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header, and two orgs may both hold an index named \"messages\" without either seeing the other. Without a validated principal the answer is 403 carrying the dialect's `invalid_api_key` body.
259pub async fn get_index_indexes(configuration: &configuration::Configuration, ) -> Result<models::IndexList, Error<GetIndexIndexesError>> {
260
261    let uri_str = format!("{}/v1/index/indexes", configuration.base_path);
262    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
263
264    if let Some(ref user_agent) = configuration.user_agent {
265        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
266    }
267    if let Some(ref token) = configuration.bearer_access_token {
268        req_builder = req_builder.bearer_auth(token.to_owned());
269    };
270
271    let req = req_builder.build()?;
272    let resp = configuration.client.execute(req).await?;
273
274    let status = resp.status();
275    let content_type = resp
276        .headers()
277        .get("content-type")
278        .and_then(|v| v.to_str().ok())
279        .unwrap_or("application/octet-stream");
280    let content_type = super::ContentType::from(content_type);
281
282    if !status.is_client_error() && !status.is_server_error() {
283        let content = resp.text().await?;
284        match content_type {
285            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
286            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexList`"))),
287            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexList`")))),
288        }
289    } else {
290        let content = resp.text().await?;
291        let entity: Option<GetIndexIndexesError> = serde_json::from_str(&content).ok();
292        Err(Error::ResponseError(ResponseContent { status, content, entity }))
293    }
294}
295
296/// Reads one index's definition.  Answers the index's uid, primary key and timestamps. An index this org does not hold answers 404 carrying the dialect's `index_not_found` — the code a Meilisearch client reads as permission to create it, which is why this is a refusal rather than an empty object.  The uid is scoped to the caller's own org, so another tenant's index is indistinguishable from one that never existed: this surface is not an existence oracle.
297pub async fn get_index_indexes_by_uid(configuration: &configuration::Configuration, uid: &str) -> Result<models::IndexView, Error<GetIndexIndexesByUidError>> {
298    // add a prefix to parameters to efficiently prevent name collisions
299    let p_uid = uid;
300
301    let uri_str = format!("{}/v1/index/indexes/{uid}", configuration.base_path, uid=crate::apis::urlencode(p_uid));
302    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
303
304    if let Some(ref user_agent) = configuration.user_agent {
305        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
306    }
307    if let Some(ref token) = configuration.bearer_access_token {
308        req_builder = req_builder.bearer_auth(token.to_owned());
309    };
310
311    let req = req_builder.build()?;
312    let resp = configuration.client.execute(req).await?;
313
314    let status = resp.status();
315    let content_type = resp
316        .headers()
317        .get("content-type")
318        .and_then(|v| v.to_str().ok())
319        .unwrap_or("application/octet-stream");
320    let content_type = super::ContentType::from(content_type);
321
322    if !status.is_client_error() && !status.is_server_error() {
323        let content = resp.text().await?;
324        match content_type {
325            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
326            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexView`"))),
327            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexView`")))),
328        }
329    } else {
330        let content = resp.text().await?;
331        let entity: Option<GetIndexIndexesByUidError> = serde_json::from_str(&content).ok();
332        Err(Error::ResponseError(ResponseContent { status, content, entity }))
333    }
334}
335
336/// Pages through the documents in an index.  Answers the org's stored documents in insertion order, whole, with the page's bounds and the index's total. It is the enumeration surface — search ranks by relevance and cannot walk a corpus — so a caller reconciling what it has written reads it here.  An index this org does not hold answers 404 carrying the dialect's `index_not_found`.
337pub async fn get_index_indexes_by_uid_documents(configuration: &configuration::Configuration, uid: &str, limit: Option<&str>, offset: Option<&str>) -> Result<models::IndexDocuments, Error<GetIndexIndexesByUidDocumentsError>> {
338    // add a prefix to parameters to efficiently prevent name collisions
339    let p_uid = uid;
340    let p_limit = limit;
341    let p_offset = offset;
342
343    let uri_str = format!("{}/v1/index/indexes/{uid}/documents", configuration.base_path, uid=crate::apis::urlencode(p_uid));
344    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
345
346    if let Some(ref param_value) = p_limit {
347        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
348    }
349    if let Some(ref param_value) = p_offset {
350        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
351    }
352    if let Some(ref user_agent) = configuration.user_agent {
353        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
354    }
355    if let Some(ref token) = configuration.bearer_access_token {
356        req_builder = req_builder.bearer_auth(token.to_owned());
357    };
358
359    let req = req_builder.build()?;
360    let resp = configuration.client.execute(req).await?;
361
362    let status = resp.status();
363    let content_type = resp
364        .headers()
365        .get("content-type")
366        .and_then(|v| v.to_str().ok())
367        .unwrap_or("application/octet-stream");
368    let content_type = super::ContentType::from(content_type);
369
370    if !status.is_client_error() && !status.is_server_error() {
371        let content = resp.text().await?;
372        match content_type {
373            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
374            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexDocuments`"))),
375            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexDocuments`")))),
376        }
377    } else {
378        let content = resp.text().await?;
379        let entity: Option<GetIndexIndexesByUidDocumentsError> = serde_json::from_str(&content).ok();
380        Err(Error::ResponseError(ResponseContent { status, content, entity }))
381    }
382}
383
384/// Reads one document by its primary key.  Answers the stored document exactly as it was written — this surface keeps documents whole rather than projecting them, so what comes back is what went in. A primary key this index does not hold answers 404 carrying the dialect's `document_not_found`; an index this org does not hold answers `index_not_found`, and the two are different facts a client acts on differently.
385pub async fn get_index_indexes_by_uid_documents_by_id(configuration: &configuration::Configuration, uid: &str, id: &str) -> Result<serde_json::Value, Error<GetIndexIndexesByUidDocumentsByIdError>> {
386    // add a prefix to parameters to efficiently prevent name collisions
387    let p_uid = uid;
388    let p_id = id;
389
390    let uri_str = format!("{}/v1/index/indexes/{uid}/documents/{id}", configuration.base_path, uid=crate::apis::urlencode(p_uid), id=crate::apis::urlencode(p_id));
391    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
392
393    if let Some(ref user_agent) = configuration.user_agent {
394        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
395    }
396    if let Some(ref token) = configuration.bearer_access_token {
397        req_builder = req_builder.bearer_auth(token.to_owned());
398    };
399
400    let req = req_builder.build()?;
401    let resp = configuration.client.execute(req).await?;
402
403    let status = resp.status();
404    let content_type = resp
405        .headers()
406        .get("content-type")
407        .and_then(|v| v.to_str().ok())
408        .unwrap_or("application/octet-stream");
409    let content_type = super::ContentType::from(content_type);
410
411    if !status.is_client_error() && !status.is_server_error() {
412        let content = resp.text().await?;
413        match content_type {
414            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
415            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
416            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
417        }
418    } else {
419        let content = resp.text().await?;
420        let entity: Option<GetIndexIndexesByUidDocumentsByIdError> = serde_json::from_str(&content).ok();
421        Err(Error::ResponseError(ResponseContent { status, content, entity }))
422    }
423}
424
425/// Reads an index's filterable attributes.  Answers the settings subset this surface implements: the attributes a search `filter` may constrain. An index this org does not hold answers 404 carrying the dialect's `index_not_found`.
426pub async fn get_index_indexes_by_uid_settings(configuration: &configuration::Configuration, uid: &str) -> Result<models::IndexSettings, Error<GetIndexIndexesByUidSettingsError>> {
427    // add a prefix to parameters to efficiently prevent name collisions
428    let p_uid = uid;
429
430    let uri_str = format!("{}/v1/index/indexes/{uid}/settings", configuration.base_path, uid=crate::apis::urlencode(p_uid));
431    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
432
433    if let Some(ref user_agent) = configuration.user_agent {
434        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
435    }
436    if let Some(ref token) = configuration.bearer_access_token {
437        req_builder = req_builder.bearer_auth(token.to_owned());
438    };
439
440    let req = req_builder.build()?;
441    let resp = configuration.client.execute(req).await?;
442
443    let status = resp.status();
444    let content_type = resp
445        .headers()
446        .get("content-type")
447        .and_then(|v| v.to_str().ok())
448        .unwrap_or("application/octet-stream");
449    let content_type = super::ContentType::from(content_type);
450
451    if !status.is_client_error() && !status.is_server_error() {
452        let content = resp.text().await?;
453        match content_type {
454            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
455            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexSettings`"))),
456            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexSettings`")))),
457        }
458    } else {
459        let content = resp.text().await?;
460        let entity: Option<GetIndexIndexesByUidSettingsError> = serde_json::from_str(&content).ok();
461        Err(Error::ResponseError(ResponseContent { status, content, entity }))
462    }
463}
464
465/// Counts the documents in each of your indexes.  Reports every index the caller's own org holds with its document count, plus the org's total. `isIndexing` is always false because writes here are applied before their response — there is never a background pass to wait on.  The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header, so this counts the caller's own documents and no other tenant's. Without a validated principal the answer is 403 carrying the dialect's `invalid_api_key` body.
466pub async fn get_index_stats(configuration: &configuration::Configuration, ) -> Result<models::IndexStats, Error<GetIndexStatsError>> {
467
468    let uri_str = format!("{}/v1/index/stats", configuration.base_path);
469    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
470
471    if let Some(ref user_agent) = configuration.user_agent {
472        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
473    }
474    if let Some(ref token) = configuration.bearer_access_token {
475        req_builder = req_builder.bearer_auth(token.to_owned());
476    };
477
478    let req = req_builder.build()?;
479    let resp = configuration.client.execute(req).await?;
480
481    let status = resp.status();
482    let content_type = resp
483        .headers()
484        .get("content-type")
485        .and_then(|v| v.to_str().ok())
486        .unwrap_or("application/octet-stream");
487    let content_type = super::ContentType::from(content_type);
488
489    if !status.is_client_error() && !status.is_server_error() {
490        let content = resp.text().await?;
491        match content_type {
492            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
493            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexStats`"))),
494            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexStats`")))),
495        }
496    } else {
497        let content = resp.text().await?;
498        let entity: Option<GetIndexStatsError> = serde_json::from_str(&content).ok();
499        Err(Error::ResponseError(ResponseContent { status, content, entity }))
500    }
501}
502
503/// Checks a write task, which has already finished.  Always reports `succeeded`. Writes here are applied to SQLite before their EnqueuedTask is returned, so a client polling waitForTask resolves on its first call rather than waiting for a queue that was never there. The three timestamps are the same instant for the same reason.  It requires a validated principal but reads no tenant data: the task id it echoes was minted by this process and names nothing about any org.
504pub async fn get_index_tasks_by_uid(configuration: &configuration::Configuration, uid: i32) -> Result<models::IndexTask, Error<GetIndexTasksByUidError>> {
505    // add a prefix to parameters to efficiently prevent name collisions
506    let p_uid = uid;
507
508    let uri_str = format!("{}/v1/index/tasks/{uid}", configuration.base_path, uid=p_uid);
509    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
510
511    if let Some(ref user_agent) = configuration.user_agent {
512        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
513    }
514    if let Some(ref token) = configuration.bearer_access_token {
515        req_builder = req_builder.bearer_auth(token.to_owned());
516    };
517
518    let req = req_builder.build()?;
519    let resp = configuration.client.execute(req).await?;
520
521    let status = resp.status();
522    let content_type = resp
523        .headers()
524        .get("content-type")
525        .and_then(|v| v.to_str().ok())
526        .unwrap_or("application/octet-stream");
527    let content_type = super::ContentType::from(content_type);
528
529    if !status.is_client_error() && !status.is_server_error() {
530        let content = resp.text().await?;
531        match content_type {
532            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
533            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexTask`"))),
534            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexTask`")))),
535        }
536    } else {
537        let content = resp.text().await?;
538        let entity: Option<GetIndexTasksByUidError> = serde_json::from_str(&content).ok();
539        Err(Error::ResponseError(ResponseContent { status, content, entity }))
540    }
541}
542
543/// Identifies the search implementation answering.  Reports the dialect's version shape with `commitSha` naming this implementation rather than a Meilisearch build, so a client that logs the version records which server answered instead of implying a release of software this is not. It requires no principal and reads no tenant data.
544pub async fn get_index_version(configuration: &configuration::Configuration, ) -> Result<models::IndexVersion, Error<GetIndexVersionError>> {
545
546    let uri_str = format!("{}/v1/index/version", configuration.base_path);
547    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
548
549    if let Some(ref user_agent) = configuration.user_agent {
550        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
551    }
552    if let Some(ref token) = configuration.bearer_access_token {
553        req_builder = req_builder.bearer_auth(token.to_owned());
554    };
555
556    let req = req_builder.build()?;
557    let resp = configuration.client.execute(req).await?;
558
559    let status = resp.status();
560    let content_type = resp
561        .headers()
562        .get("content-type")
563        .and_then(|v| v.to_str().ok())
564        .unwrap_or("application/octet-stream");
565    let content_type = super::ContentType::from(content_type);
566
567    if !status.is_client_error() && !status.is_server_error() {
568        let content = resp.text().await?;
569        match content_type {
570            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
571            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexVersion`"))),
572            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexVersion`")))),
573        }
574    } else {
575        let content = resp.text().await?;
576        let entity: Option<GetIndexVersionError> = serde_json::from_str(&content).ok();
577        Err(Error::ResponseError(ResponseContent { status, content, entity }))
578    }
579}
580
581/// Sets which attributes an index can be filtered on.  Replaces the whole filterable set. An attribute not listed here cannot be used in a search `filter`, so this is what makes a per-user or per-tag narrowing possible at all.  It CREATES the index when it is missing rather than answering 404, because a Meilisearch client configures settings on an index it has just asked for and a refusal there leaves the client with no index at all.  The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the setting is already applied when this answers.
582pub async fn patch_index_indexes_by_uid_settings(configuration: &configuration::Configuration, uid: &str, index_filter: models::IndexFilter) -> Result<models::IndexEnqueued, Error<PatchIndexIndexesByUidSettingsError>> {
583    // add a prefix to parameters to efficiently prevent name collisions
584    let p_uid = uid;
585    let p_index_filter = index_filter;
586
587    let uri_str = format!("{}/v1/index/indexes/{uid}/settings", configuration.base_path, uid=crate::apis::urlencode(p_uid));
588    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
589
590    if let Some(ref user_agent) = configuration.user_agent {
591        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
592    }
593    if let Some(ref token) = configuration.bearer_access_token {
594        req_builder = req_builder.bearer_auth(token.to_owned());
595    };
596    req_builder = req_builder.json(&p_index_filter);
597
598    let req = req_builder.build()?;
599    let resp = configuration.client.execute(req).await?;
600
601    let status = resp.status();
602    let content_type = resp
603        .headers()
604        .get("content-type")
605        .and_then(|v| v.to_str().ok())
606        .unwrap_or("application/octet-stream");
607    let content_type = super::ContentType::from(content_type);
608
609    if !status.is_client_error() && !status.is_server_error() {
610        let content = resp.text().await?;
611        match content_type {
612            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
613            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexEnqueued`"))),
614            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexEnqueued`")))),
615        }
616    } else {
617        let content = resp.text().await?;
618        let entity: Option<PatchIndexIndexesByUidSettingsError> = serde_json::from_str(&content).ok();
619        Err(Error::ResponseError(ResponseContent { status, content, entity }))
620    }
621}
622
623/// Creates an index.  Registers a named index in the caller's own org and answers the dialect's EnqueuedTask. It is idempotent: creating an index that already exists returns the same receipt and changes nothing, which is what lets a client create on startup without checking first.  `primaryKey` is optional — the first write establishes one when it is omitted. An index is a ROW here rather than a table, so an unusual uid is stored verbatim instead of being sanitised into a schema name.  The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the write is already applied when this answers. A client that polls waitForTask resolves immediately.
624pub async fn post_index_indexes(configuration: &configuration::Configuration, index_new: models::IndexNew) -> Result<models::IndexEnqueued, Error<PostIndexIndexesError>> {
625    // add a prefix to parameters to efficiently prevent name collisions
626    let p_index_new = index_new;
627
628    let uri_str = format!("{}/v1/index/indexes", configuration.base_path);
629    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
630
631    if let Some(ref user_agent) = configuration.user_agent {
632        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
633    }
634    if let Some(ref token) = configuration.bearer_access_token {
635        req_builder = req_builder.bearer_auth(token.to_owned());
636    };
637    req_builder = req_builder.json(&p_index_new);
638
639    let req = req_builder.build()?;
640    let resp = configuration.client.execute(req).await?;
641
642    let status = resp.status();
643    let content_type = resp
644        .headers()
645        .get("content-type")
646        .and_then(|v| v.to_str().ok())
647        .unwrap_or("application/octet-stream");
648    let content_type = super::ContentType::from(content_type);
649
650    if !status.is_client_error() && !status.is_server_error() {
651        let content = resp.text().await?;
652        match content_type {
653            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
654            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexEnqueued`"))),
655            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexEnqueued`")))),
656        }
657    } else {
658        let content = resp.text().await?;
659        let entity: Option<PostIndexIndexesError> = serde_json::from_str(&content).ok();
660        Err(Error::ResponseError(ResponseContent { status, content, entity }))
661    }
662}
663
664/// Writes documents into the caller's own index, keyed by the index's primary key: a document whose key is already present is REPLACED whole. The body is the dialect's own — an array of documents, or a single document — and each is stored verbatim, so a read gives back exactly what was written.  The index is CREATED when it is missing rather than refused, because a Meilisearch client writes before it configures.  The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header, so two orgs may both hold an index named \"messages\" and neither can see the other's documents. Without a validated principal the answer is 403 carrying the dialect's `invalid_api_key` body.  The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the documents are searchable when this answers, and a client that polls waitForTask resolves immediately.
665pub async fn post_index_indexes_by_uid_documents(configuration: &configuration::Configuration, uid: &str, request_body: Option<Vec<serde_json::Value>>) -> Result<models::IndexEnqueued, Error<PostIndexIndexesByUidDocumentsError>> {
666    // add a prefix to parameters to efficiently prevent name collisions
667    let p_uid = uid;
668    let p_request_body = request_body;
669
670    let uri_str = format!("{}/v1/index/indexes/{uid}/documents", configuration.base_path, uid=crate::apis::urlencode(p_uid));
671    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
672
673    if let Some(ref user_agent) = configuration.user_agent {
674        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
675    }
676    if let Some(ref token) = configuration.bearer_access_token {
677        req_builder = req_builder.bearer_auth(token.to_owned());
678    };
679    req_builder = req_builder.json(&p_request_body);
680
681    let req = req_builder.build()?;
682    let resp = configuration.client.execute(req).await?;
683
684    let status = resp.status();
685    let content_type = resp
686        .headers()
687        .get("content-type")
688        .and_then(|v| v.to_str().ok())
689        .unwrap_or("application/octet-stream");
690    let content_type = super::ContentType::from(content_type);
691
692    if !status.is_client_error() && !status.is_server_error() {
693        let content = resp.text().await?;
694        match content_type {
695            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
696            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexEnqueued`"))),
697            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexEnqueued`")))),
698        }
699    } else {
700        let content = resp.text().await?;
701        let entity: Option<PostIndexIndexesByUidDocumentsError> = serde_json::from_str(&content).ok();
702        Err(Error::ResponseError(ResponseContent { status, content, entity }))
703    }
704}
705
706/// Removes every named document from the caller's own index. The body is the dialect's own: a bare array of primary keys, which may be strings or numbers. A key that is not there is not an error, so a client reconciling its own corpus can send one list rather than checking each key first.  The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header. Without a validated principal the answer is 403 carrying the dialect's `invalid_api_key` body.  The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the documents are already gone when this answers.
707pub async fn post_index_indexes_by_uid_documents_delete_batch(configuration: &configuration::Configuration, uid: &str, request_body: Option<Vec<serde_json::Value>>) -> Result<models::IndexEnqueued, Error<PostIndexIndexesByUidDocumentsDeleteBatchError>> {
708    // add a prefix to parameters to efficiently prevent name collisions
709    let p_uid = uid;
710    let p_request_body = request_body;
711
712    let uri_str = format!("{}/v1/index/indexes/{uid}/documents/delete-batch", configuration.base_path, uid=crate::apis::urlencode(p_uid));
713    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
714
715    if let Some(ref user_agent) = configuration.user_agent {
716        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
717    }
718    if let Some(ref token) = configuration.bearer_access_token {
719        req_builder = req_builder.bearer_auth(token.to_owned());
720    };
721    req_builder = req_builder.json(&p_request_body);
722
723    let req = req_builder.build()?;
724    let resp = configuration.client.execute(req).await?;
725
726    let status = resp.status();
727    let content_type = resp
728        .headers()
729        .get("content-type")
730        .and_then(|v| v.to_str().ok())
731        .unwrap_or("application/octet-stream");
732    let content_type = super::ContentType::from(content_type);
733
734    if !status.is_client_error() && !status.is_server_error() {
735        let content = resp.text().await?;
736        match content_type {
737            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
738            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexEnqueued`"))),
739            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexEnqueued`")))),
740        }
741    } else {
742        let content = resp.text().await?;
743        let entity: Option<PostIndexIndexesByUidDocumentsDeleteBatchError> = serde_json::from_str(&content).ok();
744        Err(Error::ResponseError(ResponseContent { status, content, entity }))
745    }
746}
747
748/// Searches an index, forgiving typos.  Ranks the org's documents in one index against `q` and answers the matching documents whole, most relevant first. A prefix matches, so a partial word finds the documents containing it, and `filter` narrows the result to documents whose filterable attributes match — which is how a caller scopes results to one end user within its own org.  `estimatedTotalHits` is the dialect's name for the count; every hit is materialised here, so for this page it is exact. An index this org does not hold answers 404 carrying the dialect's `index_not_found`.
749pub async fn post_index_indexes_by_uid_search(configuration: &configuration::Configuration, uid: &str, index_query: models::IndexQuery) -> Result<models::IndexHits, Error<PostIndexIndexesByUidSearchError>> {
750    // add a prefix to parameters to efficiently prevent name collisions
751    let p_uid = uid;
752    let p_index_query = index_query;
753
754    let uri_str = format!("{}/v1/index/indexes/{uid}/search", configuration.base_path, uid=crate::apis::urlencode(p_uid));
755    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
756
757    if let Some(ref user_agent) = configuration.user_agent {
758        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
759    }
760    if let Some(ref token) = configuration.bearer_access_token {
761        req_builder = req_builder.bearer_auth(token.to_owned());
762    };
763    req_builder = req_builder.json(&p_index_query);
764
765    let req = req_builder.build()?;
766    let resp = configuration.client.execute(req).await?;
767
768    let status = resp.status();
769    let content_type = resp
770        .headers()
771        .get("content-type")
772        .and_then(|v| v.to_str().ok())
773        .unwrap_or("application/octet-stream");
774    let content_type = super::ContentType::from(content_type);
775
776    if !status.is_client_error() && !status.is_server_error() {
777        let content = resp.text().await?;
778        match content_type {
779            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
780            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexHits`"))),
781            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexHits`")))),
782        }
783    } else {
784        let content = resp.text().await?;
785        let entity: Option<PostIndexIndexesByUidSearchError> = serde_json::from_str(&content).ok();
786        Err(Error::ResponseError(ResponseContent { status, content, entity }))
787    }
788}
789
790/// The dialect's update spelling of the write above, and the same act: an upsert keyed by the index's primary key. The JS client's addDocuments and updateDocuments both reduce to this for whole documents, so both spellings are served and both behave identically.  The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header. Without a validated principal the answer is 403 carrying the dialect's `invalid_api_key` body.  The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the write is already applied when this answers.
791pub async fn put_index_indexes_by_uid_documents(configuration: &configuration::Configuration, uid: &str, request_body: Option<Vec<serde_json::Value>>) -> Result<models::IndexEnqueued, Error<PutIndexIndexesByUidDocumentsError>> {
792    // add a prefix to parameters to efficiently prevent name collisions
793    let p_uid = uid;
794    let p_request_body = request_body;
795
796    let uri_str = format!("{}/v1/index/indexes/{uid}/documents", configuration.base_path, uid=crate::apis::urlencode(p_uid));
797    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
798
799    if let Some(ref user_agent) = configuration.user_agent {
800        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
801    }
802    if let Some(ref token) = configuration.bearer_access_token {
803        req_builder = req_builder.bearer_auth(token.to_owned());
804    };
805    req_builder = req_builder.json(&p_request_body);
806
807    let req = req_builder.build()?;
808    let resp = configuration.client.execute(req).await?;
809
810    let status = resp.status();
811    let content_type = resp
812        .headers()
813        .get("content-type")
814        .and_then(|v| v.to_str().ok())
815        .unwrap_or("application/octet-stream");
816    let content_type = super::ContentType::from(content_type);
817
818    if !status.is_client_error() && !status.is_server_error() {
819        let content = resp.text().await?;
820        match content_type {
821            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
822            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexEnqueued`"))),
823            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IndexEnqueued`")))),
824        }
825    } else {
826        let content = resp.text().await?;
827        let entity: Option<PutIndexIndexesByUidDocumentsError> = serde_json::from_str(&content).ok();
828        Err(Error::ResponseError(ResponseContent { status, content, entity }))
829    }
830}
831