diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 184b3e92..414d0479 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: ] services: typesense: - image: typesense/typesense:30.0.rc26 + image: typesense/typesense:30.0.rca33 ports: - 8108:8108/tcp volumes: @@ -35,6 +35,8 @@ jobs: TYPESENSE_API_KEY: 'xyz' TYPESENSE_ENABLE_CORS: true TYPESENSE_URL: 'http://localhost:8108' + TYPESENSE_ENABLE_SEARCH_ANALYTICS: 'true' + TYPESENSE_ANALYTICS_DIR: '/analytics-data' steps: - uses: actions/checkout@v4 - name: Cache .cargo and target diff --git a/compose.yml b/compose.yml index 61065fc7..f12a4369 100644 --- a/compose.yml +++ b/compose.yml @@ -1,9 +1,9 @@ services: typesense: - image: typesense/typesense:30.0.rc26 + image: typesense/typesense:30.0.rca33 restart: on-failure ports: - '8108:8108' volumes: - ./typesense-data:/data - command: '--data-dir /data --api-key=xyz --enable-cors' + command: '--data-dir /data --api-key=xyz --enable-cors --enable-search-analytics=true --analytics-dir=/analytics-data' diff --git a/openapi.yml b/openapi.yml index e1a279de..b9d510c8 100644 --- a/openapi.yml +++ b/openapi.yml @@ -502,7 +502,7 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiResponse" - + put: tags: - synonyms @@ -650,7 +650,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/SynonymItemSchema" + $ref: "#/components/schemas/SynonymItemUpsertSchema" required: true responses: "200": @@ -1647,7 +1647,7 @@ paths: {"log-slow-requests-time-ms": 2000} responses: '200': - description: Compacting the on-disk database succeeded. + description: Toggle Slow Request Log database succeeded. content: application/json: schema: @@ -1805,7 +1805,7 @@ paths: - $ref: "#/components/schemas/AnalyticsRule" - type: array items: - anyOf: + oneOf: - $ref: "#/components/schemas/AnalyticsRule" - type: object properties: @@ -3975,8 +3975,7 @@ components: name: type: string type: - type: string - enum: [popular_queries, nohits_queries, counter, log] + $ref: "#/components/schemas/AnalyticsRuleType" collection: type: string event_type: @@ -4001,6 +4000,9 @@ components: type: string weight: type: integer + AnalyticsRuleType: + type: string + enum: [popular_queries, nohits_queries, counter, log] AnalyticsRuleUpdate: type: object description: Fields allowed to update on an analytics rule @@ -4041,7 +4043,7 @@ components: query_counter_events: { type: integer } doc_log_events: { type: integer } doc_counter_events: { type: integer } - + APIStatsResponse: type: object properties: @@ -4364,15 +4366,11 @@ components: type: string description: ID of the deleted NL search model - SynonymItemSchema: + SynonymItemUpsertSchema: type: object required: - - id - synonyms properties: - id: - type: string - description: Unique identifier for the synonym item synonyms: type: array description: Array of words that should be considered as synonyms @@ -4390,6 +4388,17 @@ components: items: type: string + SynonymItemSchema: + allOf: + - type: object + required: + - id + properties: + id: + type: string + description: Unique identifier for the synonym item + - $ref: "#/components/schemas/SynonymItemUpsertSchema" + SynonymSetCreateSchema: type: object required: diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index fad52d63..48702e16 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -1036,7 +1036,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SynonymItemSchema' + $ref: '#/components/schemas/SynonymItemUpsertSchema' responses: '200': description: Synonym item successfully created/updated @@ -2003,7 +2003,7 @@ paths: x-rust-has-borrowed-data: true responses: '200': - description: Compacting the on-disk database succeeded. + description: Toggle Slow Request Log database succeeded. content: application/json: schema: @@ -2528,7 +2528,7 @@ paths: - $ref: '#/components/schemas/AnalyticsRule' - type: array items: - anyOf: + oneOf: - $ref: '#/components/schemas/AnalyticsRule' - type: object properties: @@ -4441,12 +4441,7 @@ components: name: type: string type: - type: string - enum: - - popular_queries - - nohits_queries - - counter - - log + $ref: '#/components/schemas/AnalyticsRuleType' collection: type: string event_type: @@ -4474,6 +4469,13 @@ components: type: integer x-rust-has-borrowed-data: true x-rust-has-borrowed-data: true + AnalyticsRuleType: + type: string + enum: + - popular_queries + - nohits_queries + - counter + - log AnalyticsRuleUpdate: type: object description: Fields allowed to update on an analytics rule @@ -4859,15 +4861,11 @@ components: id: type: string description: ID of the deleted NL search model - SynonymItemSchema: + SynonymItemUpsertSchema: type: object required: - - id - synonyms properties: - id: - type: string - description: Unique identifier for the synonym item synonyms: type: array description: Array of words that should be considered as synonyms @@ -4885,6 +4883,16 @@ components: items: type: string x-rust-has-borrowed-data: true + SynonymItemSchema: + allOf: + - type: object + required: + - id + properties: + id: + type: string + description: Unique identifier for the synonym item + - $ref: '#/components/schemas/SynonymItemUpsertSchema' SynonymSetCreateSchema: type: object required: diff --git a/typesense/src/client/analytics/events.rs b/typesense/src/client/analytics/events.rs new file mode 100644 index 00000000..e131c7b6 --- /dev/null +++ b/typesense/src/client/analytics/events.rs @@ -0,0 +1,48 @@ +//! Provides access to the API endpoint for posting analytics events. +//! +//! An `Events` instance is created via the `client.analytics().events()` method. + +use crate::{Client, Error, execute_wrapper, models}; +use typesense_codegen::apis::analytics_api; + +/// Provides methods for interacting with analytics events. +/// +/// This struct is created by calling `client.analytics().events()`. +pub struct Events<'a> { + pub(super) client: &'a Client, +} + +impl<'a> Events<'a> { + /// Creates a new `Events` instance. + #[inline] + pub(super) fn new(client: &'a Client) -> Self { + Self { client } + } + + /// Posts an analytics event for tracking user behavior. + /// + /// # Arguments + /// * `schema` - An `AnalyticsEvent` object representing the event. + pub async fn create( + &self, + schema: models::AnalyticsEvent<'_>, + ) -> Result> + { + let params = analytics_api::CreateAnalyticsEventParams { + analytics_event: schema, + }; + execute_wrapper!(self, analytics_api::create_analytics_event, params) + } + + /// Retrieve the most recent analytics events for a specific user and analytics rule name. + /// + /// # Arguments + /// * `params` - `GetAnalyticsEventsParams`. + pub async fn retrieve( + &self, + params: models::GetAnalyticsEventsParams<'_>, + ) -> Result> + { + execute_wrapper!(self, analytics_api::get_analytics_events, params) + } +} diff --git a/typesense/src/client/analytics/mod.rs b/typesense/src/client/analytics/mod.rs new file mode 100644 index 00000000..021e5d53 --- /dev/null +++ b/typesense/src/client/analytics/mod.rs @@ -0,0 +1,46 @@ +//! Provides access to the analytics API endpoints for managing rules and posting events. +//! +//! An `Analytics` instance is created via the main `client.analytics()` method. +mod events; +mod rule; +mod rules; +use crate::Client; +use events::Events; +use rule::Rule; +use rules::Rules; + +/// Provides methods for interacting with Typesense analytics rules and events. +/// +/// This struct is created by calling `client.analytics()`. +pub struct Analytics<'a> { + pub(super) client: &'a Client, +} + +impl<'a> Analytics<'a> { + /// Creates a new `Analytics` instance. + #[inline] + pub(super) fn new(client: &'a Client) -> Self { + Self { client } + } + + /// Provides access to endpoints for managing a collection of analytics rules. + #[inline] + pub fn rules(&self) -> Rules<'a> { + Rules::new(self.client) + } + + /// Provides access to endpoints for managing a single analytics rule. + /// + /// # Arguments + /// * `rule_name` - The name of the analytics rule to manage. + #[inline] + pub fn rule(&self, rule_name: &'a str) -> Rule<'a> { + Rule::new(self.client, rule_name) + } + + /// Provides access to the endpoint for creating analytics events. + #[inline] + pub fn events(&self) -> Events<'a> { + Events::new(self.client) + } +} diff --git a/typesense/src/client/analytics/rule.rs b/typesense/src/client/analytics/rule.rs new file mode 100644 index 00000000..d3898f12 --- /dev/null +++ b/typesense/src/client/analytics/rule.rs @@ -0,0 +1,42 @@ +//! Provides access to the API endpoints for managing a single analytics rule. +//! +//! An `Rule` instance is created via the `client.analytics().rule("rule_name")` method. + +use crate::{Client, Error, execute_wrapper, models}; +use typesense_codegen::apis::analytics_api; + +/// Provides methods for interacting with a specific analytics rule. +/// +/// This struct is created by calling `client.analytics().rule("rule_name")`. +pub struct Rule<'a> { + pub(super) client: &'a Client, + pub(super) rule_name: &'a str, +} + +impl<'a> Rule<'a> { + /// Creates a new `Rule` instance for a specific rule name. + #[inline] + pub(super) fn new(client: &'a Client, rule_name: &'a str) -> Self { + Self { client, rule_name } + } + + /// Retrieves the details of this specific analytics rule. + pub async fn retrieve( + &self, + ) -> Result> { + let params = analytics_api::RetrieveAnalyticsRuleParams { + rule_name: self.rule_name.into(), + }; + execute_wrapper!(self, analytics_api::retrieve_analytics_rule, params) + } + + /// Permanently deletes this specific analytics rule. + pub async fn delete( + &self, + ) -> Result> { + let params = analytics_api::DeleteAnalyticsRuleParams { + rule_name: self.rule_name.into(), + }; + execute_wrapper!(self, analytics_api::delete_analytics_rule, params) + } +} diff --git a/typesense/src/client/analytics/rules.rs b/typesense/src/client/analytics/rules.rs new file mode 100644 index 00000000..d6b4f45f --- /dev/null +++ b/typesense/src/client/analytics/rules.rs @@ -0,0 +1,106 @@ +//! Provides access to the API endpoints for managing analytics rules. +//! +//! An `Rules` instance is created via the `Client::analytics().rules()` method. + +use crate::{Client, Error, execute_wrapper, models}; +use ::std::borrow::Cow; +use reqwest::StatusCode; +use serde_json::json; +use typesense_codegen::apis::{ResponseContent, analytics_api}; + +/// Provides methods for interacting with a collection of analytics rules. +/// +/// This struct is created by calling `client.analytics().rules()`. +pub struct Rules<'a> { + pub(super) client: &'a Client, +} + +impl<'a> Rules<'a> { + /// Creates a new `Rules` instance. + #[inline] + pub(super) fn new(client: &'a Client) -> Self { + Self { client } + } + + /// Creates a new analytics rule. + /// + /// # Arguments + /// * `schema` - An `AnalyticsRuleCreate` object describing the rule to be created. + pub async fn create( + &self, + schema: models::AnalyticsRuleCreate<'_>, + ) -> Result> { + let params = analytics_api::CreateAnalyticsRuleParams { + create_analytics_rule_request: models::CreateAnalyticsRuleRequest::AnalyticsRuleCreate( + Box::new(schema), + ), + }; + match execute_wrapper!(self, analytics_api::create_analytics_rule, params)? { + models::CreateAnalyticsRule200Response::AnalyticsRule(rule) => Ok(*rule), + _ => Err(Error::Api(typesense_codegen::apis::Error::ResponseError( + ResponseContent { + status: StatusCode::OK, + content: "Unexpected response type".to_owned(), + entity: Some(analytics_api::CreateAnalyticsRuleError::UnknownValue( + json!("Expected single AnalyticsRule, not a list"), + )), + }, + ))), + } + } + + /// Creates multiple analytics rules in a single request. + /// + /// # Arguments + /// * `schema` - A `Vec` describing the rules to be created. + pub async fn create_many( + &self, + schema: Vec>, + ) -> Result< + Vec, + Error, + > { + let params = analytics_api::CreateAnalyticsRuleParams { + create_analytics_rule_request: models::CreateAnalyticsRuleRequest::Array(schema), + }; + match execute_wrapper!(self, analytics_api::create_analytics_rule, params)? { + models::CreateAnalyticsRule200Response::Array(rules) => Ok(rules), + _ => Err(Error::Api(typesense_codegen::apis::Error::ResponseError( + ResponseContent { + status: StatusCode::OK, + content: "Unexpected response type".to_owned(), + entity: Some(analytics_api::CreateAnalyticsRuleError::UnknownValue( + json!("Expected a list of AnalyticsRule, not a single rule"), + )), + }, + ))), + } + } + + /// Creates or updates an analytics rule with the given name. + /// + /// # Arguments + /// * `rule_name` - The name of the analytics rule to create or update. + /// * `schema` - An `AnalyticsRuleUpsertSchema` object with the rule's parameters. + pub async fn upsert( + &self, + rule_name: impl Into>, + schema: models::AnalyticsRuleUpdate<'_>, + ) -> Result> { + let params = analytics_api::UpsertAnalyticsRuleParams { + rule_name: rule_name.into(), + analytics_rule_update: schema, + }; + execute_wrapper!(self, analytics_api::upsert_analytics_rule, params) + } + + /// Retrieves the details of all analytics rules. + pub async fn retrieve( + &self, + params: Option>, + ) -> Result, Error> { + let params = + params.unwrap_or(analytics_api::RetrieveAnalyticsRulesParams { rule_tag: None }); + execute_wrapper!(self, analytics_api::retrieve_analytics_rules, params) + } +} diff --git a/typesense/src/client/mod.rs b/typesense/src/client/mod.rs index f42cfb71..a20b4d89 100644 --- a/typesense/src/client/mod.rs +++ b/typesense/src/client/mod.rs @@ -108,6 +108,7 @@ //! ``` mod alias; mod aliases; +mod analytics; mod collection; mod collections; mod conversations; @@ -124,6 +125,7 @@ mod stopwords; use crate::{Error, traits::Document}; use alias::Alias; use aliases::Aliases; +use analytics::Analytics; use collection::Collection; use collections::Collections; use conversations::Conversations; @@ -417,6 +419,31 @@ impl Client { Alias::new(self, alias_name) } + /// Provides access to the analytics API endpoints. + /// + /// # Example + /// ```no_run + /// # #[cfg(not(target_family = "wasm"))] + /// # { + /// # use typesense::Client; + /// # + /// # #[tokio::main] + /// # async fn main() -> Result<(), Box> { + /// # let client = Client::builder() + /// # .nodes(vec!["http://localhost:8108"]) + /// # .api_key("xyz") + /// # .build() + /// # .unwrap(); + /// let all_rules = client.analytics().rules().retrieve(None).await.unwrap(); + /// # Ok(()) + /// # } + /// # } + /// ``` + #[inline] + pub fn analytics(&self) -> Analytics<'_> { + Analytics::new(self) + } + /// Provides access to API endpoints for managing collections like `create()` and `retrieve()`. /// # Example /// ```no_run diff --git a/typesense/src/models/mod.rs b/typesense/src/models/mod.rs index 3902ecbb..aaa3ad7e 100644 --- a/typesense/src/models/mod.rs +++ b/typesense/src/models/mod.rs @@ -5,6 +5,9 @@ mod scoped_key_parameters; pub use document_index_parameters::*; pub use scoped_key_parameters::*; -pub use typesense_codegen::{apis::operations_api::TakeSnapshotParams, models::*}; +pub use typesense_codegen::{ + apis::{analytics_api::GetAnalyticsEventsParams, operations_api::TakeSnapshotParams}, + models::*, +}; pub use multi_search::MultiSearchBody; diff --git a/typesense/tests/client/analytics_test.rs b/typesense/tests/client/analytics_test.rs new file mode 100644 index 00000000..b6f76a2c --- /dev/null +++ b/typesense/tests/client/analytics_test.rs @@ -0,0 +1,233 @@ +use std::vec; + +use super::{get_client, new_id}; +use typesense::models::{ + self, AnalyticsEvent, AnalyticsEventData, AnalyticsRuleCreate, + AnalyticsRuleType::PopularQueries, CollectionSchema, Field, +}; + +async fn logic_test_analytics_rules_and_events_lifecycle() { + let client = get_client(); + let rule_name_1 = new_id("product_clicks"); + let rule_name_2 = new_id("product_clicks"); + let rule_name_3 = new_id("product_clicks"); + let collection_name = new_id("products"); + let queries_collection_name = new_id("queries"); + + // Create a Collection + let schema = CollectionSchema { + name: collection_name.as_str().into(), + fields: vec![ + Field { + name: "title".into(), + r#type: "string".into(), + ..Default::default() + }, + Field { + name: "popularity".into(), + r#type: "int32".into(), + optional: Some(true), + ..Default::default() + }, + ], + ..Default::default() + }; + + let queries_collection_schema = CollectionSchema { + name: queries_collection_name.as_str().into(), + fields: vec![ + Field { + name: "q".into(), + r#type: "string".into(), + ..Default::default() + }, + Field { + name: "count".into(), + r#type: "int32".into(), + optional: Some(true), + ..Default::default() + }, + ], + ..Default::default() + }; + + let create_result = client.collections().create(schema).await; + + assert!(create_result.is_ok(), "Failed to create collection"); + let created_collection = create_result.unwrap(); + assert_eq!(created_collection.name, collection_name); + + let create_result_2 = client.collections().create(queries_collection_schema).await; + assert!( + create_result_2.is_ok(), + "Failed to create queries collection" + ); + + // Create a Rule + let create_schema = AnalyticsRuleCreate { + name: rule_name_1.as_str().into(), + r#type: PopularQueries, + collection: collection_name.as_str().into(), + event_type: "search".into(), + rule_tag: Some("homepage".into()), + params: Some(Box::new(models::AnalyticsRuleCreateParams { + destination_collection: Some(queries_collection_name.as_str().into()), + limit: Some(100), + capture_search_requests: Some(true), + ..Default::default() + })), + }; + + let create_result = client + .analytics() + .rules() + .create(create_schema.clone()) + .await; + assert!(create_result.is_ok(), "Failed to create analytics rule"); + let created_rule = create_result.unwrap(); + assert_eq!(created_rule.name, rule_name_1); + assert_eq!(created_rule.r#type, PopularQueries); + assert_eq!(created_rule.params, create_schema.params); + + let create_many_result = client + .analytics() + .rules() + .create_many(vec![ + AnalyticsRuleCreate { + name: rule_name_2.as_str().into(), + r#type: PopularQueries, + collection: collection_name.as_str().into(), + event_type: "search".into(), + rule_tag: Some("homepage".into()), + params: Some(Box::new(models::AnalyticsRuleCreateParams { + destination_collection: Some(queries_collection_name.as_str().into()), + limit: Some(25), + ..Default::default() + })), + }, + AnalyticsRuleCreate { + name: rule_name_3.as_str().into(), + r#type: PopularQueries, + collection: collection_name.as_str().into(), + event_type: "search".into(), + rule_tag: Some("homepage".into()), + params: Some(Box::new(models::AnalyticsRuleCreateParams { + destination_collection: Some(queries_collection_name.as_str().into()), + limit: Some(50), + ..Default::default() + })), + }, + ]) + .await; + println!("{:?}", create_many_result); + assert!( + create_many_result.is_ok(), + "Failed to create analytics rule" + ); + let created_rules = create_many_result.unwrap(); + if let models::CreateAnalyticsRule200ResponseOneOfInner::AnalyticsRule(rule) = &created_rules[0] + { + assert_eq!(rule.name, rule_name_2); + } else { + panic!("Expected AnalyticsRule variant"); + } + + if let models::CreateAnalyticsRule200ResponseOneOfInner::AnalyticsRule(rule) = &created_rules[1] + { + assert_eq!(rule.name, rule_name_3); + } else { + panic!("Expected AnalyticsRule variant"); + } + + // Retrieve the specific Rule + let retrieve_one_result = client.analytics().rule(&rule_name_1).retrieve().await; + assert!( + retrieve_one_result.is_ok(), + "Failed to retrieve the newly created rule." + ); + let retrieved_rule = retrieve_one_result.unwrap(); + assert_eq!(retrieved_rule.name, rule_name_1); + + // Retrieve all Rules + let retrieve_all_result = client.analytics().rules().retrieve(None).await; + assert!( + retrieve_all_result.is_ok(), + "Failed to retrieve the list of rules." + ); + let all_rules_response = retrieve_all_result.unwrap(); + assert!( + all_rules_response.len() >= 1, + "Expected at least one rule to be present." + ); + assert!(all_rules_response.iter().any(|r| r.name == rule_name_1)); + + // Sending click events + let event_result = client + .analytics() + .events() + .create(AnalyticsEvent { + name: rule_name_1.as_str().into(), + event_type: "search".into(), + data: Box::new(AnalyticsEventData { + q: Some("running shoes".into()), + user_id: Some("".into()), + ..Default::default() + }), + }) + .await; + assert!(event_result.is_ok(), "Failed to send the click event."); + assert!(event_result.unwrap().ok, "Unsuccessful click event."); + + // Retrieve events + let retrieve_events_result = client + .analytics() + .events() + .retrieve(models::GetAnalyticsEventsParams { + name: rule_name_1.as_str().into(), + user_id: "111112".into(), + n: 10, + }) + .await; + + assert!( + retrieve_events_result.is_ok(), + "Failed to retrieve analytics events." + ); + + // Delete a Rule + let delete_result = client.analytics().rule(&rule_name_1).delete().await; + assert!(delete_result.is_ok(), "Failed to delete rule"); + let deleted_response = delete_result.unwrap(); + assert_eq!(deleted_response.name, rule_name_1); + + // Verify deletion + let get_after_delete_result = client.analytics().rule(&rule_name_1).retrieve().await; + assert!( + get_after_delete_result.is_err(), + "Rule should not exist after deletion" + ); +} + +#[cfg(all(test, not(target_arch = "wasm32")))] +mod tokio_test { + use super::*; + + #[tokio::test] + async fn test_analytics_rules_and_events_lifecycle() { + logic_test_analytics_rules_and_events_lifecycle().await; + } +} + +#[cfg(all(test, target_arch = "wasm32"))] +mod wasm_test { + use super::*; + use wasm_bindgen_test::wasm_bindgen_test; + + wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + + #[wasm_bindgen_test] + async fn test_analytics_rules_and_events_lifecycle() { + console_error_panic_hook::set_once(); + logic_test_analytics_rules_and_events_lifecycle().await; + } +} diff --git a/typesense/tests/client/mod.rs b/typesense/tests/client/mod.rs index 41882a93..e3c14e76 100644 --- a/typesense/tests/client/mod.rs +++ b/typesense/tests/client/mod.rs @@ -1,4 +1,5 @@ mod aliases_test; +mod analytics_test; mod client_test; mod collections_test; mod conversation_models_test; diff --git a/typesense_codegen/.openapi-generator/FILES b/typesense_codegen/.openapi-generator/FILES index 108b0e28..3b12b38f 100644 --- a/typesense_codegen/.openapi-generator/FILES +++ b/typesense_codegen/.openapi-generator/FILES @@ -8,6 +8,7 @@ docs/AnalyticsEventsResponseEventsInner.md docs/AnalyticsRule.md docs/AnalyticsRuleCreate.md docs/AnalyticsRuleCreateParams.md +docs/AnalyticsRuleType.md docs/AnalyticsRuleUpdate.md docs/AnalyticsStatus.md docs/ApiKey.md @@ -29,7 +30,7 @@ docs/ConversationModelUpdateSchema.md docs/ConversationsApi.md docs/CreateAnalyticsRule200Response.md docs/CreateAnalyticsRule200ResponseOneOfInner.md -docs/CreateAnalyticsRule200ResponseOneOfInnerAnyOf.md +docs/CreateAnalyticsRule200ResponseOneOfInnerOneOf.md docs/CreateAnalyticsRuleRequest.md docs/CurationExclude.md docs/CurationInclude.md @@ -106,6 +107,7 @@ docs/StopwordsSetsRetrieveAllSchema.md docs/SuccessStatus.md docs/SynonymItemDeleteSchema.md docs/SynonymItemSchema.md +docs/SynonymItemUpsertSchema.md docs/SynonymSetCreateSchema.md docs/SynonymSetDeleteSchema.md docs/SynonymSetSchema.md @@ -139,6 +141,7 @@ src/models/analytics_events_response_events_inner.rs src/models/analytics_rule.rs src/models/analytics_rule_create.rs src/models/analytics_rule_create_params.rs +src/models/analytics_rule_type.rs src/models/analytics_rule_update.rs src/models/analytics_status.rs src/models/api_key.rs @@ -158,7 +161,7 @@ src/models/conversation_model_schema.rs src/models/conversation_model_update_schema.rs src/models/create_analytics_rule_200_response.rs src/models/create_analytics_rule_200_response_one_of_inner.rs -src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs +src/models/create_analytics_rule_200_response_one_of_inner_one_of.rs src/models/create_analytics_rule_request.rs src/models/curation_exclude.rs src/models/curation_include.rs @@ -226,6 +229,7 @@ src/models/stopwords_sets_retrieve_all_schema.rs src/models/success_status.rs src/models/synonym_item_delete_schema.rs src/models/synonym_item_schema.rs +src/models/synonym_item_upsert_schema.rs src/models/synonym_set_create_schema.rs src/models/synonym_set_delete_schema.rs src/models/synonym_set_schema.rs diff --git a/typesense_codegen/README.md b/typesense_codegen/README.md index 250ae463..dd7acf1f 100644 --- a/typesense_codegen/README.md +++ b/typesense_codegen/README.md @@ -9,7 +9,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat - API version: 30.0 - Package version: 30.0 -- Generator version: 7.18.0-SNAPSHOT +- Generator version: 7.14.0 - Build package: `org.openapitools.codegen.languages.RustClientCodegen` ## Installation @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description - [AnalyticsRule](docs/AnalyticsRule.md) - [AnalyticsRuleCreate](docs/AnalyticsRuleCreate.md) - [AnalyticsRuleCreateParams](docs/AnalyticsRuleCreateParams.md) + - [AnalyticsRuleType](docs/AnalyticsRuleType.md) - [AnalyticsRuleUpdate](docs/AnalyticsRuleUpdate.md) - [AnalyticsStatus](docs/AnalyticsStatus.md) - [ApiKey](docs/ApiKey.md) @@ -136,7 +137,7 @@ Class | Method | HTTP request | Description - [ConversationModelUpdateSchema](docs/ConversationModelUpdateSchema.md) - [CreateAnalyticsRule200Response](docs/CreateAnalyticsRule200Response.md) - [CreateAnalyticsRule200ResponseOneOfInner](docs/CreateAnalyticsRule200ResponseOneOfInner.md) - - [CreateAnalyticsRule200ResponseOneOfInnerAnyOf](docs/CreateAnalyticsRule200ResponseOneOfInnerAnyOf.md) + - [CreateAnalyticsRule200ResponseOneOfInnerOneOf](docs/CreateAnalyticsRule200ResponseOneOfInnerOneOf.md) - [CreateAnalyticsRuleRequest](docs/CreateAnalyticsRuleRequest.md) - [CurationExclude](docs/CurationExclude.md) - [CurationInclude](docs/CurationInclude.md) @@ -203,6 +204,7 @@ Class | Method | HTTP request | Description - [SuccessStatus](docs/SuccessStatus.md) - [SynonymItemDeleteSchema](docs/SynonymItemDeleteSchema.md) - [SynonymItemSchema](docs/SynonymItemSchema.md) + - [SynonymItemUpsertSchema](docs/SynonymItemUpsertSchema.md) - [SynonymSetCreateSchema](docs/SynonymSetCreateSchema.md) - [SynonymSetDeleteSchema](docs/SynonymSetDeleteSchema.md) - [SynonymSetSchema](docs/SynonymSetSchema.md) diff --git a/typesense_codegen/docs/AnalyticsRule.md b/typesense_codegen/docs/AnalyticsRule.md index 3e28b5cf..b559b76d 100644 --- a/typesense_codegen/docs/AnalyticsRule.md +++ b/typesense_codegen/docs/AnalyticsRule.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **String** | | -**r#type** | **String** | | +**r#type** | [**models::AnalyticsRuleType**](AnalyticsRuleType.md) | | **collection** | **String** | | **event_type** | **String** | | **rule_tag** | Option<**String**> | | [optional] diff --git a/typesense_codegen/docs/AnalyticsRuleCreate.md b/typesense_codegen/docs/AnalyticsRuleCreate.md index 9fff80dc..f71b5bda 100644 --- a/typesense_codegen/docs/AnalyticsRuleCreate.md +++ b/typesense_codegen/docs/AnalyticsRuleCreate.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **String** | | -**r#type** | **String** | | +**r#type** | [**models::AnalyticsRuleType**](AnalyticsRuleType.md) | | **collection** | **String** | | **event_type** | **String** | | **rule_tag** | Option<**String**> | | [optional] diff --git a/typesense_codegen/docs/AnalyticsRuleType.md b/typesense_codegen/docs/AnalyticsRuleType.md new file mode 100644 index 00000000..b4072442 --- /dev/null +++ b/typesense_codegen/docs/AnalyticsRuleType.md @@ -0,0 +1,15 @@ +# AnalyticsRuleType + +## Enum Variants + +| Name | Value | +|---- | -----| +| PopularQueries | popular_queries | +| NohitsQueries | nohits_queries | +| Counter | counter | +| Log | log | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CreateAnalyticsRule200ResponseOneOfInner.md b/typesense_codegen/docs/CreateAnalyticsRule200ResponseOneOfInner.md index d2f71edb..97a356d8 100644 --- a/typesense_codegen/docs/CreateAnalyticsRule200ResponseOneOfInner.md +++ b/typesense_codegen/docs/CreateAnalyticsRule200ResponseOneOfInner.md @@ -1,16 +1,11 @@ # CreateAnalyticsRule200ResponseOneOfInner -## Properties +## Enum Variants -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **String** | | -**r#type** | **String** | | -**collection** | **String** | | -**event_type** | **String** | | -**rule_tag** | Option<**String**> | | [optional] -**params** | Option<[**models::AnalyticsRuleCreateParams**](AnalyticsRuleCreate_params.md)> | | [optional] -**error** | Option<**String**> | | [optional] +| Name | Description | +|---- | -----| +| AnalyticsRule | | +| CreateAnalyticsRule200ResponseOneOfInnerOneOf | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/typesense_codegen/docs/CreateAnalyticsRule200ResponseOneOfInnerOneOf.md b/typesense_codegen/docs/CreateAnalyticsRule200ResponseOneOfInnerOneOf.md new file mode 100644 index 00000000..7603b664 --- /dev/null +++ b/typesense_codegen/docs/CreateAnalyticsRule200ResponseOneOfInnerOneOf.md @@ -0,0 +1,11 @@ +# CreateAnalyticsRule200ResponseOneOfInnerOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**error** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/SynonymItemSchema.md b/typesense_codegen/docs/SynonymItemSchema.md index 1e842d21..91bf7ae4 100644 --- a/typesense_codegen/docs/SynonymItemSchema.md +++ b/typesense_codegen/docs/SynonymItemSchema.md @@ -4,11 +4,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **String** | Unique identifier for the synonym item | **synonyms** | **Vec** | Array of words that should be considered as synonyms | **root** | Option<**String**> | For 1-way synonyms, indicates the root word that words in the synonyms parameter map to | [optional] **locale** | Option<**String**> | Locale for the synonym, leave blank to use the standard tokenizer | [optional] **symbols_to_index** | Option<**Vec**> | By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is | [optional] +**id** | **String** | Unique identifier for the synonym item | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/typesense_codegen/docs/SynonymItemUpsertSchema.md b/typesense_codegen/docs/SynonymItemUpsertSchema.md new file mode 100644 index 00000000..e8b9fdf8 --- /dev/null +++ b/typesense_codegen/docs/SynonymItemUpsertSchema.md @@ -0,0 +1,14 @@ +# SynonymItemUpsertSchema + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**synonyms** | **Vec** | Array of words that should be considered as synonyms | +**root** | Option<**String**> | For 1-way synonyms, indicates the root word that words in the synonyms parameter map to | [optional] +**locale** | Option<**String**> | Locale for the synonym, leave blank to use the standard tokenizer | [optional] +**symbols_to_index** | Option<**Vec**> | By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/SynonymsApi.md b/typesense_codegen/docs/SynonymsApi.md index f1e1fb23..7a3ce15a 100644 --- a/typesense_codegen/docs/SynonymsApi.md +++ b/typesense_codegen/docs/SynonymsApi.md @@ -227,7 +227,7 @@ Name | Type | Description | Required | Notes ## upsert_synonym_set_item -> models::SynonymItemSchema upsert_synonym_set_item(synonym_set_name, item_id, synonym_item_schema) +> models::SynonymItemSchema upsert_synonym_set_item(synonym_set_name, item_id, synonym_item_upsert_schema) Create or update a synonym set item Create or update a synonym set item with the given id @@ -239,7 +239,7 @@ Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- **synonym_set_name** | **String** | The name of the synonym set | [required] | **item_id** | **String** | The id of the synonym item to upsert | [required] | -**synonym_item_schema** | [**SynonymItemSchema**](SynonymItemSchema.md) | The synonym item to be created/updated | [required] | +**synonym_item_upsert_schema** | [**SynonymItemUpsertSchema**](SynonymItemUpsertSchema.md) | The synonym item to be created/updated | [required] | ### Return type diff --git a/typesense_codegen/src/apis/synonyms_api.rs b/typesense_codegen/src/apis/synonyms_api.rs index 2aff93aa..8e7ee3c5 100644 --- a/typesense_codegen/src/apis/synonyms_api.rs +++ b/typesense_codegen/src/apis/synonyms_api.rs @@ -59,7 +59,7 @@ pub struct UpsertSynonymSetParams<'p> { /// The name of the synonym set to create/update pub synonym_set_name: Cow<'p, str>, /// The synonym set to be created/updated - pub synonym_set_create_schema: models::SynonymSetCreateSchema<'p>, + pub synonym_set_create_schema: models::SynonymSetCreateSchema, } /// struct for passing parameters to the method [`upsert_synonym_set_item`] @@ -70,7 +70,7 @@ pub struct UpsertSynonymSetItemParams<'p> { /// The id of the synonym item to upsert pub item_id: Cow<'p, str>, /// The synonym item to be created/updated - pub synonym_item_schema: models::SynonymItemSchema<'p>, + pub synonym_item_upsert_schema: models::SynonymItemUpsertSchema<'p>, } /// struct for typed errors of method [`delete_synonym_set`] @@ -267,7 +267,7 @@ pub async fn delete_synonym_set_item( pub async fn retrieve_synonym_set( configuration: &configuration::Configuration, params: &RetrieveSynonymSetParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}", configuration.base_path, @@ -328,7 +328,7 @@ pub async fn retrieve_synonym_set( pub async fn retrieve_synonym_set_item( configuration: &configuration::Configuration, params: &RetrieveSynonymSetItemParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, @@ -390,7 +390,7 @@ pub async fn retrieve_synonym_set_item( pub async fn retrieve_synonym_set_items( configuration: &configuration::Configuration, params: &RetrieveSynonymSetItemsParams<'_>, -) -> Result>, Error> { +) -> Result, Error> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items", configuration.base_path, @@ -569,7 +569,7 @@ pub async fn upsert_synonym_set( pub async fn upsert_synonym_set_item( configuration: &configuration::Configuration, params: &UpsertSynonymSetItemParams<'_>, -) -> Result, Error> { +) -> Result> { let uri_str = format!( "{}/synonym_sets/{synonymSetName}/items/{itemId}", configuration.base_path, @@ -589,7 +589,7 @@ pub async fn upsert_synonym_set_item( }; req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); }; - req_builder = req_builder.json(¶ms.synonym_item_schema); + req_builder = req_builder.json(¶ms.synonym_item_upsert_schema); let req = req_builder.build()?; let resp = configuration.client.execute(req).await?; diff --git a/typesense_codegen/src/models/analytics_rule.rs b/typesense_codegen/src/models/analytics_rule.rs index d6445000..032f9b20 100644 --- a/typesense_codegen/src/models/analytics_rule.rs +++ b/typesense_codegen/src/models/analytics_rule.rs @@ -17,7 +17,7 @@ pub struct AnalyticsRule { #[serde(rename = "name")] pub name: String, #[serde(rename = "type")] - pub r#type: Type, + pub r#type: models::AnalyticsRuleType, #[serde(rename = "collection")] pub collection: String, #[serde(rename = "event_type")] @@ -29,7 +29,12 @@ pub struct AnalyticsRule { } impl AnalyticsRule { - pub fn new(name: String, r#type: Type, collection: String, event_type: String) -> Self { + pub fn new( + name: String, + r#type: models::AnalyticsRuleType, + collection: String, + event_type: String, + ) -> Self { Self { name, r#type, @@ -40,21 +45,3 @@ impl AnalyticsRule { } } } -/// -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Type { - #[serde(rename = "popular_queries")] - PopularQueries, - #[serde(rename = "nohits_queries")] - NohitsQueries, - #[serde(rename = "counter")] - Counter, - #[serde(rename = "log")] - Log, -} - -impl Default for Type { - fn default() -> Type { - Self::PopularQueries - } -} diff --git a/typesense_codegen/src/models/analytics_rule_create.rs b/typesense_codegen/src/models/analytics_rule_create.rs index 3d289e98..5c753853 100644 --- a/typesense_codegen/src/models/analytics_rule_create.rs +++ b/typesense_codegen/src/models/analytics_rule_create.rs @@ -17,7 +17,7 @@ pub struct AnalyticsRuleCreate<'a> { #[serde(rename = "name")] pub name: Cow<'a, str>, #[serde(rename = "type")] - pub r#type: Type, + pub r#type: models::AnalyticsRuleType, #[serde(rename = "collection")] pub collection: Cow<'a, str>, #[serde(rename = "event_type")] @@ -31,7 +31,7 @@ pub struct AnalyticsRuleCreate<'a> { impl<'a> AnalyticsRuleCreate<'a> { pub fn new( name: Cow<'a, str>, - r#type: Type, + r#type: models::AnalyticsRuleType, collection: Cow<'a, str>, event_type: Cow<'a, str>, ) -> Self { @@ -45,21 +45,3 @@ impl<'a> AnalyticsRuleCreate<'a> { } } } -/// -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Type { - #[serde(rename = "popular_queries")] - PopularQueries, - #[serde(rename = "nohits_queries")] - NohitsQueries, - #[serde(rename = "counter")] - Counter, - #[serde(rename = "log")] - Log, -} - -impl Default for Type { - fn default() -> Type { - Self::PopularQueries - } -} diff --git a/typesense_codegen/src/models/analytics_rule_type.rs b/typesense_codegen/src/models/analytics_rule_type.rs new file mode 100644 index 00000000..1f096772 --- /dev/null +++ b/typesense_codegen/src/models/analytics_rule_type.rs @@ -0,0 +1,43 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use ::std::borrow::Cow; +use serde::{Deserialize, Serialize}; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AnalyticsRuleType { + #[serde(rename = "popular_queries")] + PopularQueries, + #[serde(rename = "nohits_queries")] + NohitsQueries, + #[serde(rename = "counter")] + Counter, + #[serde(rename = "log")] + Log, +} + +impl std::fmt::Display for AnalyticsRuleType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::PopularQueries => write!(f, "popular_queries"), + Self::NohitsQueries => write!(f, "nohits_queries"), + Self::Counter => write!(f, "counter"), + Self::Log => write!(f, "log"), + } + } +} + +impl Default for AnalyticsRuleType { + fn default() -> AnalyticsRuleType { + Self::PopularQueries + } +} diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response.rs b/typesense_codegen/src/models/create_analytics_rule_200_response.rs index 4ccc84b0..3e9311e6 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response.rs @@ -24,21 +24,3 @@ impl Default for CreateAnalyticsRule200Response { Self::AnalyticsRule(Default::default()) } } -/// -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Type { - #[serde(rename = "popular_queries")] - PopularQueries, - #[serde(rename = "nohits_queries")] - NohitsQueries, - #[serde(rename = "counter")] - Counter, - #[serde(rename = "log")] - Log, -} - -impl Default for Type { - fn default() -> Type { - Self::PopularQueries - } -} diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs index db477344..c3704819 100644 --- a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner.rs @@ -12,52 +12,17 @@ use crate::models; use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CreateAnalyticsRule200ResponseOneOfInner { - #[serde(rename = "name")] - pub name: String, - #[serde(rename = "type")] - pub r#type: Type, - #[serde(rename = "collection")] - pub collection: String, - #[serde(rename = "event_type")] - pub event_type: String, - #[serde(rename = "rule_tag", skip_serializing_if = "Option::is_none")] - pub rule_tag: Option, - #[serde(rename = "params", skip_serializing_if = "Option::is_none")] - pub params: Option>>, - #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option, +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAnalyticsRule200ResponseOneOfInner { + AnalyticsRule(Box), + CreateAnalyticsRule200ResponseOneOfInnerOneOf( + Box, + ), } -impl CreateAnalyticsRule200ResponseOneOfInner { - pub fn new(name: String, r#type: Type, collection: String, event_type: String) -> Self { - Self { - name, - r#type, - collection, - event_type, - rule_tag: None, - params: None, - error: None, - } - } -} -/// -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Type { - #[serde(rename = "popular_queries")] - PopularQueries, - #[serde(rename = "nohits_queries")] - NohitsQueries, - #[serde(rename = "counter")] - Counter, - #[serde(rename = "log")] - Log, -} - -impl Default for Type { - fn default() -> Type { - Self::PopularQueries +impl Default for CreateAnalyticsRule200ResponseOneOfInner { + fn default() -> Self { + Self::AnalyticsRule(Default::default()) } } diff --git a/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_one_of.rs b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_one_of.rs new file mode 100644 index 00000000..0dad8cdc --- /dev/null +++ b/typesense_codegen/src/models/create_analytics_rule_200_response_one_of_inner_one_of.rs @@ -0,0 +1,25 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use ::std::borrow::Cow; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateAnalyticsRule200ResponseOneOfInnerOneOf { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, +} + +impl CreateAnalyticsRule200ResponseOneOfInnerOneOf { + pub fn new() -> Self { + Self { error: None } + } +} diff --git a/typesense_codegen/src/models/create_analytics_rule_request.rs b/typesense_codegen/src/models/create_analytics_rule_request.rs index e1da2636..f8fe4854 100644 --- a/typesense_codegen/src/models/create_analytics_rule_request.rs +++ b/typesense_codegen/src/models/create_analytics_rule_request.rs @@ -24,21 +24,3 @@ impl Default for CreateAnalyticsRuleRequest<'_> { Self::AnalyticsRuleCreate(Default::default()) } } -/// -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Type { - #[serde(rename = "popular_queries")] - PopularQueries, - #[serde(rename = "nohits_queries")] - NohitsQueries, - #[serde(rename = "counter")] - Counter, - #[serde(rename = "log")] - Log, -} - -impl Default for Type { - fn default() -> Type { - Self::PopularQueries - } -} diff --git a/typesense_codegen/src/models/mod.rs b/typesense_codegen/src/models/mod.rs index 47ac5d68..a02d0e0d 100644 --- a/typesense_codegen/src/models/mod.rs +++ b/typesense_codegen/src/models/mod.rs @@ -14,6 +14,8 @@ pub mod analytics_rule_create; pub use self::analytics_rule_create::AnalyticsRuleCreate; pub mod analytics_rule_create_params; pub use self::analytics_rule_create_params::AnalyticsRuleCreateParams; +pub mod analytics_rule_type; +pub use self::analytics_rule_type::AnalyticsRuleType; pub mod analytics_rule_update; pub use self::analytics_rule_update::AnalyticsRuleUpdate; pub mod analytics_status; @@ -52,8 +54,8 @@ pub mod create_analytics_rule_200_response; pub use self::create_analytics_rule_200_response::CreateAnalyticsRule200Response; pub mod create_analytics_rule_200_response_one_of_inner; pub use self::create_analytics_rule_200_response_one_of_inner::CreateAnalyticsRule200ResponseOneOfInner; -pub mod create_analytics_rule_200_response_one_of_inner_any_of; -pub use self::create_analytics_rule_200_response_one_of_inner_any_of::CreateAnalyticsRule200ResponseOneOfInnerAnyOf; +pub mod create_analytics_rule_200_response_one_of_inner_one_of; +pub use self::create_analytics_rule_200_response_one_of_inner_one_of::CreateAnalyticsRule200ResponseOneOfInnerOneOf; pub mod create_analytics_rule_request; pub use self::create_analytics_rule_request::CreateAnalyticsRuleRequest; pub mod curation_exclude; @@ -186,6 +188,8 @@ pub mod synonym_item_delete_schema; pub use self::synonym_item_delete_schema::SynonymItemDeleteSchema; pub mod synonym_item_schema; pub use self::synonym_item_schema::SynonymItemSchema; +pub mod synonym_item_upsert_schema; +pub use self::synonym_item_upsert_schema::SynonymItemUpsertSchema; pub mod synonym_set_create_schema; pub use self::synonym_set_create_schema::SynonymSetCreateSchema; pub mod synonym_set_delete_schema; diff --git a/typesense_codegen/src/models/synonym_item_schema.rs b/typesense_codegen/src/models/synonym_item_schema.rs index e09ac8b8..3bca1baa 100644 --- a/typesense_codegen/src/models/synonym_item_schema.rs +++ b/typesense_codegen/src/models/synonym_item_schema.rs @@ -13,32 +13,32 @@ use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymItemSchema<'a> { - /// Unique identifier for the synonym item - #[serde(rename = "id")] - pub id: Cow<'a, str>, +pub struct SynonymItemSchema { /// Array of words that should be considered as synonyms #[serde(rename = "synonyms")] pub synonyms: Vec, /// For 1-way synonyms, indicates the root word that words in the synonyms parameter map to #[serde(rename = "root", skip_serializing_if = "Option::is_none")] - pub root: Option>, + pub root: Option, /// Locale for the synonym, leave blank to use the standard tokenizer #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] - pub locale: Option>, + pub locale: Option, /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] pub symbols_to_index: Option>, + /// Unique identifier for the synonym item + #[serde(rename = "id")] + pub id: String, } -impl<'a> SynonymItemSchema<'a> { - pub fn new(id: Cow<'a, str>, synonyms: Vec) -> Self { +impl SynonymItemSchema { + pub fn new(synonyms: Vec, id: String) -> Self { Self { - id, synonyms, root: None, locale: None, symbols_to_index: None, + id, } } } diff --git a/typesense_codegen/src/models/synonym_item_upsert_schema.rs b/typesense_codegen/src/models/synonym_item_upsert_schema.rs new file mode 100644 index 00000000..179c2ab9 --- /dev/null +++ b/typesense_codegen/src/models/synonym_item_upsert_schema.rs @@ -0,0 +1,40 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use ::std::borrow::Cow; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SynonymItemUpsertSchema<'a> { + /// Array of words that should be considered as synonyms + #[serde(rename = "synonyms")] + pub synonyms: Vec, + /// For 1-way synonyms, indicates the root word that words in the synonyms parameter map to + #[serde(rename = "root", skip_serializing_if = "Option::is_none")] + pub root: Option>, + /// Locale for the synonym, leave blank to use the standard tokenizer + #[serde(rename = "locale", skip_serializing_if = "Option::is_none")] + pub locale: Option>, + /// By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is + #[serde(rename = "symbols_to_index", skip_serializing_if = "Option::is_none")] + pub symbols_to_index: Option>, +} + +impl<'a> SynonymItemUpsertSchema<'a> { + pub fn new(synonyms: Vec) -> Self { + Self { + synonyms, + root: None, + locale: None, + symbols_to_index: None, + } + } +} diff --git a/typesense_codegen/src/models/synonym_set_create_schema.rs b/typesense_codegen/src/models/synonym_set_create_schema.rs index 7a2b5375..fe93e17c 100644 --- a/typesense_codegen/src/models/synonym_set_create_schema.rs +++ b/typesense_codegen/src/models/synonym_set_create_schema.rs @@ -13,14 +13,14 @@ use ::std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct SynonymSetCreateSchema<'a> { +pub struct SynonymSetCreateSchema { /// Array of synonym items #[serde(rename = "items")] - pub items: Vec>, + pub items: Vec, } -impl<'a> SynonymSetCreateSchema<'a> { - pub fn new(items: Vec>) -> Self { +impl SynonymSetCreateSchema { + pub fn new(items: Vec) -> Self { Self { items } } } diff --git a/typesense_codegen/src/models/synonym_set_schema.rs b/typesense_codegen/src/models/synonym_set_schema.rs index b7616d7d..5b3b360a 100644 --- a/typesense_codegen/src/models/synonym_set_schema.rs +++ b/typesense_codegen/src/models/synonym_set_schema.rs @@ -16,14 +16,14 @@ use serde::{Deserialize, Serialize}; pub struct SynonymSetSchema { /// Array of synonym items #[serde(rename = "items")] - pub items: Vec>, + pub items: Vec, /// Name of the synonym set #[serde(rename = "name")] pub name: String, } impl SynonymSetSchema { - pub fn new(items: Vec>, name: String) -> Self { + pub fn new(items: Vec, name: String) -> Self { Self { items, name } } }