99
1010from typesense .api_call import ApiCall
1111from typesense .types .synonym_set import (
12+ SynonymItemDeleteSchema ,
13+ SynonymItemSchema ,
14+ SynonymSetCreateSchema ,
1215 SynonymSetDeleteSchema ,
1316 SynonymSetRetrieveSchema ,
14- SynonymItemSchema ,
15- SynonymItemDeleteSchema ,
1617)
1718
1819
@@ -35,13 +36,21 @@ def retrieve(self) -> SynonymSetRetrieveSchema:
3536 )
3637 return response
3738
39+ def upsert (self , set : SynonymSetCreateSchema ) -> SynonymSetCreateSchema :
40+ response : SynonymSetCreateSchema = self .api_call .put (
41+ self ._endpoint_path ,
42+ entity_type = SynonymSetCreateSchema ,
43+ body = set ,
44+ )
45+ return response
46+
3847 def delete (self ) -> SynonymSetDeleteSchema :
3948 response : SynonymSetDeleteSchema = self .api_call .delete (
4049 self ._endpoint_path ,
4150 entity_type = SynonymSetDeleteSchema ,
4251 )
4352 return response
44-
53+
4554 @property
4655 def _items_path (self ) -> str :
4756 return "/" .join ([self ._endpoint_path , "items" ]) # /synonym_sets/{name}/items
@@ -57,9 +66,7 @@ def list_items(
5766 "offset" : offset ,
5867 }
5968 clean_params : typing .Dict [str , int ] = {
60- k : v
61- for k , v in params .items ()
62- if v is not None
69+ k : v for k , v in params .items () if v is not None
6370 }
6471 response : typing .List [SynonymItemSchema ] = self .api_call .get (
6572 self ._items_path ,
@@ -91,5 +98,3 @@ def delete_item(self, item_id: str) -> SynonymItemDeleteSchema:
9198 "/" .join ([self ._items_path , item_id ]), entity_type = SynonymItemDeleteSchema
9299 )
93100 return response
94-
95-
0 commit comments