Skip to content

Commit 596a4b5

Browse files
authored
Add Export function to ReportTemplate class (#1349)
1 parent 61966d8 commit 596a4b5

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

nailgun/entities.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ def path(self, which=None):
23622362
``super`` is called otherwise.
23632363
23642364
"""
2365-
if which in ("clone", "generate", "schedule_report", "report_data"):
2365+
if which in ("clone", "generate", "schedule_report", "report_data", "export"):
23662366
prefix = "self"
23672367
return f"{super().path(prefix)}/{which}"
23682368
return super().path(which)
@@ -2443,6 +2443,24 @@ def report_data(self, synchronous=True, timeout=None, **kwargs):
24432443
response = client.get(temp_path, **kwargs)
24442444
return _handle_response(response, self._server_config, synchronous, timeout)
24452445

2446+
def export(self, synchronous=True, timeout=None, **kwargs):
2447+
"""Export a report template to ERB.
2448+
2449+
:param synchronous: What should happen if the server returns an HTTP
2450+
202 (accepted) status code? Wait for the task to complete if
2451+
``True``. Immediately return the server's response otherwise.
2452+
:param timeout: Maximum number of seconds to wait until timing out.
2453+
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
2454+
:param kwargs: Arguments to pass to requests.
2455+
:returns: The server's response, with all JSON decoded.
2456+
:raises: ``requests.exceptions.HTTPError`` If the server responds with
2457+
an HTTP 4XX or 5XX message.
2458+
"""
2459+
kwargs = kwargs.copy() # shadow the passed-in kwargs
2460+
kwargs.update(self._server_config.get_client_kwargs())
2461+
response = client.get(self.path('export'), **kwargs)
2462+
return _handle_response(response, self._server_config, synchronous, timeout)
2463+
24462464

24472465
class ContentCredential(
24482466
Entity,

0 commit comments

Comments
 (0)