Skip to content

Commit 50d6fd9

Browse files
api-clients-generation-pipeline[bot]therveci.datadog-api-spec
authored
Enable compression in responses (#612)
* Support and document gzip accept encoding * Enable by default * Regenerate client from commit 7a4f3f3 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 50a8306 commit 50d6fd9

File tree

9 files changed

+46
-7
lines changed

9 files changed

+46
-7
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-10-01 10:28:40.479970",
8-
"spec_repo_commit": "bc91052"
7+
"regenerated": "2021-10-07 07:32:01.590429",
8+
"spec_repo_commit": "7a4f3f3"
99
},
1010
"v2": {
1111
"apigentools_version": "1.5.1.dev2",
12-
"regenerated": "2021-10-01 10:29:03.830072",
13-
"spec_repo_commit": "bc91052"
12+
"regenerated": "2021-10-07 07:32:35.804199",
13+
"spec_repo_commit": "7a4f3f3"
1414
}
1515
}
1616
}

.generator/templates/api_client.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class ApiClient(object):
7070
self.default_headers = {}
7171
if header_name is not None:
7272
self.default_headers[header_name] = header_value
73+
if self.configuration.compress:
74+
self.default_headers["Accept-Encoding"] = "gzip"
7375
self.cookie = cookie
7476
# Set default User-Agent.
7577
self.user_agent = user_agent()

.generator/templates/configuration.mustache

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ class Configuration(object):
7272
:param server_operation_variables: Mapping from operation ID to a mapping with
7373
string values to replace variables in templated server configuration.
7474
The validation of enums is performed for variables with defined enum values before.
75-
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
75+
:param ssl_ca_cert: The path to a file of concatenated CA certificates
7676
in PEM format
77+
:param compress: Boolean indicating whether we accept encoding responses or not.
7778

7879
{{#hasAuthMethods}}
7980
:Example:
@@ -174,6 +175,7 @@ conf = {{{packageName}}}.Configuration(
174175
server_index=None, server_variables=None,
175176
server_operation_index=None, server_operation_variables=None,
176177
ssl_ca_cert=None,
178+
compress=True,
177179
):
178180
"""Constructor
179181
"""
@@ -294,6 +296,9 @@ conf = {{{packageName}}}.Configuration(
294296
# Options to pass down to the underlying urllib3 socket
295297
self.socket_options = None
296298

299+
# Will translate to a Accept-Encoding header
300+
self.compress = compress
301+
297302
# Keep track of unstable operations
298303
self.unstable_operations = {
299304
{{#apiInfo}}

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ configuration.api_key["apiKeyAuth"] = "YOUR_API_KEY"
9696
configuration.api_key["appKeyAuth"] = "YOUR_APPLICATION_KEY"
9797
```
9898

99+
### Disable compressed payloads
100+
101+
If you want to disable GZIP compressed responses, set the `compress` flag
102+
on your configuration object:
103+
104+
```python
105+
configuration.compress = False
106+
```
107+
99108
## Author
100109

101110

docs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ configuration.api_key["apiKeyAuth"] = "YOUR_API_KEY"
9696
configuration.api_key["appKeyAuth"] = "YOUR_APPLICATION_KEY"
9797
```
9898

99+
### Disable compressed payloads
100+
101+
If you want to disable GZIP compressed responses, set the `compress` flag
102+
on your configuration object:
103+
104+
```python
105+
configuration.compress = False
106+
```
107+
99108
## Author
100109

101110

src/datadog_api_client/v1/api_client.py

Lines changed: 2 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/v1/configuration.py

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

src/datadog_api_client/v2/api_client.py

Lines changed: 2 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/configuration.py

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

0 commit comments

Comments
 (0)