Fossology Uploads

Methods used to access “uploads/” endpoints.

class fossology.uploads.Uploads

Class dedicated to all “uploads” related endpoints

copy_upload(upload, folder)

Copy an upload in another folder

API Endpoint: PUT /uploads/{id}

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

  • folder (Folder) – the destination Folder

Raises

FossologyApiError – if the REST call failed

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, wait_time: int = 0)fossology.obj.Upload

Get detailled 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, 120)
>>> # Wait up to 5 minutes until the upload is ready
>>> long_upload = detail_upload(1, 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
list_uploads(folder=None, group=None, recursive=True, page_size=100, page=1, all_pages=False)

Get all uploads available to the registered user

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)

  • 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, folder, group=None)

Move an upload to another folder

API Endpoint: PATCH /uploads/{id}

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

  • folder (Folder) – the destination Folder

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

Raises
upload_file(folder, file=None, vcs=None, url=None, server=None, description=None, access_level=None, ignore_scm=False, group=None, wait_time=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.obj import AccessLevel
>>> foss = Fossology(FOSS_URL, FOSS_TOKEN, username)
>>> 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)

  • 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, group: str = None, agent=None, containers=False)

Get clearing information about an upload

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

The response does not generate Python objects yet, the plain JSON data is simply returned.

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

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

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

Returns

the list of licenses findings for the specified agent

Return type

list of Licenses

Raises
upload_summary(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