Fossology Jobs

Methods used to access “jobs/” endpoints.

class fossology.jobs.Jobs

Class dedicated to all “jobs” related endpoints

detail_job(job_id, wait=False, timeout=30)

Get detailled 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 (30) – stop waiting after x seconds (default: 30)

Type

int

Returns

the job data

Return type

Job

Raises

FossologyApiError – if the REST call failed

list_jobs(upload=None, page_size=100, page=1, all_pages=False)

Get all available jobs

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)

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

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

  • 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, upload, spec, group=None, wait=False, timeout=30)

Schedule jobs for a specific upload

API Endpoint: POST /jobs

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

>>> {
>>>     "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
>>>     }
>>> }
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 (30) – stop waiting after x seconds (default: 30)

Returns

the job id

Return type

Job

Raises