1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Provides access to the API endpoints for managing curation sets.
//!
//! Curation sets allow you to include or exclude specific documents for a given query.
//!
//! A `CurationSets` instance is created via the main `client.curation_sets()` method.
use crate::{Client, Error, execute_wrapper};
use ::std::borrow::Cow;
use typesense_codegen::{apis::curation_sets_api, models};
/// Provides methods for managing all of your Typesense curation sets.
///
/// This struct is created by calling `client.curation_sets()`.
pub struct CurationSets<'a> {
pub(super) client: &'a Client,
}
impl<'a> CurationSets<'a> {
/// Creates a new `CurationSets` instance.
#[inline]
pub(super) fn new(client: &'a Client) -> Self {
Self { client }
}
/// Retrieves the details of all curation sets.
pub async fn retrieve(
&self,
) -> Result<Vec<models::CurationSetSchema>, Error<curation_sets_api::RetrieveCurationSetsError>>
{
execute_wrapper!(self, curation_sets_api::retrieve_curation_sets)
}
/// Creates or updates an existing curation set.
///
/// # Arguments
/// * `name` - The name of the curation set to create or update.
/// * `schema` - A `CurationSetCreateSchema` object.
pub async fn upsert(
&self,
name: impl Into<Cow<'_, str>>,
schema: models::CurationSetCreateSchema<'_>,
) -> Result<models::CurationSetSchema, Error<curation_sets_api::UpsertCurationSetError>> {
let params = curation_sets_api::UpsertCurationSetParams {
curation_set_name: name.into(),
curation_set_create_schema: schema,
};
execute_wrapper!(self, curation_sets_api::upsert_curation_set, params)
}
}