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_timeseconds or look at theRetry-Afterto determine how long the wait period shall be.If
wait_timeis 0, the time interval specified by theRetry-Afterheader 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
- import_report(upload: Upload, report_file: str, report_format: str = 'spdxrdf', add_concluded_as_decisions: bool = False, group: str | None = None) int¶
Import an external report for a given upload.
Uploads the report file and schedules a
reportImportjob that merges the report’s license decisions into the upload.API Endpoint: POST /report/import
- Example:
>>> from fossology import Fossology >>> >>> foss = Fossology(FOSS_URL, FOSS_TOKEN) >>> job_id = foss.import_report( ... foss.detail_upload(1), ... "report.spdx.rdf", ... )
- Parameters:
upload (Upload) – the upload the report is imported for
report_file (str) – local path to the report file to import
report_format (str) – the report format (default: “spdxrdf” — the only format currently accepted by the Fossology API)
add_concluded_as_decisions (bool) – treat concluded licenses in the report as clearing decisions (default: False)
group (str | None) – the group name to act on behalf of (default: None)
- Returns:
the id of the scheduled reportImport job
- Return type:
int
- Raises:
FossologyApiError – if the REST call failed
AuthorizationError – if the REST call is not authorized