Skip to content

Commit 5fea5c1

Browse files
authored
Use esv in client meta header (#5)
1 parent 601d415 commit 5fea5c1

File tree

7 files changed

+41
-39
lines changed

7 files changed

+41
-39
lines changed

elasticsearch_serverless/_sync/client/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
SKIP_IN_PATH: Collection[Any] = (None, "", b"", [], ())
6565

6666
# To be passed to 'client_meta_service' on the Transport
67-
CLIENT_META_SERVICE = ("es", client_meta_version(__versionstr__))
67+
CLIENT_META_SERVICE = ("esv", client_meta_version(__versionstr__))
6868

6969
# Default User-Agent used by the client
7070
USER_AGENT = create_user_agent("elasticsearch-py", __versionstr__)

elasticsearch_serverless/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
__versionstr__ = "8.10.0"
18+
__versionstr__ = "0.1.0"

test_elasticsearch_serverless/test_async/test_transport.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ async def test_client_meta_header(self):
215215
assert 1 == len(calls)
216216
headers = calls[0][1]["headers"]
217217
assert re.search(
218-
r"^es=[0-9.]+p?,py=[0-9.]+p?,t=[0-9.]+p?$", headers["x-elastic-client-meta"]
218+
r"^esv=[0-9.]+p?,py=[0-9.]+p?,t=[0-9.]+p?$",
219+
headers["x-elastic-client-meta"],
219220
)
220221

221222
class DummyNodeWithMeta(DummyNode):
@@ -230,7 +231,7 @@ class DummyNodeWithMeta(DummyNode):
230231
assert 1 == len(calls)
231232
headers = calls[0][1]["headers"]
232233
assert re.search(
233-
r"^es=[0-9.]+p?,py=[0-9.]+p?,t=[0-9.]+p?,dm=1.2.3$",
234+
r"^esv=[0-9.]+p?,py=[0-9.]+p?,t=[0-9.]+p?,dm=1.2.3$",
234235
headers["x-elastic-client-meta"],
235236
)
236237
assert headers["Custom"] == "header"
@@ -244,7 +245,7 @@ async def test_client_meta_header_not_sent(self):
244245
calls = client.transport.node_pool.get().calls
245246
assert 1 == len(calls)
246247
assert calls[0][1]["headers"] == {
247-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
248+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
248249
}
249250

250251
async def test_body_surrogates_replaced_encoded_into_bytes(self):
@@ -421,7 +422,7 @@ async def test_sniff_uses_sniff_timeout(self):
421422
{
422423
"body": None,
423424
"headers": {
424-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
425+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
425426
},
426427
"request_timeout": DEFAULT,
427428
},
@@ -686,7 +687,7 @@ async def test_unsupported_product_error(headers):
686687
{
687688
"body": None,
688689
"headers": {
689-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
690+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
690691
},
691692
"request_timeout": DEFAULT,
692693
},

test_elasticsearch_serverless/test_client/test_options.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_options_passed_to_perform_request(self):
139139
assert call.pop("client_meta") is DEFAULT
140140
assert call == {
141141
"headers": {
142-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
142+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
143143
},
144144
"body": None,
145145
}
@@ -157,7 +157,7 @@ def test_options_passed_to_perform_request(self):
157157
assert call.pop("client_meta") is DEFAULT
158158
assert call == {
159159
"headers": {
160-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
160+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
161161
},
162162
"body": None,
163163
"request_timeout": 1,
@@ -182,7 +182,7 @@ def test_options_passed_to_perform_request(self):
182182
assert call.pop("client_meta") is DEFAULT
183183
assert call == {
184184
"headers": {
185-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
185+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
186186
},
187187
"body": None,
188188
"request_timeout": 1,
@@ -209,7 +209,7 @@ async def test_options_passed_to_async_perform_request(self):
209209
assert call.pop("client_meta") is DEFAULT
210210
assert call == {
211211
"headers": {
212-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
212+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
213213
},
214214
"body": None,
215215
}
@@ -227,7 +227,7 @@ async def test_options_passed_to_async_perform_request(self):
227227
assert call.pop("client_meta") is DEFAULT
228228
assert call == {
229229
"headers": {
230-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
230+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
231231
},
232232
"body": None,
233233
"request_timeout": 1,
@@ -252,7 +252,7 @@ async def test_options_passed_to_async_perform_request(self):
252252
assert call.pop("client_meta") is DEFAULT
253253
assert call == {
254254
"headers": {
255-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
255+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
256256
},
257257
"body": None,
258258
"request_timeout": 1,
@@ -294,7 +294,7 @@ def test_http_headers_overrides(self):
294294

295295
assert call["headers"] == {
296296
"key": "val",
297-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
297+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
298298
}
299299

300300
client.options(headers={"key1": "val"}).indices.get(index="2")
@@ -303,15 +303,15 @@ def test_http_headers_overrides(self):
303303
assert call["headers"] == {
304304
"key": "val",
305305
"key1": "val",
306-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
306+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
307307
}
308308

309309
client.options(headers={"key": "val2"}).indices.get(index="3")
310310
call = calls[("GET", "/3")][0]
311311

312312
assert call["headers"] == {
313313
"key": "val2",
314-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
314+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
315315
}
316316

317317
client = Elasticsearch(
@@ -338,14 +338,14 @@ def test_user_agent_override(self):
338338
call = calls[("GET", "/1")][0]
339339
assert call["headers"] == {
340340
"user-agent": "custom1",
341-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
341+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
342342
}
343343

344344
client.indices.get(index="2", headers={"user-agent": "custom2"})
345345
call = calls[("GET", "/2")][0]
346346
assert call["headers"] == {
347347
"user-agent": "custom2",
348-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
348+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
349349
}
350350

351351
client = Elasticsearch(
@@ -359,14 +359,14 @@ def test_user_agent_override(self):
359359
call = calls[("GET", "/1")][0]
360360
assert call["headers"] == {
361361
"user-agent": "custom3",
362-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
362+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
363363
}
364364

365365
client.indices.get(index="2", headers={"user-agent": "custom4"})
366366
call = calls[("GET", "/2")][0]
367367
assert call["headers"] == {
368368
"user-agent": "custom4",
369-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
369+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
370370
}
371371

372372
def test_options_timeout_parameters(self):
@@ -387,7 +387,7 @@ def test_options_timeout_parameters(self):
387387
assert call.pop("client_meta") is DEFAULT
388388
assert call == {
389389
"headers": {
390-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
390+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
391391
},
392392
"body": None,
393393
"request_timeout": 1,
@@ -416,7 +416,7 @@ def test_options_timeout_parameters(self):
416416
assert call.pop("client_meta") is DEFAULT
417417
assert call == {
418418
"headers": {
419-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
419+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
420420
},
421421
"body": None,
422422
"request_timeout": 2,
@@ -440,7 +440,7 @@ def test_options_timeout_parameters(self):
440440
assert call.pop("client_meta") is DEFAULT
441441
assert call == {
442442
"headers": {
443-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
443+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
444444
},
445445
"body": None,
446446
}
@@ -461,7 +461,7 @@ def test_options_timeout_parameters(self):
461461
assert call.pop("client_meta") is DEFAULT
462462
assert call == {
463463
"headers": {
464-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
464+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
465465
},
466466
"body": None,
467467
"request_timeout": 1,

test_elasticsearch_serverless/test_client/test_serializers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,30 @@ def test_compat_mode_on_by_default(self):
2929
self.client.get(index="test0", id="1")
3030
assert len(calls) == 1
3131
assert calls[("GET", "/test0/_doc/1")][0]["headers"] == {
32-
"Accept": "application/vnd.elasticsearch+json; compatible-with=8"
32+
"Accept": "application/vnd.elasticsearch+json; compatible-with=0"
3333
}
3434

3535
# Search with body
3636
self.client.search(index="test1", query={"match_all": {}})
3737
assert len(calls) == 2
3838
assert calls[("POST", "/test1/_search")][0]["headers"] == {
39-
"Accept": "application/vnd.elasticsearch+json; compatible-with=8",
40-
"Content-Type": "application/vnd.elasticsearch+json; compatible-with=8",
39+
"Accept": "application/vnd.elasticsearch+json; compatible-with=0",
40+
"Content-Type": "application/vnd.elasticsearch+json; compatible-with=0",
4141
}
4242

4343
# Search without body
4444
self.client.search(index="test2")
4545
assert len(calls) == 3
4646
assert calls[("POST", "/test2/_search")][0]["headers"] == {
47-
"Accept": "application/vnd.elasticsearch+json; compatible-with=8",
47+
"Accept": "application/vnd.elasticsearch+json; compatible-with=0",
4848
}
4949

5050
# Bulk uses x-ndjson
5151
self.client.bulk(operations=[])
5252
assert len(calls) == 4
5353
assert calls[("PUT", "/_bulk")][0]["headers"] == {
54-
"Accept": "application/vnd.elasticsearch+json; compatible-with=8",
55-
"Content-Type": "application/vnd.elasticsearch+x-ndjson; compatible-with=8",
54+
"Accept": "application/vnd.elasticsearch+json; compatible-with=0",
55+
"Content-Type": "application/vnd.elasticsearch+x-ndjson; compatible-with=0",
5656
}
5757

5858
@pytest.mark.parametrize("mime_subtype", ["json", "x-ndjson"])

test_elasticsearch_serverless/test_serializer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ def test_deserialize_compatibility_header(self):
197197
for content_type in (
198198
"application/vnd.elasticsearch+json;compatible-with=7",
199199
"application/vnd.elasticsearch+json; compatible-with=7",
200-
"application/vnd.elasticsearch+json;compatible-with=8",
201-
"application/vnd.elasticsearch+json; compatible-with=8",
200+
"application/vnd.elasticsearch+json;compatible-with=0",
201+
"application/vnd.elasticsearch+json; compatible-with=0",
202202
):
203203
assert {"some": "data"} == self.serializers.loads(
204204
'{"some":"data"}', content_type
@@ -210,8 +210,8 @@ def test_deserialize_compatibility_header(self):
210210
for content_type in (
211211
"application/vnd.elasticsearch+x-ndjson;compatible-with=7",
212212
"application/vnd.elasticsearch+x-ndjson; compatible-with=7",
213-
"application/vnd.elasticsearch+x-ndjson;compatible-with=8",
214-
"application/vnd.elasticsearch+x-ndjson; compatible-with=8",
213+
"application/vnd.elasticsearch+x-ndjson;compatible-with=0",
214+
"application/vnd.elasticsearch+x-ndjson; compatible-with=0",
215215
):
216216
assert b'{"some":"data"}\n{"some":"data"}\n' == self.serializers.dumps(
217217
['{"some":"data"}', {"some": "data"}], content_type

test_elasticsearch_serverless/test_transport.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ def test_client_meta_header(self):
245245
assert 1 == len(calls)
246246
headers = calls[0][1]["headers"]
247247
assert re.search(
248-
r"^es=[0-9.]+p?,py=[0-9.]+p?,t=[0-9.]+p?$", headers["x-elastic-client-meta"]
248+
r"^esv=[0-9.]+p?,py=[0-9.]+p?,t=[0-9.]+p?$",
249+
headers["x-elastic-client-meta"],
249250
)
250251

251252
class DummyNodeWithMeta(DummyNode):
@@ -258,7 +259,7 @@ class DummyNodeWithMeta(DummyNode):
258259
assert 1 == len(calls)
259260
headers = calls[0][1]["headers"]
260261
assert re.search(
261-
r"^es=[0-9.]+p?,py=[0-9.]+p?,t=[0-9.]+p?,dm=1.2.3$",
262+
r"^esv=[0-9.]+p?,py=[0-9.]+p?,t=[0-9.]+p?,dm=1.2.3$",
262263
headers["x-elastic-client-meta"],
263264
)
264265
assert headers["Custom"] == "header"
@@ -272,7 +273,7 @@ def test_client_meta_header_not_sent(self):
272273
calls = client.transport.node_pool.get().calls
273274
assert 1 == len(calls)
274275
assert calls[0][1]["headers"] == {
275-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
276+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
276277
}
277278

278279
def test_meta_header_type_error(self):
@@ -446,7 +447,7 @@ def test_sniff_uses_sniff_timeout(self):
446447
{
447448
"body": None,
448449
"headers": {
449-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
450+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
450451
},
451452
"request_timeout": DEFAULT,
452453
},
@@ -613,7 +614,7 @@ def test_unsupported_product_error(headers):
613614
{
614615
"body": None,
615616
"headers": {
616-
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
617+
"accept": "application/vnd.elasticsearch+json; compatible-with=0",
617618
},
618619
"request_timeout": DEFAULT,
619620
},

0 commit comments

Comments
 (0)