Skip to content

Commit 544c264

Browse files
api-clients-generation-pipeline[bot]therveci.datadog-api-spec
authored
Add support for gzip and deflate encoding (#593)
* Add support for deflate and gzip * Regenerate client from commit 4a04b77 of spec repo Co-authored-by: Thomas Hervé <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 5e88971 commit 544c264

File tree

7 files changed

+42
-8
lines changed

7 files changed

+42
-8
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.5.1.dev2",
7-
"regenerated": "2021-09-27 09:40:37.419998",
8-
"spec_repo_commit": "c02444e"
7+
"regenerated": "2021-09-28 11:30:21.345145",
8+
"spec_repo_commit": "4a04b77"
99
},
1010
"v2": {
1111
"apigentools_version": "1.5.1.dev2",
12-
"regenerated": "2021-09-27 09:40:59.645682",
13-
"spec_repo_commit": "c02444e"
12+
"regenerated": "2021-09-28 11:30:43.932927",
13+
"spec_repo_commit": "4a04b77"
1414
}
1515
}
1616
}

.generator/templates/rest.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import logging
66
import re
77
import ssl
88
from urllib.parse import urlencode
9+
import zlib
910

1011
import urllib3
1112

@@ -141,6 +142,11 @@ class RESTClientObject(object):
141142
request_body = None
142143
if body is not None:
143144
request_body = json.dumps(body)
145+
if headers.get("Content-Encoding") == "gzip":
146+
compress = zlib.compressobj(wbits=16 + zlib.MAX_WBITS)
147+
request_body = compress.compress(request_body.encode("utf-8")) + compress.flush()
148+
elif headers.get("Content-Encoding") == "deflate":
149+
request_body = zlib.compress(request_body.encode("utf-8"))
144150
r = self.pool_manager.request(
145151
method, url,
146152
body=request_body,

src/datadog_api_client/v1/model/content_encoding.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datadog_api_client/v1/openapi.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datadog_api_client/v1/rest.py

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datadog_api_client/v2/rest.py

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/v1/features/logs.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ Feature: Logs
2222
When the request is sent
2323
Then the response status is 200 OK
2424

25+
@integration-only
26+
Scenario: Send deflate logs returns "Response from server (always 200 empty JSON)." response
27+
Given new "SubmitLog" request
28+
And body with value [{"message": "{{ unique }}", "ddtags": "host:{{ unique_alnum }}"}]
29+
And request contains "content_encoding" parameter with value "deflate"
30+
When the request is sent
31+
Then the response status is 200 Response from server (always 200 empty JSON).
32+
33+
@integration-only
34+
Scenario: Send gzip logs returns "Response from server (always 200 empty JSON)." response
35+
Given new "SubmitLog" request
36+
And body with value [{"message": "{{ unique }}", "ddtags": "host:{{ unique_alnum }}"}]
37+
And request contains "content_encoding" parameter with value "gzip"
38+
When the request is sent
39+
Then the response status is 200 Response from server (always 200 empty JSON).
40+
2541
Scenario: Send logs returns "Response from server (always 200 empty JSON)." response
2642
Given new "SubmitLog" request
2743
And body with value [{"message": "{{ unique }}", "ddtags": "host:{{ unique_alnum }}"}]

0 commit comments

Comments
 (0)