@@ -147,10 +147,6 @@ def __init__(
147147 config = SearchConfig (transporter .config .app_id , transporter .config .api_key )
148148 elif config is None :
149149 config = SearchConfig (app_id , api_key )
150- elif config .region is not None :
151- self ._ingestion_transporter = IngestionClient .create_with_config (
152- IngestionConfig (config .app_id , config .api_key , config .region )
153- )
154150
155151 self ._config = config
156152 self ._request_options = RequestOptions (config )
@@ -179,13 +175,27 @@ def create_with_config(
179175 if transporter is None :
180176 transporter = Transporter (config )
181177
182- return SearchClient (
178+ client = SearchClient (
183179 app_id = config .app_id ,
184180 api_key = config .api_key ,
185181 transporter = transporter ,
186182 config = config ,
187183 )
188184
185+ if config .region is not None :
186+ ingestion_config = IngestionConfig (
187+ config .app_id , config .api_key , config .region
188+ )
189+
190+ if config .hosts is not None :
191+ ingestion_config .hosts = config .hosts
192+
193+ client ._ingestion_transporter = IngestionClient .create_with_config (
194+ ingestion_config
195+ )
196+
197+ return client
198+
189199 async def __aenter__ (self ) -> Self :
190200 return self
191201
@@ -5289,10 +5299,6 @@ def __init__(
52895299 config = SearchConfig (transporter .config .app_id , transporter .config .api_key )
52905300 elif config is None :
52915301 config = SearchConfig (app_id , api_key )
5292- elif config .region is not None :
5293- self ._ingestion_transporter = IngestionClientSync .create_with_config (
5294- IngestionConfig (config .app_id , config .api_key , config .region )
5295- )
52965302
52975303 self ._config = config
52985304 self ._request_options = RequestOptions (config )
@@ -5321,13 +5327,27 @@ def create_with_config(
53215327 if transporter is None :
53225328 transporter = TransporterSync (config )
53235329
5324- return SearchClientSync (
5330+ client = SearchClientSync (
53255331 app_id = config .app_id ,
53265332 api_key = config .api_key ,
53275333 transporter = transporter ,
53285334 config = config ,
53295335 )
53305336
5337+ if config .region is not None :
5338+ ingestion_config = IngestionConfig (
5339+ config .app_id , config .api_key , config .region
5340+ )
5341+
5342+ if config .hosts is not None :
5343+ ingestion_config .hosts = config .hosts
5344+
5345+ client ._ingestion_transporter = IngestionClientSync .create_with_config (
5346+ ingestion_config
5347+ )
5348+
5349+ return client
5350+
53315351 def __enter__ (self ) -> Self :
53325352 return self
53335353
0 commit comments