Skip to content

Commit 05eb6c1

Browse files
committed
fix: forward hosts to ingestion transporter
1 parent 1e50912 commit 05eb6c1

File tree

5 files changed

+41
-25
lines changed

5 files changed

+41
-25
lines changed

scripts/cts/testServer/pushMock.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ function addRoutes(app: Express): void {
3939
const helper = match?.[1] as string;
4040
const lang = match?.[2] as string;
4141

42-
console.log(match, helper, lang);
43-
4442
if (!pushMockState[lang]) {
4543
pushMockState[lang] = {};
4644
}
@@ -49,9 +47,10 @@ function addRoutes(app: Express): void {
4947
switch (helper) {
5048
case 'saveObjectsWithTransformation':
5149
expect(req.body).to.deep.equal({
52-
requests: [
53-
{ action: 'addObject', body: { objectID: '1', name: 'Adam' } },
54-
{ action: 'addObject', body: { objectID: '2', name: 'Benoit' } },
50+
action: 'addObject',
51+
records: [
52+
{ objectID: '1', name: 'Adam' },
53+
{ objectID: '2', name: 'Benoit' },
5554
],
5655
});
5756

@@ -65,9 +64,10 @@ function addRoutes(app: Express): void {
6564
break;
6665
case 'partialUpdateObjectsWithTransformation':
6766
expect(req.body).to.deep.equal({
68-
requests: [
69-
{ action: 'partialUpdateObject', body: { objectID: '1', name: 'Adam' } },
70-
{ action: 'partialUpdateObject', body: { objectID: '2', name: 'Benoit' } },
67+
action: 'partialUpdateObject',
68+
records: [
69+
{ objectID: '1', name: 'Adam' },
70+
{ objectID: '2', name: 'Benoit' },
7171
],
7272
});
7373

templates/go/client.mustache

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,26 @@ func NewClientWithConfig(cfg {{#lambda.titlecase}}{{#lambda.camelcase}}{{client}
8585
}
8686

8787
{{#isSearchClient}}
88-
if cfg.Transformation != nil && cfg.Transformation.Region != "" {
89-
ingestionClient, err := ingestion.NewClient(apiClient.appID, cfg.ApiKey, cfg.Transformation.Region)
90-
if err != nil {
91-
return nil, err //nolint:wrapcheck
88+
if cfg.Transformation != nil && cfg.Transformation.Region != "" {
89+
ingestionConfig := ingestion.IngestionConfiguration{
90+
Configuration: transport.Configuration{
91+
AppID: cfg.AppID,
92+
ApiKey: cfg.ApiKey,
93+
},
94+
Region: cfg.Transformation.Region,
9295
}
9396

94-
apiClient.ingestionTransporter = ingestionClient
95-
}
97+
if len(cfg.Hosts) > 0 {
98+
ingestionConfig.Hosts = cfg.Hosts
99+
}
100+
101+
ingestionClient, err := ingestion.NewClientWithConfig(ingestionConfig)
102+
if err != nil {
103+
return nil, err //nolint:wrapcheck
104+
}
105+
106+
apiClient.ingestionTransporter = ingestionClient
107+
}
96108
{{/isSearchClient}}
97109

98110
return &apiClient, nil

templates/python/api.mustache

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ class {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}:
5454
config = {{#lambda.pascalcase}}{{client}}Config{{/lambda.pascalcase}}(transporter.config.app_id, transporter.config.api_key{{#hasRegionalHost}}, region{{/hasRegionalHost}})
5555
elif config is None:
5656
config = {{#lambda.pascalcase}}{{client}}Config{{/lambda.pascalcase}}(app_id, api_key{{#hasRegionalHost}}, region{{/hasRegionalHost}})
57-
{{#isSearchClient}}
58-
elif config.region is not None:
59-
self._ingestion_transporter = IngestionClient{{#isSyncClient}}Sync{{/isSyncClient}}.create_with_config(IngestionConfig(config.app_id, config.api_key, config.region))
60-
{{/isSearchClient}}
6157

6258
self._config = config
6359
self._request_options = RequestOptions(config)
@@ -84,7 +80,19 @@ class {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}:
8480
if transporter is None:
8581
transporter = Transporter{{#isSyncClient}}Sync{{/isSyncClient}}(config)
8682

87-
return {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}(app_id=config.app_id, api_key=config.api_key, {{#hasRegionalHost}}region=config.region, {{/hasRegionalHost}}transporter=transporter, config=config)
83+
client = {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}(app_id=config.app_id, api_key=config.api_key, {{#hasRegionalHost}}region=config.region, {{/hasRegionalHost}}transporter=transporter, config=config)
84+
85+
{{#isSearchClient}}
86+
if config.region is not None:
87+
ingestion_config = IngestionConfig(config.app_id, config.api_key, config.region)
88+
89+
if config.hosts is not None:
90+
ingestion_config.hosts = config.hosts
91+
92+
client._ingestion_transporter = IngestionClient{{#isSyncClient}}Sync{{/isSyncClient}}.create_with_config(ingestion_config)
93+
{{/isSearchClient}}
94+
95+
return client
8896

8997
{{^isSyncClient}}
9098
async def __aenter__(self) -> Self:

tests/CTS/client/search/partialUpdateObjectsWithTransformation.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@
3535
},
3636
"expected": {
3737
"type": "response",
38-
"match": [
39-
{
38+
"match": {
4039
"runID": "b1b7a982-524c-40d2-bb7f-48aab075abda",
4140
"eventID": "113b2068-6337-4c85-b5c2-e7b213d82925",
4241
"message": "OK",
4342
"createdAt": "2022-05-12T06:24:30.049Z"
4443
}
45-
]
4644
}
4745
}
4846
]

tests/CTS/client/search/saveObjectsWithTransformation.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@
3434
},
3535
"expected": {
3636
"type": "response",
37-
"match": [
38-
{
37+
"match": {
3938
"runID": "b1b7a982-524c-40d2-bb7f-48aab075abda",
4039
"eventID": "113b2068-6337-4c85-b5c2-e7b213d82925",
4140
"message": "OK",
4241
"createdAt": "2022-05-12T06:24:30.049Z"
4342
}
44-
]
4543
}
4644
}
4745
]

0 commit comments

Comments
 (0)