Fossology¶
The initialization class, used to create a session with the FOSSology server and get user relevant information.
- class fossology.Fossology(url, token, version='v1')¶
Main Fossology API class
Authentication against a running Fossology instance is performed using an API token.
- Example:
>>> from fossology import Fossology >>> foss = Fossology(FOSS_URL, FOSS_TOKEN)
- Parameters:
url (str) – URL of the Fossology instance
token (str) – The API token generated using the Fossology UI
version (str) – the version of the API to use (default: “v1”)
- Raises:
FossologyApiError – if a REST call failed
AuthenticationError – if the user couldn’t be authenticated
- get_health() ApiInfo ¶
Get health from the server
API endpoint: GET /health
- Returns:
the server health information
- Return type:
- Raises:
FossologyApiError – if the REST call failed
- get_info() ApiInfo ¶
Get info from the server
API endpoint: GET /info
- Returns:
the API information
- Return type:
- Raises:
FossologyApiError – if the REST call failed
- get_self()¶
Perform the first API request and populate user variables
API Endpoint: GET /users/self
- Returns:
the authenticated user’s details
- Return type:
- Raises:
FossologyApiError – if the REST call failed
AuthenticationError – if the user couldn’t be found
- fossology.fossology_token(url, username, password, token_name, token_scope=TokenScope.READ, token_expire=None, version='v1')¶
Generate an API token using username/password
API endpoint: POST /tokens
- Example:
>>> from fossology import fossology_token >>> from fossology.obj import TokenScope >>> token = fossology_token("https://fossology.example.com/repo", "Me", "MyPassword", "MyToken", version="v1")
- Parameters:
url (string) – the URL of the Fossology server
username (string) – name of the user the token will be generated for
password (string) – the password of the user
name (string) – the name of the token
scope (TokenScope) – the scope of the token (default: TokenScope.READ)
expire (string) – the expire date of the token, e.g. 2019-12-25 (default: max. 30 days)
version (string) – the version of the API to use (default: “v1”)
- Returns:
the new token
- Return type:
string
- Raises:
AuthenticationError – if the username or password is incorrect
FossologyApiError – if another error occurs