Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report arguments #163

Merged
merged 3 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [unreleased]

### Added
* Added ignore_pagination and details arguments for get_report [PR 163](https://github.com/greenbone/python-gvm/pull/163)
* Introducing Gmpv9 [PR 157](https://github.com/greenbone/python-gvm/pull/157)
* Added new `create_audit` method, to create a task with the `usage_type` `audit` [PR 157](https://github.com/greenbone/python-gvm/pull/157)
* Added new `create_policy` method, to create a config with the `usage_type` `policy` [PR 157](https://github.com/greenbone/python-gvm/pull/157)
Expand Down
13 changes: 12 additions & 1 deletion gvm/protocols/gmpv7/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3407,7 +3407,9 @@ def get_report(
filter: Optional[str] = None,
filter_id: Optional[str] = None,
delta_report_id: Optional[str] = None,
report_format_id: Optional[str] = None
report_format_id: Optional[str] = None,
ignore_pagination: Optional[bool] = None,
details: Optional[bool] = None
) -> Any:
"""Request a single report

Expand All @@ -3417,6 +3419,9 @@ def get_report(
filter_id: UUID of filter to use to filter results in the report
delta_report_id: UUID of an existing report to compare report to.
report_format_id: UUID of report format to use
ignore_pagination: Whether to ignore the filter terms "first" and
"rows".
details: Request addititional report information details

Returns:
The response. See :py:meth:`send_command` for details.
Expand All @@ -3435,6 +3440,12 @@ def get_report(
if report_format_id:
cmd.set_attribute("format_id", report_format_id)

if ignore_pagination is not None:
cmd.set_attribute("ignore_pagination", _to_bool(ignore_pagination))

if details is not None:
cmd.set_attribute("details", _to_bool(details))

return self._send_xml_command(cmd)

def get_report_formats(
Expand Down
26 changes: 26 additions & 0 deletions tests/protocols/gmpv7/test_get_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ def test_get_report_with_delta_report_id(self):
'<get_reports report_id="r1" delta_report_id="r2"/>'
)

def test_get_report_with_ignore_pagination(self):
self.gmp.get_report(report_id='r1', ignore_pagination=True)

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" ignore_pagination="1"/>'
)

self.gmp.get_report(report_id='r1', ignore_pagination=False)

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" ignore_pagination="0"/>'
)

def test_get_report_with_details(self):
self.gmp.get_report(report_id='r1', details=True)

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" details="1"/>'
)

self.gmp.get_report(report_id='r1', details=False)

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" details="0"/>'
)


if __name__ == '__main__':
unittest.main()