Skip to content

feat(uploads): wrap clearing-progress and licenses/histogram endpoints#193

Closed
Valyrian-Code wants to merge 1 commit into
fossology:mainfrom
Valyrian-Code:feat/upload-analysis-endpoints
Closed

feat(uploads): wrap clearing-progress and licenses/histogram endpoints#193
Valyrian-Code wants to merge 1 commit into
fossology:mainfrom
Valyrian-Code:feat/upload-analysis-endpoints

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

Refs #52.

Adds two read-only upload analysis getters:

  • clearing_progress()GET /uploads/{id}/clearing-progress — returns a ClearingProgress (totalFilesOfInterest / totalFilesCleared)
  • license_histogram()GET /uploads/{id}/licenses/histogram — returns 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.

API details

Validated against the OpenAPI spec (API 1.6.2 / Fossology 4.4.0).

Tests

Live happy paths, 404/500 error paths, and a mocked payload assertion exercising histogram parsing and the agentId query param.

Static checks (ruff, mypy) pass locally; the integration suite runs in CI.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 1, 2026 06:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and Uploads.license_histogram() client methods.
  • Adds ClearingProgress and LicenseHistogram models in obj.py following the existing from_json pattern.
  • Extends tests/test_uploads.py with 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 thread fossology/uploads.py
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 thread fossology/uploads.py
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 thread fossology/uploads.py
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>
@Valyrian-Code Valyrian-Code force-pushed the feat/upload-analysis-endpoints branch from a0cb276 to fbd7096 Compare July 1, 2026 16:29
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback in fbd7096:

  • clearing_progress() and license_histogram() now raise AuthorizationError on HTTP 403, consistent with the other uploads endpoints (upload_summary, detail_upload, …).
  • Fixed the license_histogram docstring: :type agent_id: int | None and documented :raises AuthorizationError:.
  • Added mocked 403 tests for both methods.

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).

@Valyrian-Code Valyrian-Code deleted the feat/upload-analysis-endpoints branch July 1, 2026 17:03
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Replaced by #197.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants