diff --git a/qdrant_client/http/api/cluster_api.py b/qdrant_client/http/api/cluster_api.py index 7bdc5dba..cd1bb9df 100644 --- a/qdrant_client/http/api/cluster_api.py +++ b/qdrant_client/http/api/cluster_api.py @@ -1,7 +1,7 @@ # flake8: noqa E501 from typing import TYPE_CHECKING, Any, Dict, Set, Union -from qdrant_client._pydantic_compat import to_dict +from qdrant_client._pydantic_compat import to_json from qdrant_client.http.models import * from qdrant_client.http.models import models as m @@ -18,8 +18,8 @@ def jsonable_encoder( skip_defaults: bool = None, exclude_unset: bool = False, ): - if hasattr(obj, "dict") or hasattr(obj, "model_dump"): - return to_dict( + if hasattr(obj, "json") or hasattr(obj, "model_dump_json"): + return to_json( obj, include=include, exclude=exclude, @@ -115,15 +115,17 @@ def _build_for_update_collection_cluster( if timeout is not None: query_params["timeout"] = str(timeout) + headers = {} body = jsonable_encoder(cluster_operations) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2003, method="POST", url="/collections/{collection_name}/cluster", path_params=path_params, params=query_params, - json=body, + data=body, ) diff --git a/qdrant_client/http/api/collections_api.py b/qdrant_client/http/api/collections_api.py index 41a388c3..f7d321fd 100644 --- a/qdrant_client/http/api/collections_api.py +++ b/qdrant_client/http/api/collections_api.py @@ -1,7 +1,7 @@ # flake8: noqa E501 from typing import IO, TYPE_CHECKING, Any, Dict, Set, Union -from qdrant_client._pydantic_compat import to_dict +from qdrant_client._pydantic_compat import to_json from qdrant_client.http.models import * from qdrant_client.http.models import models as m @@ -18,8 +18,8 @@ def jsonable_encoder( skip_defaults: bool = None, exclude_unset: bool = False, ): - if hasattr(obj, "dict") or hasattr(obj, "model_dump"): - return to_dict( + if hasattr(obj, "json") or hasattr(obj, "model_dump_json"): + return to_json( obj, include=include, exclude=exclude, @@ -73,15 +73,17 @@ def _build_for_create_collection( if timeout is not None: query_params["timeout"] = str(timeout) + headers = {} body = jsonable_encoder(create_collection) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2003, method="PUT", url="/collections/{collection_name}", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_create_field_index( @@ -104,15 +106,17 @@ def _build_for_create_field_index( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(create_field_index) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="PUT", url="/collections/{collection_name}/index", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_create_snapshot( @@ -333,15 +337,17 @@ def _build_for_recover_from_snapshot( if wait is not None: query_params["wait"] = str(wait).lower() + headers = {} body = jsonable_encoder(snapshot_recover) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2003, method="PUT", url="/collections/{collection_name}/snapshots/recover", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_recover_from_uploaded_snapshot( @@ -388,10 +394,12 @@ def _build_for_update_aliases( if timeout is not None: query_params["timeout"] = str(timeout) + headers = {} body = jsonable_encoder(change_aliases_operation) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( - type_=m.InlineResponse2003, method="POST", url="/collections/aliases", params=query_params, json=body + type_=m.InlineResponse2003, method="POST", url="/collections/aliases", params=query_params, data=body ) def _build_for_update_collection( @@ -411,15 +419,17 @@ def _build_for_update_collection( if timeout is not None: query_params["timeout"] = str(timeout) + headers = {} body = jsonable_encoder(update_collection) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2003, method="PATCH", url="/collections/{collection_name}", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_update_collection_cluster( @@ -436,15 +446,17 @@ def _build_for_update_collection_cluster( if timeout is not None: query_params["timeout"] = str(timeout) + headers = {} body = jsonable_encoder(cluster_operations) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2003, method="POST", url="/collections/{collection_name}/cluster", path_params=path_params, params=query_params, - json=body, + data=body, ) diff --git a/qdrant_client/http/api/points_api.py b/qdrant_client/http/api/points_api.py index 24db7ddf..2d3589f8 100644 --- a/qdrant_client/http/api/points_api.py +++ b/qdrant_client/http/api/points_api.py @@ -1,7 +1,7 @@ # flake8: noqa E501 from typing import TYPE_CHECKING, Any, Dict, Set, Union -from qdrant_client._pydantic_compat import to_dict +from qdrant_client._pydantic_compat import to_json from qdrant_client.http.models import * from qdrant_client.http.models import models as m @@ -18,8 +18,8 @@ def jsonable_encoder( skip_defaults: bool = None, exclude_unset: bool = False, ): - if hasattr(obj, "dict") or hasattr(obj, "model_dump"): - return to_dict( + if hasattr(obj, "json") or hasattr(obj, "model_dump_json"): + return to_json( obj, include=include, exclude=exclude, @@ -58,15 +58,17 @@ def _build_for_clear_payload( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(points_selector) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="POST", url="/collections/{collection_name}/points/payload/clear", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_count_points( @@ -81,14 +83,16 @@ def _build_for_count_points( "collection_name": str(collection_name), } + headers = {} body = jsonable_encoder(count_request) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20017, method="POST", url="/collections/{collection_name}/points/count", path_params=path_params, - json=body, + data=body, ) def _build_for_delete_payload( @@ -111,15 +115,17 @@ def _build_for_delete_payload( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(delete_payload) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="POST", url="/collections/{collection_name}/points/payload/delete", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_delete_points( @@ -142,15 +148,17 @@ def _build_for_delete_points( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(points_selector) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="POST", url="/collections/{collection_name}/points/delete", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_delete_vectors( @@ -173,15 +181,17 @@ def _build_for_delete_vectors( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(delete_vectors) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="POST", url="/collections/{collection_name}/points/vectors/delete", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_get_point( @@ -227,15 +237,17 @@ def _build_for_get_points( if consistency is not None: query_params["consistency"] = str(consistency) + headers = {} body = jsonable_encoder(point_request) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20012, method="POST", url="/collections/{collection_name}/points", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_overwrite_payload( @@ -258,15 +270,17 @@ def _build_for_overwrite_payload( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(set_payload) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="PUT", url="/collections/{collection_name}/points/payload", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_recommend_batch_points( @@ -286,15 +300,17 @@ def _build_for_recommend_batch_points( if consistency is not None: query_params["consistency"] = str(consistency) + headers = {} body = jsonable_encoder(recommend_request_batch) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20015, method="POST", url="/collections/{collection_name}/points/recommend/batch", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_recommend_point_groups( @@ -314,15 +330,17 @@ def _build_for_recommend_point_groups( if consistency is not None: query_params["consistency"] = str(consistency) + headers = {} body = jsonable_encoder(recommend_groups_request) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20016, method="POST", url="/collections/{collection_name}/points/recommend/groups", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_recommend_points( @@ -342,15 +360,17 @@ def _build_for_recommend_points( if consistency is not None: query_params["consistency"] = str(consistency) + headers = {} body = jsonable_encoder(recommend_request) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20014, method="POST", url="/collections/{collection_name}/points/recommend", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_scroll_points( @@ -370,15 +390,17 @@ def _build_for_scroll_points( if consistency is not None: query_params["consistency"] = str(consistency) + headers = {} body = jsonable_encoder(scroll_request) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20013, method="POST", url="/collections/{collection_name}/points/scroll", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_search_batch_points( @@ -398,15 +420,17 @@ def _build_for_search_batch_points( if consistency is not None: query_params["consistency"] = str(consistency) + headers = {} body = jsonable_encoder(search_request_batch) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20015, method="POST", url="/collections/{collection_name}/points/search/batch", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_search_point_groups( @@ -426,15 +450,17 @@ def _build_for_search_point_groups( if consistency is not None: query_params["consistency"] = str(consistency) + headers = {} body = jsonable_encoder(search_groups_request) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20016, method="POST", url="/collections/{collection_name}/points/search/groups", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_search_points( @@ -454,15 +480,17 @@ def _build_for_search_points( if consistency is not None: query_params["consistency"] = str(consistency) + headers = {} body = jsonable_encoder(search_request) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse20014, method="POST", url="/collections/{collection_name}/points/search", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_set_payload( @@ -485,15 +513,17 @@ def _build_for_set_payload( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(set_payload) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="POST", url="/collections/{collection_name}/points/payload", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_update_vectors( @@ -516,15 +546,17 @@ def _build_for_update_vectors( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(update_vectors) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="PUT", url="/collections/{collection_name}/points/vectors", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_upsert_points( @@ -547,15 +579,17 @@ def _build_for_upsert_points( if ordering is not None: query_params["ordering"] = str(ordering) + headers = {} body = jsonable_encoder(point_insert_operations) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2006, method="PUT", url="/collections/{collection_name}/points", path_params=path_params, params=query_params, - json=body, + data=body, ) diff --git a/qdrant_client/http/api/service_api.py b/qdrant_client/http/api/service_api.py index 40afda9b..b4fa3fb2 100644 --- a/qdrant_client/http/api/service_api.py +++ b/qdrant_client/http/api/service_api.py @@ -1,7 +1,7 @@ # flake8: noqa E501 from typing import TYPE_CHECKING, Any, Dict, Set, Union -from qdrant_client._pydantic_compat import to_dict +from qdrant_client._pydantic_compat import to_json from qdrant_client.http.models import * from qdrant_client.http.models import models as m @@ -18,8 +18,8 @@ def jsonable_encoder( skip_defaults: bool = None, exclude_unset: bool = False, ): - if hasattr(obj, "dict") or hasattr(obj, "model_dump"): - return to_dict( + if hasattr(obj, "json") or hasattr(obj, "model_dump_json"): + return to_json( obj, include=include, exclude=exclude, @@ -75,9 +75,11 @@ def _build_for_post_locks( """ Set lock options. If write is locked, all write operations and collection creation are forbidden. Returns previous lock options """ + headers = {} body = jsonable_encoder(locks_option) - - return self.api_client.request(type_=m.InlineResponse2001, method="POST", url="/locks", json=body) + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" + return self.api_client.request(type_=m.InlineResponse2001, method="POST", url="/locks", data=body) def _build_for_telemetry( self, diff --git a/qdrant_client/http/api/snapshots_api.py b/qdrant_client/http/api/snapshots_api.py index b96b2ff2..7c3cc687 100644 --- a/qdrant_client/http/api/snapshots_api.py +++ b/qdrant_client/http/api/snapshots_api.py @@ -1,7 +1,7 @@ # flake8: noqa E501 from typing import IO, TYPE_CHECKING, Any, Dict, Set, Union -from qdrant_client._pydantic_compat import to_dict +from qdrant_client._pydantic_compat import to_json from qdrant_client.http.models import * from qdrant_client.http.models import models as m @@ -18,8 +18,8 @@ def jsonable_encoder( skip_defaults: bool = None, exclude_unset: bool = False, ): - if hasattr(obj, "dict") or hasattr(obj, "model_dump"): - return to_dict( + if hasattr(obj, "json") or hasattr(obj, "model_dump_json"): + return to_json( obj, include=include, exclude=exclude, @@ -215,15 +215,17 @@ def _build_for_recover_from_snapshot( if wait is not None: query_params["wait"] = str(wait).lower() + headers = {} body = jsonable_encoder(snapshot_recover) - + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" return self.api_client.request( type_=m.InlineResponse2003, method="PUT", url="/collections/{collection_name}/snapshots/recover", path_params=path_params, params=query_params, - json=body, + data=body, ) def _build_for_recover_from_uploaded_snapshot(