Fossology Uploads

Methods used to access “uploads/” endpoints.

class fossology.uploads.Uploads

Class dedicated to all “uploads” related endpoints

change_upload_permissions(upload: Upload, all_uploads: bool = False, group: Group | None = None, new_permission: Permission | None = None, public_permission: Permission | None = None)

Change the permission of an upload

API Endpoint: PUT /uploads/{id}/permission

Parameters:
  • upload (Upload) – the upload to update

  • group (Group (default: None)) – the group you want to add or edit permission for this upload

  • new_permission (Permission (default: None)) – the permission for the selected group

  • public_permission (Permission (default: None)) – the public permission for this upload

Raises:
delete_upload(upload, group=None)

Delete an upload

API Endpoint: DELETE /uploads/{id}

Parameters:
  • upload (Upload) – the upload to be deleted

  • group (string) – the group name to chose while deleting the upload (default: None)

Raises:
detail_upload(upload_id: int, group: str | None = None, wait_time: int = 0) Upload

Get detailed information about an upload

API Endpoint: GET /uploads/{id}

Get information about a given upload. If the upload is not ready wait another wait_time seconds or look at the Retry-After to determine how long the wait period shall be.

If wait_time is 0, the time interval specified by the Retry-After header is used.

The function stops trying after 10 attempts.

Examples:

>>> # Wait up to 20 minutes until the upload is ready
>>> long_upload = detail_upload(1, wait_time=120) 
>>> # Wait up to 5 minutes until the upload is ready
>>> long_upload = detail_upload(1, wait_time=30) 
Parameters:
  • upload_id (int) – the id of the upload

  • group (string) – the group the upload shall belong to

  • wait_time (int) – use a customized upload wait time instead of Retry-After (in seconds, default: 0)

Returns:

the upload data

Return type:

Upload

Raises:
download_upload(upload: Upload) Tuple[str, str]

Download an upload by its id

API Endpoint: GET /uploads/{id}/download

Parameters:

upload (Upload) – the Upload to be downloaded

Returns:

the upload content and the upload name

Return type:

Tuple[str, str]

Raises:
list_uploads(folder: Folder | None = None, group: str | None = None, recursive: bool = True, name: str | None = None, status: ClearingStatus | None = None, assignee: str | None = None, since: str | None = None, page_size=100, page=1, all_pages=False)

Get uploads according to filtering criteria (or all available)

API Endpoint: GET /uploads

Parameters:
  • folder (Folder) – only list uploads from the given folder

  • group (string) – list uploads from a specific group (not only your own uploads) (default: None)

  • recursive (boolean) – wether to list uploads from children folders or not (default: True)

  • name (str) – filter pattern for name and description

  • status (ClearingStatus) – status of uploads

  • assignee (str) – user name to which uploads are assigned to or “-me-” or “-unassigned-”

  • since (str) – uploads since given date in YYYY-MM-DD format

  • page_size (int) – limit the number of uploads per page (default: 100)

  • page (int) – the number of the page to fetch uploads from (default: 1)

  • all_pages (boolean) – get all uploads (default: False)

Returns:

a tuple containing the list of uploads and the total number of pages

Return type:

Tuple(list of Upload, int)

Raises:
move_upload(upload: Upload, folder: Folder, action: str)

Copy or move an upload by id

API Endpoint: PUT /uploads/{id}

Parameters:
  • upload (Upload) – the Upload to be copied or moved in another folder

  • folder (Folder) – the destination Folder

  • action (str) – the action to be performed, ‘copy’ or ‘move’

Raises:
update_upload(upload: Upload, status: ClearingStatus | None = None, comment: str = '', assignee: User | None = None, group: str | None = None)

Update an upload information

API Endpoint: PATCH /uploads/{id}

Parameters:
  • upload (Upload) – the Upload to be updated

  • status (ClearingStatus) – the new status of the upload (Open, InProgress, Closed, Rejected)

  • comment (string) – the comment on the status, required for Closed and Rejected states. Ignored for others. (default: empty)

  • assignee (User) – the user assigned to the upload (default: None)

  • group (string) – the group name to chose while changing the upload (default: None)

Raises:
upload_copyrights(upload: Upload)

Get copyright matches from an upload

API Endpoint: GET /uploads/{id}/copyrights

Parameters:

upload (Upload) – the upload to gather data from

Returns:

the list of copyrights findings

Return type:

list of Licenses

Raises:
upload_file(folder: Folder, file: str | None = None, vcs: dict | None = None, url: dict | None = None, server: dict | None = None, description: str | None = None, access_level: AccessLevel | None = None, apply_global: bool = False, ignore_scm: bool = False, group: str | None = None, wait_time: int = 0)

Upload a package to FOSSology

API Endpoint: POST /uploads

Perform a file, VCS or URL upload and get information about the upload using detail_upload() and passing the wait_time argument.

See description of detail_upload() to configure how long the client shall wait for the upload to be ready.

Example for a file upload:

>>> from fossology import Fossology
>>> from fossology.enums import AccessLevel
>>> foss = Fossology(FOSS_URL, FOSS_TOKEN) 
>>> my_upload = foss.upload_file(
...        foss.rootFolder,
...        file="my-package.zip",
...        description="My product package",
...        access_level=AccessLevel.PUBLIC,
...    )  
Example for a VCS upload:

>>> vcs = {
...        "vcsType": "git",
...        "vcsUrl": "https://github.com/fossology/fossology-python",
...        "vcsName": "fossology-python-github-master",
...        "vcsUsername": "",
...        "vcsPassword": "",
...    }
>>> vcs_upload = foss.upload_file(
...        foss.rootFolder,
...        vcs=vcs,
...        description="Upload from VCS",
...        access_level=AccessLevel.PUBLIC,
...    )  
Example for a URL upload:

>>> url = {
...        "url": "https://github.com/fossology/fossology-python/archive/master.zip",
...        "name": "fossology-python-master.zip",
...        "accept": "zip",
...        "reject": "",
...        "maxRecursionDepth": "1",
...    }
>>> url_upload = foss.upload_file(
...        foss.rootFolder,
...        url=url,
...        description="Upload from URL",
...        access_level=AccessLevel.PUBLIC,
...    )  
Example for a SERVER upload:

>>> server = {
...        "path": "/tmp/fossology-python",
...        "name": "fossology-python",
...    }
>>> server_upload = foss.upload_file(
...        foss.rootFolder,
...        server=server,
...        description="Upload from SERVER",
...        access_level=AccessLevel.PUBLIC,
...    )  
Parameters:
  • folder (Folder) – the upload Fossology folder

  • file (string) – the local path of the file to be uploaded

  • vcs (dict()) – the VCS specification to upload from an online repository

  • url (dict()) – the URL specification to upload from a url

  • server (dict()) – the SERVER specification to upload from fossology server

  • description (string) – description of the upload (default: None)

  • access_level (AccessLevel) – access permissions of the upload (default: protected)

  • apply_global (boolean) – apply global decisions for current upload (default: False)

  • ignore_scm (boolean) – ignore SCM files (Git, SVN, TFS) (default: True)

  • group (string) – the group name to chose while uploading the file (default: None)

  • wait_time (int) – use a customized upload wait time instead of Retry-After (in seconds, default: 0)

Returns:

the upload data

Return type:

Upload

Raises:
upload_licenses(upload: Upload, group: str | None = None, agent: str | None = None, containers: bool = False, license: bool = True, copyright: bool = False) list[UploadLicenses] | None

Get clearing information about an upload

API Endpoint: GET /uploads/{id}/licenses

Parameters:
  • upload (Upload) – the upload to gather data from

  • group (string) – the group name to chose while accessing the upload (default: None)

  • agent (string) – the license agents to use (e.g. “nomos,monk,ninka,ojo,reportImport”, default: “nomos”)

  • containers (boolean) – wether to show containers or not (default: False)

  • license (boolean) – wether to expose license matches (default: True)

  • copyright (boolean) – wether to expose copyright matches (default: False)

Returns:

the list of UploadLicenses for the specified agent

Return type:

list of UploadLicenses

Raises:
upload_permissions(upload: Upload)

Get all the groups with their respective permissions for an upload

API Endpoint: GET /uploads/{id}/perm-groups

Parameters:

upload (Upload) – the upload to get permission from

Raises:
upload_summary(upload: Upload, group=None)

Get clearing information about an upload

API Endpoint: GET /uploads/{id}/summary

Parameters:
  • upload – the upload to gather data from

  • group (string) – the group name to chose while accessing an upload (default: None)

Type:

Upload

Returns:

the upload summary data

Return type:

Summary

Raises:
fossology.uploads.list_uploads_parameters(folder: Folder | None = None, recursive: bool = True, name: str | None = None, status: ClearingStatus | None = None, assignee: str | None = None, since: str | None = None, group: str | None = None, limit: str | None = None) dict

Helper function to list of query parameters for GET /uploads endpoint