mafw.devtools.gitlab.api
GitLab API configuration and authentication helpers.
- author:
Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)
Functions
|
Build a GitLab API configuration from provided values and environment context. |
|
Build authentication headers for GitLab API requests. |
Classes
|
Configuration needed to communicate with the GitLab API. |
- class mafw.devtools.gitlab.api.GitlabAPIConfiguration(api_url: str, on_ci: bool, project_id: int, token: str, token_type: Literal['job_token', 'api_token'])[source]
Bases:
objectConfiguration needed to communicate with the GitLab API.
- Parameters:
api_url (str) – Base GitLab API v4 URL.
on_ci (bool) – Whether the process runs on GitLab CI.
project_id (int) – GitLab project numeric ID.
token (str) – Authentication token value.
token_type (Literal['job_token', 'api_token']) – Token kind used for authentication.
- mafw.devtools.gitlab.api.build_gitlab_api_configuration(api_url: str | None, project_id: int | None, token: str | None) GitlabAPIConfiguration[source]
Build a GitLab API configuration from provided values and environment context.
- Parameters:
api_url (str | None) – Optional override for the GitLab API URL.
project_id (int | None) – Optional override for the GitLab project ID.
token (str | None) – Optional override for the authentication token.
- Returns:
The validated GitLab API configuration.
- Return type:
- Raises:
ValueError – If any required configuration value is missing.
- mafw.devtools.gitlab.api.build_gitlab_auth_headers(api_config: GitlabAPIConfiguration) MutableMapping[str, str | bytes][source]
Build authentication headers for GitLab API requests.
- Parameters:
api_config (gitlab.GitlabAPIConfiguration) – The GitLab API configuration.
- Returns:
A mutable mapping of HTTP headers.
- Return type:
MutableMapping[str, str | bytes]