Skip to content

Commit 74d9811

Browse files
feat(clients): add replaceAllObjectsWithTransformation (generated)
algolia/api-clients-automation#5013 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 85f002e commit 74d9811

File tree

21 files changed

+300
-40
lines changed

21 files changed

+300
-40
lines changed

algoliasearch/abtesting/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def __init__(
7676
elif config is None:
7777
config = AbtestingConfig(app_id, api_key, region)
7878

79+
config.set_default_hosts()
80+
7981
self._config = config
8082
self._request_options = RequestOptions(config)
8183

@@ -912,6 +914,8 @@ def __init__(
912914
elif config is None:
913915
config = AbtestingConfig(app_id, api_key, region)
914916

917+
config.set_default_hosts()
918+
915919
self._config = config
916920
self._request_options = RequestOptions(config)
917921

algoliasearch/abtesting/config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ def __init__(
4848
self.proxies["https"] = https_proxy
4949

5050
self.region = region
51+
52+
def set_default_hosts(self):
53+
if self.hosts is not None:
54+
return
55+
5156
_regions = ["de", "us"]
5257

53-
if region is not None and region not in _regions:
58+
if self.region is not None and self.region not in _regions:
5459
raise ValueError(
5560
f"`region` must be one of the following: {', '.join(_regions)}"
5661
)
@@ -59,9 +64,9 @@ def __init__(
5964
[
6065
Host(
6166
"analytics.algolia.com"
62-
if region is None
67+
if self.region is None
6368
else "analytics.{region}.algolia.com".replace(
64-
"{region}", region or ""
69+
"{region}", self.region or ""
6570
)
6671
)
6772
]

algoliasearch/analytics/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def __init__(
9090
elif config is None:
9191
config = AnalyticsConfig(app_id, api_key, region)
9292

93+
config.set_default_hosts()
94+
9395
self._config = config
9496
self._request_options = RequestOptions(config)
9597

@@ -3116,6 +3118,8 @@ def __init__(
31163118
elif config is None:
31173119
config = AnalyticsConfig(app_id, api_key, region)
31183120

3121+
config.set_default_hosts()
3122+
31193123
self._config = config
31203124
self._request_options = RequestOptions(config)
31213125

algoliasearch/analytics/config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ def __init__(
4848
self.proxies["https"] = https_proxy
4949

5050
self.region = region
51+
52+
def set_default_hosts(self):
53+
if self.hosts is not None:
54+
return
55+
5156
_regions = ["de", "us"]
5257

53-
if region is not None and region not in _regions:
58+
if self.region is not None and self.region not in _regions:
5459
raise ValueError(
5560
f"`region` must be one of the following: {', '.join(_regions)}"
5661
)
@@ -59,9 +64,9 @@ def __init__(
5964
[
6065
Host(
6166
"analytics.algolia.com"
62-
if region is None
67+
if self.region is None
6368
else "analytics.{region}.algolia.com".replace(
64-
"{region}", region or ""
69+
"{region}", self.region or ""
6570
)
6671
)
6772
]

algoliasearch/composition/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ def __init__(
7171
elif config is None:
7272
config = CompositionConfig(app_id, api_key)
7373

74+
config.set_default_hosts()
75+
7476
self._config = config
7577
self._request_options = RequestOptions(config)
7678

@@ -331,6 +333,8 @@ def __init__(
331333
elif config is None:
332334
config = CompositionConfig(app_id, api_key)
333335

336+
config.set_default_hosts()
337+
334338
self._config = config
335339
self._request_options = RequestOptions(config)
336340

algoliasearch/composition/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def __init__(self, app_id: Optional[str], api_key: Optional[str]) -> None:
4242
if https_proxy is not None:
4343
self.proxies["https"] = https_proxy
4444

45+
def set_default_hosts(self):
46+
if self.hosts is not None:
47+
return
48+
4549
self.hosts = HostsCollection(
4650
[
4751
Host(

algoliasearch/ingestion/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def __init__(
145145
elif config is None:
146146
config = IngestionConfig(app_id, api_key, region)
147147

148+
config.set_default_hosts()
149+
148150
self._config = config
149151
self._request_options = RequestOptions(config)
150152

@@ -230,6 +232,7 @@ async def chunked_push(
230232
request_options=request_options,
231233
)
232234
)
235+
records = []
233236
if wait_for_tasks:
234237
for response in responses:
235238

@@ -5226,6 +5229,8 @@ def __init__(
52265229
elif config is None:
52275230
config = IngestionConfig(app_id, api_key, region)
52285231

5232+
config.set_default_hosts()
5233+
52295234
self._config = config
52305235
self._request_options = RequestOptions(config)
52315236

@@ -5310,6 +5315,7 @@ def chunked_push(
53105315
request_options=request_options,
53115316
)
53125317
)
5318+
records = []
53135319
if wait_for_tasks:
53145320
for response in responses:
53155321

algoliasearch/ingestion/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ def __init__(
4545
self.proxies["https"] = https_proxy
4646

4747
self.region = region
48+
49+
def set_default_hosts(self):
50+
if self.hosts is not None:
51+
return
52+
4853
_regions = ["eu", "us"]
4954

50-
if not region or (region is not None and region not in _regions):
55+
if not self.region or (self.region is not None and self.region not in _regions):
5156
raise ValueError(
5257
f"`region` is required and must be one of the following: {', '.join(_regions)}"
5358
)
5459

5560
self.hosts = HostsCollection(
56-
[Host("data.{region}.algolia.com".replace("{region}", region or ""))]
61+
[Host("data.{region}.algolia.com".replace("{region}", self.region or ""))]
5762
)

algoliasearch/insights/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def __init__(
6767
elif config is None:
6868
config = InsightsConfig(app_id, api_key, region)
6969

70+
config.set_default_hosts()
71+
7072
self._config = config
7173
self._request_options = RequestOptions(config)
7274

@@ -601,6 +603,8 @@ def __init__(
601603
elif config is None:
602604
config = InsightsConfig(app_id, api_key, region)
603605

606+
config.set_default_hosts()
607+
604608
self._config = config
605609
self._request_options = RequestOptions(config)
606610

algoliasearch/insights/config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ def __init__(
4848
self.proxies["https"] = https_proxy
4949

5050
self.region = region
51+
52+
def set_default_hosts(self):
53+
if self.hosts is not None:
54+
return
55+
5156
_regions = ["de", "us"]
5257

53-
if region is not None and region not in _regions:
58+
if self.region is not None and self.region not in _regions:
5459
raise ValueError(
5560
f"`region` must be one of the following: {', '.join(_regions)}"
5661
)
@@ -59,9 +64,9 @@ def __init__(
5964
[
6065
Host(
6166
"insights.algolia.io"
62-
if region is None
67+
if self.region is None
6368
else "insights.{region}.algolia.io".replace(
64-
"{region}", region or ""
69+
"{region}", self.region or ""
6570
)
6671
)
6772
]

algoliasearch/monitoring/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def __init__(
7575
elif config is None:
7676
config = MonitoringConfig(app_id, api_key)
7777

78+
config.set_default_hosts()
79+
7880
self._config = config
7981
self._request_options = RequestOptions(config)
8082

@@ -937,6 +939,8 @@ def __init__(
937939
elif config is None:
938940
config = MonitoringConfig(app_id, api_key)
939941

942+
config.set_default_hosts()
943+
940944
self._config = config
941945
self._request_options = RequestOptions(config)
942946

algoliasearch/monitoring/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def __init__(self, app_id: Optional[str], api_key: Optional[str]) -> None:
4242
if https_proxy is not None:
4343
self.proxies["https"] = https_proxy
4444

45+
def set_default_hosts(self):
46+
if self.hosts is not None:
47+
return
48+
4549
self.hosts = HostsCollection(
4650
[
4751
Host("status.algolia.com"),

algoliasearch/personalization/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def __init__(
7272
elif config is None:
7373
config = PersonalizationConfig(app_id, api_key, region)
7474

75+
config.set_default_hosts()
76+
7577
self._config = config
7678
self._request_options = RequestOptions(config)
7779

@@ -710,6 +712,8 @@ def __init__(
710712
elif config is None:
711713
config = PersonalizationConfig(app_id, api_key, region)
712714

715+
config.set_default_hosts()
716+
713717
self._config = config
714718
self._request_options = RequestOptions(config)
715719

algoliasearch/personalization/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ def __init__(
4545
self.proxies["https"] = https_proxy
4646

4747
self.region = region
48+
49+
def set_default_hosts(self):
50+
if self.hosts is not None:
51+
return
52+
4853
_regions = ["eu", "us"]
4954

50-
if not region or (region is not None and region not in _regions):
55+
if not self.region or (self.region is not None and self.region not in _regions):
5156
raise ValueError(
5257
f"`region` is required and must be one of the following: {', '.join(_regions)}"
5358
)
@@ -56,7 +61,7 @@ def __init__(
5661
[
5762
Host(
5863
"personalization.{region}.algolia.com".replace(
59-
"{region}", region or ""
64+
"{region}", self.region or ""
6065
)
6166
)
6267
]

algoliasearch/query_suggestions/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def __init__(
7474
elif config is None:
7575
config = QuerySuggestionsConfig(app_id, api_key, region)
7676

77+
config.set_default_hosts()
78+
7779
self._config = config
7880
self._request_options = RequestOptions(config)
7981

@@ -878,6 +880,8 @@ def __init__(
878880
elif config is None:
879881
config = QuerySuggestionsConfig(app_id, api_key, region)
880882

883+
config.set_default_hosts()
884+
881885
self._config = config
882886
self._request_options = RequestOptions(config)
883887

algoliasearch/query_suggestions/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ def __init__(
4545
self.proxies["https"] = https_proxy
4646

4747
self.region = region
48+
49+
def set_default_hosts(self):
50+
if self.hosts is not None:
51+
return
52+
4853
_regions = ["eu", "us"]
4954

50-
if not region or (region is not None and region not in _regions):
55+
if not self.region or (self.region is not None and self.region not in _regions):
5156
raise ValueError(
5257
f"`region` is required and must be one of the following: {', '.join(_regions)}"
5358
)
@@ -56,7 +61,7 @@ def __init__(
5661
[
5762
Host(
5863
"query-suggestions.{region}.algolia.com".replace(
59-
"{region}", region or ""
64+
"{region}", self.region or ""
6065
)
6166
)
6267
]

algoliasearch/recommend/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def __init__(
7676
elif config is None:
7777
config = RecommendConfig(app_id, api_key)
7878

79+
config.set_default_hosts()
80+
7981
self._config = config
8082
self._request_options = RequestOptions(config)
8183

@@ -1047,6 +1049,8 @@ def __init__(
10471049
elif config is None:
10481050
config = RecommendConfig(app_id, api_key)
10491051

1052+
config.set_default_hosts()
1053+
10501054
self._config = config
10511055
self._request_options = RequestOptions(config)
10521056

algoliasearch/recommend/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def __init__(self, app_id: Optional[str], api_key: Optional[str]) -> None:
4242
if https_proxy is not None:
4343
self.proxies["https"] = https_proxy
4444

45+
def set_default_hosts(self):
46+
if self.hosts is not None:
47+
return
48+
4549
self.hosts = HostsCollection(
4650
[
4751
Host(

0 commit comments

Comments
 (0)