Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/SynonymSetRetrieveSchema"
$ref: "#/components/schemas/SynonymSetSchema"
"404":
description: Synonym set not found
content:
Expand Down Expand Up @@ -735,7 +735,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/CurationSetRetrieveSchema"
$ref: "#/components/schemas/CurationSetSchema"
"404":
description: Curation set not found
content:
Expand Down Expand Up @@ -4432,8 +4432,6 @@ components:
items:
$ref: "#/components/schemas/SynonymSetSchema"

SynonymSetRetrieveSchema:
$ref: "#/components/schemas/SynonymSetCreateSchema"

SynonymSetDeleteSchema:
type: object
Expand Down Expand Up @@ -4595,9 +4593,6 @@ components:
type: string
description: document id that should be excluded from the search results.

CurationSetRetrieveSchema:
$ref: '#/components/schemas/CurationSetCreateSchema'

CurationSetDeleteSchema:
type: object
required:
Expand Down
8 changes: 2 additions & 6 deletions preprocessed_openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/SynonymSetRetrieveSchema'
$ref: '#/components/schemas/SynonymSetSchema'
'404':
description: Synonym set not found
content:
Expand Down Expand Up @@ -1118,7 +1118,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/CurationSetRetrieveSchema'
$ref: '#/components/schemas/CurationSetSchema'
'404':
description: Curation set not found
content:
Expand Down Expand Up @@ -4924,8 +4924,6 @@ components:
description: Array of synonym sets
items:
$ref: '#/components/schemas/SynonymSetSchema'
SynonymSetRetrieveSchema:
$ref: '#/components/schemas/SynonymSetCreateSchema'
SynonymSetDeleteSchema:
type: object
required:
Expand Down Expand Up @@ -5074,8 +5072,6 @@ components:
id:
type: string
description: document id that should be excluded from the search results.
CurationSetRetrieveSchema:
$ref: '#/components/schemas/CurationSetCreateSchema'
CurationSetDeleteSchema:
type: object
required:
Expand Down
57 changes: 57 additions & 0 deletions typesense/src/client/curation_set/item.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//! Provides access to the API endpoints for managing a curation set item.
//!
//! Curation sets allow you to include or exclude specific documents for a given query.
//!
//! A `CurationSetItem` instance is created via the main `client.curation_set("curation_set_name").item("item_id")` method.
use crate::{Client, Error, execute_wrapper};
use typesense_codegen::{
apis::curation_sets_api::{self, RetrieveCurationSetItemParams},
models,
};

/// Provides methods for managing a curation set item.
///
/// This struct is created by calling `client.curation_set("curation_set_name").item("item_id")`.
pub struct CurationSetItem<'a> {
pub(super) client: &'a Client,
pub(super) curation_set_name: &'a str,
pub(super) item_id: &'a str,
}

impl<'a> CurationSetItem<'a> {
/// Creates a new `CurationSetItem` instance.
#[inline]
pub(super) fn new(client: &'a Client, curation_set_name: &'a str, item_id: &'a str) -> Self {
Self {
client,
curation_set_name,
item_id,
}
}

/// Retrieve this curation set item.
pub async fn retrieve(
&self,
) -> Result<models::CurationItemSchema, Error<curation_sets_api::RetrieveCurationSetItemError>>
{
let params = RetrieveCurationSetItemParams {
curation_set_name: self.curation_set_name.into(),
item_id: self.item_id.into(),
};
execute_wrapper!(self, curation_sets_api::retrieve_curation_set_item, params)
}

/// Delete this curation set item.
pub async fn delete(
&self,
) -> Result<
models::CurationItemDeleteSchema,
Error<curation_sets_api::DeleteCurationSetItemError>,
> {
let params = curation_sets_api::DeleteCurationSetItemParams {
curation_set_name: self.curation_set_name.into(),
item_id: self.item_id.into(),
};
execute_wrapper!(self, curation_sets_api::delete_curation_set_item, params)
}
}
64 changes: 64 additions & 0 deletions typesense/src/client/curation_set/items.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//! Provides access to the API endpoints for managing items of a curation set.
//!
//! Curation sets allow you to include or exclude specific documents for a given query.
//!
//! A `CurationSetItems` instance is created via the main `client.curation_set("curation_set_name").items()` method.

use ::std::borrow::Cow;

use crate::{Client, Error, execute_wrapper};
use typesense_codegen::{
apis::curation_sets_api::{self, RetrieveCurationSetItemsParams},
models,
};

/// Provides methods for managing items of a curation set.
///
/// This struct is created by calling `client.curation_set("curation_set_name").items()`.
pub struct CurationSetItems<'a> {
pub(super) client: &'a Client,
pub(super) curation_set_name: &'a str,
}

impl<'a> CurationSetItems<'a> {
/// Creates a new `CurationSetItems` instance.
#[inline]
pub(super) fn new(client: &'a Client, curation_set_name: &'a str) -> Self {
Self {
client,
curation_set_name,
}
}

/// Retrieves all the items of this curation set.
pub async fn retrieve(
&self,
) -> Result<
Vec<models::CurationItemSchema>,
Error<curation_sets_api::RetrieveCurationSetItemsError>,
> {
let params = RetrieveCurationSetItemsParams {
curation_set_name: self.curation_set_name.into(),
};
execute_wrapper!(self, curation_sets_api::retrieve_curation_set_items, params)
}

/// Creates or updates an existing item of a curation set.
///
/// # Arguments
/// * `item_id` - The id of the curation set item to create or update.
/// * `schema` - A `CurationItemCreateSchema` object.
pub async fn upsert(
&self,
item_id: impl Into<Cow<'_, str>>,
schema: models::CurationItemCreateSchema<'_>,
) -> Result<models::CurationItemSchema, Error<curation_sets_api::UpsertCurationSetItemError>>
{
let params = curation_sets_api::UpsertCurationSetItemParams {
item_id: item_id.into(),
curation_set_name: self.curation_set_name.into(),
curation_item_create_schema: schema,
};
execute_wrapper!(self, curation_sets_api::upsert_curation_set_item, params)
}
}
68 changes: 68 additions & 0 deletions typesense/src/client/curation_set/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//! Provides access to the API endpoints for managing a specific curation set.
//!
//! Curation sets allow you to include or exclude specific documents for a given query.
//!
//! A `CurationSet` instance is created via the main `client.curation_set("curation_set_name")` method.

mod item;
mod items;

use crate::{Client, Error, execute_wrapper};
use item::CurationSetItem;
use items::CurationSetItems;
use typesense_codegen::{
apis::curation_sets_api::{self, RetrieveCurationSetParams},
models,
};

/// Provides methods for managing a specific curation set.
///
/// This struct is created by calling `client.curation_set("curation_set_name")`.
pub struct CurationSet<'a> {
pub(super) client: &'a Client,
pub(super) curation_set_name: &'a str,
}

impl<'a> CurationSet<'a> {
/// Creates a new `CurationSet` instance.
#[inline]
pub(super) fn new(client: &'a Client, curation_set_name: &'a str) -> Self {
Self {
client,
curation_set_name,
}
}

/// Provides access to the items of this curation set.
#[inline]
pub fn items(&self) -> CurationSetItems<'_> {
CurationSetItems::new(self.client, self.curation_set_name)
}

/// Provides access to this specific item of this curation set.
#[inline]
pub fn item(&self, item_id: &'a str) -> CurationSetItem<'a> {
CurationSetItem::new(self.client, self.curation_set_name, item_id)
}

/// Retrieves the details of this curation set.
pub async fn retrieve(
&self,
) -> Result<models::CurationSetSchema, Error<curation_sets_api::RetrieveCurationSetError>> {
let params = RetrieveCurationSetParams {
curation_set_name: self.curation_set_name.into(),
};
execute_wrapper!(self, curation_sets_api::retrieve_curation_set, params)
}

/// Delete this curation set.
pub async fn delete(
&self,
) -> Result<models::CurationSetDeleteSchema, Error<curation_sets_api::DeleteCurationSetError>>
{
let params = curation_sets_api::DeleteCurationSetParams {
curation_set_name: self.curation_set_name.into(),
};
execute_wrapper!(self, curation_sets_api::delete_curation_set, params)
}
}
49 changes: 49 additions & 0 deletions typesense/src/client/curation_sets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
}
}
Loading
Loading