Skip to content

Commit 9710bf0

Browse files
Add Export function to ReportTemplate class (#1349) (#1355)
(cherry picked from commit 596a4b5) Co-authored-by: Nakul Pathak <33572967+nacoool@users.noreply.github.com>
1 parent f5e72e3 commit 9710bf0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

nailgun/entities.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,7 @@ def path(self, which=None):
23282328
``super`` is called otherwise.
23292329
23302330
"""
2331-
if which in ("clone", "generate", "schedule_report", "report_data"):
2331+
if which in ("clone", "generate", "schedule_report", "report_data", "export"):
23322332
prefix = "self"
23332333
return f"{super().path(prefix)}/{which}"
23342334
return super().path(which)
@@ -2409,6 +2409,24 @@ def report_data(self, synchronous=True, timeout=None, **kwargs):
24092409
response = client.get(temp_path, **kwargs)
24102410
return _handle_response(response, self._server_config, synchronous, timeout)
24112411

2412+
def export(self, synchronous=True, timeout=None, **kwargs):
2413+
"""Export a report template to ERB.
2414+
2415+
:param synchronous: What should happen if the server returns an HTTP
2416+
202 (accepted) status code? Wait for the task to complete if
2417+
``True``. Immediately return the server's response otherwise.
2418+
:param timeout: Maximum number of seconds to wait until timing out.
2419+
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
2420+
:param kwargs: Arguments to pass to requests.
2421+
:returns: The server's response, with all JSON decoded.
2422+
:raises: ``requests.exceptions.HTTPError`` If the server responds with
2423+
an HTTP 4XX or 5XX message.
2424+
"""
2425+
kwargs = kwargs.copy() # shadow the passed-in kwargs
2426+
kwargs.update(self._server_config.get_client_kwargs())
2427+
response = client.get(self.path('export'), **kwargs)
2428+
return _handle_response(response, self._server_config, synchronous, timeout)
2429+
24122430

24132431
class ContentCredential(
24142432
Entity,

0 commit comments

Comments
 (0)