From 7a43b0e14a2314b83a85f5f0f2c0a06554bd7129 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Tue, 30 Jul 2024 13:47:55 +0000 Subject: [PATCH] fix(specs): required prop for dictionaryEntry (generated) https://github.com/algolia/api-clients-automation/pull/3449 Co-authored-by: algolia-bot Co-authored-by: Kai Welke Co-authored-by: Pierre Millot --- .../abtesting/models/custom_search_params.py | 63 --- algoliasearch/abtesting/models/error_base.py | 76 ---- algoliasearch/analytics/models/error_base.py | 76 ---- algoliasearch/ingestion/models/error_base.py | 76 ---- .../ingestion/models/source_shopify_base.py | 63 --- algoliasearch/insights/models/error_base.py | 76 ---- .../monitoring/models/bad_request.py | 61 --- algoliasearch/monitoring/models/error_base.py | 76 ---- algoliasearch/monitoring/models/forbidden.py | 61 --- .../monitoring/models/unauthorized.py | 61 --- .../personalization/models/error_base.py | 76 ---- .../query_suggestions/models/app_id.py | 65 ---- .../query_suggestions/models/error_base.py | 76 ---- .../models/base_recommend_request.py | 94 ----- .../recommend/models/base_search_params.py | 290 -------------- .../base_search_params_without_query.py | 288 -------------- .../recommend/models/base_search_response.py | 285 -------------- algoliasearch/recommend/models/error_base.py | 76 ---- .../models/frequently_bought_together.py | 68 ---- .../models/index_settings_as_search_params.py | 359 ------------------ .../recommend/models/looking_similar.py | 82 ---- .../recommend/models/recommendations_hits.py | 77 ---- .../recommend/models/recommended_for_you.py | 80 ---- .../recommend/models/related_products.py | 82 ---- .../recommend/models/search_pagination.py | 77 ---- .../recommend/models/search_params_query.py | 61 --- .../recommend/models/trending_facets.py | 83 ---- .../recommend/models/trending_items.py | 90 ----- .../models/base_get_api_key_response.py | 67 ---- .../search/models/base_index_settings.py | 172 --------- .../search/models/base_search_params.py | 290 -------------- .../base_search_params_without_query.py | 288 -------------- .../search/models/base_search_response.py | 285 -------------- .../search/models/browse_pagination.py | 79 ---- algoliasearch/search/models/cursor.py | 64 ---- .../search/models/dictionary_entry.py | 2 +- algoliasearch/search/models/error_base.py | 76 ---- .../models/index_settings_as_search_params.py | 357 ----------------- algoliasearch/search/models/params.py | 109 ------ .../models/search_for_facets_options.py | 85 ----- .../search/models/search_for_hits_options.py | 68 ---- algoliasearch/search/models/search_hits.py | 100 ----- .../search/models/search_pagination.py | 77 ---- .../search/models/search_params_query.py | 61 --- algoliasearch/search/models/with_primary.py | 64 ---- algoliasearch/usage/models/error_base.py | 76 ---- algoliasearch/usage/models/forbidden.py | 73 ---- algoliasearch/usage/models/invalid_request.py | 73 ---- 48 files changed, 1 insertion(+), 5463 deletions(-) delete mode 100644 algoliasearch/abtesting/models/custom_search_params.py delete mode 100644 algoliasearch/abtesting/models/error_base.py delete mode 100644 algoliasearch/analytics/models/error_base.py delete mode 100644 algoliasearch/ingestion/models/error_base.py delete mode 100644 algoliasearch/ingestion/models/source_shopify_base.py delete mode 100644 algoliasearch/insights/models/error_base.py delete mode 100644 algoliasearch/monitoring/models/bad_request.py delete mode 100644 algoliasearch/monitoring/models/error_base.py delete mode 100644 algoliasearch/monitoring/models/forbidden.py delete mode 100644 algoliasearch/monitoring/models/unauthorized.py delete mode 100644 algoliasearch/personalization/models/error_base.py delete mode 100644 algoliasearch/query_suggestions/models/app_id.py delete mode 100644 algoliasearch/query_suggestions/models/error_base.py delete mode 100644 algoliasearch/recommend/models/base_recommend_request.py delete mode 100644 algoliasearch/recommend/models/base_search_params.py delete mode 100644 algoliasearch/recommend/models/base_search_params_without_query.py delete mode 100644 algoliasearch/recommend/models/base_search_response.py delete mode 100644 algoliasearch/recommend/models/error_base.py delete mode 100644 algoliasearch/recommend/models/frequently_bought_together.py delete mode 100644 algoliasearch/recommend/models/index_settings_as_search_params.py delete mode 100644 algoliasearch/recommend/models/looking_similar.py delete mode 100644 algoliasearch/recommend/models/recommendations_hits.py delete mode 100644 algoliasearch/recommend/models/recommended_for_you.py delete mode 100644 algoliasearch/recommend/models/related_products.py delete mode 100644 algoliasearch/recommend/models/search_pagination.py delete mode 100644 algoliasearch/recommend/models/search_params_query.py delete mode 100644 algoliasearch/recommend/models/trending_facets.py delete mode 100644 algoliasearch/recommend/models/trending_items.py delete mode 100644 algoliasearch/search/models/base_get_api_key_response.py delete mode 100644 algoliasearch/search/models/base_index_settings.py delete mode 100644 algoliasearch/search/models/base_search_params.py delete mode 100644 algoliasearch/search/models/base_search_params_without_query.py delete mode 100644 algoliasearch/search/models/base_search_response.py delete mode 100644 algoliasearch/search/models/browse_pagination.py delete mode 100644 algoliasearch/search/models/cursor.py delete mode 100644 algoliasearch/search/models/error_base.py delete mode 100644 algoliasearch/search/models/index_settings_as_search_params.py delete mode 100644 algoliasearch/search/models/params.py delete mode 100644 algoliasearch/search/models/search_for_facets_options.py delete mode 100644 algoliasearch/search/models/search_for_hits_options.py delete mode 100644 algoliasearch/search/models/search_hits.py delete mode 100644 algoliasearch/search/models/search_pagination.py delete mode 100644 algoliasearch/search/models/search_params_query.py delete mode 100644 algoliasearch/search/models/with_primary.py delete mode 100644 algoliasearch/usage/models/error_base.py delete mode 100644 algoliasearch/usage/models/forbidden.py delete mode 100644 algoliasearch/usage/models/invalid_request.py diff --git a/algoliasearch/abtesting/models/custom_search_params.py b/algoliasearch/abtesting/models/custom_search_params.py deleted file mode 100644 index 8b0146ad2..000000000 --- a/algoliasearch/abtesting/models/custom_search_params.py +++ /dev/null @@ -1,63 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Self - -from pydantic import BaseModel, ConfigDict, Field - - -class CustomSearchParams(BaseModel): - """ - Search parameters to add to the test variant. Only use this parameter if the two variants use the same index. - """ - - custom_search_parameters: Dict[str, Any] = Field(alias="customSearchParameters") - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CustomSearchParams from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of CustomSearchParams from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - {"customSearchParameters": obj.get("customSearchParameters")} - ) - return _obj diff --git a/algoliasearch/abtesting/models/error_base.py b/algoliasearch/abtesting/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/abtesting/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/analytics/models/error_base.py b/algoliasearch/analytics/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/analytics/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/ingestion/models/error_base.py b/algoliasearch/ingestion/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/ingestion/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/ingestion/models/source_shopify_base.py b/algoliasearch/ingestion/models/source_shopify_base.py deleted file mode 100644 index f9979f3a9..000000000 --- a/algoliasearch/ingestion/models/source_shopify_base.py +++ /dev/null @@ -1,63 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - - -class SourceShopifyBase(BaseModel): - """ - SourceShopifyBase - """ - - shop_url: StrictStr = Field( - description="URL of the Shopify store.", alias="shopURL" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of SourceShopifyBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of SourceShopifyBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"shopURL": obj.get("shopURL")}) - return _obj diff --git a/algoliasearch/insights/models/error_base.py b/algoliasearch/insights/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/insights/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/monitoring/models/bad_request.py b/algoliasearch/monitoring/models/bad_request.py deleted file mode 100644 index ec92a5064..000000000 --- a/algoliasearch/monitoring/models/bad_request.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class BadRequest(BaseModel): - """ - BadRequest - """ - - reason: Optional[StrictStr] = None - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BadRequest from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BadRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"reason": obj.get("reason")}) - return _obj diff --git a/algoliasearch/monitoring/models/error_base.py b/algoliasearch/monitoring/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/monitoring/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/monitoring/models/forbidden.py b/algoliasearch/monitoring/models/forbidden.py deleted file mode 100644 index 3a6c8c94e..000000000 --- a/algoliasearch/monitoring/models/forbidden.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class Forbidden(BaseModel): - """ - Forbidden - """ - - reason: Optional[StrictStr] = None - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of Forbidden from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of Forbidden from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"reason": obj.get("reason")}) - return _obj diff --git a/algoliasearch/monitoring/models/unauthorized.py b/algoliasearch/monitoring/models/unauthorized.py deleted file mode 100644 index fadef00eb..000000000 --- a/algoliasearch/monitoring/models/unauthorized.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class Unauthorized(BaseModel): - """ - Unauthorized - """ - - reason: Optional[StrictStr] = None - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of Unauthorized from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of Unauthorized from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"reason": obj.get("reason")}) - return _obj diff --git a/algoliasearch/personalization/models/error_base.py b/algoliasearch/personalization/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/personalization/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/query_suggestions/models/app_id.py b/algoliasearch/query_suggestions/models/app_id.py deleted file mode 100644 index 209b9c7b1..000000000 --- a/algoliasearch/query_suggestions/models/app_id.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - - -class AppID(BaseModel): - """ - AppID - """ - - app_id: Optional[StrictStr] = Field( - default=None, - description="Algolia application ID to which this Query Suggestions configuration belongs.", - alias="appID", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of AppID from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of AppID from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"appID": obj.get("appID")}) - return _obj diff --git a/algoliasearch/query_suggestions/models/error_base.py b/algoliasearch/query_suggestions/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/query_suggestions/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/recommend/models/base_recommend_request.py b/algoliasearch/recommend/models/base_recommend_request.py deleted file mode 100644 index 52d751ccd..000000000 --- a/algoliasearch/recommend/models/base_recommend_request.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, Optional, Self, Union - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.recommend.models.search_params import SearchParams - - -class BaseRecommendRequest(BaseModel): - """ - BaseRecommendRequest - """ - - index_name: StrictStr = Field( - description="Index name (case-sensitive).", alias="indexName" - ) - threshold: Union[ - Annotated[float, Field(le=100, strict=True, ge=0)], - Annotated[int, Field(le=100, strict=True, ge=0)], - ] = Field( - description="Minimum score a recommendation must have to be included in the response." - ) - max_recommendations: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = ( - Field( - default=30, - description="Maximum number of recommendations to retrieve. By default, all recommendations are returned and no fallback request is made. Depending on the available recommendations and the other request parameters, the actual number of recommendations may be lower than this value. ", - alias="maxRecommendations", - ) - ) - query_parameters: Optional[SearchParams] = Field( - default=None, alias="queryParameters" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseRecommendRequest from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.query_parameters: - _dict["queryParameters"] = self.query_parameters.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseRecommendRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "indexName": obj.get("indexName"), - "threshold": obj.get("threshold"), - "maxRecommendations": obj.get("maxRecommendations"), - "queryParameters": ( - SearchParams.from_dict(obj.get("queryParameters")) - if obj.get("queryParameters") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/base_search_params.py b/algoliasearch/recommend/models/base_search_params.py deleted file mode 100644 index 9a60a3148..000000000 --- a/algoliasearch/recommend/models/base_search_params.py +++ /dev/null @@ -1,290 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, List, Optional, Self, Union - -from pydantic import ( - BaseModel, - ConfigDict, - Field, - StrictBool, - StrictFloat, - StrictInt, - StrictStr, -) - -from algoliasearch.recommend.models.around_precision import AroundPrecision -from algoliasearch.recommend.models.around_radius import AroundRadius -from algoliasearch.recommend.models.facet_filters import FacetFilters -from algoliasearch.recommend.models.numeric_filters import NumericFilters -from algoliasearch.recommend.models.optional_filters import OptionalFilters -from algoliasearch.recommend.models.supported_language import SupportedLanguage -from algoliasearch.recommend.models.tag_filters import TagFilters - - -class BaseSearchParams(BaseModel): - """ - BaseSearchParams - """ - - query: Optional[StrictStr] = Field(default="", description="Search query.") - similar_query: Optional[StrictStr] = Field( - default="", - description="Keywords to be used instead of the search query to conduct a more broader search. Using the `similarQuery` parameter changes other settings: - `queryType` is set to `prefixNone`. - `removeStopWords` is set to true. - `words` is set as the first ranking criterion. - All remaining words are treated as `optionalWords`. Since the `similarQuery` is supposed to do a broad search, they usually return many results. Combine it with `filters` to narrow down the list of results. ", - alias="similarQuery", - ) - filters: Optional[StrictStr] = Field( - default=None, - description="Filter expression to only include items that match the filter criteria in the response. You can use these filter expressions: - **Numeric filters.** ` `, where `` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `: TO ` where `` and `` are the lower and upper limits of the range (inclusive). - **Facet filters.** `:` where `` is a facet attribute (case-sensitive) and `` a facet value. - **Tag filters.** `_tags:` or just `` (case-sensitive). - **Boolean filters.** `: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/). ", - ) - facet_filters: Optional[FacetFilters] = Field(default=None, alias="facetFilters") - optional_filters: Optional[OptionalFilters] = Field( - default=None, alias="optionalFilters" - ) - numeric_filters: Optional[NumericFilters] = Field( - default=None, alias="numericFilters" - ) - tag_filters: Optional[TagFilters] = Field(default=None, alias="tagFilters") - sum_or_filters_scores: Optional[StrictBool] = Field( - default=False, - description="Whether to sum all filter scores. If true, all filter scores are summed. Otherwise, the maximum filter score is kept. For more information, see [filter scores](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/in-depth/filter-scoring/#accumulating-scores-with-sumorfiltersscores). ", - alias="sumOrFiltersScores", - ) - restrict_searchable_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Restricts a search to a subset of your searchable attributes. Attribute names are case-sensitive. ", - alias="restrictSearchableAttributes", - ) - facets: Optional[List[StrictStr]] = Field( - default=None, - description="Facets for which to retrieve facet values that match the search criteria and the number of matching facet values. To retrieve all facets, use the wildcard character `*`. For more information, see [facets](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#contextual-facet-values-and-counts). ", - ) - faceting_after_distinct: Optional[StrictBool] = Field( - default=False, - description="Whether faceting should be applied after deduplication with `distinct`. This leads to accurate facet counts when using faceting in combination with `distinct`. It's usually better to use `afterDistinct` modifiers in the `attributesForFaceting` setting, as `facetingAfterDistinct` only computes correct facet counts if all records have the same facet values for the `attributeForDistinct`. ", - alias="facetingAfterDistinct", - ) - page: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( - default=0, description="Page of search results to retrieve." - ) - offset: Optional[StrictInt] = Field( - default=None, description="Position of the first hit to retrieve." - ) - length: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( - default=None, - description="Number of hits to retrieve (used in combination with `offset`).", - ) - around_lat_lng: Optional[StrictStr] = Field( - default="", - description="Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only records included within circle around this central location are included in the results. The radius of the circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you also specify `insidePolygon` or `insideBoundingBox`. ", - alias="aroundLatLng", - ) - around_lat_lng_via_ip: Optional[StrictBool] = Field( - default=False, - description="Whether to obtain the coordinates from the request's IP address.", - alias="aroundLatLngViaIP", - ) - around_radius: Optional[AroundRadius] = Field(default=None, alias="aroundRadius") - around_precision: Optional[AroundPrecision] = Field( - default=None, alias="aroundPrecision" - ) - minimum_around_radius: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field( - default=None, - description="Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.", - alias="minimumAroundRadius", - ) - inside_bounding_box: Optional[ - List[ - Annotated[ - List[Union[StrictFloat, StrictInt]], Field(min_length=4, max_length=4) - ] - ] - ] = Field( - default=None, - description="Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). ", - alias="insideBoundingBox", - ) - inside_polygon: Optional[ - List[ - Annotated[ - List[Union[StrictFloat, StrictInt]], - Field(min_length=6, max_length=20000), - ] - ] - ] = Field( - default=None, - description="Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). This parameter is ignored if you also specify `insideBoundingBox`. ", - alias="insidePolygon", - ) - natural_languages: Optional[List[SupportedLanguage]] = Field( - default=None, - description="ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches): - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and `analyticsTags`. ", - alias="naturalLanguages", - ) - rule_contexts: Optional[List[StrictStr]] = Field( - default=None, - description="Assigns a rule context to the search query. [Rule contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) are strings that you can use to trigger matching rules. ", - alias="ruleContexts", - ) - personalization_impact: Optional[ - Annotated[int, Field(le=100, strict=True, ge=0)] - ] = Field( - default=100, - description="Impact that Personalization should have on this search. The higher this value is, the more Personalization determines the ranking compared to other factors. For more information, see [Understanding Personalization impact](https://www.algolia.com/doc/guides/personalization/personalizing-results/in-depth/configuring-personalization/#understanding-personalization-impact). ", - alias="personalizationImpact", - ) - user_token: Optional[StrictStr] = Field( - default=None, - description="Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/). ", - alias="userToken", - ) - get_ranking_info: Optional[StrictBool] = Field( - default=False, - description="Whether the search response should include detailed ranking information.", - alias="getRankingInfo", - ) - synonyms: Optional[StrictBool] = Field( - default=True, - description="Whether to take into account an index's synonyms for this search.", - ) - click_analytics: Optional[StrictBool] = Field( - default=False, - description="Whether to include a `queryID` attribute in the response. The query ID is a unique identifier for a search query and is required for tracking [click and conversion events](https://www.algolia.com/guides/sending-events/getting-started/). ", - alias="clickAnalytics", - ) - analytics: Optional[StrictBool] = Field( - default=True, description="Whether this search will be included in Analytics." - ) - analytics_tags: Optional[List[StrictStr]] = Field( - default=None, - description="Tags to apply to the query for [segmenting analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).", - alias="analyticsTags", - ) - percentile_computation: Optional[StrictBool] = Field( - default=True, - description="Whether to include this search when calculating processing-time percentiles.", - alias="percentileComputation", - ) - enable_ab_test: Optional[StrictBool] = Field( - default=True, - description="Whether to enable A/B testing for this search.", - alias="enableABTest", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseSearchParams from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.facet_filters: - _dict["facetFilters"] = self.facet_filters.to_dict() - if self.optional_filters: - _dict["optionalFilters"] = self.optional_filters.to_dict() - if self.numeric_filters: - _dict["numericFilters"] = self.numeric_filters.to_dict() - if self.tag_filters: - _dict["tagFilters"] = self.tag_filters.to_dict() - if self.around_radius: - _dict["aroundRadius"] = self.around_radius.to_dict() - if self.around_precision: - _dict["aroundPrecision"] = self.around_precision.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseSearchParams from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "query": obj.get("query"), - "similarQuery": obj.get("similarQuery"), - "filters": obj.get("filters"), - "facetFilters": ( - FacetFilters.from_dict(obj.get("facetFilters")) - if obj.get("facetFilters") is not None - else None - ), - "optionalFilters": ( - OptionalFilters.from_dict(obj.get("optionalFilters")) - if obj.get("optionalFilters") is not None - else None - ), - "numericFilters": ( - NumericFilters.from_dict(obj.get("numericFilters")) - if obj.get("numericFilters") is not None - else None - ), - "tagFilters": ( - TagFilters.from_dict(obj.get("tagFilters")) - if obj.get("tagFilters") is not None - else None - ), - "sumOrFiltersScores": obj.get("sumOrFiltersScores"), - "restrictSearchableAttributes": obj.get("restrictSearchableAttributes"), - "facets": obj.get("facets"), - "facetingAfterDistinct": obj.get("facetingAfterDistinct"), - "page": obj.get("page"), - "offset": obj.get("offset"), - "length": obj.get("length"), - "aroundLatLng": obj.get("aroundLatLng"), - "aroundLatLngViaIP": obj.get("aroundLatLngViaIP"), - "aroundRadius": ( - AroundRadius.from_dict(obj.get("aroundRadius")) - if obj.get("aroundRadius") is not None - else None - ), - "aroundPrecision": ( - AroundPrecision.from_dict(obj.get("aroundPrecision")) - if obj.get("aroundPrecision") is not None - else None - ), - "minimumAroundRadius": obj.get("minimumAroundRadius"), - "insideBoundingBox": obj.get("insideBoundingBox"), - "insidePolygon": obj.get("insidePolygon"), - "naturalLanguages": obj.get("naturalLanguages"), - "ruleContexts": obj.get("ruleContexts"), - "personalizationImpact": obj.get("personalizationImpact"), - "userToken": obj.get("userToken"), - "getRankingInfo": obj.get("getRankingInfo"), - "synonyms": obj.get("synonyms"), - "clickAnalytics": obj.get("clickAnalytics"), - "analytics": obj.get("analytics"), - "analyticsTags": obj.get("analyticsTags"), - "percentileComputation": obj.get("percentileComputation"), - "enableABTest": obj.get("enableABTest"), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/base_search_params_without_query.py b/algoliasearch/recommend/models/base_search_params_without_query.py deleted file mode 100644 index 09dd2fdd8..000000000 --- a/algoliasearch/recommend/models/base_search_params_without_query.py +++ /dev/null @@ -1,288 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, List, Optional, Self, Union - -from pydantic import ( - BaseModel, - ConfigDict, - Field, - StrictBool, - StrictFloat, - StrictInt, - StrictStr, -) - -from algoliasearch.recommend.models.around_precision import AroundPrecision -from algoliasearch.recommend.models.around_radius import AroundRadius -from algoliasearch.recommend.models.facet_filters import FacetFilters -from algoliasearch.recommend.models.numeric_filters import NumericFilters -from algoliasearch.recommend.models.optional_filters import OptionalFilters -from algoliasearch.recommend.models.supported_language import SupportedLanguage -from algoliasearch.recommend.models.tag_filters import TagFilters - - -class BaseSearchParamsWithoutQuery(BaseModel): - """ - BaseSearchParamsWithoutQuery - """ - - similar_query: Optional[StrictStr] = Field( - default="", - description="Keywords to be used instead of the search query to conduct a more broader search. Using the `similarQuery` parameter changes other settings: - `queryType` is set to `prefixNone`. - `removeStopWords` is set to true. - `words` is set as the first ranking criterion. - All remaining words are treated as `optionalWords`. Since the `similarQuery` is supposed to do a broad search, they usually return many results. Combine it with `filters` to narrow down the list of results. ", - alias="similarQuery", - ) - filters: Optional[StrictStr] = Field( - default=None, - description="Filter expression to only include items that match the filter criteria in the response. You can use these filter expressions: - **Numeric filters.** ` `, where `` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `: TO ` where `` and `` are the lower and upper limits of the range (inclusive). - **Facet filters.** `:` where `` is a facet attribute (case-sensitive) and `` a facet value. - **Tag filters.** `_tags:` or just `` (case-sensitive). - **Boolean filters.** `: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/). ", - ) - facet_filters: Optional[FacetFilters] = Field(default=None, alias="facetFilters") - optional_filters: Optional[OptionalFilters] = Field( - default=None, alias="optionalFilters" - ) - numeric_filters: Optional[NumericFilters] = Field( - default=None, alias="numericFilters" - ) - tag_filters: Optional[TagFilters] = Field(default=None, alias="tagFilters") - sum_or_filters_scores: Optional[StrictBool] = Field( - default=False, - description="Whether to sum all filter scores. If true, all filter scores are summed. Otherwise, the maximum filter score is kept. For more information, see [filter scores](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/in-depth/filter-scoring/#accumulating-scores-with-sumorfiltersscores). ", - alias="sumOrFiltersScores", - ) - restrict_searchable_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Restricts a search to a subset of your searchable attributes. Attribute names are case-sensitive. ", - alias="restrictSearchableAttributes", - ) - facets: Optional[List[StrictStr]] = Field( - default=None, - description="Facets for which to retrieve facet values that match the search criteria and the number of matching facet values. To retrieve all facets, use the wildcard character `*`. For more information, see [facets](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#contextual-facet-values-and-counts). ", - ) - faceting_after_distinct: Optional[StrictBool] = Field( - default=False, - description="Whether faceting should be applied after deduplication with `distinct`. This leads to accurate facet counts when using faceting in combination with `distinct`. It's usually better to use `afterDistinct` modifiers in the `attributesForFaceting` setting, as `facetingAfterDistinct` only computes correct facet counts if all records have the same facet values for the `attributeForDistinct`. ", - alias="facetingAfterDistinct", - ) - page: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( - default=0, description="Page of search results to retrieve." - ) - offset: Optional[StrictInt] = Field( - default=None, description="Position of the first hit to retrieve." - ) - length: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( - default=None, - description="Number of hits to retrieve (used in combination with `offset`).", - ) - around_lat_lng: Optional[StrictStr] = Field( - default="", - description="Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only records included within circle around this central location are included in the results. The radius of the circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you also specify `insidePolygon` or `insideBoundingBox`. ", - alias="aroundLatLng", - ) - around_lat_lng_via_ip: Optional[StrictBool] = Field( - default=False, - description="Whether to obtain the coordinates from the request's IP address.", - alias="aroundLatLngViaIP", - ) - around_radius: Optional[AroundRadius] = Field(default=None, alias="aroundRadius") - around_precision: Optional[AroundPrecision] = Field( - default=None, alias="aroundPrecision" - ) - minimum_around_radius: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field( - default=None, - description="Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.", - alias="minimumAroundRadius", - ) - inside_bounding_box: Optional[ - List[ - Annotated[ - List[Union[StrictFloat, StrictInt]], Field(min_length=4, max_length=4) - ] - ] - ] = Field( - default=None, - description="Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). ", - alias="insideBoundingBox", - ) - inside_polygon: Optional[ - List[ - Annotated[ - List[Union[StrictFloat, StrictInt]], - Field(min_length=6, max_length=20000), - ] - ] - ] = Field( - default=None, - description="Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). This parameter is ignored if you also specify `insideBoundingBox`. ", - alias="insidePolygon", - ) - natural_languages: Optional[List[SupportedLanguage]] = Field( - default=None, - description="ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches): - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and `analyticsTags`. ", - alias="naturalLanguages", - ) - rule_contexts: Optional[List[StrictStr]] = Field( - default=None, - description="Assigns a rule context to the search query. [Rule contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) are strings that you can use to trigger matching rules. ", - alias="ruleContexts", - ) - personalization_impact: Optional[ - Annotated[int, Field(le=100, strict=True, ge=0)] - ] = Field( - default=100, - description="Impact that Personalization should have on this search. The higher this value is, the more Personalization determines the ranking compared to other factors. For more information, see [Understanding Personalization impact](https://www.algolia.com/doc/guides/personalization/personalizing-results/in-depth/configuring-personalization/#understanding-personalization-impact). ", - alias="personalizationImpact", - ) - user_token: Optional[StrictStr] = Field( - default=None, - description="Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/). ", - alias="userToken", - ) - get_ranking_info: Optional[StrictBool] = Field( - default=False, - description="Whether the search response should include detailed ranking information.", - alias="getRankingInfo", - ) - synonyms: Optional[StrictBool] = Field( - default=True, - description="Whether to take into account an index's synonyms for this search.", - ) - click_analytics: Optional[StrictBool] = Field( - default=False, - description="Whether to include a `queryID` attribute in the response. The query ID is a unique identifier for a search query and is required for tracking [click and conversion events](https://www.algolia.com/guides/sending-events/getting-started/). ", - alias="clickAnalytics", - ) - analytics: Optional[StrictBool] = Field( - default=True, description="Whether this search will be included in Analytics." - ) - analytics_tags: Optional[List[StrictStr]] = Field( - default=None, - description="Tags to apply to the query for [segmenting analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).", - alias="analyticsTags", - ) - percentile_computation: Optional[StrictBool] = Field( - default=True, - description="Whether to include this search when calculating processing-time percentiles.", - alias="percentileComputation", - ) - enable_ab_test: Optional[StrictBool] = Field( - default=True, - description="Whether to enable A/B testing for this search.", - alias="enableABTest", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseSearchParamsWithoutQuery from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.facet_filters: - _dict["facetFilters"] = self.facet_filters.to_dict() - if self.optional_filters: - _dict["optionalFilters"] = self.optional_filters.to_dict() - if self.numeric_filters: - _dict["numericFilters"] = self.numeric_filters.to_dict() - if self.tag_filters: - _dict["tagFilters"] = self.tag_filters.to_dict() - if self.around_radius: - _dict["aroundRadius"] = self.around_radius.to_dict() - if self.around_precision: - _dict["aroundPrecision"] = self.around_precision.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseSearchParamsWithoutQuery from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "similarQuery": obj.get("similarQuery"), - "filters": obj.get("filters"), - "facetFilters": ( - FacetFilters.from_dict(obj.get("facetFilters")) - if obj.get("facetFilters") is not None - else None - ), - "optionalFilters": ( - OptionalFilters.from_dict(obj.get("optionalFilters")) - if obj.get("optionalFilters") is not None - else None - ), - "numericFilters": ( - NumericFilters.from_dict(obj.get("numericFilters")) - if obj.get("numericFilters") is not None - else None - ), - "tagFilters": ( - TagFilters.from_dict(obj.get("tagFilters")) - if obj.get("tagFilters") is not None - else None - ), - "sumOrFiltersScores": obj.get("sumOrFiltersScores"), - "restrictSearchableAttributes": obj.get("restrictSearchableAttributes"), - "facets": obj.get("facets"), - "facetingAfterDistinct": obj.get("facetingAfterDistinct"), - "page": obj.get("page"), - "offset": obj.get("offset"), - "length": obj.get("length"), - "aroundLatLng": obj.get("aroundLatLng"), - "aroundLatLngViaIP": obj.get("aroundLatLngViaIP"), - "aroundRadius": ( - AroundRadius.from_dict(obj.get("aroundRadius")) - if obj.get("aroundRadius") is not None - else None - ), - "aroundPrecision": ( - AroundPrecision.from_dict(obj.get("aroundPrecision")) - if obj.get("aroundPrecision") is not None - else None - ), - "minimumAroundRadius": obj.get("minimumAroundRadius"), - "insideBoundingBox": obj.get("insideBoundingBox"), - "insidePolygon": obj.get("insidePolygon"), - "naturalLanguages": obj.get("naturalLanguages"), - "ruleContexts": obj.get("ruleContexts"), - "personalizationImpact": obj.get("personalizationImpact"), - "userToken": obj.get("userToken"), - "getRankingInfo": obj.get("getRankingInfo"), - "synonyms": obj.get("synonyms"), - "clickAnalytics": obj.get("clickAnalytics"), - "analytics": obj.get("analytics"), - "analyticsTags": obj.get("analyticsTags"), - "percentileComputation": obj.get("percentileComputation"), - "enableABTest": obj.get("enableABTest"), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/base_search_response.py b/algoliasearch/recommend/models/base_search_response.py deleted file mode 100644 index 16b8bbd22..000000000 --- a/algoliasearch/recommend/models/base_search_response.py +++ /dev/null @@ -1,285 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from re import match -from typing import Annotated, Any, ClassVar, Dict, List, Optional, Self - -from pydantic import ( - BaseModel, - ConfigDict, - Field, - StrictBool, - StrictInt, - StrictStr, - field_validator, -) - -from algoliasearch.recommend.models.exhaustive import Exhaustive -from algoliasearch.recommend.models.facets_stats import FacetsStats -from algoliasearch.recommend.models.redirect import Redirect -from algoliasearch.recommend.models.rendering_content import RenderingContent - - -class BaseSearchResponse(BaseModel): - """ - BaseSearchResponse - """ - - ab_test_id: Optional[StrictInt] = Field( - default=None, - description="A/B test ID. This is only included in the response for indices that are part of an A/B test.", - alias="abTestID", - ) - ab_test_variant_id: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field( - default=None, - description="Variant ID. This is only included in the response for indices that are part of an A/B test.", - alias="abTestVariantID", - ) - around_lat_lng: Optional[Annotated[str, Field(strict=True)]] = Field( - default=None, - description="Computed geographical location.", - alias="aroundLatLng", - ) - automatic_radius: Optional[StrictStr] = Field( - default=None, - description="Distance from a central coordinate provided by `aroundLatLng`.", - alias="automaticRadius", - ) - exhaustive: Optional[Exhaustive] = None - exhaustive_facets_count: Optional[StrictBool] = Field( - default=None, - description="See the `facetsCount` field of the `exhaustive` object in the response.", - alias="exhaustiveFacetsCount", - ) - exhaustive_nb_hits: Optional[StrictBool] = Field( - default=None, - description="See the `nbHits` field of the `exhaustive` object in the response.", - alias="exhaustiveNbHits", - ) - exhaustive_typo: Optional[StrictBool] = Field( - default=None, - description="See the `typo` field of the `exhaustive` object in the response.", - alias="exhaustiveTypo", - ) - facets: Optional[Dict[str, Dict[str, StrictInt]]] = Field( - default=None, description="Facet counts." - ) - facets_stats: Optional[Dict[str, FacetsStats]] = Field( - default=None, description="Statistics for numerical facets." - ) - index: Optional[StrictStr] = Field( - default=None, description="Index name used for the query." - ) - index_used: Optional[StrictStr] = Field( - default=None, - description="Index name used for the query. During A/B testing, the targeted index isn't always the index used by the query.", - alias="indexUsed", - ) - message: Optional[StrictStr] = Field( - default=None, description="Warnings about the query." - ) - nb_sorted_hits: Optional[StrictInt] = Field( - default=None, - description="Number of hits selected and sorted by the relevant sort algorithm.", - alias="nbSortedHits", - ) - parsed_query: Optional[StrictStr] = Field( - default=None, - description="Post-[normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/#what-does-normalization-mean) query string that will be searched.", - alias="parsedQuery", - ) - processing_time_ms: StrictInt = Field( - description="Time the server took to process the request, in milliseconds.", - alias="processingTimeMS", - ) - processing_timings_ms: Optional[Dict[str, Any]] = Field( - default=None, - description="Experimental. List of processing steps and their times, in milliseconds. You can use this list to investigate performance issues.", - alias="processingTimingsMS", - ) - query_after_removal: Optional[StrictStr] = Field( - default=None, - description="Markup text indicating which parts of the original query have been removed to retrieve a non-empty result set.", - alias="queryAfterRemoval", - ) - redirect: Optional[Redirect] = None - rendering_content: Optional[RenderingContent] = Field( - default=None, alias="renderingContent" - ) - server_time_ms: Optional[StrictInt] = Field( - default=None, - description="Time the server took to process the request, in milliseconds.", - alias="serverTimeMS", - ) - server_used: Optional[StrictStr] = Field( - default=None, - description="Host name of the server that processed the request.", - alias="serverUsed", - ) - user_data: Optional[Dict[str, Any]] = Field( - default=None, - description="An object with custom data. You can store up to 32kB as custom data. ", - alias="userData", - ) - query_id: Optional[StrictStr] = Field( - default=None, - description="Unique identifier for the query. This is used for [click analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).", - alias="queryID", - ) - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = [ - "abTestID", - "abTestVariantID", - "aroundLatLng", - "automaticRadius", - "exhaustive", - "exhaustiveFacetsCount", - "exhaustiveNbHits", - "exhaustiveTypo", - "facets", - "facets_stats", - "index", - "indexUsed", - "message", - "nbSortedHits", - "parsedQuery", - "processingTimeMS", - "processingTimingsMS", - "queryAfterRemoval", - "redirect", - "renderingContent", - "serverTimeMS", - "serverUsed", - "userData", - "queryID", - ] - - @field_validator("around_lat_lng") - def around_lat_lng_validate_regular_expression(cls, value): - """Validates the regular expression""" - if value is None: - return value - - if not match(r"^(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)$", value): - raise ValueError( - r"must validate the regular expression /^(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)$/" - ) - return value - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseSearchResponse from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - if self.exhaustive: - _dict["exhaustive"] = self.exhaustive.to_dict() - _field_dict = {} - if self.facets_stats: - for _key in self.facets_stats: - if self.facets_stats[_key]: - _field_dict[_key] = self.facets_stats[_key].to_dict() - _dict["facets_stats"] = _field_dict - if self.redirect: - _dict["redirect"] = self.redirect.to_dict() - if self.rendering_content: - _dict["renderingContent"] = self.rendering_content.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseSearchResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "abTestID": obj.get("abTestID"), - "abTestVariantID": obj.get("abTestVariantID"), - "aroundLatLng": obj.get("aroundLatLng"), - "automaticRadius": obj.get("automaticRadius"), - "exhaustive": ( - Exhaustive.from_dict(obj.get("exhaustive")) - if obj.get("exhaustive") is not None - else None - ), - "exhaustiveFacetsCount": obj.get("exhaustiveFacetsCount"), - "exhaustiveNbHits": obj.get("exhaustiveNbHits"), - "exhaustiveTypo": obj.get("exhaustiveTypo"), - "facets": obj.get("facets"), - "facets_stats": ( - dict( - (_k, FacetsStats.from_dict(_v)) - for _k, _v in obj.get("facets_stats").items() - ) - if obj.get("facets_stats") is not None - else None - ), - "index": obj.get("index"), - "indexUsed": obj.get("indexUsed"), - "message": obj.get("message"), - "nbSortedHits": obj.get("nbSortedHits"), - "parsedQuery": obj.get("parsedQuery"), - "processingTimeMS": obj.get("processingTimeMS"), - "processingTimingsMS": obj.get("processingTimingsMS"), - "queryAfterRemoval": obj.get("queryAfterRemoval"), - "redirect": ( - Redirect.from_dict(obj.get("redirect")) - if obj.get("redirect") is not None - else None - ), - "renderingContent": ( - RenderingContent.from_dict(obj.get("renderingContent")) - if obj.get("renderingContent") is not None - else None - ), - "serverTimeMS": obj.get("serverTimeMS"), - "serverUsed": obj.get("serverUsed"), - "userData": obj.get("userData"), - "queryID": obj.get("queryID"), - } - ) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/recommend/models/error_base.py b/algoliasearch/recommend/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/recommend/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/recommend/models/frequently_bought_together.py b/algoliasearch/recommend/models/frequently_bought_together.py deleted file mode 100644 index a652adb32..000000000 --- a/algoliasearch/recommend/models/frequently_bought_together.py +++ /dev/null @@ -1,68 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.recommend.models.fbt_model import FbtModel - - -class FrequentlyBoughtTogether(BaseModel): - """ - FrequentlyBoughtTogether - """ - - model: FbtModel - object_id: StrictStr = Field( - description="Unique record identifier.", alias="objectID" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of FrequentlyBoughtTogether from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of FrequentlyBoughtTogether from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - {"model": obj.get("model"), "objectID": obj.get("objectID")} - ) - return _obj diff --git a/algoliasearch/recommend/models/index_settings_as_search_params.py b/algoliasearch/recommend/models/index_settings_as_search_params.py deleted file mode 100644 index f87881863..000000000 --- a/algoliasearch/recommend/models/index_settings_as_search_params.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr - -from algoliasearch.recommend.models.advanced_syntax_features import ( - AdvancedSyntaxFeatures, -) -from algoliasearch.recommend.models.alternatives_as_exact import AlternativesAsExact -from algoliasearch.recommend.models.distinct import Distinct -from algoliasearch.recommend.models.exact_on_single_word_query import ( - ExactOnSingleWordQuery, -) -from algoliasearch.recommend.models.ignore_plurals import IgnorePlurals -from algoliasearch.recommend.models.mode import Mode -from algoliasearch.recommend.models.query_type import QueryType -from algoliasearch.recommend.models.re_ranking_apply_filter import ReRankingApplyFilter -from algoliasearch.recommend.models.remove_stop_words import RemoveStopWords -from algoliasearch.recommend.models.remove_words_if_no_results import ( - RemoveWordsIfNoResults, -) -from algoliasearch.recommend.models.rendering_content import RenderingContent -from algoliasearch.recommend.models.semantic_search import SemanticSearch -from algoliasearch.recommend.models.supported_language import SupportedLanguage -from algoliasearch.recommend.models.typo_tolerance import TypoTolerance - - -class IndexSettingsAsSearchParams(BaseModel): - """ - IndexSettingsAsSearchParams - """ - - attributes_to_retrieve: Optional[List[StrictStr]] = Field( - default=None, - description='Attributes to include in the API response. To reduce the size of your response, you can retrieve only some of the attributes. Attribute names are case-sensitive. - `*` retrieves all attributes, except attributes included in the `customRanking` and `unretrievableAttributes` settings. - To retrieve all attributes except a specific one, prefix the attribute with a dash and combine it with the `*`: `["*", "-ATTRIBUTE"]`. - The `objectID` attribute is always included. ', - alias="attributesToRetrieve", - ) - ranking: Optional[List[StrictStr]] = Field( - default=None, - description='Determines the order in which Algolia returns your results. By default, each entry corresponds to a [ranking criteria](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/). The tie-breaking algorithm sequentially applies each criterion in the order they\'re specified. If you configure a replica index for [sorting by an attribute](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/sort-by-attribute/), you put the sorting attribute at the top of the list. **Modifiers** - `asc("ATTRIBUTE")`. Sort the index by the values of an attribute, in ascending order. - `desc("ATTRIBUTE")`. Sort the index by the values of an attribute, in descending order. Before you modify the default setting, you should test your changes in the dashboard, and by [A/B testing](https://www.algolia.com/doc/guides/ab-testing/what-is-ab-testing/). ', - ) - custom_ranking: Optional[List[StrictStr]] = Field( - default=None, - description='Attributes to use as [custom ranking](https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/). Attribute names are case-sensitive. The custom ranking attributes decide which items are shown first if the other ranking criteria are equal. Records with missing values for your selected custom ranking attributes are always sorted last. Boolean attributes are sorted based on their alphabetical order. **Modifiers** - `asc("ATTRIBUTE")`. Sort the index by the values of an attribute, in ascending order. - `desc("ATTRIBUTE")`. Sort the index by the values of an attribute, in descending order. If you use two or more custom ranking attributes, [reduce the precision](https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/how-to/controlling-custom-ranking-metrics-precision/) of your first attributes, or the other attributes will never be applied. ', - alias="customRanking", - ) - relevancy_strictness: Optional[StrictInt] = Field( - default=100, - description="Relevancy threshold below which less relevant results aren't included in the results. You can only set `relevancyStrictness` on [virtual replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas). Use this setting to strike a balance between the relevance and number of returned results. ", - alias="relevancyStrictness", - ) - attributes_to_highlight: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes to highlight. By default, all searchable attributes are highlighted. Use `*` to highlight all attributes or use an empty array `[]` to turn off highlighting. Attribute names are case-sensitive. With highlighting, strings that match the search query are surrounded by HTML tags defined by `highlightPreTag` and `highlightPostTag`. You can use this to visually highlight matching parts of a search query in your UI. For more information, see [Highlighting and snippeting](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/highlighting-snippeting/js/). ", - alias="attributesToHighlight", - ) - attributes_to_snippet: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes for which to enable snippets. Attribute names are case-sensitive. Snippets provide additional context to matched words. If you enable snippets, they include 10 words, including the matched word. The matched word will also be wrapped by HTML tags for highlighting. You can adjust the number of words with the following notation: `ATTRIBUTE:NUMBER`, where `NUMBER` is the number of words to be extracted. ", - alias="attributesToSnippet", - ) - highlight_pre_tag: Optional[StrictStr] = Field( - default="", - description="HTML tag to insert before the highlighted parts in all highlighted results and snippets.", - alias="highlightPreTag", - ) - highlight_post_tag: Optional[StrictStr] = Field( - default="", - description="HTML tag to insert after the highlighted parts in all highlighted results and snippets.", - alias="highlightPostTag", - ) - snippet_ellipsis_text: Optional[StrictStr] = Field( - default="…", - description="String used as an ellipsis indicator when a snippet is truncated.", - alias="snippetEllipsisText", - ) - restrict_highlight_and_snippet_arrays: Optional[StrictBool] = Field( - default=False, - description="Whether to restrict highlighting and snippeting to items that at least partially matched the search query. By default, all items are highlighted and snippeted. ", - alias="restrictHighlightAndSnippetArrays", - ) - hits_per_page: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( - default=20, description="Number of hits per page.", alias="hitsPerPage" - ) - min_word_sizefor1_typo: Optional[StrictInt] = Field( - default=4, - description="Minimum number of characters a word in the search query must contain to accept matches with [one typo](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/in-depth/configuring-typo-tolerance/#configuring-word-length-for-typos).", - alias="minWordSizefor1Typo", - ) - min_word_sizefor2_typos: Optional[StrictInt] = Field( - default=8, - description="Minimum number of characters a word in the search query must contain to accept matches with [two typos](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/in-depth/configuring-typo-tolerance/#configuring-word-length-for-typos).", - alias="minWordSizefor2Typos", - ) - typo_tolerance: Optional[TypoTolerance] = Field(default=None, alias="typoTolerance") - allow_typos_on_numeric_tokens: Optional[StrictBool] = Field( - default=True, - description="Whether to allow typos on numbers in the search query. Turn off this setting to reduce the number of irrelevant matches when searching in large sets of similar numbers. ", - alias="allowTyposOnNumericTokens", - ) - disable_typo_tolerance_on_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes for which you want to turn off [typo tolerance](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/). Attribute names are case-sensitive. Returning only exact matches can help when: - [Searching in hyphenated attributes](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/how-to/how-to-search-in-hyphenated-attributes/). - Reducing the number of matches when you have too many. This can happen with attributes that are long blocks of text, such as product descriptions. Consider alternatives such as `disableTypoToleranceOnWords` or adding synonyms if your attributes have intentional unusual spellings that might look like typos. ", - alias="disableTypoToleranceOnAttributes", - ) - ignore_plurals: Optional[IgnorePlurals] = Field(default=None, alias="ignorePlurals") - remove_stop_words: Optional[RemoveStopWords] = Field( - default=None, alias="removeStopWords" - ) - keep_diacritics_on_characters: Optional[StrictStr] = Field( - default="", - description="Characters for which diacritics should be preserved. By default, Algolia removes diacritics from letters. For example, `é` becomes `e`. If this causes issues in your search, you can specify characters that should keep their diacritics. ", - alias="keepDiacriticsOnCharacters", - ) - query_languages: Optional[List[SupportedLanguage]] = Field( - default=None, - description="Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries. This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` settings. This setting also sets a dictionary for word detection in the logogram-based [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) languages. To support this, you must place the CJK language **first**. **You should always specify a query language.** If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/), or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to unexpected search results. For more information, see [Language-specific configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/). ", - alias="queryLanguages", - ) - decompound_query: Optional[StrictBool] = Field( - default=True, - description="Whether to split compound words in the query into their building blocks. For more information, see [Word segmentation](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/#splitting-compound-words). Word segmentation is supported for these languages: German, Dutch, Finnish, Swedish, and Norwegian. Decompounding doesn't work for words with [non-spacing mark Unicode characters](https://www.charactercodes.net/category/non-spacing_mark). For example, `Gartenstühle` won't be decompounded if the `ü` consists of `u` (U+0075) and `◌̈` (U+0308). ", - alias="decompoundQuery", - ) - enable_rules: Optional[StrictBool] = Field( - default=True, description="Whether to enable rules.", alias="enableRules" - ) - enable_personalization: Optional[StrictBool] = Field( - default=False, - description="Whether to enable Personalization.", - alias="enablePersonalization", - ) - query_type: Optional[QueryType] = Field(default=None, alias="queryType") - remove_words_if_no_results: Optional[RemoveWordsIfNoResults] = Field( - default=None, alias="removeWordsIfNoResults" - ) - mode: Optional[Mode] = None - semantic_search: Optional[SemanticSearch] = Field( - default=None, alias="semanticSearch" - ) - advanced_syntax: Optional[StrictBool] = Field( - default=False, - description="Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. ", - alias="advancedSyntax", - ) - optional_words: Optional[List[StrictStr]] = Field( - default=None, - description='Words that should be considered optional when found in the query. By default, records must match all words in the search query to be included in the search results. Adding optional words can help to increase the number of search results by running an additional search query that doesn\'t include the optional words. For example, if the search query is "action video" and "video" is an optional word, the search engine runs two queries. One for "action video" and one for "action". Records that match all words are ranked higher. For a search query with 4 or more words **and** all its words are optional, the number of matched words required for a record to be included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of optional words dividied by 5 (rounded down). For example, with 18 optional words: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more information, see [Optional words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words). ', - alias="optionalWords", - ) - disable_exact_on_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Searchable attributes for which you want to [turn off the Exact ranking criterion](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/in-depth/adjust-exact-settings/#turn-off-exact-for-some-attributes). Attribute names are case-sensitive. This can be useful for attributes with long values, where the likelyhood of an exact match is high, such as product descriptions. Turning off the Exact ranking criterion for these attributes favors exact matching on other attributes. This reduces the impact of individual attributes with a lot of content on ranking. ", - alias="disableExactOnAttributes", - ) - exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = Field( - default=None, alias="exactOnSingleWordQuery" - ) - alternatives_as_exact: Optional[List[AlternativesAsExact]] = Field( - default=None, - description='Alternatives of query words that should be considered as exact matches by the Exact ranking criterion. - `ignorePlurals`. Plurals and similar declensions added by the `ignorePlurals` setting are considered exact matches. - `singleWordSynonym`. Single-word synonyms, such as "NY/NYC" are considered exact matches. - `multiWordsSynonym`. Multi-word synonyms, such as "NY/New York" are considered exact matches. ', - alias="alternativesAsExact", - ) - advanced_syntax_features: Optional[List[AdvancedSyntaxFeatures]] = Field( - default=None, - description='Advanced search syntax features you want to support. - `exactPhrase`. Phrases in quotes must match exactly. For example, `sparkly blue "iPhone case"` only returns records with the exact string "iPhone case". - `excludeWords`. Query words prefixed with a `-` must not occur in a record. For example, `search -engine` matches records that contain "search" but not "engine". This setting only has an effect if `advancedSyntax` is true. ', - alias="advancedSyntaxFeatures", - ) - distinct: Optional[Distinct] = None - replace_synonyms_in_highlight: Optional[StrictBool] = Field( - default=False, - description='Whether to replace a highlighted word with the matched synonym. By default, the original words are highlighted even if a synonym matches. For example, with `home` as a synonym for `house` and a search for `home`, records matching either "home" or "house" are included in the search results, and either "home" or "house" are highlighted. With `replaceSynonymsInHighlight` set to `true`, a search for `home` still matches the same records, but all occurences of "house" are replaced by "home" in the highlighted response. ', - alias="replaceSynonymsInHighlight", - ) - min_proximity: Optional[Annotated[int, Field(le=7, strict=True, ge=1)]] = Field( - default=1, - description="Minimum proximity score for two matching words. This adjusts the [Proximity ranking criterion](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/#proximity) by equally scoring matches that are farther apart. For example, if `minProximity` is 2, neighboring matches and matches with one word between them would have the same score. ", - alias="minProximity", - ) - response_fields: Optional[List[StrictStr]] = Field( - default=None, - description="Properties to include in the API response of `search` and `browse` requests. By default, all response properties are included. To reduce the response size, you can select, which attributes should be included. You can't exclude these properties: `message`, `warning`, `cursor`, `serverUsed`, `indexUsed`, `abTestVariantID`, `parsedQuery`, or any property triggered by the `getRankingInfo` parameter. Don't exclude properties that you might need in your search UI. ", - alias="responseFields", - ) - max_facet_hits: Optional[Annotated[int, Field(le=100, strict=True)]] = Field( - default=10, - description="Maximum number of facet values to return when [searching for facet values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).", - alias="maxFacetHits", - ) - max_values_per_facet: Optional[Annotated[int, Field(le=1000, strict=True)]] = Field( - default=100, - description="Maximum number of facet values to return for each facet.", - alias="maxValuesPerFacet", - ) - sort_facet_values_by: Optional[StrictStr] = Field( - default="count", - description="Order in which to retrieve facet values. - `count`. Facet values are retrieved by decreasing count. The count is the number of matching records containing this facet value. - `alpha`. Retrieve facet values alphabetically. This setting doesn't influence how facet values are displayed in your UI (see `renderingContent`). For more information, see [facet value display](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/facet-display/js/). ", - alias="sortFacetValuesBy", - ) - attribute_criteria_computed_by_min_proximity: Optional[StrictBool] = Field( - default=False, - description="Whether the best matching attribute should be determined by minimum proximity. This setting only affects ranking if the Attribute ranking criterion comes before Proximity in the `ranking` setting. If true, the best matching attribute is selected based on the minimum proximity of multiple matches. Otherwise, the best matching attribute is determined by the order in the `searchableAttributes` setting. ", - alias="attributeCriteriaComputedByMinProximity", - ) - rendering_content: Optional[RenderingContent] = Field( - default=None, alias="renderingContent" - ) - enable_re_ranking: Optional[StrictBool] = Field( - default=True, - description="Whether this search will use [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/). This setting only has an effect if you activated Dynamic Re-Ranking for this index in the Algolia dashboard. ", - alias="enableReRanking", - ) - re_ranking_apply_filter: Optional[ReRankingApplyFilter] = Field( - default=None, alias="reRankingApplyFilter" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of IndexSettingsAsSearchParams from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.typo_tolerance: - _dict["typoTolerance"] = self.typo_tolerance.to_dict() - if self.ignore_plurals: - _dict["ignorePlurals"] = self.ignore_plurals.to_dict() - if self.remove_stop_words: - _dict["removeStopWords"] = self.remove_stop_words.to_dict() - if self.semantic_search: - _dict["semanticSearch"] = self.semantic_search.to_dict() - if self.distinct: - _dict["distinct"] = self.distinct.to_dict() - if self.rendering_content: - _dict["renderingContent"] = self.rendering_content.to_dict() - if self.re_ranking_apply_filter: - _dict["reRankingApplyFilter"] = self.re_ranking_apply_filter.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of IndexSettingsAsSearchParams from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "attributesToRetrieve": obj.get("attributesToRetrieve"), - "ranking": obj.get("ranking"), - "customRanking": obj.get("customRanking"), - "relevancyStrictness": obj.get("relevancyStrictness"), - "attributesToHighlight": obj.get("attributesToHighlight"), - "attributesToSnippet": obj.get("attributesToSnippet"), - "highlightPreTag": obj.get("highlightPreTag"), - "highlightPostTag": obj.get("highlightPostTag"), - "snippetEllipsisText": obj.get("snippetEllipsisText"), - "restrictHighlightAndSnippetArrays": obj.get( - "restrictHighlightAndSnippetArrays" - ), - "hitsPerPage": obj.get("hitsPerPage"), - "minWordSizefor1Typo": obj.get("minWordSizefor1Typo"), - "minWordSizefor2Typos": obj.get("minWordSizefor2Typos"), - "typoTolerance": ( - TypoTolerance.from_dict(obj.get("typoTolerance")) - if obj.get("typoTolerance") is not None - else None - ), - "allowTyposOnNumericTokens": obj.get("allowTyposOnNumericTokens"), - "disableTypoToleranceOnAttributes": obj.get( - "disableTypoToleranceOnAttributes" - ), - "ignorePlurals": ( - IgnorePlurals.from_dict(obj.get("ignorePlurals")) - if obj.get("ignorePlurals") is not None - else None - ), - "removeStopWords": ( - RemoveStopWords.from_dict(obj.get("removeStopWords")) - if obj.get("removeStopWords") is not None - else None - ), - "keepDiacriticsOnCharacters": obj.get("keepDiacriticsOnCharacters"), - "queryLanguages": obj.get("queryLanguages"), - "decompoundQuery": obj.get("decompoundQuery"), - "enableRules": obj.get("enableRules"), - "enablePersonalization": obj.get("enablePersonalization"), - "queryType": obj.get("queryType"), - "removeWordsIfNoResults": obj.get("removeWordsIfNoResults"), - "mode": obj.get("mode"), - "semanticSearch": ( - SemanticSearch.from_dict(obj.get("semanticSearch")) - if obj.get("semanticSearch") is not None - else None - ), - "advancedSyntax": obj.get("advancedSyntax"), - "optionalWords": obj.get("optionalWords"), - "disableExactOnAttributes": obj.get("disableExactOnAttributes"), - "exactOnSingleWordQuery": obj.get("exactOnSingleWordQuery"), - "alternativesAsExact": obj.get("alternativesAsExact"), - "advancedSyntaxFeatures": obj.get("advancedSyntaxFeatures"), - "distinct": ( - Distinct.from_dict(obj.get("distinct")) - if obj.get("distinct") is not None - else None - ), - "replaceSynonymsInHighlight": obj.get("replaceSynonymsInHighlight"), - "minProximity": obj.get("minProximity"), - "responseFields": obj.get("responseFields"), - "maxFacetHits": obj.get("maxFacetHits"), - "maxValuesPerFacet": obj.get("maxValuesPerFacet"), - "sortFacetValuesBy": obj.get("sortFacetValuesBy"), - "attributeCriteriaComputedByMinProximity": obj.get( - "attributeCriteriaComputedByMinProximity" - ), - "renderingContent": ( - RenderingContent.from_dict(obj.get("renderingContent")) - if obj.get("renderingContent") is not None - else None - ), - "enableReRanking": obj.get("enableReRanking"), - "reRankingApplyFilter": ( - ReRankingApplyFilter.from_dict(obj.get("reRankingApplyFilter")) - if obj.get("reRankingApplyFilter") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/looking_similar.py b/algoliasearch/recommend/models/looking_similar.py deleted file mode 100644 index b060049ac..000000000 --- a/algoliasearch/recommend/models/looking_similar.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.recommend.models.fallback_params import FallbackParams -from algoliasearch.recommend.models.looking_similar_model import LookingSimilarModel - - -class LookingSimilar(BaseModel): - """ - LookingSimilar - """ - - model: LookingSimilarModel - object_id: StrictStr = Field( - description="Unique record identifier.", alias="objectID" - ) - fallback_parameters: Optional[FallbackParams] = Field( - default=None, alias="fallbackParameters" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of LookingSimilar from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.fallback_parameters: - _dict["fallbackParameters"] = self.fallback_parameters.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of LookingSimilar from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "model": obj.get("model"), - "objectID": obj.get("objectID"), - "fallbackParameters": ( - FallbackParams.from_dict(obj.get("fallbackParameters")) - if obj.get("fallbackParameters") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/recommendations_hits.py b/algoliasearch/recommend/models/recommendations_hits.py deleted file mode 100644 index b58ef4f47..000000000 --- a/algoliasearch/recommend/models/recommendations_hits.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, List, Self - -from pydantic import BaseModel, ConfigDict - -from algoliasearch.recommend.models.recommendations_hit import RecommendationsHit - - -class RecommendationsHits(BaseModel): - """ - RecommendationsHits - """ - - hits: List[RecommendationsHit] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of RecommendationsHits from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - _items = [] - if self.hits: - for _item in self.hits: - if _item: - _items.append(_item.to_dict()) - _dict["hits"] = _items - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of RecommendationsHits from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "hits": ( - [RecommendationsHit.from_dict(_item) for _item in obj.get("hits")] - if obj.get("hits") is not None - else None - ) - } - ) - return _obj diff --git a/algoliasearch/recommend/models/recommended_for_you.py b/algoliasearch/recommend/models/recommended_for_you.py deleted file mode 100644 index b7d2df812..000000000 --- a/algoliasearch/recommend/models/recommended_for_you.py +++ /dev/null @@ -1,80 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field - -from algoliasearch.recommend.models.fallback_params import FallbackParams -from algoliasearch.recommend.models.recommended_for_you_model import ( - RecommendedForYouModel, -) - - -class RecommendedForYou(BaseModel): - """ - RecommendedForYou - """ - - model: RecommendedForYouModel - fallback_parameters: Optional[FallbackParams] = Field( - default=None, alias="fallbackParameters" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of RecommendedForYou from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.fallback_parameters: - _dict["fallbackParameters"] = self.fallback_parameters.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of RecommendedForYou from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "model": obj.get("model"), - "fallbackParameters": ( - FallbackParams.from_dict(obj.get("fallbackParameters")) - if obj.get("fallbackParameters") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/related_products.py b/algoliasearch/recommend/models/related_products.py deleted file mode 100644 index 357ada8e1..000000000 --- a/algoliasearch/recommend/models/related_products.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.recommend.models.fallback_params import FallbackParams -from algoliasearch.recommend.models.related_model import RelatedModel - - -class RelatedProducts(BaseModel): - """ - RelatedProducts - """ - - model: RelatedModel - object_id: StrictStr = Field( - description="Unique record identifier.", alias="objectID" - ) - fallback_parameters: Optional[FallbackParams] = Field( - default=None, alias="fallbackParameters" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of RelatedProducts from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.fallback_parameters: - _dict["fallbackParameters"] = self.fallback_parameters.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of RelatedProducts from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "model": obj.get("model"), - "objectID": obj.get("objectID"), - "fallbackParameters": ( - FallbackParams.from_dict(obj.get("fallbackParameters")) - if obj.get("fallbackParameters") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/search_pagination.py b/algoliasearch/recommend/models/search_pagination.py deleted file mode 100644 index 9881e858f..000000000 --- a/algoliasearch/recommend/models/search_pagination.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictInt - - -class SearchPagination(BaseModel): - """ - SearchPagination - """ - - page: Annotated[int, Field(strict=True, ge=0)] = Field( - description="Page of search results to retrieve." - ) - nb_hits: StrictInt = Field(description="Number of results (hits).", alias="nbHits") - nb_pages: StrictInt = Field( - description="Number of pages of results.", alias="nbPages" - ) - hits_per_page: Annotated[int, Field(le=1000, strict=True, ge=1)] = Field( - description="Number of hits per page.", alias="hitsPerPage" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of SearchPagination from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of SearchPagination from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "page": obj.get("page"), - "nbHits": obj.get("nbHits"), - "nbPages": obj.get("nbPages"), - "hitsPerPage": obj.get("hitsPerPage"), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/search_params_query.py b/algoliasearch/recommend/models/search_params_query.py deleted file mode 100644 index c31750cda..000000000 --- a/algoliasearch/recommend/models/search_params_query.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - - -class SearchParamsQuery(BaseModel): - """ - SearchParamsQuery - """ - - query: Optional[StrictStr] = Field(default="", description="Search query.") - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of SearchParamsQuery from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of SearchParamsQuery from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"query": obj.get("query")}) - return _obj diff --git a/algoliasearch/recommend/models/trending_facets.py b/algoliasearch/recommend/models/trending_facets.py deleted file mode 100644 index 8fa4c0deb..000000000 --- a/algoliasearch/recommend/models/trending_facets.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field - -from algoliasearch.recommend.models.fallback_params import FallbackParams -from algoliasearch.recommend.models.trending_facets_model import TrendingFacetsModel - - -class TrendingFacets(BaseModel): - """ - TrendingFacets - """ - - facet_name: Optional[Any] = Field( - description="Facet attribute for which to retrieve trending facet values.", - alias="facetName", - ) - model: TrendingFacetsModel - fallback_parameters: Optional[FallbackParams] = Field( - default=None, alias="fallbackParameters" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of TrendingFacets from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.fallback_parameters: - _dict["fallbackParameters"] = self.fallback_parameters.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of TrendingFacets from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "facetName": obj.get("facetName"), - "model": obj.get("model"), - "fallbackParameters": ( - FallbackParams.from_dict(obj.get("fallbackParameters")) - if obj.get("fallbackParameters") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/recommend/models/trending_items.py b/algoliasearch/recommend/models/trending_items.py deleted file mode 100644 index 14279618a..000000000 --- a/algoliasearch/recommend/models/trending_items.py +++ /dev/null @@ -1,90 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.recommend.models.search_params_object import SearchParamsObject -from algoliasearch.recommend.models.trending_items_model import TrendingItemsModel - - -class TrendingItems(BaseModel): - """ - TrendingItems - """ - - facet_name: Optional[StrictStr] = Field( - default=None, - description="Facet attribute. To be used in combination with `facetValue`. If specified, only recommendations matching the facet filter will be returned. ", - alias="facetName", - ) - facet_value: Optional[StrictStr] = Field( - default=None, - description="Facet value. To be used in combination with `facetName`. If specified, only recommendations matching the facet filter will be returned. ", - alias="facetValue", - ) - model: TrendingItemsModel - fallback_parameters: Optional[SearchParamsObject] = Field( - default=None, alias="fallbackParameters" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of TrendingItems from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.fallback_parameters: - _dict["fallbackParameters"] = self.fallback_parameters.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of TrendingItems from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "facetName": obj.get("facetName"), - "facetValue": obj.get("facetValue"), - "model": obj.get("model"), - "fallbackParameters": ( - SearchParamsObject.from_dict(obj.get("fallbackParameters")) - if obj.get("fallbackParameters") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/search/models/base_get_api_key_response.py b/algoliasearch/search/models/base_get_api_key_response.py deleted file mode 100644 index c8f8daa6a..000000000 --- a/algoliasearch/search/models/base_get_api_key_response.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr - - -class BaseGetApiKeyResponse(BaseModel): - """ - BaseGetApiKeyResponse - """ - - value: Optional[StrictStr] = Field(default=None, description="API key.") - created_at: StrictInt = Field( - description="Timestamp when the object was created, in milliseconds since the Unix epoch.", - alias="createdAt", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseGetApiKeyResponse from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseGetApiKeyResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - {"value": obj.get("value"), "createdAt": obj.get("createdAt")} - ) - return _obj diff --git a/algoliasearch/search/models/base_index_settings.py b/algoliasearch/search/models/base_index_settings.py deleted file mode 100644 index 15a9c86f1..000000000 --- a/algoliasearch/search/models/base_index_settings.py +++ /dev/null @@ -1,172 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr - -from algoliasearch.search.models.supported_language import SupportedLanguage - - -class BaseIndexSettings(BaseModel): - """ - BaseIndexSettings - """ - - attributes_for_faceting: Optional[List[StrictStr]] = Field( - default=None, - description='Attributes used for [faceting](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/). Facets are attributes that let you categorize search results. They can be used for filtering search results. By default, no attribute is used for faceting. Attribute names are case-sensitive. **Modifiers** - `filterOnly("ATTRIBUTE")`. Allows using this attribute as a filter, but doesn\'t evalue the facet values. - `searchable("ATTRIBUTE")`. Allows searching for facet values. - `afterDistinct("ATTRIBUTE")`. Evaluates the facet count _after_ deduplication with `distinct`. This ensures accurate facet counts. You can apply this modifier to searchable facets: `afterDistinct(searchable(ATTRIBUTE))`. ', - alias="attributesForFaceting", - ) - replicas: Optional[List[StrictStr]] = Field( - default=None, - description="Creates [replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/). Replicas are copies of a primary index with the same records but different settings, synonyms, or rules. If you want to offer a different ranking or sorting of your search results, you'll use replica indices. All index operations on a primary index are automatically forwarded to its replicas. To add a replica index, you must provide the complete set of replicas to this parameter. If you omit a replica from this list, the replica turns into a regular, standalone index that will no longer by synced with the primary index. **Modifier** - `virtual(\"REPLICA\")`. Create a virtual replica, Virtual replicas don't increase the number of records and are optimized for [Relevant sorting](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/relevant-sort/). ", - ) - pagination_limited_to: Optional[Annotated[int, Field(le=20000, strict=True)]] = ( - Field( - default=1000, - description="Maximum number of search results that can be obtained through pagination. Higher pagination limits might slow down your search. For pagination limits above 1,000, the sorting of results beyond the 1,000th hit can't be guaranteed. ", - alias="paginationLimitedTo", - ) - ) - unretrievable_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes that can't be retrieved at query time. This can be useful if you want to use an attribute for ranking or to [restrict access](https://www.algolia.com/doc/guides/security/api-keys/how-to/user-restricted-access-to-data/), but don't want to include it in the search results. Attribute names are case-sensitive. ", - alias="unretrievableAttributes", - ) - disable_typo_tolerance_on_words: Optional[List[StrictStr]] = Field( - default=None, - description="Words for which you want to turn off [typo tolerance](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/). This also turns off [word splitting and concatenation](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/splitting-and-concatenation/) for the specified words. ", - alias="disableTypoToleranceOnWords", - ) - attributes_to_transliterate: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes, for which you want to support [Japanese transliteration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/#japanese-transliteration-and-type-ahead). Transliteration supports searching in any of the Japanese writing systems. To support transliteration, you must set the indexing language to Japanese. Attribute names are case-sensitive. ", - alias="attributesToTransliterate", - ) - camel_case_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes for which to split [camel case](https://wikipedia.org/wiki/Camel_case) words. Attribute names are case-sensitive. ", - alias="camelCaseAttributes", - ) - decompounded_attributes: Optional[Dict[str, Any]] = Field( - default=None, - description="Searchable attributes to which Algolia should apply [word segmentation](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/how-to/customize-segmentation/) (decompounding). Attribute names are case-sensitive. Compound words are formed by combining two or more individual words, and are particularly prevalent in Germanic languages—for example, \"firefighter\". With decompounding, the individual components are indexed separately. You can specify different lists for different languages. Decompounding is supported for these languages: Dutch (`nl`), German (`de`), Finnish (`fi`), Danish (`da`), Swedish (`sv`), and Norwegian (`no`). Decompounding doesn't work for words with [non-spacing mark Unicode characters](https://www.charactercodes.net/category/non-spacing_mark). For example, `Gartenstühle` won't be decompounded if the `ü` consists of `u` (U+0075) and `◌̈` (U+0308). ", - alias="decompoundedAttributes", - ) - index_languages: Optional[List[SupportedLanguage]] = Field( - default=None, - description="Languages for language-specific processing steps, such as word detection and dictionary settings. **You should always specify an indexing language.** If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/), or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to unexpected search results. For more information, see [Language-specific configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/). ", - alias="indexLanguages", - ) - disable_prefix_on_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Searchable attributes for which you want to turn off [prefix matching](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/#adjusting-prefix-search). Attribute names are case-sensitive. ", - alias="disablePrefixOnAttributes", - ) - allow_compression_of_integer_array: Optional[StrictBool] = Field( - default=False, - description="Whether arrays with exclusively non-negative integers should be compressed for better performance. If true, the compressed arrays may be reordered. ", - alias="allowCompressionOfIntegerArray", - ) - numeric_attributes_for_filtering: Optional[List[StrictStr]] = Field( - default=None, - description='Numeric attributes that can be used as [numerical filters](https://www.algolia.com/doc/guides/managing-results/rules/detecting-intent/how-to/applying-a-custom-filter-for-a-specific-query/#numerical-filters). Attribute names are case-sensitive. By default, all numeric attributes are available as numerical filters. For faster indexing, reduce the number of numeric attributes. If you want to turn off filtering for all numeric attributes, specifiy an attribute that doesn\'t exist in your index, such as `NO_NUMERIC_FILTERING`. **Modifier** - `equalOnly("ATTRIBUTE")`. Support only filtering based on equality comparisons `=` and `!=`. ', - alias="numericAttributesForFiltering", - ) - separators_to_index: Optional[StrictStr] = Field( - default="", - description="Controls which separators are indexed. Separators are all non-letter characters except spaces and currency characters, such as $€£¥. By default, separator characters aren't indexed. With `separatorsToIndex`, Algolia treats separator characters as separate words. For example, a search for `C#` would report two matches. ", - alias="separatorsToIndex", - ) - searchable_attributes: Optional[List[StrictStr]] = Field( - default=None, - description='Attributes used for searching. Attribute names are case-sensitive. By default, all attributes are searchable and the [Attribute](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/#attribute) ranking criterion is turned off. With a non-empty list, Algolia only returns results with matches in the selected attributes. In addition, the Attribute ranking criterion is turned on: matches in attributes that are higher in the list of `searchableAttributes` rank first. To make matches in two attributes rank equally, include them in a comma-separated string, such as `"title,alternate_title"`. Attributes with the same priority are always unordered. For more information, see [Searchable attributes](https://www.algolia.com/doc/guides/sending-and-managing-data/prepare-your-data/how-to/setting-searchable-attributes/). **Modifier** - `unordered("ATTRIBUTE")`. Ignore the position of a match within the attribute. Without modifier, matches at the beginning of an attribute rank higer than matches at the end. ', - alias="searchableAttributes", - ) - user_data: Optional[Dict[str, Any]] = Field( - default=None, - description="An object with custom data. You can store up to 32kB as custom data. ", - alias="userData", - ) - custom_normalization: Optional[Dict[str, Dict[str, StrictStr]]] = Field( - default=None, - description="Characters and their normalized replacements. This overrides Algolia's default [normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/). ", - alias="customNormalization", - ) - attribute_for_distinct: Optional[StrictStr] = Field( - default=None, - description="Attribute that should be used to establish groups of results. Attribute names are case-sensitive. All records with the same value for this attribute are considered a group. You can combine `attributeForDistinct` with the `distinct` search parameter to control how many items per group are included in the search results. If you want to use the same attribute also for faceting, use the `afterDistinct` modifier of the `attributesForFaceting` setting. This applies faceting _after_ deduplication, which will result in accurate facet counts. ", - alias="attributeForDistinct", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseIndexSettings from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseIndexSettings from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "attributesForFaceting": obj.get("attributesForFaceting"), - "replicas": obj.get("replicas"), - "paginationLimitedTo": obj.get("paginationLimitedTo"), - "unretrievableAttributes": obj.get("unretrievableAttributes"), - "disableTypoToleranceOnWords": obj.get("disableTypoToleranceOnWords"), - "attributesToTransliterate": obj.get("attributesToTransliterate"), - "camelCaseAttributes": obj.get("camelCaseAttributes"), - "decompoundedAttributes": obj.get("decompoundedAttributes"), - "indexLanguages": obj.get("indexLanguages"), - "disablePrefixOnAttributes": obj.get("disablePrefixOnAttributes"), - "allowCompressionOfIntegerArray": obj.get( - "allowCompressionOfIntegerArray" - ), - "numericAttributesForFiltering": obj.get( - "numericAttributesForFiltering" - ), - "separatorsToIndex": obj.get("separatorsToIndex"), - "searchableAttributes": obj.get("searchableAttributes"), - "userData": obj.get("userData"), - "customNormalization": obj.get("customNormalization"), - "attributeForDistinct": obj.get("attributeForDistinct"), - } - ) - return _obj diff --git a/algoliasearch/search/models/base_search_params.py b/algoliasearch/search/models/base_search_params.py deleted file mode 100644 index cc1155ead..000000000 --- a/algoliasearch/search/models/base_search_params.py +++ /dev/null @@ -1,290 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, List, Optional, Self, Union - -from pydantic import ( - BaseModel, - ConfigDict, - Field, - StrictBool, - StrictFloat, - StrictInt, - StrictStr, -) - -from algoliasearch.search.models.around_precision import AroundPrecision -from algoliasearch.search.models.around_radius import AroundRadius -from algoliasearch.search.models.facet_filters import FacetFilters -from algoliasearch.search.models.numeric_filters import NumericFilters -from algoliasearch.search.models.optional_filters import OptionalFilters -from algoliasearch.search.models.supported_language import SupportedLanguage -from algoliasearch.search.models.tag_filters import TagFilters - - -class BaseSearchParams(BaseModel): - """ - BaseSearchParams - """ - - query: Optional[StrictStr] = Field(default="", description="Search query.") - similar_query: Optional[StrictStr] = Field( - default="", - description="Keywords to be used instead of the search query to conduct a more broader search. Using the `similarQuery` parameter changes other settings: - `queryType` is set to `prefixNone`. - `removeStopWords` is set to true. - `words` is set as the first ranking criterion. - All remaining words are treated as `optionalWords`. Since the `similarQuery` is supposed to do a broad search, they usually return many results. Combine it with `filters` to narrow down the list of results. ", - alias="similarQuery", - ) - filters: Optional[StrictStr] = Field( - default=None, - description="Filter expression to only include items that match the filter criteria in the response. You can use these filter expressions: - **Numeric filters.** ` `, where `` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `: TO ` where `` and `` are the lower and upper limits of the range (inclusive). - **Facet filters.** `:` where `` is a facet attribute (case-sensitive) and `` a facet value. - **Tag filters.** `_tags:` or just `` (case-sensitive). - **Boolean filters.** `: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/). ", - ) - facet_filters: Optional[FacetFilters] = Field(default=None, alias="facetFilters") - optional_filters: Optional[OptionalFilters] = Field( - default=None, alias="optionalFilters" - ) - numeric_filters: Optional[NumericFilters] = Field( - default=None, alias="numericFilters" - ) - tag_filters: Optional[TagFilters] = Field(default=None, alias="tagFilters") - sum_or_filters_scores: Optional[StrictBool] = Field( - default=False, - description="Whether to sum all filter scores. If true, all filter scores are summed. Otherwise, the maximum filter score is kept. For more information, see [filter scores](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/in-depth/filter-scoring/#accumulating-scores-with-sumorfiltersscores). ", - alias="sumOrFiltersScores", - ) - restrict_searchable_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Restricts a search to a subset of your searchable attributes. Attribute names are case-sensitive. ", - alias="restrictSearchableAttributes", - ) - facets: Optional[List[StrictStr]] = Field( - default=None, - description="Facets for which to retrieve facet values that match the search criteria and the number of matching facet values. To retrieve all facets, use the wildcard character `*`. For more information, see [facets](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#contextual-facet-values-and-counts). ", - ) - faceting_after_distinct: Optional[StrictBool] = Field( - default=False, - description="Whether faceting should be applied after deduplication with `distinct`. This leads to accurate facet counts when using faceting in combination with `distinct`. It's usually better to use `afterDistinct` modifiers in the `attributesForFaceting` setting, as `facetingAfterDistinct` only computes correct facet counts if all records have the same facet values for the `attributeForDistinct`. ", - alias="facetingAfterDistinct", - ) - page: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( - default=0, description="Page of search results to retrieve." - ) - offset: Optional[StrictInt] = Field( - default=None, description="Position of the first hit to retrieve." - ) - length: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( - default=None, - description="Number of hits to retrieve (used in combination with `offset`).", - ) - around_lat_lng: Optional[StrictStr] = Field( - default="", - description="Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only records included within circle around this central location are included in the results. The radius of the circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you also specify `insidePolygon` or `insideBoundingBox`. ", - alias="aroundLatLng", - ) - around_lat_lng_via_ip: Optional[StrictBool] = Field( - default=False, - description="Whether to obtain the coordinates from the request's IP address.", - alias="aroundLatLngViaIP", - ) - around_radius: Optional[AroundRadius] = Field(default=None, alias="aroundRadius") - around_precision: Optional[AroundPrecision] = Field( - default=None, alias="aroundPrecision" - ) - minimum_around_radius: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field( - default=None, - description="Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.", - alias="minimumAroundRadius", - ) - inside_bounding_box: Optional[ - List[ - Annotated[ - List[Union[StrictFloat, StrictInt]], Field(min_length=4, max_length=4) - ] - ] - ] = Field( - default=None, - description="Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). ", - alias="insideBoundingBox", - ) - inside_polygon: Optional[ - List[ - Annotated[ - List[Union[StrictFloat, StrictInt]], - Field(min_length=6, max_length=20000), - ] - ] - ] = Field( - default=None, - description="Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). This parameter is ignored if you also specify `insideBoundingBox`. ", - alias="insidePolygon", - ) - natural_languages: Optional[List[SupportedLanguage]] = Field( - default=None, - description="ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches): - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and `analyticsTags`. ", - alias="naturalLanguages", - ) - rule_contexts: Optional[List[StrictStr]] = Field( - default=None, - description="Assigns a rule context to the search query. [Rule contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) are strings that you can use to trigger matching rules. ", - alias="ruleContexts", - ) - personalization_impact: Optional[ - Annotated[int, Field(le=100, strict=True, ge=0)] - ] = Field( - default=100, - description="Impact that Personalization should have on this search. The higher this value is, the more Personalization determines the ranking compared to other factors. For more information, see [Understanding Personalization impact](https://www.algolia.com/doc/guides/personalization/personalizing-results/in-depth/configuring-personalization/#understanding-personalization-impact). ", - alias="personalizationImpact", - ) - user_token: Optional[StrictStr] = Field( - default=None, - description="Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/). ", - alias="userToken", - ) - get_ranking_info: Optional[StrictBool] = Field( - default=False, - description="Whether the search response should include detailed ranking information.", - alias="getRankingInfo", - ) - synonyms: Optional[StrictBool] = Field( - default=True, - description="Whether to take into account an index's synonyms for this search.", - ) - click_analytics: Optional[StrictBool] = Field( - default=False, - description="Whether to include a `queryID` attribute in the response. The query ID is a unique identifier for a search query and is required for tracking [click and conversion events](https://www.algolia.com/guides/sending-events/getting-started/). ", - alias="clickAnalytics", - ) - analytics: Optional[StrictBool] = Field( - default=True, description="Whether this search will be included in Analytics." - ) - analytics_tags: Optional[List[StrictStr]] = Field( - default=None, - description="Tags to apply to the query for [segmenting analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).", - alias="analyticsTags", - ) - percentile_computation: Optional[StrictBool] = Field( - default=True, - description="Whether to include this search when calculating processing-time percentiles.", - alias="percentileComputation", - ) - enable_ab_test: Optional[StrictBool] = Field( - default=True, - description="Whether to enable A/B testing for this search.", - alias="enableABTest", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseSearchParams from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.facet_filters: - _dict["facetFilters"] = self.facet_filters.to_dict() - if self.optional_filters: - _dict["optionalFilters"] = self.optional_filters.to_dict() - if self.numeric_filters: - _dict["numericFilters"] = self.numeric_filters.to_dict() - if self.tag_filters: - _dict["tagFilters"] = self.tag_filters.to_dict() - if self.around_radius: - _dict["aroundRadius"] = self.around_radius.to_dict() - if self.around_precision: - _dict["aroundPrecision"] = self.around_precision.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseSearchParams from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "query": obj.get("query"), - "similarQuery": obj.get("similarQuery"), - "filters": obj.get("filters"), - "facetFilters": ( - FacetFilters.from_dict(obj.get("facetFilters")) - if obj.get("facetFilters") is not None - else None - ), - "optionalFilters": ( - OptionalFilters.from_dict(obj.get("optionalFilters")) - if obj.get("optionalFilters") is not None - else None - ), - "numericFilters": ( - NumericFilters.from_dict(obj.get("numericFilters")) - if obj.get("numericFilters") is not None - else None - ), - "tagFilters": ( - TagFilters.from_dict(obj.get("tagFilters")) - if obj.get("tagFilters") is not None - else None - ), - "sumOrFiltersScores": obj.get("sumOrFiltersScores"), - "restrictSearchableAttributes": obj.get("restrictSearchableAttributes"), - "facets": obj.get("facets"), - "facetingAfterDistinct": obj.get("facetingAfterDistinct"), - "page": obj.get("page"), - "offset": obj.get("offset"), - "length": obj.get("length"), - "aroundLatLng": obj.get("aroundLatLng"), - "aroundLatLngViaIP": obj.get("aroundLatLngViaIP"), - "aroundRadius": ( - AroundRadius.from_dict(obj.get("aroundRadius")) - if obj.get("aroundRadius") is not None - else None - ), - "aroundPrecision": ( - AroundPrecision.from_dict(obj.get("aroundPrecision")) - if obj.get("aroundPrecision") is not None - else None - ), - "minimumAroundRadius": obj.get("minimumAroundRadius"), - "insideBoundingBox": obj.get("insideBoundingBox"), - "insidePolygon": obj.get("insidePolygon"), - "naturalLanguages": obj.get("naturalLanguages"), - "ruleContexts": obj.get("ruleContexts"), - "personalizationImpact": obj.get("personalizationImpact"), - "userToken": obj.get("userToken"), - "getRankingInfo": obj.get("getRankingInfo"), - "synonyms": obj.get("synonyms"), - "clickAnalytics": obj.get("clickAnalytics"), - "analytics": obj.get("analytics"), - "analyticsTags": obj.get("analyticsTags"), - "percentileComputation": obj.get("percentileComputation"), - "enableABTest": obj.get("enableABTest"), - } - ) - return _obj diff --git a/algoliasearch/search/models/base_search_params_without_query.py b/algoliasearch/search/models/base_search_params_without_query.py deleted file mode 100644 index d0911bc28..000000000 --- a/algoliasearch/search/models/base_search_params_without_query.py +++ /dev/null @@ -1,288 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, List, Optional, Self, Union - -from pydantic import ( - BaseModel, - ConfigDict, - Field, - StrictBool, - StrictFloat, - StrictInt, - StrictStr, -) - -from algoliasearch.search.models.around_precision import AroundPrecision -from algoliasearch.search.models.around_radius import AroundRadius -from algoliasearch.search.models.facet_filters import FacetFilters -from algoliasearch.search.models.numeric_filters import NumericFilters -from algoliasearch.search.models.optional_filters import OptionalFilters -from algoliasearch.search.models.supported_language import SupportedLanguage -from algoliasearch.search.models.tag_filters import TagFilters - - -class BaseSearchParamsWithoutQuery(BaseModel): - """ - BaseSearchParamsWithoutQuery - """ - - similar_query: Optional[StrictStr] = Field( - default="", - description="Keywords to be used instead of the search query to conduct a more broader search. Using the `similarQuery` parameter changes other settings: - `queryType` is set to `prefixNone`. - `removeStopWords` is set to true. - `words` is set as the first ranking criterion. - All remaining words are treated as `optionalWords`. Since the `similarQuery` is supposed to do a broad search, they usually return many results. Combine it with `filters` to narrow down the list of results. ", - alias="similarQuery", - ) - filters: Optional[StrictStr] = Field( - default=None, - description="Filter expression to only include items that match the filter criteria in the response. You can use these filter expressions: - **Numeric filters.** ` `, where `` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `: TO ` where `` and `` are the lower and upper limits of the range (inclusive). - **Facet filters.** `:` where `` is a facet attribute (case-sensitive) and `` a facet value. - **Tag filters.** `_tags:` or just `` (case-sensitive). - **Boolean filters.** `: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/). ", - ) - facet_filters: Optional[FacetFilters] = Field(default=None, alias="facetFilters") - optional_filters: Optional[OptionalFilters] = Field( - default=None, alias="optionalFilters" - ) - numeric_filters: Optional[NumericFilters] = Field( - default=None, alias="numericFilters" - ) - tag_filters: Optional[TagFilters] = Field(default=None, alias="tagFilters") - sum_or_filters_scores: Optional[StrictBool] = Field( - default=False, - description="Whether to sum all filter scores. If true, all filter scores are summed. Otherwise, the maximum filter score is kept. For more information, see [filter scores](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/in-depth/filter-scoring/#accumulating-scores-with-sumorfiltersscores). ", - alias="sumOrFiltersScores", - ) - restrict_searchable_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Restricts a search to a subset of your searchable attributes. Attribute names are case-sensitive. ", - alias="restrictSearchableAttributes", - ) - facets: Optional[List[StrictStr]] = Field( - default=None, - description="Facets for which to retrieve facet values that match the search criteria and the number of matching facet values. To retrieve all facets, use the wildcard character `*`. For more information, see [facets](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#contextual-facet-values-and-counts). ", - ) - faceting_after_distinct: Optional[StrictBool] = Field( - default=False, - description="Whether faceting should be applied after deduplication with `distinct`. This leads to accurate facet counts when using faceting in combination with `distinct`. It's usually better to use `afterDistinct` modifiers in the `attributesForFaceting` setting, as `facetingAfterDistinct` only computes correct facet counts if all records have the same facet values for the `attributeForDistinct`. ", - alias="facetingAfterDistinct", - ) - page: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( - default=0, description="Page of search results to retrieve." - ) - offset: Optional[StrictInt] = Field( - default=None, description="Position of the first hit to retrieve." - ) - length: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( - default=None, - description="Number of hits to retrieve (used in combination with `offset`).", - ) - around_lat_lng: Optional[StrictStr] = Field( - default="", - description="Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only records included within circle around this central location are included in the results. The radius of the circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you also specify `insidePolygon` or `insideBoundingBox`. ", - alias="aroundLatLng", - ) - around_lat_lng_via_ip: Optional[StrictBool] = Field( - default=False, - description="Whether to obtain the coordinates from the request's IP address.", - alias="aroundLatLngViaIP", - ) - around_radius: Optional[AroundRadius] = Field(default=None, alias="aroundRadius") - around_precision: Optional[AroundPrecision] = Field( - default=None, alias="aroundPrecision" - ) - minimum_around_radius: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field( - default=None, - description="Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.", - alias="minimumAroundRadius", - ) - inside_bounding_box: Optional[ - List[ - Annotated[ - List[Union[StrictFloat, StrictInt]], Field(min_length=4, max_length=4) - ] - ] - ] = Field( - default=None, - description="Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). ", - alias="insideBoundingBox", - ) - inside_polygon: Optional[ - List[ - Annotated[ - List[Union[StrictFloat, StrictInt]], - Field(min_length=6, max_length=20000), - ] - ] - ] = Field( - default=None, - description="Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). This parameter is ignored if you also specify `insideBoundingBox`. ", - alias="insidePolygon", - ) - natural_languages: Optional[List[SupportedLanguage]] = Field( - default=None, - description="ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches): - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and `analyticsTags`. ", - alias="naturalLanguages", - ) - rule_contexts: Optional[List[StrictStr]] = Field( - default=None, - description="Assigns a rule context to the search query. [Rule contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) are strings that you can use to trigger matching rules. ", - alias="ruleContexts", - ) - personalization_impact: Optional[ - Annotated[int, Field(le=100, strict=True, ge=0)] - ] = Field( - default=100, - description="Impact that Personalization should have on this search. The higher this value is, the more Personalization determines the ranking compared to other factors. For more information, see [Understanding Personalization impact](https://www.algolia.com/doc/guides/personalization/personalizing-results/in-depth/configuring-personalization/#understanding-personalization-impact). ", - alias="personalizationImpact", - ) - user_token: Optional[StrictStr] = Field( - default=None, - description="Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/). ", - alias="userToken", - ) - get_ranking_info: Optional[StrictBool] = Field( - default=False, - description="Whether the search response should include detailed ranking information.", - alias="getRankingInfo", - ) - synonyms: Optional[StrictBool] = Field( - default=True, - description="Whether to take into account an index's synonyms for this search.", - ) - click_analytics: Optional[StrictBool] = Field( - default=False, - description="Whether to include a `queryID` attribute in the response. The query ID is a unique identifier for a search query and is required for tracking [click and conversion events](https://www.algolia.com/guides/sending-events/getting-started/). ", - alias="clickAnalytics", - ) - analytics: Optional[StrictBool] = Field( - default=True, description="Whether this search will be included in Analytics." - ) - analytics_tags: Optional[List[StrictStr]] = Field( - default=None, - description="Tags to apply to the query for [segmenting analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).", - alias="analyticsTags", - ) - percentile_computation: Optional[StrictBool] = Field( - default=True, - description="Whether to include this search when calculating processing-time percentiles.", - alias="percentileComputation", - ) - enable_ab_test: Optional[StrictBool] = Field( - default=True, - description="Whether to enable A/B testing for this search.", - alias="enableABTest", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseSearchParamsWithoutQuery from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.facet_filters: - _dict["facetFilters"] = self.facet_filters.to_dict() - if self.optional_filters: - _dict["optionalFilters"] = self.optional_filters.to_dict() - if self.numeric_filters: - _dict["numericFilters"] = self.numeric_filters.to_dict() - if self.tag_filters: - _dict["tagFilters"] = self.tag_filters.to_dict() - if self.around_radius: - _dict["aroundRadius"] = self.around_radius.to_dict() - if self.around_precision: - _dict["aroundPrecision"] = self.around_precision.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseSearchParamsWithoutQuery from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "similarQuery": obj.get("similarQuery"), - "filters": obj.get("filters"), - "facetFilters": ( - FacetFilters.from_dict(obj.get("facetFilters")) - if obj.get("facetFilters") is not None - else None - ), - "optionalFilters": ( - OptionalFilters.from_dict(obj.get("optionalFilters")) - if obj.get("optionalFilters") is not None - else None - ), - "numericFilters": ( - NumericFilters.from_dict(obj.get("numericFilters")) - if obj.get("numericFilters") is not None - else None - ), - "tagFilters": ( - TagFilters.from_dict(obj.get("tagFilters")) - if obj.get("tagFilters") is not None - else None - ), - "sumOrFiltersScores": obj.get("sumOrFiltersScores"), - "restrictSearchableAttributes": obj.get("restrictSearchableAttributes"), - "facets": obj.get("facets"), - "facetingAfterDistinct": obj.get("facetingAfterDistinct"), - "page": obj.get("page"), - "offset": obj.get("offset"), - "length": obj.get("length"), - "aroundLatLng": obj.get("aroundLatLng"), - "aroundLatLngViaIP": obj.get("aroundLatLngViaIP"), - "aroundRadius": ( - AroundRadius.from_dict(obj.get("aroundRadius")) - if obj.get("aroundRadius") is not None - else None - ), - "aroundPrecision": ( - AroundPrecision.from_dict(obj.get("aroundPrecision")) - if obj.get("aroundPrecision") is not None - else None - ), - "minimumAroundRadius": obj.get("minimumAroundRadius"), - "insideBoundingBox": obj.get("insideBoundingBox"), - "insidePolygon": obj.get("insidePolygon"), - "naturalLanguages": obj.get("naturalLanguages"), - "ruleContexts": obj.get("ruleContexts"), - "personalizationImpact": obj.get("personalizationImpact"), - "userToken": obj.get("userToken"), - "getRankingInfo": obj.get("getRankingInfo"), - "synonyms": obj.get("synonyms"), - "clickAnalytics": obj.get("clickAnalytics"), - "analytics": obj.get("analytics"), - "analyticsTags": obj.get("analyticsTags"), - "percentileComputation": obj.get("percentileComputation"), - "enableABTest": obj.get("enableABTest"), - } - ) - return _obj diff --git a/algoliasearch/search/models/base_search_response.py b/algoliasearch/search/models/base_search_response.py deleted file mode 100644 index 194f64f8b..000000000 --- a/algoliasearch/search/models/base_search_response.py +++ /dev/null @@ -1,285 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from re import match -from typing import Annotated, Any, ClassVar, Dict, List, Optional, Self - -from pydantic import ( - BaseModel, - ConfigDict, - Field, - StrictBool, - StrictInt, - StrictStr, - field_validator, -) - -from algoliasearch.search.models.exhaustive import Exhaustive -from algoliasearch.search.models.facets_stats import FacetsStats -from algoliasearch.search.models.redirect import Redirect -from algoliasearch.search.models.rendering_content import RenderingContent - - -class BaseSearchResponse(BaseModel): - """ - BaseSearchResponse - """ - - ab_test_id: Optional[StrictInt] = Field( - default=None, - description="A/B test ID. This is only included in the response for indices that are part of an A/B test.", - alias="abTestID", - ) - ab_test_variant_id: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field( - default=None, - description="Variant ID. This is only included in the response for indices that are part of an A/B test.", - alias="abTestVariantID", - ) - around_lat_lng: Optional[Annotated[str, Field(strict=True)]] = Field( - default=None, - description="Computed geographical location.", - alias="aroundLatLng", - ) - automatic_radius: Optional[StrictStr] = Field( - default=None, - description="Distance from a central coordinate provided by `aroundLatLng`.", - alias="automaticRadius", - ) - exhaustive: Optional[Exhaustive] = None - exhaustive_facets_count: Optional[StrictBool] = Field( - default=None, - description="See the `facetsCount` field of the `exhaustive` object in the response.", - alias="exhaustiveFacetsCount", - ) - exhaustive_nb_hits: Optional[StrictBool] = Field( - default=None, - description="See the `nbHits` field of the `exhaustive` object in the response.", - alias="exhaustiveNbHits", - ) - exhaustive_typo: Optional[StrictBool] = Field( - default=None, - description="See the `typo` field of the `exhaustive` object in the response.", - alias="exhaustiveTypo", - ) - facets: Optional[Dict[str, Dict[str, StrictInt]]] = Field( - default=None, description="Facet counts." - ) - facets_stats: Optional[Dict[str, FacetsStats]] = Field( - default=None, description="Statistics for numerical facets." - ) - index: Optional[StrictStr] = Field( - default=None, description="Index name used for the query." - ) - index_used: Optional[StrictStr] = Field( - default=None, - description="Index name used for the query. During A/B testing, the targeted index isn't always the index used by the query.", - alias="indexUsed", - ) - message: Optional[StrictStr] = Field( - default=None, description="Warnings about the query." - ) - nb_sorted_hits: Optional[StrictInt] = Field( - default=None, - description="Number of hits selected and sorted by the relevant sort algorithm.", - alias="nbSortedHits", - ) - parsed_query: Optional[StrictStr] = Field( - default=None, - description="Post-[normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/#what-does-normalization-mean) query string that will be searched.", - alias="parsedQuery", - ) - processing_time_ms: StrictInt = Field( - description="Time the server took to process the request, in milliseconds.", - alias="processingTimeMS", - ) - processing_timings_ms: Optional[Dict[str, Any]] = Field( - default=None, - description="Experimental. List of processing steps and their times, in milliseconds. You can use this list to investigate performance issues.", - alias="processingTimingsMS", - ) - query_after_removal: Optional[StrictStr] = Field( - default=None, - description="Markup text indicating which parts of the original query have been removed to retrieve a non-empty result set.", - alias="queryAfterRemoval", - ) - redirect: Optional[Redirect] = None - rendering_content: Optional[RenderingContent] = Field( - default=None, alias="renderingContent" - ) - server_time_ms: Optional[StrictInt] = Field( - default=None, - description="Time the server took to process the request, in milliseconds.", - alias="serverTimeMS", - ) - server_used: Optional[StrictStr] = Field( - default=None, - description="Host name of the server that processed the request.", - alias="serverUsed", - ) - user_data: Optional[Dict[str, Any]] = Field( - default=None, - description="An object with custom data. You can store up to 32kB as custom data. ", - alias="userData", - ) - query_id: Optional[StrictStr] = Field( - default=None, - description="Unique identifier for the query. This is used for [click analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).", - alias="queryID", - ) - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = [ - "abTestID", - "abTestVariantID", - "aroundLatLng", - "automaticRadius", - "exhaustive", - "exhaustiveFacetsCount", - "exhaustiveNbHits", - "exhaustiveTypo", - "facets", - "facets_stats", - "index", - "indexUsed", - "message", - "nbSortedHits", - "parsedQuery", - "processingTimeMS", - "processingTimingsMS", - "queryAfterRemoval", - "redirect", - "renderingContent", - "serverTimeMS", - "serverUsed", - "userData", - "queryID", - ] - - @field_validator("around_lat_lng") - def around_lat_lng_validate_regular_expression(cls, value): - """Validates the regular expression""" - if value is None: - return value - - if not match(r"^(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)$", value): - raise ValueError( - r"must validate the regular expression /^(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)$/" - ) - return value - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BaseSearchResponse from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - if self.exhaustive: - _dict["exhaustive"] = self.exhaustive.to_dict() - _field_dict = {} - if self.facets_stats: - for _key in self.facets_stats: - if self.facets_stats[_key]: - _field_dict[_key] = self.facets_stats[_key].to_dict() - _dict["facets_stats"] = _field_dict - if self.redirect: - _dict["redirect"] = self.redirect.to_dict() - if self.rendering_content: - _dict["renderingContent"] = self.rendering_content.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BaseSearchResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "abTestID": obj.get("abTestID"), - "abTestVariantID": obj.get("abTestVariantID"), - "aroundLatLng": obj.get("aroundLatLng"), - "automaticRadius": obj.get("automaticRadius"), - "exhaustive": ( - Exhaustive.from_dict(obj.get("exhaustive")) - if obj.get("exhaustive") is not None - else None - ), - "exhaustiveFacetsCount": obj.get("exhaustiveFacetsCount"), - "exhaustiveNbHits": obj.get("exhaustiveNbHits"), - "exhaustiveTypo": obj.get("exhaustiveTypo"), - "facets": obj.get("facets"), - "facets_stats": ( - dict( - (_k, FacetsStats.from_dict(_v)) - for _k, _v in obj.get("facets_stats").items() - ) - if obj.get("facets_stats") is not None - else None - ), - "index": obj.get("index"), - "indexUsed": obj.get("indexUsed"), - "message": obj.get("message"), - "nbSortedHits": obj.get("nbSortedHits"), - "parsedQuery": obj.get("parsedQuery"), - "processingTimeMS": obj.get("processingTimeMS"), - "processingTimingsMS": obj.get("processingTimingsMS"), - "queryAfterRemoval": obj.get("queryAfterRemoval"), - "redirect": ( - Redirect.from_dict(obj.get("redirect")) - if obj.get("redirect") is not None - else None - ), - "renderingContent": ( - RenderingContent.from_dict(obj.get("renderingContent")) - if obj.get("renderingContent") is not None - else None - ), - "serverTimeMS": obj.get("serverTimeMS"), - "serverUsed": obj.get("serverUsed"), - "userData": obj.get("userData"), - "queryID": obj.get("queryID"), - } - ) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/search/models/browse_pagination.py b/algoliasearch/search/models/browse_pagination.py deleted file mode 100644 index f821ec2ea..000000000 --- a/algoliasearch/search/models/browse_pagination.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictInt - - -class BrowsePagination(BaseModel): - """ - BrowsePagination - """ - - page: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( - default=0, description="Page of search results to retrieve." - ) - nb_hits: Optional[StrictInt] = Field( - default=None, description="Number of results (hits).", alias="nbHits" - ) - nb_pages: Optional[StrictInt] = Field( - default=None, description="Number of pages of results.", alias="nbPages" - ) - hits_per_page: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( - default=20, description="Number of hits per page.", alias="hitsPerPage" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of BrowsePagination from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of BrowsePagination from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "page": obj.get("page"), - "nbHits": obj.get("nbHits"), - "nbPages": obj.get("nbPages"), - "hitsPerPage": obj.get("hitsPerPage"), - } - ) - return _obj diff --git a/algoliasearch/search/models/cursor.py b/algoliasearch/search/models/cursor.py deleted file mode 100644 index 90015ff5b..000000000 --- a/algoliasearch/search/models/cursor.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - - -class Cursor(BaseModel): - """ - Cursor - """ - - cursor: Optional[StrictStr] = Field( - default=None, - description="Cursor to get the next page of the response. The parameter must match the value returned in the response of a previous request. The last page of the response does not return a `cursor` attribute. ", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of Cursor from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of Cursor from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"cursor": obj.get("cursor")}) - return _obj diff --git a/algoliasearch/search/models/dictionary_entry.py b/algoliasearch/search/models/dictionary_entry.py index e8dc7c7a4..b4f1de9d6 100644 --- a/algoliasearch/search/models/dictionary_entry.py +++ b/algoliasearch/search/models/dictionary_entry.py @@ -23,7 +23,7 @@ class DictionaryEntry(BaseModel): object_id: StrictStr = Field( description="Unique identifier for the dictionary entry.", alias="objectID" ) - language: SupportedLanguage + language: Optional[SupportedLanguage] = None word: Optional[StrictStr] = Field( default=None, description="Matching dictionary word for `stopwords` and `compounds` dictionaries.", diff --git a/algoliasearch/search/models/error_base.py b/algoliasearch/search/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/search/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/search/models/index_settings_as_search_params.py b/algoliasearch/search/models/index_settings_as_search_params.py deleted file mode 100644 index 3121d7f1a..000000000 --- a/algoliasearch/search/models/index_settings_as_search_params.py +++ /dev/null @@ -1,357 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr - -from algoliasearch.search.models.advanced_syntax_features import AdvancedSyntaxFeatures -from algoliasearch.search.models.alternatives_as_exact import AlternativesAsExact -from algoliasearch.search.models.distinct import Distinct -from algoliasearch.search.models.exact_on_single_word_query import ( - ExactOnSingleWordQuery, -) -from algoliasearch.search.models.ignore_plurals import IgnorePlurals -from algoliasearch.search.models.mode import Mode -from algoliasearch.search.models.query_type import QueryType -from algoliasearch.search.models.re_ranking_apply_filter import ReRankingApplyFilter -from algoliasearch.search.models.remove_stop_words import RemoveStopWords -from algoliasearch.search.models.remove_words_if_no_results import ( - RemoveWordsIfNoResults, -) -from algoliasearch.search.models.rendering_content import RenderingContent -from algoliasearch.search.models.semantic_search import SemanticSearch -from algoliasearch.search.models.supported_language import SupportedLanguage -from algoliasearch.search.models.typo_tolerance import TypoTolerance - - -class IndexSettingsAsSearchParams(BaseModel): - """ - IndexSettingsAsSearchParams - """ - - attributes_to_retrieve: Optional[List[StrictStr]] = Field( - default=None, - description='Attributes to include in the API response. To reduce the size of your response, you can retrieve only some of the attributes. Attribute names are case-sensitive. - `*` retrieves all attributes, except attributes included in the `customRanking` and `unretrievableAttributes` settings. - To retrieve all attributes except a specific one, prefix the attribute with a dash and combine it with the `*`: `["*", "-ATTRIBUTE"]`. - The `objectID` attribute is always included. ', - alias="attributesToRetrieve", - ) - ranking: Optional[List[StrictStr]] = Field( - default=None, - description='Determines the order in which Algolia returns your results. By default, each entry corresponds to a [ranking criteria](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/). The tie-breaking algorithm sequentially applies each criterion in the order they\'re specified. If you configure a replica index for [sorting by an attribute](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/sort-by-attribute/), you put the sorting attribute at the top of the list. **Modifiers** - `asc("ATTRIBUTE")`. Sort the index by the values of an attribute, in ascending order. - `desc("ATTRIBUTE")`. Sort the index by the values of an attribute, in descending order. Before you modify the default setting, you should test your changes in the dashboard, and by [A/B testing](https://www.algolia.com/doc/guides/ab-testing/what-is-ab-testing/). ', - ) - custom_ranking: Optional[List[StrictStr]] = Field( - default=None, - description='Attributes to use as [custom ranking](https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/). Attribute names are case-sensitive. The custom ranking attributes decide which items are shown first if the other ranking criteria are equal. Records with missing values for your selected custom ranking attributes are always sorted last. Boolean attributes are sorted based on their alphabetical order. **Modifiers** - `asc("ATTRIBUTE")`. Sort the index by the values of an attribute, in ascending order. - `desc("ATTRIBUTE")`. Sort the index by the values of an attribute, in descending order. If you use two or more custom ranking attributes, [reduce the precision](https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/how-to/controlling-custom-ranking-metrics-precision/) of your first attributes, or the other attributes will never be applied. ', - alias="customRanking", - ) - relevancy_strictness: Optional[StrictInt] = Field( - default=100, - description="Relevancy threshold below which less relevant results aren't included in the results. You can only set `relevancyStrictness` on [virtual replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas). Use this setting to strike a balance between the relevance and number of returned results. ", - alias="relevancyStrictness", - ) - attributes_to_highlight: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes to highlight. By default, all searchable attributes are highlighted. Use `*` to highlight all attributes or use an empty array `[]` to turn off highlighting. Attribute names are case-sensitive. With highlighting, strings that match the search query are surrounded by HTML tags defined by `highlightPreTag` and `highlightPostTag`. You can use this to visually highlight matching parts of a search query in your UI. For more information, see [Highlighting and snippeting](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/highlighting-snippeting/js/). ", - alias="attributesToHighlight", - ) - attributes_to_snippet: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes for which to enable snippets. Attribute names are case-sensitive. Snippets provide additional context to matched words. If you enable snippets, they include 10 words, including the matched word. The matched word will also be wrapped by HTML tags for highlighting. You can adjust the number of words with the following notation: `ATTRIBUTE:NUMBER`, where `NUMBER` is the number of words to be extracted. ", - alias="attributesToSnippet", - ) - highlight_pre_tag: Optional[StrictStr] = Field( - default="", - description="HTML tag to insert before the highlighted parts in all highlighted results and snippets.", - alias="highlightPreTag", - ) - highlight_post_tag: Optional[StrictStr] = Field( - default="", - description="HTML tag to insert after the highlighted parts in all highlighted results and snippets.", - alias="highlightPostTag", - ) - snippet_ellipsis_text: Optional[StrictStr] = Field( - default="…", - description="String used as an ellipsis indicator when a snippet is truncated.", - alias="snippetEllipsisText", - ) - restrict_highlight_and_snippet_arrays: Optional[StrictBool] = Field( - default=False, - description="Whether to restrict highlighting and snippeting to items that at least partially matched the search query. By default, all items are highlighted and snippeted. ", - alias="restrictHighlightAndSnippetArrays", - ) - hits_per_page: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( - default=20, description="Number of hits per page.", alias="hitsPerPage" - ) - min_word_sizefor1_typo: Optional[StrictInt] = Field( - default=4, - description="Minimum number of characters a word in the search query must contain to accept matches with [one typo](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/in-depth/configuring-typo-tolerance/#configuring-word-length-for-typos).", - alias="minWordSizefor1Typo", - ) - min_word_sizefor2_typos: Optional[StrictInt] = Field( - default=8, - description="Minimum number of characters a word in the search query must contain to accept matches with [two typos](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/in-depth/configuring-typo-tolerance/#configuring-word-length-for-typos).", - alias="minWordSizefor2Typos", - ) - typo_tolerance: Optional[TypoTolerance] = Field(default=None, alias="typoTolerance") - allow_typos_on_numeric_tokens: Optional[StrictBool] = Field( - default=True, - description="Whether to allow typos on numbers in the search query. Turn off this setting to reduce the number of irrelevant matches when searching in large sets of similar numbers. ", - alias="allowTyposOnNumericTokens", - ) - disable_typo_tolerance_on_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Attributes for which you want to turn off [typo tolerance](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/). Attribute names are case-sensitive. Returning only exact matches can help when: - [Searching in hyphenated attributes](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/how-to/how-to-search-in-hyphenated-attributes/). - Reducing the number of matches when you have too many. This can happen with attributes that are long blocks of text, such as product descriptions. Consider alternatives such as `disableTypoToleranceOnWords` or adding synonyms if your attributes have intentional unusual spellings that might look like typos. ", - alias="disableTypoToleranceOnAttributes", - ) - ignore_plurals: Optional[IgnorePlurals] = Field(default=None, alias="ignorePlurals") - remove_stop_words: Optional[RemoveStopWords] = Field( - default=None, alias="removeStopWords" - ) - keep_diacritics_on_characters: Optional[StrictStr] = Field( - default="", - description="Characters for which diacritics should be preserved. By default, Algolia removes diacritics from letters. For example, `é` becomes `e`. If this causes issues in your search, you can specify characters that should keep their diacritics. ", - alias="keepDiacriticsOnCharacters", - ) - query_languages: Optional[List[SupportedLanguage]] = Field( - default=None, - description="Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries. This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` settings. This setting also sets a dictionary for word detection in the logogram-based [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) languages. To support this, you must place the CJK language **first**. **You should always specify a query language.** If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/), or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to unexpected search results. For more information, see [Language-specific configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/). ", - alias="queryLanguages", - ) - decompound_query: Optional[StrictBool] = Field( - default=True, - description="Whether to split compound words in the query into their building blocks. For more information, see [Word segmentation](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/#splitting-compound-words). Word segmentation is supported for these languages: German, Dutch, Finnish, Swedish, and Norwegian. Decompounding doesn't work for words with [non-spacing mark Unicode characters](https://www.charactercodes.net/category/non-spacing_mark). For example, `Gartenstühle` won't be decompounded if the `ü` consists of `u` (U+0075) and `◌̈` (U+0308). ", - alias="decompoundQuery", - ) - enable_rules: Optional[StrictBool] = Field( - default=True, description="Whether to enable rules.", alias="enableRules" - ) - enable_personalization: Optional[StrictBool] = Field( - default=False, - description="Whether to enable Personalization.", - alias="enablePersonalization", - ) - query_type: Optional[QueryType] = Field(default=None, alias="queryType") - remove_words_if_no_results: Optional[RemoveWordsIfNoResults] = Field( - default=None, alias="removeWordsIfNoResults" - ) - mode: Optional[Mode] = None - semantic_search: Optional[SemanticSearch] = Field( - default=None, alias="semanticSearch" - ) - advanced_syntax: Optional[StrictBool] = Field( - default=False, - description="Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. ", - alias="advancedSyntax", - ) - optional_words: Optional[List[StrictStr]] = Field( - default=None, - description='Words that should be considered optional when found in the query. By default, records must match all words in the search query to be included in the search results. Adding optional words can help to increase the number of search results by running an additional search query that doesn\'t include the optional words. For example, if the search query is "action video" and "video" is an optional word, the search engine runs two queries. One for "action video" and one for "action". Records that match all words are ranked higher. For a search query with 4 or more words **and** all its words are optional, the number of matched words required for a record to be included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of optional words dividied by 5 (rounded down). For example, with 18 optional words: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more information, see [Optional words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words). ', - alias="optionalWords", - ) - disable_exact_on_attributes: Optional[List[StrictStr]] = Field( - default=None, - description="Searchable attributes for which you want to [turn off the Exact ranking criterion](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/in-depth/adjust-exact-settings/#turn-off-exact-for-some-attributes). Attribute names are case-sensitive. This can be useful for attributes with long values, where the likelyhood of an exact match is high, such as product descriptions. Turning off the Exact ranking criterion for these attributes favors exact matching on other attributes. This reduces the impact of individual attributes with a lot of content on ranking. ", - alias="disableExactOnAttributes", - ) - exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = Field( - default=None, alias="exactOnSingleWordQuery" - ) - alternatives_as_exact: Optional[List[AlternativesAsExact]] = Field( - default=None, - description='Alternatives of query words that should be considered as exact matches by the Exact ranking criterion. - `ignorePlurals`. Plurals and similar declensions added by the `ignorePlurals` setting are considered exact matches. - `singleWordSynonym`. Single-word synonyms, such as "NY/NYC" are considered exact matches. - `multiWordsSynonym`. Multi-word synonyms, such as "NY/New York" are considered exact matches. ', - alias="alternativesAsExact", - ) - advanced_syntax_features: Optional[List[AdvancedSyntaxFeatures]] = Field( - default=None, - description='Advanced search syntax features you want to support. - `exactPhrase`. Phrases in quotes must match exactly. For example, `sparkly blue "iPhone case"` only returns records with the exact string "iPhone case". - `excludeWords`. Query words prefixed with a `-` must not occur in a record. For example, `search -engine` matches records that contain "search" but not "engine". This setting only has an effect if `advancedSyntax` is true. ', - alias="advancedSyntaxFeatures", - ) - distinct: Optional[Distinct] = None - replace_synonyms_in_highlight: Optional[StrictBool] = Field( - default=False, - description='Whether to replace a highlighted word with the matched synonym. By default, the original words are highlighted even if a synonym matches. For example, with `home` as a synonym for `house` and a search for `home`, records matching either "home" or "house" are included in the search results, and either "home" or "house" are highlighted. With `replaceSynonymsInHighlight` set to `true`, a search for `home` still matches the same records, but all occurences of "house" are replaced by "home" in the highlighted response. ', - alias="replaceSynonymsInHighlight", - ) - min_proximity: Optional[Annotated[int, Field(le=7, strict=True, ge=1)]] = Field( - default=1, - description="Minimum proximity score for two matching words. This adjusts the [Proximity ranking criterion](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/#proximity) by equally scoring matches that are farther apart. For example, if `minProximity` is 2, neighboring matches and matches with one word between them would have the same score. ", - alias="minProximity", - ) - response_fields: Optional[List[StrictStr]] = Field( - default=None, - description="Properties to include in the API response of `search` and `browse` requests. By default, all response properties are included. To reduce the response size, you can select, which attributes should be included. You can't exclude these properties: `message`, `warning`, `cursor`, `serverUsed`, `indexUsed`, `abTestVariantID`, `parsedQuery`, or any property triggered by the `getRankingInfo` parameter. Don't exclude properties that you might need in your search UI. ", - alias="responseFields", - ) - max_facet_hits: Optional[Annotated[int, Field(le=100, strict=True)]] = Field( - default=10, - description="Maximum number of facet values to return when [searching for facet values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).", - alias="maxFacetHits", - ) - max_values_per_facet: Optional[Annotated[int, Field(le=1000, strict=True)]] = Field( - default=100, - description="Maximum number of facet values to return for each facet.", - alias="maxValuesPerFacet", - ) - sort_facet_values_by: Optional[StrictStr] = Field( - default="count", - description="Order in which to retrieve facet values. - `count`. Facet values are retrieved by decreasing count. The count is the number of matching records containing this facet value. - `alpha`. Retrieve facet values alphabetically. This setting doesn't influence how facet values are displayed in your UI (see `renderingContent`). For more information, see [facet value display](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/facet-display/js/). ", - alias="sortFacetValuesBy", - ) - attribute_criteria_computed_by_min_proximity: Optional[StrictBool] = Field( - default=False, - description="Whether the best matching attribute should be determined by minimum proximity. This setting only affects ranking if the Attribute ranking criterion comes before Proximity in the `ranking` setting. If true, the best matching attribute is selected based on the minimum proximity of multiple matches. Otherwise, the best matching attribute is determined by the order in the `searchableAttributes` setting. ", - alias="attributeCriteriaComputedByMinProximity", - ) - rendering_content: Optional[RenderingContent] = Field( - default=None, alias="renderingContent" - ) - enable_re_ranking: Optional[StrictBool] = Field( - default=True, - description="Whether this search will use [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/). This setting only has an effect if you activated Dynamic Re-Ranking for this index in the Algolia dashboard. ", - alias="enableReRanking", - ) - re_ranking_apply_filter: Optional[ReRankingApplyFilter] = Field( - default=None, alias="reRankingApplyFilter" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of IndexSettingsAsSearchParams from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.typo_tolerance: - _dict["typoTolerance"] = self.typo_tolerance.to_dict() - if self.ignore_plurals: - _dict["ignorePlurals"] = self.ignore_plurals.to_dict() - if self.remove_stop_words: - _dict["removeStopWords"] = self.remove_stop_words.to_dict() - if self.semantic_search: - _dict["semanticSearch"] = self.semantic_search.to_dict() - if self.distinct: - _dict["distinct"] = self.distinct.to_dict() - if self.rendering_content: - _dict["renderingContent"] = self.rendering_content.to_dict() - if self.re_ranking_apply_filter: - _dict["reRankingApplyFilter"] = self.re_ranking_apply_filter.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of IndexSettingsAsSearchParams from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "attributesToRetrieve": obj.get("attributesToRetrieve"), - "ranking": obj.get("ranking"), - "customRanking": obj.get("customRanking"), - "relevancyStrictness": obj.get("relevancyStrictness"), - "attributesToHighlight": obj.get("attributesToHighlight"), - "attributesToSnippet": obj.get("attributesToSnippet"), - "highlightPreTag": obj.get("highlightPreTag"), - "highlightPostTag": obj.get("highlightPostTag"), - "snippetEllipsisText": obj.get("snippetEllipsisText"), - "restrictHighlightAndSnippetArrays": obj.get( - "restrictHighlightAndSnippetArrays" - ), - "hitsPerPage": obj.get("hitsPerPage"), - "minWordSizefor1Typo": obj.get("minWordSizefor1Typo"), - "minWordSizefor2Typos": obj.get("minWordSizefor2Typos"), - "typoTolerance": ( - TypoTolerance.from_dict(obj.get("typoTolerance")) - if obj.get("typoTolerance") is not None - else None - ), - "allowTyposOnNumericTokens": obj.get("allowTyposOnNumericTokens"), - "disableTypoToleranceOnAttributes": obj.get( - "disableTypoToleranceOnAttributes" - ), - "ignorePlurals": ( - IgnorePlurals.from_dict(obj.get("ignorePlurals")) - if obj.get("ignorePlurals") is not None - else None - ), - "removeStopWords": ( - RemoveStopWords.from_dict(obj.get("removeStopWords")) - if obj.get("removeStopWords") is not None - else None - ), - "keepDiacriticsOnCharacters": obj.get("keepDiacriticsOnCharacters"), - "queryLanguages": obj.get("queryLanguages"), - "decompoundQuery": obj.get("decompoundQuery"), - "enableRules": obj.get("enableRules"), - "enablePersonalization": obj.get("enablePersonalization"), - "queryType": obj.get("queryType"), - "removeWordsIfNoResults": obj.get("removeWordsIfNoResults"), - "mode": obj.get("mode"), - "semanticSearch": ( - SemanticSearch.from_dict(obj.get("semanticSearch")) - if obj.get("semanticSearch") is not None - else None - ), - "advancedSyntax": obj.get("advancedSyntax"), - "optionalWords": obj.get("optionalWords"), - "disableExactOnAttributes": obj.get("disableExactOnAttributes"), - "exactOnSingleWordQuery": obj.get("exactOnSingleWordQuery"), - "alternativesAsExact": obj.get("alternativesAsExact"), - "advancedSyntaxFeatures": obj.get("advancedSyntaxFeatures"), - "distinct": ( - Distinct.from_dict(obj.get("distinct")) - if obj.get("distinct") is not None - else None - ), - "replaceSynonymsInHighlight": obj.get("replaceSynonymsInHighlight"), - "minProximity": obj.get("minProximity"), - "responseFields": obj.get("responseFields"), - "maxFacetHits": obj.get("maxFacetHits"), - "maxValuesPerFacet": obj.get("maxValuesPerFacet"), - "sortFacetValuesBy": obj.get("sortFacetValuesBy"), - "attributeCriteriaComputedByMinProximity": obj.get( - "attributeCriteriaComputedByMinProximity" - ), - "renderingContent": ( - RenderingContent.from_dict(obj.get("renderingContent")) - if obj.get("renderingContent") is not None - else None - ), - "enableReRanking": obj.get("enableReRanking"), - "reRankingApplyFilter": ( - ReRankingApplyFilter.from_dict(obj.get("reRankingApplyFilter")) - if obj.get("reRankingApplyFilter") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/search/models/params.py b/algoliasearch/search/models/params.py deleted file mode 100644 index e841fd42b..000000000 --- a/algoliasearch/search/models/params.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field - -from algoliasearch.search.models.automatic_facet_filters import AutomaticFacetFilters -from algoliasearch.search.models.consequence_query import ConsequenceQuery -from algoliasearch.search.models.rendering_content import RenderingContent - - -class Params(BaseModel): - """ - Parameters to apply to this search. You can use all search parameters, plus special `automaticFacetFilters`, `automaticOptionalFacetFilters`, and `query`. - """ - - query: Optional[ConsequenceQuery] = None - automatic_facet_filters: Optional[AutomaticFacetFilters] = Field( - default=None, alias="automaticFacetFilters" - ) - automatic_optional_facet_filters: Optional[AutomaticFacetFilters] = Field( - default=None, alias="automaticOptionalFacetFilters" - ) - rendering_content: Optional[RenderingContent] = Field( - default=None, alias="renderingContent" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of Params from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.query: - _dict["query"] = self.query.to_dict() - if self.automatic_facet_filters: - _dict["automaticFacetFilters"] = self.automatic_facet_filters.to_dict() - if self.automatic_optional_facet_filters: - _dict["automaticOptionalFacetFilters"] = ( - self.automatic_optional_facet_filters.to_dict() - ) - if self.rendering_content: - _dict["renderingContent"] = self.rendering_content.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of Params from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "query": ( - ConsequenceQuery.from_dict(obj.get("query")) - if obj.get("query") is not None - else None - ), - "automaticFacetFilters": ( - AutomaticFacetFilters.from_dict(obj.get("automaticFacetFilters")) - if obj.get("automaticFacetFilters") is not None - else None - ), - "automaticOptionalFacetFilters": ( - AutomaticFacetFilters.from_dict( - obj.get("automaticOptionalFacetFilters") - ) - if obj.get("automaticOptionalFacetFilters") is not None - else None - ), - "renderingContent": ( - RenderingContent.from_dict(obj.get("renderingContent")) - if obj.get("renderingContent") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/search/models/search_for_facets_options.py b/algoliasearch/search/models/search_for_facets_options.py deleted file mode 100644 index 68ddbe54f..000000000 --- a/algoliasearch/search/models/search_for_facets_options.py +++ /dev/null @@ -1,85 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.search.models.search_type_facet import SearchTypeFacet - - -class SearchForFacetsOptions(BaseModel): - """ - SearchForFacetsOptions - """ - - facet: StrictStr = Field(description="Facet name.") - index_name: StrictStr = Field( - description="Index name (case-sensitive).", alias="indexName" - ) - facet_query: Optional[StrictStr] = Field( - default="", - description="Text to search inside the facet's values.", - alias="facetQuery", - ) - max_facet_hits: Optional[Annotated[int, Field(le=100, strict=True)]] = Field( - default=10, - description="Maximum number of facet values to return when [searching for facet values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).", - alias="maxFacetHits", - ) - type: SearchTypeFacet - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of SearchForFacetsOptions from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of SearchForFacetsOptions from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "facet": obj.get("facet"), - "indexName": obj.get("indexName"), - "facetQuery": obj.get("facetQuery"), - "maxFacetHits": obj.get("maxFacetHits"), - "type": obj.get("type"), - } - ) - return _obj diff --git a/algoliasearch/search/models/search_for_hits_options.py b/algoliasearch/search/models/search_for_hits_options.py deleted file mode 100644 index af341364f..000000000 --- a/algoliasearch/search/models/search_for_hits_options.py +++ /dev/null @@ -1,68 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.search.models.search_type_default import SearchTypeDefault - - -class SearchForHitsOptions(BaseModel): - """ - SearchForHitsOptions - """ - - index_name: StrictStr = Field( - description="Index name (case-sensitive).", alias="indexName" - ) - type: Optional[SearchTypeDefault] = None - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of SearchForHitsOptions from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of SearchForHitsOptions from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - {"indexName": obj.get("indexName"), "type": obj.get("type")} - ) - return _obj diff --git a/algoliasearch/search/models/search_hits.py b/algoliasearch/search/models/search_hits.py deleted file mode 100644 index 4aaa37282..000000000 --- a/algoliasearch/search/models/search_hits.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.search.models.hit import Hit - - -class SearchHits(BaseModel): - """ - SearchHits - """ - - hits: List[Hit] = Field( - description="Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. " - ) - query: StrictStr = Field(description="Search query.") - params: StrictStr = Field( - description="URL-encoded string of all search parameters." - ) - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["hits", "query", "params"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of SearchHits from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - _items = [] - if self.hits: - for _item in self.hits: - if _item: - _items.append(_item.to_dict()) - _dict["hits"] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of SearchHits from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "hits": ( - [Hit.from_dict(_item) for _item in obj.get("hits")] - if obj.get("hits") is not None - else None - ), - "query": obj.get("query"), - "params": obj.get("params"), - } - ) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/search/models/search_pagination.py b/algoliasearch/search/models/search_pagination.py deleted file mode 100644 index 9881e858f..000000000 --- a/algoliasearch/search/models/search_pagination.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Annotated, Any, Dict, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictInt - - -class SearchPagination(BaseModel): - """ - SearchPagination - """ - - page: Annotated[int, Field(strict=True, ge=0)] = Field( - description="Page of search results to retrieve." - ) - nb_hits: StrictInt = Field(description="Number of results (hits).", alias="nbHits") - nb_pages: StrictInt = Field( - description="Number of pages of results.", alias="nbPages" - ) - hits_per_page: Annotated[int, Field(le=1000, strict=True, ge=1)] = Field( - description="Number of hits per page.", alias="hitsPerPage" - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of SearchPagination from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of SearchPagination from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "page": obj.get("page"), - "nbHits": obj.get("nbHits"), - "nbPages": obj.get("nbPages"), - "hitsPerPage": obj.get("hitsPerPage"), - } - ) - return _obj diff --git a/algoliasearch/search/models/search_params_query.py b/algoliasearch/search/models/search_params_query.py deleted file mode 100644 index c31750cda..000000000 --- a/algoliasearch/search/models/search_params_query.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - - -class SearchParamsQuery(BaseModel): - """ - SearchParamsQuery - """ - - query: Optional[StrictStr] = Field(default="", description="Search query.") - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of SearchParamsQuery from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of SearchParamsQuery from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"query": obj.get("query")}) - return _obj diff --git a/algoliasearch/search/models/with_primary.py b/algoliasearch/search/models/with_primary.py deleted file mode 100644 index 78bca3446..000000000 --- a/algoliasearch/search/models/with_primary.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - - -class WithPrimary(BaseModel): - """ - WithPrimary - """ - - primary: Optional[StrictStr] = Field( - default=None, - description="Replica indices only: the name of the primary index for this replica. ", - ) - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of WithPrimary from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of WithPrimary from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"primary": obj.get("primary")}) - return _obj diff --git a/algoliasearch/usage/models/error_base.py b/algoliasearch/usage/models/error_base.py deleted file mode 100644 index 7d8edf328..000000000 --- a/algoliasearch/usage/models/error_base.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, ClassVar, Dict, List, Optional, Self - -from pydantic import BaseModel, ConfigDict, StrictStr - - -class ErrorBase(BaseModel): - """ - Error. - """ - - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["message"] - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ErrorBase from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ErrorBase from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({"message": obj.get("message")}) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/algoliasearch/usage/models/forbidden.py b/algoliasearch/usage/models/forbidden.py deleted file mode 100644 index e88ae5058..000000000 --- a/algoliasearch/usage/models/forbidden.py +++ /dev/null @@ -1,73 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Self - -from pydantic import BaseModel, ConfigDict - -from algoliasearch.usage.models.forbidden_error import ForbiddenError - - -class Forbidden(BaseModel): - """ - Forbidden - """ - - error: ForbiddenError - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of Forbidden from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.error: - _dict["error"] = self.error.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of Forbidden from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "error": ( - ForbiddenError.from_dict(obj.get("error")) - if obj.get("error") is not None - else None - ) - } - ) - return _obj diff --git a/algoliasearch/usage/models/invalid_request.py b/algoliasearch/usage/models/invalid_request.py deleted file mode 100644 index 1737c6187..000000000 --- a/algoliasearch/usage/models/invalid_request.py +++ /dev/null @@ -1,73 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Self - -from pydantic import BaseModel, ConfigDict - -from algoliasearch.usage.models.invalid_request_error import InvalidRequestError - - -class InvalidRequest(BaseModel): - """ - InvalidRequest - """ - - error: InvalidRequestError - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of InvalidRequest from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.error: - _dict["error"] = self.error.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of InvalidRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "error": ( - InvalidRequestError.from_dict(obj.get("error")) - if obj.get("error") is not None - else None - ) - } - ) - return _obj