This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.py
120 lines (99 loc) · 4.06 KB
/
report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Copyright (C) 2018-2021
# Author: Cesar Roman
# Contact: cesar@thecesrom.dev
"""Report Functions
The following functions give you access to report details and the
ability to run reports.
"""
__all__ = [
"executeAndDistribute",
"executeReport",
"getReportNamesAsDataset",
"getReportNamesAsList",
]
from java.lang import IllegalArgumentException
from system.dataset import Dataset
def executeAndDistribute(
path, project="project", parameters=None, action=None, actionSettings=None
):
"""Executes and distributes a report. Similar to scheduling a report
to execute, except a schedule in not required to utilize this
function. This is a great way to distribute the report on demand
from a client.
Args:
path (str): The path to the existing report.
project (str): The name of the project where the report is
located. Optional in client scope.
parameters (dict): An optional dictionary of parameter
overrides, in the form name:value.
action (str): The name of the distribution action to use.
actionSettings (dict): An optional dictionary of settings
particular to the action. Missing values will use the
default value for that action.
Raises:
IllegalArgumentException: Thrown when any of the following
occurs: If the file type is not recognized, path does not
exist, project does not exist, or a key is not valid.
"""
if project is None:
raise IllegalArgumentException()
else:
print(path, project, parameters, action, actionSettings)
def executeReport(path, project="project", parameters=None, fileType="pdf"):
"""Immediately executes an existing report and returns a byte[] of
the output.
Args:
path (str): The path to the existing report.
project (str): The name of the project where the report is
located. Optional in client scope.
parameters (dict): An optional dictionary of parameter
overrides, in the form name:value. Optional.
fileType (str): The file type the resulting byte array should
represent. Defaults to "pdf". Not case-sensitive. Optional.
Returns:
object: A byte array of the resulting report.
Raises:
IllegalArgumentException: Thrown when any of the following
occurs: If the file type is not recognized, path does not
exist, project does not exist.
"""
_fileTypes = ["pdf", "html", "csv", "rtf", "jpeg", "png", "xml"]
if path is None or project is None or fileType not in _fileTypes:
raise IllegalArgumentException()
print(path, project, parameters, fileType)
return None
def getReportNamesAsDataset(project="project"):
"""Gets a data of all reports for a project. This dataset is
particularly suited for display in a Tree View component.
Args:
project (str): The name of the project where the reports are
located. Optional in client scope.
Returns:
Dataset: A dataset of report paths and names for the project.
Returns an empty dataset if the project has no reports.
Raises:
IllegalArgumentException: Thrown when any of the following
occurs: If the project name is omitted in the Gateway scope,
project does not exist.
"""
if project is None:
raise IllegalArgumentException()
else:
return Dataset()
def getReportNamesAsList(project="project"):
"""Gets a list of all reports for a project.
Args:
project (str): The name of the project where the reports are
located. Optional in client scope.
Returns:
list[str]: A list of report paths for the project. Returns an
empty list if the project has no reports.
Raises:
IllegalArgumentException: Thrown when any of the following
occurs: If the project name is omitted in the Gateway scope,
project does not exist.
"""
if project is None:
raise IllegalArgumentException()
else:
return []