feat(uploads): wrap clearing-progress and licenses/histogram endpoints#193
Closed
Valyrian-Code wants to merge 1 commit into
Closed
feat(uploads): wrap clearing-progress and licenses/histogram endpoints#193Valyrian-Code wants to merge 1 commit into
Valyrian-Code wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds wrapper support in the Python client for two additional read-only Fossology upload analysis endpoints (/clearing-progress and /licenses/histogram), including new response models and accompanying tests.
Changes:
- Introduces
Uploads.clearing_progress()andUploads.license_histogram()client methods. - Adds
ClearingProgressandLicenseHistogrammodels inobj.pyfollowing the existingfrom_jsonpattern. - Extends
tests/test_uploads.pywith live-path tests plus mocked 404/500 and payload/query-param coverage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/test_uploads.py | Adds tests covering clearing-progress and license histogram behavior, including error and payload assertions. |
| fossology/uploads.py | Implements two new upload-analysis getters and parses responses into new models. |
| fossology/obj.py | Adds model classes for clearing progress and license histogram entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+367
to
+389
| """Get the clearing progress information for an upload | ||
|
|
||
| API Endpoint: GET /uploads/{id}/clearing-progress | ||
|
|
||
| :param upload: the upload to gather data from | ||
| :type upload: Upload | ||
| :return: the clearing progress of the upload | ||
| :rtype: ClearingProgress | ||
| :raises FossologyApiError: if the REST call failed | ||
| """ | ||
| response = self.session.get( # type: ignore | ||
| f"{self.api}/uploads/{upload.id}/clearing-progress" # type: ignore | ||
| ) | ||
|
|
||
| if response.status_code == 200: | ||
| return ClearingProgress.from_json(response.json()) | ||
|
|
||
| elif response.status_code == 404: | ||
| description = f"Upload {upload.id} not found" | ||
| raise FossologyApiError(description, response) | ||
| else: | ||
| description = f"Unable to get clearing progress for upload {upload.uploadname} (id={upload.id})" | ||
| raise FossologyApiError(description, response) |
Comment on lines
+414
to
+422
| if response.status_code == 200: | ||
| return [LicenseHistogram.from_json(item) for item in response.json()] | ||
|
|
||
| elif response.status_code == 404: | ||
| description = f"Upload {upload.id} not found" | ||
| raise FossologyApiError(description, response) | ||
| else: | ||
| description = f"Unable to get license histogram for upload {upload.uploadname} (id={upload.id})" | ||
| raise FossologyApiError(description, response) |
Comment on lines
+394
to
+405
| """Get the licenses histogram for an upload | ||
|
|
||
| API Endpoint: GET /uploads/{id}/licenses/histogram | ||
|
|
||
| :param upload: the upload to gather data from | ||
| :param agent_id: limit the histogram to a specific agent (default: None) | ||
| :type upload: Upload | ||
| :type agent_id: int | ||
| :return: the license histogram of the upload | ||
| :rtype: list[LicenseHistogram] | ||
| :raises FossologyApiError: if the REST call failed | ||
| """ |
Refs fossology#52. Adds two read-only upload analysis getters: - clearing_progress() -> GET /uploads/{id}/clearing-progress, returning a ClearingProgress (totalFilesOfInterest / totalFilesCleared) - license_histogram() -> GET /uploads/{id}/licenses/histogram, returning a list[LicenseHistogram] (id / name / scannerCount / concludedCount), with an optional agentId filter Adds the ClearingProgress and LicenseHistogram models to obj.py following the existing from_json convention. Both methods raise AuthorizationError on HTTP 403, consistent with the other uploads endpoints. Verified against Fossology 4.4.0 (API 1.6.1) running in a container: all 8 tests pass (live happy paths, mocked 403/404/500 error paths, and a payload assertion exercising histogram parsing and the agentId query param). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: RAJVEER42 <irajveer.bishnoi2310@gmail.com>
a0cb276 to
fbd7096
Compare
Contributor
Author
|
Addressed the review feedback in
Re-verified against a live Fossology 4.4.0 (API 1.6.1) container — all 8 clearing-progress / histogram tests pass (live happy paths + mocked 403/404/500 + payload/agentId assertion). |
Contributor
Author
|
Replaced by #197. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #52.
Adds two read-only upload analysis getters:
clearing_progress()→GET /uploads/{id}/clearing-progress— returns aClearingProgress(totalFilesOfInterest/totalFilesCleared)license_histogram()→GET /uploads/{id}/licenses/histogram— returns alist[LicenseHistogram](id/name/scannerCount/concludedCount), with an optionalagentIdfilterAdds the
ClearingProgressandLicenseHistogrammodels toobj.py, following the existingfrom_jsonconvention.API details
Validated against the OpenAPI spec (API 1.6.2 / Fossology 4.4.0).
Tests
Live happy paths,
404/500error paths, and a mocked payload assertion exercising histogram parsing and theagentIdquery param.Static checks (
ruff,mypy) pass locally; the integration suite runs in CI.🤖 Generated with Claude Code