|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" |
| 3 | +Lacework ReportDefinitions API wrapper. |
| 4 | +""" |
| 5 | + |
| 6 | +from laceworksdk.api.crud_endpoint import CrudEndpoint |
| 7 | + |
| 8 | + |
| 9 | +class ReportDefinitionsAPI(CrudEndpoint): |
| 10 | + |
| 11 | + def __init__(self, session): |
| 12 | + """ |
| 13 | + Initializes the ReportDefinitionsAPI object. |
| 14 | +
|
| 15 | + :param session: An instance of the HttpSession class |
| 16 | +
|
| 17 | + :return ReportDefinitionsAPI object. |
| 18 | + """ |
| 19 | + |
| 20 | + super().__init__(session, "ReportDefinitions") |
| 21 | + |
| 22 | + def create(self, |
| 23 | + report_name, |
| 24 | + report_type, |
| 25 | + sub_report_type, |
| 26 | + report_definition, |
| 27 | + props, |
| 28 | + alert_channels, |
| 29 | + distribution_type, |
| 30 | + frequency, |
| 31 | + **request_params): |
| 32 | + """ |
| 33 | + A method to create a new ReportDefinitions object. |
| 34 | +
|
| 35 | + :param report_name: A string representing the name of the report definition. |
| 36 | + :param report_type: A string representing the type of the report definition. |
| 37 | + :param sub_report_name: A string representing the sub-type of the report definition. |
| 38 | + ("AWS", "GCP", "Azure") |
| 39 | + :param report_definition: An object representing the the report definition. |
| 40 | + obj: |
| 41 | + :param sections: An array of objects representing the sections of the report definition. |
| 42 | + :param category: A string representing the section's category. |
| 43 | + :param title: A string representing the section's title. |
| 44 | + :param policies: An array of strings representing the section's policies. |
| 45 | + :param overrides: An array of objects representing the overrides of the report definition. |
| 46 | + :param title: A string representing the policy's title. |
| 47 | + :param policy: A string representing the policy ID. |
| 48 | + :param props: An object representing metadata about the report definition. |
| 49 | + obj: |
| 50 | + :param engine: A string representing the evaluation engine used for the report. |
| 51 | + :param integrations: An array of strings representing integrations (e.g. AWS Account IDs) |
| 52 | + :param resource_groups: An array of strings representing resource group IDs. |
| 53 | + :param alert_channels: An array of strings representing the alert channels for report distribution. |
| 54 | + :param distribution_type: A string representing the report format. |
| 55 | + ("csv", "html", "pdf") |
| 56 | + :param frequency: A string representing the frequency of report distribution. |
| 57 | + ("daily", "weekly") |
| 58 | + :param request_params: Additional request parameters. |
| 59 | + (provides support for parameters that may be added in the future) |
| 60 | +
|
| 61 | + :return response json |
| 62 | + """ |
| 63 | + |
| 64 | + return super().create( |
| 65 | + report_name=report_name, |
| 66 | + report_type=report_type, |
| 67 | + sub_report_type=sub_report_type, |
| 68 | + report_definition=report_definition, |
| 69 | + props=props, |
| 70 | + alert_channels=alert_channels, |
| 71 | + distribution_type=distribution_type, |
| 72 | + frequency=frequency, |
| 73 | + **request_params |
| 74 | + ) |
| 75 | + |
| 76 | + def get(self, |
| 77 | + id=None): |
| 78 | + """ |
| 79 | + A method to get ReportDefinitions objects. |
| 80 | +
|
| 81 | + :param id: A string representing the object ID. |
| 82 | +
|
| 83 | + :return response json |
| 84 | + """ |
| 85 | + |
| 86 | + return super().get(id=id) |
| 87 | + |
| 88 | + def get_by_id(self, |
| 89 | + id): |
| 90 | + """ |
| 91 | + A method to get a ReportDefinitions object by ID. |
| 92 | +
|
| 93 | + :param id: A string representing the object ID. |
| 94 | +
|
| 95 | + :return response json |
| 96 | + """ |
| 97 | + |
| 98 | + return self.get(id=id) |
| 99 | + |
| 100 | + def search(self, **request_params): |
| 101 | + """ |
| 102 | + A method to 'pass' when attempting to search ReportDefinitions objects. |
| 103 | +
|
| 104 | + Search functionality is not yet implemented for Alert Profiles. |
| 105 | + """ |
| 106 | + pass |
| 107 | + |
| 108 | + def update(self, |
| 109 | + id, |
| 110 | + report_name, |
| 111 | + report_type, |
| 112 | + sub_report_type, |
| 113 | + report_definition, |
| 114 | + props=None, |
| 115 | + alert_channels=None, |
| 116 | + distribution_type=None, |
| 117 | + frequency=None, |
| 118 | + update_type=None, |
| 119 | + **request_params): |
| 120 | + """ |
| 121 | + A method to update an ReportDefinitions object. |
| 122 | +
|
| 123 | + :param id: A string representing the object ID. |
| 124 | + :param report_name: A string representing the name of the report definition. |
| 125 | + :param report_type: A string representing the type of the report definition. |
| 126 | + :param sub_report_name: A string representing the sub-type of the report definition. |
| 127 | + ("AWS", "GCP", "Azure") |
| 128 | + :param report_definition: An object representing the the report definition. |
| 129 | + obj: |
| 130 | + :param sections: An array of objects representing the sections of the report definition. |
| 131 | + :param category: A string representing the section's category. |
| 132 | + :param title: A string representing the section's title. |
| 133 | + :param policies: An array of strings representing the section's policies. |
| 134 | + :param overrides: An array of objects representing the overrides of the report definition. |
| 135 | + :param title: A string representing the policy's title. |
| 136 | + :param policy: A string representing the policy ID. |
| 137 | + :param props: An object representing metadata about the report definition. |
| 138 | + obj: |
| 139 | + :param engine: A string representing the evaluation engine used for the report. |
| 140 | + :param integrations: An array of strings representing integrations (e.g. AWS Account IDs) |
| 141 | + :param resource_groups: An array of strings representing resource group IDs. |
| 142 | + :param alert_channels: An array of strings representing the alert channels for report distribution. |
| 143 | + :param distribution_type: A string representing the report format. |
| 144 | + ("csv", "html", "pdf") |
| 145 | + :param frequency: A string representing the frequency of report distribution. |
| 146 | + ("daily", "weekly") |
| 147 | + :param update_type: A string representing the type of update for the report definition. |
| 148 | + ("Update", "Revert") |
| 149 | + :param request_params: Additional request parameters. |
| 150 | + (provides support for parameters that may be added in the future) |
| 151 | +
|
| 152 | + :return response json |
| 153 | + """ |
| 154 | + |
| 155 | + json = self.build_dict_from_items( |
| 156 | + report_name=report_name, |
| 157 | + report_type=report_type, |
| 158 | + sub_report_type=sub_report_type, |
| 159 | + report_definition=report_definition, |
| 160 | + props=props, |
| 161 | + alert_channels=alert_channels, |
| 162 | + distribution_type=distribution_type, |
| 163 | + frequency=frequency, |
| 164 | + update_type=update_type, |
| 165 | + **request_params |
| 166 | + ) |
| 167 | + |
| 168 | + response = self._session.put(self.build_url(id=id), json=json) |
| 169 | + |
| 170 | + return response.json() |
| 171 | + |
| 172 | + def delete(self, |
| 173 | + id): |
| 174 | + """ |
| 175 | + A method to delete a ReportDefinitions object. |
| 176 | +
|
| 177 | + :param guid: A string representing the object ID. |
| 178 | +
|
| 179 | + :return response json |
| 180 | + """ |
| 181 | + |
| 182 | + return super().delete(id=id) |
0 commit comments