Fossology Jobs

Methods used to access “jobs/” endpoints.

class fossology.jobs.Jobs

Class dedicated to all “jobs” related endpoints

detail_job(job_id: int, wait: bool = False, timeout: int = 10) Job

Get detailed information about a job

API Endpoint: GET /jobs/{id}

Parameters:
  • job_id – the id of the job

  • wait (boolean) – wait until the job is finished (default: False)

  • timeout (10) – stop waiting after x seconds (default: 10)

Type:

int

Returns:

the job data

Return type:

Job

Raises:

FossologyApiError – if the REST call failed

list_jobs(upload: Upload | None = None, all: bool = False, page_size: int = 100, page: int = 1, all_pages: bool = False) tuple[list[Job], int]

Get all jobs created by the logged in user

API Endpoint: GET /jobs

The answer is limited to the first page of 20 results by default

Parameters:
  • upload (Upload) – list only jobs of the given upload (default: None)

  • all (boolean) – list all jobs created by all users, only available for admins (default: False)

  • page_size (int) – the maximum number of results per page (default: 100)

  • page (int) – the number of pages to be retrieved (default: 1)

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

Returns:

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

Return type:

Tuple(list of Job, int)

Raises:

FossologyApiError – if the REST call failed

schedule_jobs(folder: Folder, upload: Upload, spec: dict, group: str | None = None, wait: bool = False, timeout: int = 10) Job

Schedule jobs for a specific upload

API Endpoint: POST /jobs

Job specifications spec are added to the request body, following options are available:

>>> job_spec = {
...     "analysis": {
...         "bucket": True,
...         "copyright_email_author": True,
...         "ecc": True,
...         "keyword": True,
...         "monk": True,
...         "mime": True,
...         "monk": True,
...         "nomos": True,
...         "ojo": True,
...         "package": True,
...         "specific_agent": True,
...     },
...     "decider": {
...         "nomos_monk": True,
...         "bulk_reused": True,
...         "new_scanner": True,
...         "ojo_decider": True
...     },
...     "reuse": {
...         "reuse_upload": 0,
...         "reuse_group": 0,
...         "reuse_main": True,
...         "reuse_enhanced": True,
...         "reuse_report": True,
...         "reuse_copyright": True,
...     }
... }
Parameters:
  • folder (Folder) – the upload folder

  • upload (Upload) – the upload for which jobs will be scheduled

  • spec (dict) – the job specification

  • group (string) – the group name to choose while scheduling jobs (default: None)

  • wait (boolean) – wait for the scheduled job to finish (default: False)

  • timeout (10) – stop waiting after x seconds (default: 10)

Returns:

the job id

Return type:

Job

Raises:

FossologyApiError – if the REST call failed