| @@ 1984-2026 (lines=43) @@ | ||
| 1981 | ||
| 1982 | return self._send_xml_command(cmd) |
|
| 1983 | ||
| 1984 | def import_report( |
|
| 1985 | self, |
|
| 1986 | report: str, |
|
| 1987 | *, |
|
| 1988 | task_id: Optional[str] = None, |
|
| 1989 | in_assets: Optional[bool] = None, |
|
| 1990 | ) -> Any: |
|
| 1991 | """Import a Report from XML |
|
| 1992 | ||
| 1993 | Arguments: |
|
| 1994 | report: Report XML as string to import. This XML must contain |
|
| 1995 | a :code:`<report>` root element. |
|
| 1996 | task_id: UUID of task to import report to |
|
| 1997 | in_asset: Whether to create or update assets using the report |
|
| 1998 | ||
| 1999 | Returns: |
|
| 2000 | The response. See :py:meth:`send_command` for details. |
|
| 2001 | """ |
|
| 2002 | if not report: |
|
| 2003 | raise RequiredArgument( |
|
| 2004 | function=self.import_report.__name__, argument='report' |
|
| 2005 | ) |
|
| 2006 | ||
| 2007 | cmd = XmlCommand("create_report") |
|
| 2008 | ||
| 2009 | if task_id: |
|
| 2010 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 2011 | else: |
|
| 2012 | raise RequiredArgument( |
|
| 2013 | function=self.import_report.__name__, argument='task_id' |
|
| 2014 | ) |
|
| 2015 | ||
| 2016 | if in_assets is not None: |
|
| 2017 | cmd.add_element("in_assets", _to_bool(in_assets)) |
|
| 2018 | ||
| 2019 | try: |
|
| 2020 | cmd.append_xml_str(report) |
|
| 2021 | except etree.XMLSyntaxError as e: |
|
| 2022 | raise InvalidArgument( |
|
| 2023 | "Invalid xml passed as report to import_report {}".format(e) |
|
| 2024 | ) from None |
|
| 2025 | ||
| 2026 | return self._send_xml_command(cmd) |
|
| 2027 | ||
| @@ 2143-2185 (lines=43) @@ | ||
| 2140 | ||
| 2141 | return self._send_xml_command(cmd) |
|
| 2142 | ||
| 2143 | def import_report( |
|
| 2144 | self, |
|
| 2145 | report: str, |
|
| 2146 | *, |
|
| 2147 | task_id: Optional[str] = None, |
|
| 2148 | in_assets: Optional[bool] = None, |
|
| 2149 | ) -> Any: |
|
| 2150 | """Import a Report from XML |
|
| 2151 | ||
| 2152 | Arguments: |
|
| 2153 | report: Report XML as string to import. This XML must contain |
|
| 2154 | a :code:`<report>` root element. |
|
| 2155 | task_id: UUID of task to import report to |
|
| 2156 | in_asset: Whether to create or update assets using the report |
|
| 2157 | ||
| 2158 | Returns: |
|
| 2159 | The response. See :py:meth:`send_command` for details. |
|
| 2160 | """ |
|
| 2161 | if not report: |
|
| 2162 | raise RequiredArgument( |
|
| 2163 | function=self.import_report.__name__, argument='report' |
|
| 2164 | ) |
|
| 2165 | ||
| 2166 | cmd = XmlCommand("create_report") |
|
| 2167 | ||
| 2168 | if task_id: |
|
| 2169 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 2170 | else: |
|
| 2171 | raise RequiredArgument( |
|
| 2172 | function=self.import_report.__name__, argument='task_id' |
|
| 2173 | ) |
|
| 2174 | ||
| 2175 | if in_assets is not None: |
|
| 2176 | cmd.add_element("in_assets", _to_bool(in_assets)) |
|
| 2177 | ||
| 2178 | try: |
|
| 2179 | cmd.append_xml_str(report) |
|
| 2180 | except etree.XMLSyntaxError as e: |
|
| 2181 | raise InvalidArgument( |
|
| 2182 | "Invalid xml passed as report to import_report {}".format(e) |
|
| 2183 | ) from None |
|
| 2184 | ||
| 2185 | return self._send_xml_command(cmd) |
|
| 2186 | ||
| 2187 | def create_agent( |
|
| 2188 | self, |
|