Fossology Report¶
Methods used to access “report/” endpoints.
- class fossology.report.Report¶
Class dedicated to all “report” related endpoints
- download_report(report_id: int, group: str | None = None, wait_time: int = 0) Tuple[str, str] ¶
Download a report
API Endpoint: GET /report/{id}
Get report for a given upload. If the report is not ready wait another
wait_time
seconds or look at theRetry-After
to determine how long the wait period shall be.If
wait_time
is 0, the time interval specified by theRetry-After
header is used.The function stops trying after 10 attempts.
- Example:
>>> from fossology import Fossology >>> >>> foss = Fossology(FOSS_URL, FOSS_TOKEN, username) >>> >>> # Generate a report for upload 1 >>> report_id = foss.generate_report(foss.detail_upload(1)) >>> # Wait up to 20 Minutes until the report is ready >>> report_content, report_name = foss.download_report(report_id, wait_time=120) >>> with open(report_name, "wb") as report_file: ... report_file.write(report_content)
- Parameters:
report_id (int) – the id of the generated report
group (string) – the group name to choose while downloading a specific report (default: None)
wait_time (int) – use a customized upload wait time instead of Retry-After (in seconds, default: 0)
- Returns:
the report content and the report name
- Return type:
Tuple[str, str]
- Raises:
FossologyApiError – if the REST call failed
AuthorizationError – if the REST call is not authorized
TryAgain – if the report generation times out after 10 retries
- generate_report(upload: Upload, report_format: ReportFormat | None = None, group: str | None = None)¶
Generate a report for a given upload
API Endpoint: GET /report
- Parameters:
upload (Upload) – the upload which report will be generated
format (ReportFormat) – the report format (default: ReportFormat.READMEOSS)
group (string) – the group name to choose while generating the report (default: None)
- Returns:
the report id
- Return type:
int
- Raises:
FossologyApiError – if the REST call failed
AuthorizationError – if the REST call is not authorized