Fossology License¶
Methods used to access “license/” endpoints.
- class fossology.license.LicenseEndpoint¶
Class dedicated to all “license” related endpoints
- add_license(license: License, merge_request: bool = False)¶
Add a new license to the DB
API Endpoint: POST /license
License data are added to the request body, here is an example:
>>> new_license = License( ... "GPL-1.0", ... "GNU General Public License 1.0", ... "Text of the license...", ... "http://www.gnu.org/licenses/gpl-1.0.txt", ... "red", ... "false" ... ) >>> foss.add_license(new_license, merge_request=True)
- Parameters:
license (License) – the license data
merge_request (bool) – open a merge request for the license candidate? (default: False)
- Raises:
FossologyApiError – if the REST call failed
- detail_license(shortname: str, group: int | None = None) Tuple[int, License, list[Obligation]] ¶
Get a license from the DB
API Endpoint: GET /license/{shortname}
- Parameters:
shortname – Short name of the license
group (int) – the group this license belongs to (default: None)
- Returns:
the license id, the license data and the associated obligations
- Return type:
tuple(int, License, list[Obligation])
- Raises:
FossologyApiError – if the REST call failed
- list_licenses(active: bool = False, kind: LicenseType = LicenseType.ALL, page_size: int = 100, page: int = 1, all_pages: bool = False) Tuple[list[License], int] ¶
Get all license from the DB
API Endpoint: GET /license
- Parameters:
active (bool) – list only active licenses (default: False)
kind (LicenseType) – list only licenses from type LicenseType (default: LicenseType.ALL)
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 licenses (default: False)
- Returns:
a list of licenses
- Return type:
List[License]
- Raises:
FossologyApiError – if the REST call failed
- update_license(shortname: str, fullname: str = '', text: str = '', url: str = '', risk: int = 2)¶
Update a license
API Endpoint: PATCH /license/{shortname}
- Parameters:
shortName (str) – the short name of the license to be updated
fullName (str) – the new fullName of the license (optional)
text (str) – the new text of the license (optional)
url (str) – the new url of the license (optional)
risk (int) – the new risk of the license (default: 2)
- Raises:
FossologyApiError – if the REST call failed