Skip to content

Commit ae9e413

Browse files
committed
Regenerated the client
1 parent b2c0780 commit ae9e413

File tree

11 files changed

+383
-17
lines changed

11 files changed

+383
-17
lines changed

.openapi-generator/FILES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ docs/Highlight.md
2424
docs/HighlightFieldOption.md
2525
docs/HighlightFields.md
2626
docs/HitsHits.md
27+
docs/HitsHitsId.md
28+
docs/HitsHitsScore.md
2729
docs/IndexApi.md
2830
docs/InsertDocumentRequest.md
2931
docs/Join.md
@@ -83,6 +85,8 @@ manticoresearch/models/highlight.py
8385
manticoresearch/models/highlight_field_option.py
8486
manticoresearch/models/highlight_fields.py
8587
manticoresearch/models/hits_hits.py
88+
manticoresearch/models/hits_hits_id.py
89+
manticoresearch/models/hits_hits_score.py
8690
manticoresearch/models/insert_document_request.py
8791
manticoresearch/models/join.py
8892
manticoresearch/models/join_cond.py
@@ -136,6 +140,8 @@ test/test_highlight.py
136140
test/test_highlight_field_option.py
137141
test/test_highlight_fields.py
138142
test/test_hits_hits.py
143+
test/test_hits_hits_id.py
144+
test/test_hits_hits_score.py
139145
test/test_index_api.py
140146
test/test_insert_document_request.py
141147
test/test_join.py

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Сlient for Manticore Search.
44

55

6-
❗ WARNING: this is a development version of the client. The latest release's readme is https://github.com/manticoresoftware/manticoresearch-python-asyncio/tree/1.0.0
6+
❗ WARNING: this is a development version of the client. The latest release's readme is https://github.com/manticoresoftware/manticoresearch-python-asyncio/tree/2.0.0
77

88
## Requirements.
99

@@ -150,6 +150,8 @@ Class | Method | HTTP request | Description
150150
- [HighlightFieldOption](docs/HighlightFieldOption.md)
151151
- [HighlightFields](docs/HighlightFields.md)
152152
- [HitsHits](docs/HitsHits.md)
153+
- [HitsHitsId](docs/HitsHitsId.md)
154+
- [HitsHitsScore](docs/HitsHitsScore.md)
153155
- [InsertDocumentRequest](docs/InsertDocumentRequest.md)
154156
- [Join](docs/Join.md)
155157
- [JoinCond](docs/JoinCond.md)

docs/HitsHits.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Search hit representing a matched document
66

77
Name | Type | Description | Notes
88
------------ | ------------- | ------------- | -------------
9-
**id** | **int** | The ID of the matched document | [optional]
10-
**score** | **int** | The score of the matched document | [optional]
9+
**id** | [**HitsHitsId**](HitsHitsId.md) | | [optional]
10+
**score** | [**HitsHitsScore**](HitsHitsScore.md) | | [optional]
1111
**source** | **object** | The source data of the matched document | [optional]
1212
**knn_dist** | **float** | The knn distance of the matched document returned for knn queries | [optional]
1313
**highlight** | **object** | The highlighting-related data of the matched document | [optional]

docs/HitsHitsId.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# HitsHitsId
2+
3+
4+
## Properties
5+
6+
Name | Type | Description | Notes
7+
------------ | ------------- | ------------- | -------------
8+
9+
## Example
10+
11+
```python
12+
from manticoresearch.models.hits_hits_id import HitsHitsId
13+
14+
# TODO update the JSON string below
15+
json = "{}"
16+
# create an instance of HitsHitsId from a JSON string
17+
hits_hits_id_instance = HitsHitsId.from_json(json)
18+
# print the JSON string representation of the object
19+
print(HitsHitsId.to_json())
20+
21+
# convert the object into a dict
22+
hits_hits_id_dict = hits_hits_id_instance.to_dict()
23+
# create an instance of HitsHitsId from a dict
24+
hits_hits_id_from_dict = HitsHitsId.from_dict(hits_hits_id_dict)
25+
```
26+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
27+
28+

docs/HitsHitsScore.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# HitsHitsScore
2+
3+
4+
## Properties
5+
6+
Name | Type | Description | Notes
7+
------------ | ------------- | ------------- | -------------
8+
9+
## Example
10+
11+
```python
12+
from manticoresearch.models.hits_hits_score import HitsHitsScore
13+
14+
# TODO update the JSON string below
15+
json = "{}"
16+
# create an instance of HitsHitsScore from a JSON string
17+
hits_hits_score_instance = HitsHitsScore.from_json(json)
18+
# print the JSON string representation of the object
19+
print(HitsHitsScore.to_json())
20+
21+
# convert the object into a dict
22+
hits_hits_score_dict = hits_hits_score_instance.to_dict()
23+
# create an instance of HitsHitsScore from a dict
24+
hits_hits_score_from_dict = HitsHitsScore.from_dict(hits_hits_score_dict)
25+
```
26+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
27+
28+

manticoresearch/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
"HighlightFieldOption",
5252
"HighlightFields",
5353
"HitsHits",
54+
"HitsHitsId",
55+
"HitsHitsScore",
5456
"InsertDocumentRequest",
5557
"Join",
5658
"JoinCond",
@@ -115,6 +117,8 @@
115117
from manticoresearch.models.highlight_field_option import HighlightFieldOption as HighlightFieldOption
116118
from manticoresearch.models.highlight_fields import HighlightFields as HighlightFields
117119
from manticoresearch.models.hits_hits import HitsHits as HitsHits
120+
from manticoresearch.models.hits_hits_id import HitsHitsId as HitsHitsId
121+
from manticoresearch.models.hits_hits_score import HitsHitsScore as HitsHitsScore
118122
from manticoresearch.models.insert_document_request import InsertDocumentRequest as InsertDocumentRequest
119123
from manticoresearch.models.join import Join as Join
120124
from manticoresearch.models.join_cond import JoinCond as JoinCond

manticoresearch/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
from manticoresearch.models.highlight_field_option import HighlightFieldOption
3535
from manticoresearch.models.highlight_fields import HighlightFields
3636
from manticoresearch.models.hits_hits import HitsHits
37+
from manticoresearch.models.hits_hits_id import HitsHitsId
38+
from manticoresearch.models.hits_hits_score import HitsHitsScore
3739
from manticoresearch.models.insert_document_request import InsertDocumentRequest
3840
from manticoresearch.models.join import Join
3941
from manticoresearch.models.join_cond import JoinCond

manticoresearch/models/hits_hits.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020

2121
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
2222
from typing import Any, ClassVar, Dict, List, Optional, Union
23+
from manticoresearch.models.hits_hits_id import HitsHitsId
24+
from manticoresearch.models.hits_hits_score import HitsHitsScore
2325
from typing import Optional, Set
2426
from typing_extensions import Self
2527

2628
class HitsHits(BaseModel):
2729
"""
2830
Search hit representing a matched document
2931
""" # noqa: E501
30-
id: Optional[StrictInt] = Field(default=None, description="The ID of the matched document", alias="_id")
31-
score: Optional[StrictInt] = Field(default=None, description="The score of the matched document", alias="_score")
32+
id: Optional[HitsHitsId] = Field(default=None, alias="_id")
33+
score: Optional[HitsHitsScore] = Field(default=None, alias="_score")
3234
source: Optional[Dict[str, Any]] = Field(default=None, description="The source data of the matched document", alias="_source")
3335
knn_dist: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The knn distance of the matched document returned for knn queries", alias="_knn_dist")
3436
highlight: Optional[Dict[str, Any]] = Field(default=None, description="The highlighting-related data of the matched document")
@@ -76,6 +78,12 @@ def to_dict(self) -> Dict[str, Any]:
7678
exclude=excluded_fields,
7779
exclude_none=True,
7880
)
81+
# override the default output from pydantic by calling `to_dict()` of id
82+
if self.id:
83+
_dict['_id'] = self.id.to_dict()
84+
# override the default output from pydantic by calling `to_dict()` of score
85+
if self.score:
86+
_dict['_score'] = self.score.to_dict()
7987
return _dict
8088

8189
@classmethod
@@ -88,8 +96,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
8896
return cls.model_validate(obj)
8997

9098
_obj = cls.model_validate({
91-
"_id": obj.get("_id"),
92-
"_score": obj.get("_score"),
99+
"_id": HitsHitsId.from_dict(obj["_id"]) if obj.get("_id") is not None else None,
100+
"_score": HitsHitsScore.from_dict(obj["_score"]) if obj.get("_score") is not None else None,
93101
"_source": obj.get("_source"),
94102
"_knn_dist": obj.get("_knn_dist"),
95103
"highlight": obj.get("highlight"),
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# coding: utf-8
2+
3+
"""
4+
Manticore Search Client
5+
6+
Сlient for Manticore Search.
7+
8+
The version of the OpenAPI document: 5.0.0
9+
Contact: info@manticoresearch.com
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
11+
12+
Do not edit the class manually.
13+
""" # noqa: E501
14+
15+
16+
from __future__ import annotations
17+
import json
18+
import pprint
19+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, ValidationError, field_validator
20+
from typing import Any, List, Optional
21+
from pydantic import StrictStr, Field
22+
from typing import Union, List, Set, Optional, Dict
23+
from typing_extensions import Literal, Self
24+
25+
HITSHITSID_ONE_OF_SCHEMAS = ["int", "str"]
26+
27+
class HitsHitsId(BaseModel):
28+
"""
29+
HitsHitsId
30+
"""
31+
# data type: str
32+
oneof_schema_1_validator: Optional[StrictStr] = Field(default=None, description="The ID of the matched document")
33+
# data type: int
34+
oneof_schema_2_validator: Optional[StrictInt] = Field(default=None, description="The ID of the matched document")
35+
actual_instance: Optional[Union[int, str]] = None
36+
one_of_schemas: Set[str] = { "int", "str" }
37+
38+
model_config = ConfigDict(
39+
validate_assignment=True,
40+
protected_namespaces=(),
41+
)
42+
43+
44+
def __init__(self, *args, **kwargs) -> None:
45+
if args:
46+
if len(args) > 1:
47+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
48+
if kwargs:
49+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
50+
super().__init__(actual_instance=args[0])
51+
else:
52+
super().__init__(**kwargs)
53+
54+
@field_validator('actual_instance')
55+
def actual_instance_must_validate_oneof(cls, v):
56+
instance = HitsHitsId.model_construct()
57+
error_messages = []
58+
match = 0
59+
# validate data type: str
60+
try:
61+
instance.oneof_schema_1_validator = v
62+
match += 1
63+
except (ValidationError, ValueError) as e:
64+
error_messages.append(str(e))
65+
# validate data type: int
66+
try:
67+
instance.oneof_schema_2_validator = v
68+
match += 1
69+
except (ValidationError, ValueError) as e:
70+
error_messages.append(str(e))
71+
if match > 1:
72+
# more than 1 match
73+
raise ValueError("Multiple matches found when setting `actual_instance` in HitsHitsId with oneOf schemas: int, str. Details: " + ", ".join(error_messages))
74+
elif match == 0:
75+
# no match
76+
raise ValueError("No match found when setting `actual_instance` in HitsHitsId with oneOf schemas: int, str. Details: " + ", ".join(error_messages))
77+
else:
78+
return v
79+
80+
@classmethod
81+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
82+
return cls.from_json(json.dumps(obj))
83+
84+
@classmethod
85+
def from_json(cls, json_str: str) -> Self:
86+
"""Returns the object represented by the json string"""
87+
instance = cls.model_construct()
88+
error_messages = []
89+
match = 0
90+
91+
# deserialize data into str
92+
try:
93+
# validation
94+
instance.oneof_schema_1_validator = json.loads(json_str)
95+
# assign value to actual_instance
96+
instance.actual_instance = instance.oneof_schema_1_validator
97+
match += 1
98+
except (ValidationError, ValueError) as e:
99+
error_messages.append(str(e))
100+
# deserialize data into int
101+
try:
102+
# validation
103+
instance.oneof_schema_2_validator = json.loads(json_str)
104+
# assign value to actual_instance
105+
instance.actual_instance = instance.oneof_schema_2_validator
106+
match += 1
107+
except (ValidationError, ValueError) as e:
108+
error_messages.append(str(e))
109+
110+
if match > 1:
111+
# more than 1 match
112+
raise ValueError("Multiple matches found when deserializing the JSON string into HitsHitsId with oneOf schemas: int, str. Details: " + ", ".join(error_messages))
113+
elif match == 0:
114+
# no match
115+
raise ValueError("No match found when deserializing the JSON string into HitsHitsId with oneOf schemas: int, str. Details: " + ", ".join(error_messages))
116+
else:
117+
return instance
118+
119+
def to_json(self) -> str:
120+
"""Returns the JSON representation of the actual instance"""
121+
if self.actual_instance is None:
122+
return "null"
123+
124+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
125+
return self.actual_instance.to_json()
126+
else:
127+
return json.dumps(self.actual_instance)
128+
129+
def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]:
130+
"""Returns the dict representation of the actual instance"""
131+
if self.actual_instance is None:
132+
return None
133+
134+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
135+
return self.actual_instance.to_dict()
136+
else:
137+
# primitive type
138+
return self.actual_instance
139+
140+
def to_str(self) -> str:
141+
"""Returns the string representation of the actual instance"""
142+
return pprint.pformat(self.model_dump())
143+
144+

0 commit comments

Comments
 (0)