Skip to content

Commit cc946ce

Browse files
algolia-bote-krebsshortcutsmillotp
committed
feat(specs): rename composition to composition-full (private) and add composition (public) (generated)
algolia/api-clients-automation#4357 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Emmanuel Krebs <[email protected]> Co-authored-by: shortcuts <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 80fd501 commit cc946ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+5317
-0
lines changed

algoliasearch/composition/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# coding: utf-8
2+
3+
"""
4+
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.
5+
"""
6+
7+
# The version of the algoliasearch package
8+
__version__ = "4.12.0"

algoliasearch/composition/client.py

Lines changed: 550 additions & 0 deletions
Large diffs are not rendered by default.

algoliasearch/composition/config.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from os import environ
2+
from typing import Optional
3+
4+
from algoliasearch import __version__
5+
from algoliasearch.http.base_config import BaseConfig
6+
from algoliasearch.http.hosts import CallType, Host, HostsCollection
7+
from algoliasearch.http.user_agent import UserAgent
8+
9+
10+
class CompositionConfig(BaseConfig):
11+
def __init__(self, app_id: Optional[str], api_key: Optional[str]) -> None:
12+
super().__init__(app_id, api_key)
13+
14+
# In milliseconds
15+
self.read_timeout = 5000
16+
self.write_timeout = 30000
17+
self.connect_timeout = 2000
18+
19+
self._user_agent = UserAgent()
20+
self.add_user_agent("Composition", __version__)
21+
22+
if app_id is None or not app_id:
23+
raise ValueError("`app_id` is missing.")
24+
25+
if api_key is None or not api_key:
26+
raise ValueError("`api_key` is missing.")
27+
28+
self.headers = {
29+
"x-algolia-application-id": app_id,
30+
"x-algolia-api-key": api_key,
31+
"user-agent": self._user_agent.get(),
32+
"content-type": "application/json",
33+
}
34+
35+
http_proxy = environ.get("HTTP_PROXY")
36+
https_proxy = environ.get("HTTPS_PROXY")
37+
38+
self.proxies = {}
39+
40+
if http_proxy is not None:
41+
self.proxies["http"] = http_proxy
42+
if https_proxy is not None:
43+
self.proxies["https"] = https_proxy
44+
45+
self.hosts = HostsCollection(
46+
[
47+
Host(
48+
url="{}-dsn.algolia.net".format(self.app_id),
49+
priority=10,
50+
accept=CallType.READ,
51+
),
52+
Host(
53+
url="{}.algolia.net".format(self.app_id),
54+
priority=10,
55+
accept=CallType.WRITE,
56+
),
57+
Host("{}-1.algolianet.com".format(self.app_id)),
58+
Host("{}-2.algolianet.com".format(self.app_id)),
59+
Host("{}-3.algolianet.com".format(self.app_id)),
60+
],
61+
reorder_hosts=True,
62+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# coding: utf-8
2+
3+
"""
4+
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.
5+
"""
6+
7+
# The version of the algoliasearch package
8+
__version__ = "4.12.0"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# coding: utf-8
2+
3+
"""
4+
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.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from json import dumps, loads
10+
from sys import version_info
11+
from typing import Any, Dict, List, Optional, Set, Union
12+
13+
from pydantic import BaseModel, Field, ValidationError, model_serializer
14+
15+
if version_info >= (3, 11):
16+
from typing import Self
17+
else:
18+
from typing_extensions import Self
19+
20+
21+
from algoliasearch.composition.models.range import Range
22+
23+
24+
class AroundPrecision(BaseModel):
25+
"""
26+
Precision of a coordinate-based search in meters to group results with similar distances. The Geo ranking criterion considers all matches within the same range of distances to be equal.
27+
"""
28+
29+
oneof_schema_1_validator: Optional[int] = Field(default=None)
30+
""" Distance in meters to group results by similar distances. For example, if you set `aroundPrecision` to 100, records wihin 100 meters to the central coordinate are considered to have the same distance, as are records between 100 and 199 meters. """
31+
oneof_schema_2_validator: Optional[List[Range]] = Field(default=None)
32+
33+
actual_instance: Union[List[Range], int, None] = None
34+
one_of_schemas: Set[str] = {"List[Range]", "int"}
35+
36+
def __init__(self, *args, **kwargs) -> None:
37+
if args:
38+
if len(args) > 1:
39+
raise ValueError(
40+
"If a position argument is used, only 1 is allowed to set `actual_instance`"
41+
)
42+
if kwargs:
43+
raise ValueError(
44+
"If a position argument is used, keyword arguments cannot be used."
45+
)
46+
super().__init__(actual_instance=args[0]) # pyright: ignore
47+
else:
48+
super().__init__(**kwargs)
49+
50+
@model_serializer
51+
def unwrap_actual_instance(self) -> Union[List[Range], int, Self, None]:
52+
"""
53+
Unwraps the `actual_instance` when calling the `to_json` method.
54+
"""
55+
return self.actual_instance if hasattr(self, "actual_instance") else self
56+
57+
@classmethod
58+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
59+
"""Create an instance of AroundPrecision from a JSON string"""
60+
return cls.from_json(dumps(obj))
61+
62+
@classmethod
63+
def from_json(cls, json_str: str) -> Self:
64+
"""Returns the object represented by the json string"""
65+
instance = cls.model_construct()
66+
error_messages = []
67+
68+
try:
69+
instance.oneof_schema_1_validator = loads(json_str)
70+
instance.actual_instance = instance.oneof_schema_1_validator
71+
72+
return instance
73+
except (ValidationError, ValueError) as e:
74+
error_messages.append(str(e))
75+
try:
76+
instance.oneof_schema_2_validator = loads(json_str)
77+
instance.actual_instance = instance.oneof_schema_2_validator
78+
79+
return instance
80+
except (ValidationError, ValueError) as e:
81+
error_messages.append(str(e))
82+
83+
raise ValueError(
84+
"No match found when deserializing the JSON string into AroundPrecision with oneOf schemas: List[Range], int. Details: "
85+
+ ", ".join(error_messages)
86+
)
87+
88+
def to_json(self) -> str:
89+
"""Returns the JSON representation of the actual instance"""
90+
if self.actual_instance is None:
91+
return "null"
92+
93+
if hasattr(self.actual_instance, "to_json") and callable(
94+
self.actual_instance.to_json # pyright: ignore
95+
):
96+
return self.actual_instance.to_json() # pyright: ignore
97+
else:
98+
return dumps(self.actual_instance)
99+
100+
def to_dict(self) -> Optional[Union[Dict[str, Any], List[Range], int]]:
101+
"""Returns the dict representation of the actual instance"""
102+
if self.actual_instance is None:
103+
return None
104+
105+
if hasattr(self.actual_instance, "to_dict") and callable(
106+
self.actual_instance.to_dict # pyright: ignore
107+
):
108+
return self.actual_instance.to_dict() # pyright: ignore
109+
else:
110+
return self.actual_instance # pyright: ignore
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# coding: utf-8
2+
3+
"""
4+
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.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from json import dumps, loads
10+
from sys import version_info
11+
from typing import Any, Dict, Optional, Set, Union
12+
13+
from pydantic import BaseModel, Field, ValidationError, model_serializer
14+
15+
if version_info >= (3, 11):
16+
from typing import Self
17+
else:
18+
from typing_extensions import Self
19+
20+
21+
from algoliasearch.composition.models.around_radius_all import AroundRadiusAll
22+
23+
24+
class AroundRadius(BaseModel):
25+
"""
26+
Maximum radius for a search around a central location. This parameter works in combination with the `aroundLatLng` and `aroundLatLngViaIP` parameters. By default, the search radius is determined automatically from the density of hits around the central location. The search radius is small if there are many hits close to the central coordinates.
27+
"""
28+
29+
oneof_schema_1_validator: Optional[int] = Field(default=None)
30+
""" Maximum search radius around a central location in meters. """
31+
oneof_schema_2_validator: Optional[AroundRadiusAll] = Field(default=None)
32+
33+
actual_instance: Union[AroundRadiusAll, int, None] = None
34+
one_of_schemas: Set[str] = {"AroundRadiusAll", "int"}
35+
36+
def __init__(self, *args, **kwargs) -> None:
37+
if args:
38+
if len(args) > 1:
39+
raise ValueError(
40+
"If a position argument is used, only 1 is allowed to set `actual_instance`"
41+
)
42+
if kwargs:
43+
raise ValueError(
44+
"If a position argument is used, keyword arguments cannot be used."
45+
)
46+
super().__init__(actual_instance=args[0]) # pyright: ignore
47+
else:
48+
super().__init__(**kwargs)
49+
50+
@model_serializer
51+
def unwrap_actual_instance(self) -> Union[AroundRadiusAll, int, Self, None]:
52+
"""
53+
Unwraps the `actual_instance` when calling the `to_json` method.
54+
"""
55+
return self.actual_instance if hasattr(self, "actual_instance") else self
56+
57+
@classmethod
58+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
59+
"""Create an instance of AroundRadius from a JSON string"""
60+
return cls.from_json(dumps(obj))
61+
62+
@classmethod
63+
def from_json(cls, json_str: str) -> Self:
64+
"""Returns the object represented by the json string"""
65+
instance = cls.model_construct()
66+
error_messages = []
67+
68+
try:
69+
instance.oneof_schema_1_validator = loads(json_str)
70+
instance.actual_instance = instance.oneof_schema_1_validator
71+
72+
return instance
73+
except (ValidationError, ValueError) as e:
74+
error_messages.append(str(e))
75+
try:
76+
instance.actual_instance = AroundRadiusAll.from_json(json_str)
77+
78+
return instance
79+
except (ValidationError, ValueError) as e:
80+
error_messages.append(str(e))
81+
82+
raise ValueError(
83+
"No match found when deserializing the JSON string into AroundRadius with oneOf schemas: AroundRadiusAll, int. Details: "
84+
+ ", ".join(error_messages)
85+
)
86+
87+
def to_json(self) -> str:
88+
"""Returns the JSON representation of the actual instance"""
89+
if self.actual_instance is None:
90+
return "null"
91+
92+
if hasattr(self.actual_instance, "to_json") and callable(
93+
self.actual_instance.to_json # pyright: ignore
94+
):
95+
return self.actual_instance.to_json() # pyright: ignore
96+
else:
97+
return dumps(self.actual_instance)
98+
99+
def to_dict(self) -> Optional[Union[Dict[str, Any], AroundRadiusAll, int]]:
100+
"""Returns the dict representation of the actual instance"""
101+
if self.actual_instance is None:
102+
return None
103+
104+
if hasattr(self.actual_instance, "to_dict") and callable(
105+
self.actual_instance.to_dict # pyright: ignore
106+
):
107+
return self.actual_instance.to_dict() # pyright: ignore
108+
else:
109+
return self.actual_instance # pyright: ignore
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# coding: utf-8
2+
3+
"""
4+
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.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from enum import Enum
10+
from json import loads
11+
from sys import version_info
12+
13+
if version_info >= (3, 11):
14+
from typing import Self
15+
else:
16+
from typing_extensions import Self
17+
18+
19+
class AroundRadiusAll(str, Enum):
20+
"""
21+
Return all records with a valid `_geoloc` attribute. Don't filter by distance.
22+
"""
23+
24+
"""
25+
allowed enum values
26+
"""
27+
ALL = "all"
28+
29+
@classmethod
30+
def from_json(cls, json_str: str) -> Self:
31+
"""Create an instance of AroundRadiusAll from a JSON string"""
32+
return cls(loads(json_str))

0 commit comments

Comments
 (0)