API reference (gitlab
package)¶
Module contents¶
Wrapper for the GitLab API.
- class gitlab.Gitlab(url: str | None = None, private_token: str | None = None, oauth_token: str | None = None, job_token: str | None = None, ssl_verify: bool | str = True, http_username: str | None = None, http_password: str | None = None, timeout: float | None = None, api_version: str = '4', per_page: int | None = None, pagination: str | None = None, order_by: str | None = None, user_agent: str = 'python-gitlab/4.8.0', retry_transient_errors: bool = False, keep_base_url: bool = False, **kwargs: Any)
Bases:
object
Represents a GitLab server connection.
- Parameters:
url (str | None) – The URL of the GitLab server (defaults to https://gitlab.com).
private_token (str | None) – The user private token
oauth_token (str | None) – An oauth token
job_token (str | None) – A CI job token
ssl_verify (bool | str) – Whether SSL certificates should be validated. If the value is a string, it is the path to a CA file used for certificate validation.
timeout (float | None) – Timeout to use for requests to the GitLab server.
http_username (str | None) – Username for HTTP authentication
http_password (str | None) – Password for HTTP authentication
api_version (str) – Gitlab API version to use (support for 4 only)
pagination (str | None) – Can be set to ‘keyset’ to use keyset pagination
order_by (str | None) – Set order_by globally
user_agent (str) – A custom user agent to use for making HTTP requests.
retry_transient_errors (bool) – Whether to retry after 500, 502, 503, 504 or 52x responses. Defaults to False.
keep_base_url (bool) – keep user-provided base URL for pagination if it differs from response headers
session (requests.Session) – HTTP Requests Session
backend (RequestsBackend) – Backend that will be used to make http requests
per_page (int | None)
kwargs (Any)
- property api_url: str
The computed API base URL.
- property api_version: str
The API version used (4 only).
- appearance
- applications
- audit_events
- auth() None
Performs an authentication using private token. Warns the user if a potentially misconfigured URL is detected on the client or server side.
The user attribute will hold a gitlab.objects.CurrentUser object on success.
- Return type:
None
- broadcastmessages
- bulk_import_entities
- bulk_imports
- ci_lint
See
CiLintManager
- deploykeys
See
DeployKeyManager
- deploytokens
- dockerfiles
- enable_debug(mask_credentials: bool = True) None
- Parameters:
mask_credentials (bool)
- Return type:
None
- events
See
EventManager
- features
See
FeatureManager
- classmethod from_config(gitlab_id: str | None = None, config_files: List[str] | None = None, **kwargs: Any) Gitlab
Create a Gitlab connection from configuration files.
- Parameters:
gitlab_id (str | None) – ID of the configuration section.
list[str] (config_files) – List of paths to configuration files.
config_files (List[str] | None)
kwargs (Any)
- Return type:
- kwargs:
session requests.Session: Custom requests Session
- Returns:
A Gitlab connection.
- Raises:
gitlab.config.GitlabDataError – If the configuration is not correct.
- Parameters:
gitlab_id (str | None)
config_files (List[str] | None)
kwargs (Any)
- Return type:
- geonodes
See
GeoNodeManager
- get_license(**kwargs: Any) Dict[str, str | Dict[str, str]]
Retrieve information about the current license.
- Parameters:
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabGetError – If the server cannot perform the request
- Returns:
The current license information
- Return type:
Dict[str, str | Dict[str, str]]
- gitignores
See
GitignoreManager
- gitlabciymls
- groups
See
GroupManager
- headers
Headers that will be used in request to GitLab
- hooks
See
HookManager
- http_delete(path: str, **kwargs: Any) Response
Make a DELETE request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The requests object.
- Raises:
GitlabHttpError – When the return code is not 2xx
- Return type:
Response
- http_get(path: str, query_data: Dict[str, Any] | None = None, streamed: bool = False, raw: bool = False, **kwargs: Any) Dict[str, Any] | Response
Make a GET request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
streamed (bool) – Whether the data should be streamed
raw (bool) – If True do not try to parse the output as json
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
A requests result object is streamed is True or the content type is not json. The parsed json data otherwise.
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
Dict[str, Any] | Response
- http_head(path: str, query_data: Dict[str, Any] | None = None, **kwargs: Any) CaseInsensitiveDict[Any]
Make a HEAD request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
**kwargs (Any) – Extra options to send to the server (e.g. sudo, page, per_page)
- Returns:
A requests.header object
- Raises:
GitlabHttpError – When the return code is not 2xx
- Return type:
CaseInsensitiveDict[Any]
- http_list(path: str, query_data: Dict[str, Any] | None = None, *, iterator: bool | None = None, message_details: WarnMessageData | None = None, **kwargs: Any) GitlabList | List[Dict[str, Any]]
Make a GET request to the Gitlab server for list-oriented queries.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projects’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
iterator (bool | None) – Indicate if should return a generator (True)
**kwargs (Any) – Extra options to send to the server (e.g. sudo, page, per_page)
message_details (WarnMessageData | None)
**kwargs
- Returns:
A list of the objects returned by the server. If iterator is True and no pagination-related arguments (page, per_page, get_all) are defined then a GitlabList object (generator) is returned instead. This object will make API calls when needed to fetch the next items from the server.
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
GitlabList | List[Dict[str, Any]]
- http_patch(path: str, *, query_data: Dict[str, Any] | None = None, post_data: Dict[str, Any] | bytes | None = None, raw: bool = False, **kwargs: Any) Dict[str, Any] | Response
Make a PATCH request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
post_data (Dict[str, Any] | bytes | None) – Data to send in the body (will be converted to json by default)
raw (bool) – If True, do not convert post_data to json
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The parsed json returned by the server.
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
Dict[str, Any] | Response
- http_post(path: str, query_data: Dict[str, Any] | None = None, post_data: Dict[str, Any] | None = None, raw: bool = False, files: Dict[str, Any] | None = None, **kwargs: Any) Dict[str, Any] | Response
Make a POST request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
post_data (Dict[str, Any] | None) – Data to send in the body (will be converted to json by default)
raw (bool) – If True, do not convert post_data to json
files (Dict[str, Any] | None) – The files to send to the server
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The parsed json returned by the server if json is return, else the raw content
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
Dict[str, Any] | Response
- http_put(path: str, query_data: Dict[str, Any] | None = None, post_data: Dict[str, Any] | bytes | BinaryIO | None = None, raw: bool = False, files: Dict[str, Any] | None = None, **kwargs: Any) Dict[str, Any] | Response
Make a PUT request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
post_data (Dict[str, Any] | bytes | BinaryIO | None) – Data to send in the body (will be converted to json by default)
raw (bool) – If True, do not convert post_data to json
files (Dict[str, Any] | None) – The files to send to the server
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The parsed json returned by the server.
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
Dict[str, Any] | Response
- http_request(verb: str, path: str, query_data: Dict[str, Any] | None = None, post_data: Dict[str, Any] | bytes | BinaryIO | None = None, raw: bool = False, streamed: bool = False, files: Dict[str, Any] | None = None, timeout: float | None = None, obey_rate_limit: bool = True, retry_transient_errors: bool | None = None, max_retries: int = 10, **kwargs: Any) Response
Make an HTTP request to the Gitlab server.
- Parameters:
verb (str) – The HTTP method to call (‘get’, ‘post’, ‘put’, ‘delete’)
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
post_data (Dict[str, Any] | bytes | BinaryIO | None) – Data to send in the body (will be converted to json by default)
raw (bool) – If True, do not convert post_data to json
streamed (bool) – Whether the data should be streamed
files (Dict[str, Any] | None) – The files to send to the server
timeout (float | None) – The timeout, in seconds, for the request
obey_rate_limit (bool) – Whether to obey 429 Too Many Request responses. Defaults to True.
retry_transient_errors (bool | None) – Whether to retry after 500, 502, 503, 504 or 52x responses. Defaults to False.
max_retries (int) – Max retries after 429 or transient errors, set to -1 to retry forever. Defaults to 10.
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
A requests result object.
- Raises:
GitlabHttpError – When the return code is not 2xx
- Return type:
Response
- issues
See
IssueManager
- issues_statistics
- keys
See
KeyManager
- ldapgroups
See
LDAPGroupManager
- licenses
See
LicenseManager
- markdown(text: str, gfm: bool = False, project: str | None = None, **kwargs: Any) str
Render an arbitrary Markdown document.
- Parameters:
text (str) – The markdown text to render
gfm (bool) – Render text using GitLab Flavored Markdown. Default is False
project (str | None) – Full path of a project used a context when gfm is True
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabMarkdownError – If the server cannot perform the request
- Returns:
The HTML rendering of the markdown text.
- Return type:
str
- classmethod merge_config(options: Dict[str, Any], gitlab_id: str | None = None, config_files: List[str] | None = None) Gitlab
Create a Gitlab connection by merging configuration with the following precedence:
Explicitly provided CLI arguments,
Environment variables,
- Configuration files:
- explicitly defined config files:
via the –config-file CLI argument,
via the PYTHON_GITLAB_CFG environment variable,
user-specific config file,
system-level config file,
Environment variables always present in CI (CI_SERVER_URL, CI_JOB_TOKEN).
- Parameters:
options (Dict[str, Any]) – A dictionary of explicitly provided key-value options.
gitlab_id (str | None) – ID of the configuration section.
config_files (List[str] | None) – List of paths to configuration files.
- Returns:
A Gitlab connection.
- Return type:
- Raises:
gitlab.config.GitlabDataError – If the configuration is not correct.
- mergerequests
- namespaces
See
NamespaceManager
- notificationsettings
- pagesdomains
- personal_access_tokens
- projects
See
ProjectManager
- registry_repositories
- runners
See
RunnerManager
- runners_all
See
RunnerManager
- search(scope: str, search: str, **kwargs: Any) GitlabList | List[Dict[str, Any]]
Search GitLab resources matching the provided string.’
- Parameters:
scope (str) – Scope of the search
search (str) – Search string
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabSearchError – If the server failed to perform the request
- Returns:
A list of dicts describing the resources found.
- Return type:
GitlabList | List[Dict[str, Any]]
- set_license(license: str, **kwargs: Any) Dict[str, Any]
Add a new license.
- Parameters:
license (str) – The license string
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabPostError – If the server cannot perform the request
- Returns:
The new license information
- Return type:
Dict[str, Any]
- settings
- sidekiq
See
SidekiqManager
- snippets
See
SnippetManager
- ssl_verify
Whether SSL certificates should be validated
- statistics
- timeout
Timeout to use for requests to gitlab server
- todos
See
TodoManager
- topics
See
TopicManager
- property url: str
The user-provided server URL.
- user_activities
- users
See
UserManager
- variables
See
VariableManager
- version() Tuple[str, str]
Returns the version and revision of the gitlab server.
Note that self.version and self.revision will be set on the gitlab object.
- Returns:
- The server version and server revision.
(‘unknown’, ‘unknown’) if the server doesn’t perform as expected.
- Return type:
Tuple[str, str]
- exception gitlab.GitlabActivateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabAttachFileError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabAuthenticationError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabBanError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabBlockError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabBuildCancelError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabCancelError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabBuildEraseError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabBuildPlayError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabBuildRetryError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabCancelError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabCherryPickError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabCiLintError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabConnectionError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabCreateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabDeactivateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabDeleteError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabDeploymentApprovalError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
Exception
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabFollowError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabGetError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabGroupTransferError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabHeadError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabHousekeepingError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabHttpError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabImportError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabInvitationError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabJobCancelError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabCancelError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabJobEraseError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabJobPlayError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabJobRetryError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabLicenseError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- class gitlab.GitlabList(gl: Gitlab, url: str, query_data: Dict[str, Any], get_next: bool = True, **kwargs: Any)
Bases:
object
Generator representing a list of remote objects.
The object handles the links returned by a query to the API, and will call the API again when needed.
- property current_page: int
The current page number.
- property next_page: int | None
The next page number.
If None, the current page is the last.
- property per_page: int | None
The number of items per page.
- property prev_page: int | None
The previous page number.
If None, the current page is the first.
- property total: int | None
The total number of items.
- property total_pages: int | None
The total number of pages.
- exception gitlab.GitlabListError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabMRApprovalError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabMRClosedError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabMRForbiddenError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabMROnBuildSuccessError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabMRRebaseError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabMRResetApprovalError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabMarkdownError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabOperationError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabOwnershipError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabParsingError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabPipelineCancelError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabCancelError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabPipelinePlayError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabPipelineRetryError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabProjectDeployKeyError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabPromoteError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabProtectError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabRenderError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabRepairError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabRestoreError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabRetryError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabRevertError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabRotateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabSearchError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabSetError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabStopError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabSubscribeError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabTimeTrackingError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabTodoError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabTopicMergeError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabTransferProjectError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabUnbanError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabUnblockError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabUnfollowError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabUnsubscribeError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabUpdateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabUploadError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabUserApproveError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabUserRejectError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.GitlabVerifyError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.RedirectError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- class gitlab.Gitlab(url: str | None = None, private_token: str | None = None, oauth_token: str | None = None, job_token: str | None = None, ssl_verify: bool | str = True, http_username: str | None = None, http_password: str | None = None, timeout: float | None = None, api_version: str = '4', per_page: int | None = None, pagination: str | None = None, order_by: str | None = None, user_agent: str = 'python-gitlab/4.8.0', retry_transient_errors: bool = False, keep_base_url: bool = False, **kwargs: Any)¶
Bases:
object
Represents a GitLab server connection.
- Parameters:
url (str | None) – The URL of the GitLab server (defaults to https://gitlab.com).
private_token (str | None) – The user private token
oauth_token (str | None) – An oauth token
job_token (str | None) – A CI job token
ssl_verify (bool | str) – Whether SSL certificates should be validated. If the value is a string, it is the path to a CA file used for certificate validation.
timeout (float | None) – Timeout to use for requests to the GitLab server.
http_username (str | None) – Username for HTTP authentication
http_password (str | None) – Password for HTTP authentication
api_version (str) – Gitlab API version to use (support for 4 only)
pagination (str | None) – Can be set to ‘keyset’ to use keyset pagination
order_by (str | None) – Set order_by globally
user_agent (str) – A custom user agent to use for making HTTP requests.
retry_transient_errors (bool) – Whether to retry after 500, 502, 503, 504 or 52x responses. Defaults to False.
keep_base_url (bool) – keep user-provided base URL for pagination if it differs from response headers
session (requests.Session) – HTTP Requests Session
backend (RequestsBackend) – Backend that will be used to make http requests
per_page (int | None)
kwargs (Any)
- property api_url: str¶
The computed API base URL.
- property api_version: str¶
The API version used (4 only).
- appearance¶
- applications¶
- audit_events¶
- auth() None ¶
Performs an authentication using private token. Warns the user if a potentially misconfigured URL is detected on the client or server side.
The user attribute will hold a gitlab.objects.CurrentUser object on success.
- Return type:
None
- broadcastmessages¶
- bulk_import_entities¶
- bulk_imports¶
- ci_lint¶
See
CiLintManager
- deploykeys¶
See
DeployKeyManager
- deploytokens¶
- dockerfiles¶
- enable_debug(mask_credentials: bool = True) None ¶
- Parameters:
mask_credentials (bool)
- Return type:
None
- events¶
See
EventManager
- features¶
See
FeatureManager
- classmethod from_config(gitlab_id: str | None = None, config_files: List[str] | None = None, **kwargs: Any) Gitlab ¶
Create a Gitlab connection from configuration files.
- Parameters:
gitlab_id (str | None) – ID of the configuration section.
list[str] (config_files) – List of paths to configuration files.
config_files (List[str] | None)
kwargs (Any)
- Return type:
- kwargs:
session requests.Session: Custom requests Session
- Returns:
A Gitlab connection.
- Raises:
gitlab.config.GitlabDataError – If the configuration is not correct.
- Parameters:
gitlab_id (str | None)
config_files (List[str] | None)
kwargs (Any)
- Return type:
- geonodes¶
See
GeoNodeManager
- get_license(**kwargs: Any) Dict[str, str | Dict[str, str]] ¶
Retrieve information about the current license.
- Parameters:
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabGetError – If the server cannot perform the request
- Returns:
The current license information
- Return type:
Dict[str, str | Dict[str, str]]
- gitignores¶
See
GitignoreManager
- gitlabciymls¶
- groups¶
See
GroupManager
- headers¶
Headers that will be used in request to GitLab
- hooks¶
See
HookManager
- http_delete(path: str, **kwargs: Any) Response ¶
Make a DELETE request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The requests object.
- Raises:
GitlabHttpError – When the return code is not 2xx
- Return type:
Response
- http_get(path: str, query_data: Dict[str, Any] | None = None, streamed: bool = False, raw: bool = False, **kwargs: Any) Dict[str, Any] | Response ¶
Make a GET request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
streamed (bool) – Whether the data should be streamed
raw (bool) – If True do not try to parse the output as json
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
A requests result object is streamed is True or the content type is not json. The parsed json data otherwise.
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
Dict[str, Any] | Response
- http_head(path: str, query_data: Dict[str, Any] | None = None, **kwargs: Any) CaseInsensitiveDict[Any] ¶
Make a HEAD request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
**kwargs (Any) – Extra options to send to the server (e.g. sudo, page, per_page)
- Returns:
A requests.header object
- Raises:
GitlabHttpError – When the return code is not 2xx
- Return type:
CaseInsensitiveDict[Any]
- http_list(path: str, query_data: Dict[str, Any] | None = None, *, iterator: bool | None = None, message_details: WarnMessageData | None = None, **kwargs: Any) GitlabList | List[Dict[str, Any]] ¶
Make a GET request to the Gitlab server for list-oriented queries.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projects’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
iterator (bool | None) – Indicate if should return a generator (True)
**kwargs (Any) – Extra options to send to the server (e.g. sudo, page, per_page)
message_details (WarnMessageData | None)
**kwargs
- Returns:
A list of the objects returned by the server. If iterator is True and no pagination-related arguments (page, per_page, get_all) are defined then a GitlabList object (generator) is returned instead. This object will make API calls when needed to fetch the next items from the server.
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
GitlabList | List[Dict[str, Any]]
- http_patch(path: str, *, query_data: Dict[str, Any] | None = None, post_data: Dict[str, Any] | bytes | None = None, raw: bool = False, **kwargs: Any) Dict[str, Any] | Response ¶
Make a PATCH request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
post_data (Dict[str, Any] | bytes | None) – Data to send in the body (will be converted to json by default)
raw (bool) – If True, do not convert post_data to json
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The parsed json returned by the server.
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
Dict[str, Any] | Response
- http_post(path: str, query_data: Dict[str, Any] | None = None, post_data: Dict[str, Any] | None = None, raw: bool = False, files: Dict[str, Any] | None = None, **kwargs: Any) Dict[str, Any] | Response ¶
Make a POST request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
post_data (Dict[str, Any] | None) – Data to send in the body (will be converted to json by default)
raw (bool) – If True, do not convert post_data to json
files (Dict[str, Any] | None) – The files to send to the server
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The parsed json returned by the server if json is return, else the raw content
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
Dict[str, Any] | Response
- http_put(path: str, query_data: Dict[str, Any] | None = None, post_data: Dict[str, Any] | bytes | BinaryIO | None = None, raw: bool = False, files: Dict[str, Any] | None = None, **kwargs: Any) Dict[str, Any] | Response ¶
Make a PUT request to the Gitlab server.
- Parameters:
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
post_data (Dict[str, Any] | bytes | BinaryIO | None) – Data to send in the body (will be converted to json by default)
raw (bool) – If True, do not convert post_data to json
files (Dict[str, Any] | None) – The files to send to the server
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The parsed json returned by the server.
- Raises:
GitlabHttpError – When the return code is not 2xx
GitlabParsingError – If the json data could not be parsed
- Return type:
Dict[str, Any] | Response
- http_request(verb: str, path: str, query_data: Dict[str, Any] | None = None, post_data: Dict[str, Any] | bytes | BinaryIO | None = None, raw: bool = False, streamed: bool = False, files: Dict[str, Any] | None = None, timeout: float | None = None, obey_rate_limit: bool = True, retry_transient_errors: bool | None = None, max_retries: int = 10, **kwargs: Any) Response ¶
Make an HTTP request to the Gitlab server.
- Parameters:
verb (str) – The HTTP method to call (‘get’, ‘post’, ‘put’, ‘delete’)
path (str) – Path or full URL to query (‘/projects’ or ‘http://whatever/v4/api/projecs’)
query_data (Dict[str, Any] | None) – Data to send as query parameters
post_data (Dict[str, Any] | bytes | BinaryIO | None) – Data to send in the body (will be converted to json by default)
raw (bool) – If True, do not convert post_data to json
streamed (bool) – Whether the data should be streamed
files (Dict[str, Any] | None) – The files to send to the server
timeout (float | None) – The timeout, in seconds, for the request
obey_rate_limit (bool) – Whether to obey 429 Too Many Request responses. Defaults to True.
retry_transient_errors (bool | None) – Whether to retry after 500, 502, 503, 504 or 52x responses. Defaults to False.
max_retries (int) – Max retries after 429 or transient errors, set to -1 to retry forever. Defaults to 10.
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
A requests result object.
- Raises:
GitlabHttpError – When the return code is not 2xx
- Return type:
Response
- issues¶
See
IssueManager
- issues_statistics¶
- keys¶
See
KeyManager
- ldapgroups¶
See
LDAPGroupManager
- licenses¶
See
LicenseManager
- markdown(text: str, gfm: bool = False, project: str | None = None, **kwargs: Any) str ¶
Render an arbitrary Markdown document.
- Parameters:
text (str) – The markdown text to render
gfm (bool) – Render text using GitLab Flavored Markdown. Default is False
project (str | None) – Full path of a project used a context when gfm is True
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabMarkdownError – If the server cannot perform the request
- Returns:
The HTML rendering of the markdown text.
- Return type:
str
- classmethod merge_config(options: Dict[str, Any], gitlab_id: str | None = None, config_files: List[str] | None = None) Gitlab ¶
Create a Gitlab connection by merging configuration with the following precedence:
Explicitly provided CLI arguments,
Environment variables,
- Configuration files:
- explicitly defined config files:
via the –config-file CLI argument,
via the PYTHON_GITLAB_CFG environment variable,
user-specific config file,
system-level config file,
Environment variables always present in CI (CI_SERVER_URL, CI_JOB_TOKEN).
- Parameters:
options (Dict[str, Any]) – A dictionary of explicitly provided key-value options.
gitlab_id (str | None) – ID of the configuration section.
config_files (List[str] | None) – List of paths to configuration files.
- Returns:
A Gitlab connection.
- Return type:
- Raises:
gitlab.config.GitlabDataError – If the configuration is not correct.
- mergerequests¶
- namespaces¶
See
NamespaceManager
- notificationsettings¶
- pagesdomains¶
- personal_access_tokens¶
- projects¶
See
ProjectManager
- registry_repositories¶
- runners¶
See
RunnerManager
- runners_all¶
See
RunnerManager
- search(scope: str, search: str, **kwargs: Any) GitlabList | List[Dict[str, Any]] ¶
Search GitLab resources matching the provided string.’
- Parameters:
scope (str) – Scope of the search
search (str) – Search string
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabSearchError – If the server failed to perform the request
- Returns:
A list of dicts describing the resources found.
- Return type:
GitlabList | List[Dict[str, Any]]
- set_license(license: str, **kwargs: Any) Dict[str, Any] ¶
Add a new license.
- Parameters:
license (str) – The license string
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabPostError – If the server cannot perform the request
- Returns:
The new license information
- Return type:
Dict[str, Any]
- settings¶
- sidekiq¶
See
SidekiqManager
- snippets¶
See
SnippetManager
- ssl_verify¶
Whether SSL certificates should be validated
- statistics¶
- timeout¶
Timeout to use for requests to gitlab server
- todos¶
See
TodoManager
- topics¶
See
TopicManager
- property url: str¶
The user-provided server URL.
- user: objects.CurrentUser | None¶
- user_activities¶
- users¶
See
UserManager
- variables¶
See
VariableManager
- version() Tuple[str, str] ¶
Returns the version and revision of the gitlab server.
Note that self.version and self.revision will be set on the gitlab object.
- Returns:
- The server version and server revision.
(‘unknown’, ‘unknown’) if the server doesn’t perform as expected.
- Return type:
Tuple[str, str]
- class gitlab.GitlabList(gl: Gitlab, url: str, query_data: Dict[str, Any], get_next: bool = True, **kwargs: Any)¶
Bases:
object
Generator representing a list of remote objects.
The object handles the links returned by a query to the API, and will call the API again when needed.
- property current_page: int¶
The current page number.
- property next_page: int | None¶
The next page number.
If None, the current page is the last.
- property per_page: int | None¶
The number of items per page.
- property prev_page: int | None¶
The previous page number.
If None, the current page is the first.
- property total: int | None¶
The total number of items.
- property total_pages: int | None¶
The total number of pages.
Subpackages¶
- gitlab.v4 package
- Submodules
- gitlab.v4.objects module
Any
Application
ApplicationAppearance
ApplicationAppearanceManager
ApplicationManager
ApplicationSettings
ApplicationSettingsManager
ApplicationStatistics
ApplicationStatisticsManager
AuditEvent
AuditEventManager
BroadcastMessage
BroadcastMessageManager
BulkImport
BulkImportAllEntity
BulkImportAllEntityManager
BulkImportEntity
BulkImportEntityManager
BulkImportManager
CiLint
CiLintManager
CurrentUser
CurrentUserEmail
CurrentUserEmailManager
CurrentUserGPGKey
CurrentUserGPGKeyManager
CurrentUserKey
CurrentUserKeyManager
CurrentUserManager
CurrentUserRunner
CurrentUserRunnerManager
CurrentUserStatus
CurrentUserStatusManager
DeployKey
DeployKeyManager
DeployToken
DeployTokenManager
Dockerfile
DockerfileManager
Event
EventManager
Feature
FeatureManager
GenericPackage
GenericPackageManager
GeoNode
GeoNodeManager
Gitignore
GitignoreManager
Gitlabciyml
GitlabciymlManager
Group
Group.access_tokens
Group.accessrequests
Group.audit_events
Group.badges
Group.billable_members
Group.boards
Group.clusters
Group.customattributes
Group.deploytokens
Group.descendant_groups
Group.epics
Group.exports
Group.hooks
Group.imports
Group.invitations
Group.issues
Group.issues_statistics
Group.iterations
Group.labels
Group.ldap_group_links
Group.ldap_sync()
Group.members
Group.members_all
Group.mergerequests
Group.milestones
Group.notificationsettings
Group.packages
Group.projects
Group.pushrules
Group.registry_repositories
Group.restore()
Group.runners
Group.saml_group_links
Group.search()
Group.service_accounts
Group.share()
Group.shared_projects
Group.subgroups
Group.transfer()
Group.transfer_project()
Group.unshare()
Group.variables
Group.wikis
GroupAccessRequest
GroupAccessRequestManager
GroupAccessToken
GroupAccessTokenManager
GroupAuditEvent
GroupAuditEventManager
GroupBadge
GroupBadgeManager
GroupBillableMember
GroupBillableMemberManager
GroupBillableMemberMembership
GroupBillableMemberMembershipManager
GroupBoard
GroupBoardList
GroupBoardListManager
GroupBoardManager
GroupCluster
GroupClusterManager
GroupCustomAttribute
GroupCustomAttributeManager
GroupDeployToken
GroupDeployTokenManager
GroupDescendantGroup
GroupDescendantGroupManager
GroupEpic
GroupEpicAwardEmoji
GroupEpicAwardEmojiManager
GroupEpicDiscussionNote
GroupEpicDiscussionNoteManager
GroupEpicIssue
GroupEpicIssueManager
GroupEpicManager
GroupEpicNote
GroupEpicNoteAwardEmoji
GroupEpicNoteAwardEmojiManager
GroupEpicNoteManager
GroupEpicResourceLabelEvent
GroupEpicResourceLabelEventManager
GroupExport
GroupExportManager
GroupHook
GroupHookManager
GroupImport
GroupImportManager
GroupInvitation
GroupInvitationManager
GroupIssue
GroupIssueManager
GroupIssuesStatistics
GroupIssuesStatisticsManager
GroupIteration
GroupIterationManager
GroupLDAPGroupLink
GroupLDAPGroupLinkManager
GroupLabel
GroupLabelManager
GroupManager
GroupMember
GroupMemberAll
GroupMemberAllManager
GroupMemberManager
GroupMergeRequest
GroupMergeRequestManager
GroupMilestone
GroupMilestoneManager
GroupNotificationSettings
GroupNotificationSettingsManager
GroupPackage
GroupPackageManager
GroupProject
GroupProjectManager
GroupPushRules
GroupPushRulesManager
GroupRegistryRepositoryManager
GroupRunner
GroupRunnerManager
GroupSAMLGroupLink
GroupSAMLGroupLinkManager
GroupServiceAccount
GroupServiceAccountManager
GroupSubgroup
GroupSubgroupManager
GroupVariable
GroupVariableManager
GroupWiki
GroupWikiManager
Hook
HookManager
Issue
IssueManager
IssuesStatistics
IssuesStatisticsManager
Key
KeyManager
LDAPGroup
LDAPGroupManager
License
LicenseManager
MergeRequest
MergeRequestManager
Namespace
NamespaceManager
NotificationSettings
NotificationSettingsManager
PagesDomain
PagesDomainManager
PersonalAccessToken
PersonalAccessTokenManager
Project
Project.access_tokens
Project.accessrequests
Project.additionalstatistics
Project.approvalrules
Project.approvals
Project.archive()
Project.artifacts
Project.audit_events
Project.badges
Project.boards
Project.branches
Project.ci_lint
Project.cluster_agents
Project.clusters
Project.commits
Project.create_fork_relation()
Project.customattributes
Project.delete_fork_relation()
Project.deployments
Project.deploytokens
Project.environments
Project.events
Project.exports
Project.files
Project.forks
Project.generic_packages
Project.groups
Project.hooks
Project.housekeeping()
Project.imports
Project.integrations
Project.invitations
Project.issues
Project.issues_statistics
Project.iterations
Project.job_token_scope
Project.jobs
Project.keys
Project.labels
Project.languages()
Project.members
Project.members_all
Project.merge_trains
Project.mergerequests
Project.milestones
Project.mirror_pull()
Project.mirror_pull_details()
Project.notes
Project.notificationsettings
Project.package_protection_rules
Project.packages
Project.pagesdomains
Project.pipelines
Project.pipelineschedules
Project.protected_environments
Project.protectedbranches
Project.protectedtags
Project.pushrules
Project.registry_protection_rules
Project.releases
Project.remote_mirrors
Project.repositories
Project.resource_groups
Project.restore()
Project.runners
Project.search()
Project.secure_files
Project.services
Project.share()
Project.snapshot()
Project.snippets
Project.star()
Project.storage
Project.tags
Project.transfer()
Project.trigger_pipeline()
Project.triggers
Project.unarchive()
Project.unshare()
Project.unstar()
Project.users
Project.variables
Project.wikis
ProjectAccessRequest
ProjectAccessRequestManager
ProjectAccessToken
ProjectAccessTokenManager
ProjectAdditionalStatistics
ProjectAdditionalStatisticsManager
ProjectApproval
ProjectApprovalManager
ProjectApprovalRule
ProjectApprovalRuleManager
ProjectArtifact
ProjectArtifactManager
ProjectAudit
ProjectAuditEvent
ProjectAuditEventManager
ProjectAuditManager
ProjectBadge
ProjectBadgeManager
ProjectBoard
ProjectBoardList
ProjectBoardListManager
ProjectBoardManager
ProjectBranch
ProjectBranchManager
ProjectCiLint
ProjectCiLintManager
ProjectCluster
ProjectClusterAgent
ProjectClusterAgentManager
ProjectClusterManager
ProjectCommit
ProjectCommitComment
ProjectCommitCommentManager
ProjectCommitDiscussion
ProjectCommitDiscussionManager
ProjectCommitDiscussionNote
ProjectCommitDiscussionNoteManager
ProjectCommitManager
ProjectCommitStatus
ProjectCommitStatusManager
ProjectCustomAttribute
ProjectCustomAttributeManager
ProjectDeployToken
ProjectDeployTokenManager
ProjectDeployment
ProjectDeploymentManager
ProjectDeploymentMergeRequest
ProjectDeploymentMergeRequestManager
ProjectEnvironment
ProjectEnvironmentManager
ProjectEvent
ProjectEventManager
ProjectExport
ProjectExportManager
ProjectFile
ProjectFileManager
ProjectFork
ProjectForkManager
ProjectHook
ProjectHookManager
ProjectImport
ProjectImportManager
ProjectIntegration
ProjectIntegrationManager
ProjectInvitation
ProjectInvitationManager
ProjectIssue
ProjectIssue.awardemojis
ProjectIssue.closed_by()
ProjectIssue.discussions
ProjectIssue.links
ProjectIssue.move()
ProjectIssue.notes
ProjectIssue.related_merge_requests()
ProjectIssue.reorder()
ProjectIssue.resource_iteration_events
ProjectIssue.resource_weight_events
ProjectIssue.resourcelabelevents
ProjectIssue.resourcemilestoneevents
ProjectIssue.resourcestateevents
ProjectIssueAwardEmoji
ProjectIssueAwardEmojiManager
ProjectIssueDiscussion
ProjectIssueDiscussionManager
ProjectIssueDiscussionNote
ProjectIssueDiscussionNoteManager
ProjectIssueLink
ProjectIssueLinkManager
ProjectIssueManager
ProjectIssueNote
ProjectIssueNoteAwardEmoji
ProjectIssueNoteAwardEmojiManager
ProjectIssueNoteManager
ProjectIssueResourceIterationEvent
ProjectIssueResourceIterationEventManager
ProjectIssueResourceLabelEvent
ProjectIssueResourceLabelEventManager
ProjectIssueResourceMilestoneEvent
ProjectIssueResourceMilestoneEventManager
ProjectIssueResourceStateEvent
ProjectIssueResourceStateEventManager
ProjectIssueResourceWeightEvent
ProjectIssueResourceWeightEventManager
ProjectIssuesStatistics
ProjectIssuesStatisticsManager
ProjectIterationManager
ProjectJob
ProjectJobManager
ProjectJobTokenScope
ProjectJobTokenScopeManager
ProjectKey
ProjectKeyManager
ProjectLabel
ProjectLabelManager
ProjectManager
ProjectMember
ProjectMemberAll
ProjectMemberAllManager
ProjectMemberManager
ProjectMergeRequest
ProjectMergeRequest.approval_rules
ProjectMergeRequest.approval_state
ProjectMergeRequest.approvals
ProjectMergeRequest.approve()
ProjectMergeRequest.awardemojis
ProjectMergeRequest.cancel_merge_when_pipeline_succeeds()
ProjectMergeRequest.changes()
ProjectMergeRequest.closes_issues()
ProjectMergeRequest.commits()
ProjectMergeRequest.diffs
ProjectMergeRequest.discussions
ProjectMergeRequest.draft_notes
ProjectMergeRequest.merge()
ProjectMergeRequest.merge_ref()
ProjectMergeRequest.notes
ProjectMergeRequest.pipelines
ProjectMergeRequest.rebase()
ProjectMergeRequest.reset_approvals()
ProjectMergeRequest.resourcelabelevents
ProjectMergeRequest.resourcemilestoneevents
ProjectMergeRequest.resourcestateevents
ProjectMergeRequest.reviewer_details
ProjectMergeRequest.unapprove()
ProjectMergeRequestApproval
ProjectMergeRequestApprovalManager
ProjectMergeRequestApprovalRule
ProjectMergeRequestApprovalRuleManager
ProjectMergeRequestApprovalState
ProjectMergeRequestApprovalStateManager
ProjectMergeRequestAwardEmoji
ProjectMergeRequestAwardEmojiManager
ProjectMergeRequestDiff
ProjectMergeRequestDiffManager
ProjectMergeRequestDiscussion
ProjectMergeRequestDiscussionManager
ProjectMergeRequestDiscussionNote
ProjectMergeRequestDiscussionNoteManager
ProjectMergeRequestDraftNote
ProjectMergeRequestDraftNoteManager
ProjectMergeRequestManager
ProjectMergeRequestNote
ProjectMergeRequestNoteAwardEmoji
ProjectMergeRequestNoteAwardEmojiManager
ProjectMergeRequestNoteManager
ProjectMergeRequestPipeline
ProjectMergeRequestPipelineManager
ProjectMergeRequestResourceLabelEvent
ProjectMergeRequestResourceLabelEventManager
ProjectMergeRequestResourceMilestoneEvent
ProjectMergeRequestResourceMilestoneEventManager
ProjectMergeRequestResourceStateEvent
ProjectMergeRequestResourceStateEventManager
ProjectMergeRequestReviewerDetail
ProjectMergeRequestReviewerDetailManager
ProjectMergeTrain
ProjectMergeTrainManager
ProjectMilestone
ProjectMilestoneManager
ProjectNote
ProjectNoteManager
ProjectNotificationSettings
ProjectNotificationSettingsManager
ProjectPackage
ProjectPackageFile
ProjectPackageFileManager
ProjectPackageManager
ProjectPackagePipeline
ProjectPackagePipelineManager
ProjectPackageProtectionRule
ProjectPackageProtectionRuleManager
ProjectPagesDomain
ProjectPagesDomainManager
ProjectPipeline
ProjectPipelineBridge
ProjectPipelineBridgeManager
ProjectPipelineJob
ProjectPipelineJobManager
ProjectPipelineManager
ProjectPipelineSchedule
ProjectPipelineScheduleManager
ProjectPipelineSchedulePipeline
ProjectPipelineSchedulePipelineManager
ProjectPipelineScheduleVariable
ProjectPipelineScheduleVariableManager
ProjectPipelineTestReport
ProjectPipelineTestReportManager
ProjectPipelineTestReportSummary
ProjectPipelineTestReportSummaryManager
ProjectPipelineVariable
ProjectPipelineVariableManager
ProjectProtectedBranch
ProjectProtectedBranchManager
ProjectProtectedEnvironment
ProjectProtectedEnvironmentManager
ProjectProtectedTag
ProjectProtectedTagManager
ProjectPushRules
ProjectPushRulesManager
ProjectRegistryProtectionRule
ProjectRegistryProtectionRuleManager
ProjectRegistryRepository
ProjectRegistryRepositoryManager
ProjectRegistryTag
ProjectRegistryTagManager
ProjectRelease
ProjectReleaseLink
ProjectReleaseLinkManager
ProjectReleaseManager
ProjectRemoteMirror
ProjectRemoteMirrorManager
ProjectResourceGroup
ProjectResourceGroupManager
ProjectResourceGroupUpcomingJob
ProjectResourceGroupUpcomingJobManager
ProjectRunner
ProjectRunnerManager
ProjectSecureFile
ProjectSecureFileManager
ProjectService
ProjectServiceManager
ProjectSnippet
ProjectSnippetAwardEmoji
ProjectSnippetAwardEmojiManager
ProjectSnippetDiscussion
ProjectSnippetDiscussionManager
ProjectSnippetDiscussionNote
ProjectSnippetDiscussionNoteManager
ProjectSnippetManager
ProjectSnippetNote
ProjectSnippetNoteAwardEmoji
ProjectSnippetNoteAwardEmojiManager
ProjectSnippetNoteManager
ProjectStorage
ProjectStorageManager
ProjectTag
ProjectTagManager
ProjectTrigger
ProjectTriggerManager
ProjectUser
ProjectUserManager
ProjectVariable
ProjectVariableManager
ProjectWiki
ProjectWikiManager
RegistryRepository
RegistryRepositoryManager
RepositoryMixin
RepositoryMixin.delete_merged_branches()
RepositoryMixin.repository_archive()
RepositoryMixin.repository_blob()
RepositoryMixin.repository_compare()
RepositoryMixin.repository_contributors()
RepositoryMixin.repository_merge_base()
RepositoryMixin.repository_raw_blob()
RepositoryMixin.repository_tree()
RepositoryMixin.update_submodule()
Runner
RunnerAll
RunnerAllManager
RunnerJob
RunnerJobManager
RunnerManager
SharedProject
SharedProjectManager
SidekiqManager
Snippet
SnippetManager
StarredProject
StarredProjectManager
Todo
TodoManager
Topic
TopicManager
User
User.activate()
User.approve()
User.ban()
User.block()
User.customattributes
User.deactivate()
User.emails
User.events
User.follow()
User.followers_users
User.following_users
User.gpgkeys
User.identityproviders
User.impersonationtokens
User.keys
User.memberships
User.personal_access_tokens
User.projects
User.reject()
User.starred_projects
User.status
User.unban()
User.unblock()
User.unfollow()
UserActivities
UserActivitiesManager
UserCustomAttribute
UserCustomAttributeManager
UserEmail
UserEmailManager
UserEvent
UserEventManager
UserGPGKey
UserGPGKeyManager
UserIdentityProviderManager
UserImpersonationToken
UserImpersonationTokenManager
UserKey
UserKeyManager
UserManager
UserMembership
UserMembershipManager
UserPersonalAccessToken
UserPersonalAccessTokenManager
UserProject
UserProjectManager
UserStatus
UserStatusManager
Variable
VariableManager
- Module contents
Submodules¶
gitlab.base module¶
- class gitlab.base.RESTManager(gl: Gitlab, parent: RESTObject | None = None)¶
Bases:
object
Base class for CRUD operations on objects.
Derived class must define
_path
and_obj_cls
._path
: Base URL path on which requests will be sent (e.g. ‘/projects’)_obj_cls
: The class of objects that will be created- Parameters:
gl (Gitlab)
parent (RESTObject | None)
- property path: str | None¶
- class gitlab.base.RESTObject(manager: RESTManager, attrs: Dict[str, Any], *, created_from_list: bool = False, lazy: bool = False)¶
Bases:
object
Represents an object built from server data.
It holds the attributes know from the server, and the updated attributes in another. This allows smart updates, if the object allows it.
You can redefine
_id_attr
in child classes to specify which attribute must be used as the unique ID.None
means that the object can be updated without ID in the url.Likewise, you can define a
_repr_attr
in subclasses to specify which attribute should be added as a human-readable identifier when called in the object’s__repr__()
method.- Parameters:
manager (RESTManager)
attrs (Dict[str, Any])
created_from_list (bool)
lazy (bool)
- asdict(*, with_parent_attrs: bool = False) Dict[str, Any] ¶
- Parameters:
with_parent_attrs (bool)
- Return type:
Dict[str, Any]
- property encoded_id: int | str | None¶
Ensure that the ID is url-encoded so that it can be safely used in a URL path
- get_id() int | str | None ¶
Returns the id of the resource.
- Return type:
int | str | None
- manager: RESTManager¶
- pformat() str ¶
- Return type:
str
- pprint() None ¶
- Return type:
None
- class gitlab.base.RESTObjectList(manager: RESTManager, obj_cls: Type[RESTObject], _list: GitlabList)¶
Bases:
object
Generator object representing a list of RESTObject’s.
This generator uses the Gitlab pagination system to fetch new data when required.
Note: you should not instantiate such objects, they are returned by calls to RESTManager.list()
- Parameters:
manager (RESTManager) – Manager to attach to the created objects
obj_cls (Type[RESTObject]) – Type of objects to create from the json data
_list (GitlabList) – A GitlabList object
- property current_page: int¶
The current page number.
- next() RESTObject ¶
- Return type:
- property next_page: int | None¶
The next page number.
If None, the current page is the last.
- property per_page: int | None¶
The number of items per page.
- property prev_page: int | None¶
The previous page number.
If None, the current page is the first.
- property total: int | None¶
The total number of items.
- property total_pages: int | None¶
The total number of pages.
gitlab.cli module¶
- class gitlab.cli.CustomAction(required: Tuple[str, ...], optional: Tuple[str, ...], in_object: bool, requires_id: bool, help: str | None)¶
Bases:
object
- Parameters:
required (Tuple[str, ...])
optional (Tuple[str, ...])
in_object (bool)
requires_id (bool)
help (str | None)
- help: str | None¶
- in_object: bool¶
- optional: Tuple[str, ...]¶
- required: Tuple[str, ...]¶
- requires_id: bool¶
- gitlab.cli.cls_to_gitlab_resource(cls: RESTObject) str ¶
- Parameters:
cls (RESTObject)
- Return type:
str
- gitlab.cli.die(msg: str, e: Exception | None = None) NoReturn ¶
- Parameters:
msg (str)
e (Exception | None)
- Return type:
NoReturn
- gitlab.cli.docs() ArgumentParser ¶
Provide a statically generated parser for sphinx only, so we don’t need to provide dummy gitlab config for readthedocs.
- Return type:
ArgumentParser
- gitlab.cli.gitlab_resource_to_cls(gitlab_resource: str, namespace: ModuleType) Type[RESTObject] ¶
- Parameters:
gitlab_resource (str)
namespace (ModuleType)
- Return type:
Type[RESTObject]
- gitlab.cli.main() None ¶
- Return type:
None
- gitlab.cli.register_custom_action(*, cls_names: str | Tuple[str, ...], required: Tuple[str, ...] = (), optional: Tuple[str, ...] = (), custom_action: str | None = None, requires_id: bool = True, help: str | None = None) Callable[[__F], __F] ¶
- Parameters:
cls_names (str | Tuple[str, ...])
required (Tuple[str, ...])
optional (Tuple[str, ...])
custom_action (str | None)
requires_id (bool)
help (str | None)
- Return type:
Callable[[__F], __F]
gitlab.config module¶
- exception gitlab.config.ConfigError¶
Bases:
Exception
- exception gitlab.config.GitlabConfigHelperError¶
Bases:
ConfigError
- exception gitlab.config.GitlabConfigMissingError¶
Bases:
ConfigError
- class gitlab.config.GitlabConfigParser(gitlab_id: str | None = None, config_files: List[str] | None = None)¶
Bases:
object
- Parameters:
gitlab_id (str | None)
config_files (List[str] | None)
- exception gitlab.config.GitlabDataError¶
Bases:
ConfigError
- exception gitlab.config.GitlabIDError¶
Bases:
ConfigError
gitlab.const module¶
- class gitlab.const.AccessLevel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
IntEnum
- ADMIN: int = 60¶
- DEVELOPER: int = 30¶
- GUEST: int = 10¶
- MAINTAINER: int = 40¶
- MINIMAL_ACCESS: int = 5¶
- NO_ACCESS: int = 0¶
- OWNER: int = 50¶
- REPORTER: int = 20¶
- class gitlab.const.NotificationLevel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
GitlabEnum
- CUSTOM: str = 'custom'¶
- DISABLED: str = 'disabled'¶
- GLOBAL: str = 'global'¶
- MENTION: str = 'mention'¶
- PARTICIPATING: str = 'participating'¶
- WATCH: str = 'watch'¶
- class gitlab.const.SearchScope(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
GitlabEnum
- BLOBS: str = 'blobs'¶
- COMMITS: str = 'commits'¶
- GLOBAL_SNIPPET_TITLES: str = 'snippet_titles'¶
- ISSUES: str = 'issues'¶
- MERGE_REQUESTS: str = 'merge_requests'¶
- MILESTONES: str = 'milestones'¶
- PROJECTS: str = 'projects'¶
- PROJECT_NOTES: str = 'notes'¶
- USERS: str = 'users'¶
- WIKI_BLOBS: str = 'wiki_blobs'¶
gitlab.exceptions module¶
- exception gitlab.exceptions.GitlabActivateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabAttachFileError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabAuthenticationError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabBanError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabBlockError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabBuildCancelError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabCancelError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabBuildEraseError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabBuildPlayError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabBuildRetryError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabCancelError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabCherryPickError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabCiLintError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabConnectionError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabCreateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabDeactivateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabDeleteError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabDeploymentApprovalError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
Exception
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabFollowError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabGetError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabGroupTransferError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabHeadError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabHousekeepingError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabHttpError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabImportError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabInvitationError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabJobCancelError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabCancelError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabJobEraseError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabJobPlayError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabJobRetryError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabLicenseError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabListError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabMRApprovalError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabMRClosedError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabMRForbiddenError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabMROnBuildSuccessError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabMRRebaseError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabMRResetApprovalError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabMarkdownError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabOperationError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabOwnershipError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabParsingError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabPipelineCancelError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabCancelError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabPipelinePlayError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabPipelineRetryError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabRetryError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabProjectDeployKeyError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabPromoteError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabProtectError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabRenderError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabRepairError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabRestoreError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabRetryError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabRevertError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabRotateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabSearchError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabSetError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabStopError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabSubscribeError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabTimeTrackingError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabTodoError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabTopicMergeError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabTransferProjectError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabUnbanError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabUnblockError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabUnfollowError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabUnsubscribeError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabUpdateError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabUploadError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabUserApproveError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabUserRejectError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.GitlabVerifyError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabOperationError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
- exception gitlab.exceptions.RedirectError(error_message: str | bytes = '', response_code: int | None = None, response_body: bytes | None = None)¶
Bases:
GitlabError
- Parameters:
error_message (str | bytes)
response_code (int | None)
response_body (bytes | None)
- Return type:
None
gitlab.mixins module¶
- class gitlab.mixins.AccessRequestMixin¶
Bases:
object
- approve(access_level: int = 30, **kwargs: Any) None ¶
Approve an access request.
- Parameters:
access_level (int) – The access level for the user
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabUpdateError – If the server fails to perform the request
- Return type:
None
- manager: RESTManager¶
- class gitlab.mixins.BadgeRenderMixin¶
Bases:
object
- render(link_url: str, image_url: str, **kwargs: Any) Dict[str, Any] ¶
Preview link_url and image_url after interpolation.
- Parameters:
link_url (str) – URL of the badge link
image_url (str) – URL of the badge image
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabRenderError – If the rendering failed
- Returns:
The rendering properties
- Return type:
Dict[str, Any]
- class gitlab.mixins.CRUDMixin¶
Bases:
GetMixin
,ListMixin
,CreateMixin
,UpdateMixin
,DeleteMixin
- class gitlab.mixins.CreateMixin¶
Bases:
object
- create(data: Dict[str, Any] | None = None, **kwargs: Any) RESTObject ¶
Create a new object.
- Parameters:
- Returns:
- A new instance of the managed object class built with
the data sent by the server
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabCreateError – If the server cannot perform the request
- Return type:
- class gitlab.mixins.DeleteMixin¶
Bases:
object
- delete(id: int | str | None = None, **kwargs: Any) None ¶
Delete an object on the server.
- Parameters:
id (int | str | None) – ID of the object to delete
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabDeleteError – If the server cannot perform the request
- Return type:
None
- class gitlab.mixins.DownloadMixin¶
Bases:
object
- download(streamed: bool = False, action: Callable[[bytes], None] | None = None, chunk_size: int = 1024, *, iterator: bool = False, **kwargs: Any) bytes | Iterator[Any] | None ¶
Download the archive of a resource export.
- Parameters:
streamed (bool) – If True the data will be processed by chunks of chunk_size and each chunk is passed to action for treatment
iterator (bool) – If True directly return the underlying response iterator
action (Callable[[bytes], None] | None) – Callable responsible of dealing with chunk of data
chunk_size (int) – Size of each chunk
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabGetError – If the server failed to perform the request
- Returns:
The blob content if streamed is False, None otherwise
- Return type:
bytes | Iterator[Any] | None
- manager: RESTManager¶
- class gitlab.mixins.GetMixin¶
Bases:
HeadMixin
,object
- get(id: str | int, lazy: bool = False, **kwargs: Any) RESTObject ¶
Retrieve a single object.
- Parameters:
id (str | int) – ID of the object to retrieve
lazy (bool) – If True, don’t request the server, but create a shallow object giving access to the managers. This is useful if you want to avoid useless calls to the API.
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The generated RESTObject.
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabGetError – If the server cannot perform the request
- Return type:
- class gitlab.mixins.GetWithoutIdMixin¶
Bases:
HeadMixin
,object
- get(**kwargs: Any) RESTObject ¶
Retrieve a single object.
- Parameters:
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The generated RESTObject
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabGetError – If the server cannot perform the request
- Return type:
- class gitlab.mixins.ListMixin¶
Bases:
HeadMixin
,object
- list(**kwargs: Any) RESTObjectList | List[RESTObject] ¶
Retrieve a list of objects.
- Parameters:
all – If True, return all the items, without pagination
per_page – Number of items to retrieve per request
page – ID of the page to return (starts with page 1)
iterator – If set to True and no pagination option is defined, return a generator instead of a list
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Returns:
The list of objects, or a generator if iterator is True
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabListError – If the server cannot perform the request
- Return type:
RESTObjectList | List[RESTObject]
- class gitlab.mixins.NoUpdateMixin¶
Bases:
GetMixin
,ListMixin
,CreateMixin
,DeleteMixin
- class gitlab.mixins.ObjectDeleteMixin¶
Bases:
object
Mixin for RESTObject’s that can be deleted.
- delete(**kwargs: Any) None ¶
Delete the object from the server.
- Parameters:
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabDeleteError – If the server cannot perform the request
- Return type:
None
- manager: RESTManager¶
- class gitlab.mixins.ParticipantsMixin¶
Bases:
object
- manager: RESTManager¶
- participants(**kwargs: Any) GitlabList | List[Dict[str, Any]] ¶
List the participants.
- Parameters:
all – If True, return all the items, without pagination
per_page – Number of items to retrieve per request
page – ID of the page to return (starts with page 1)
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabListError – If the list could not be retrieved
- Returns:
The list of participants
- Return type:
GitlabList | List[Dict[str, Any]]
- class gitlab.mixins.RefreshMixin¶
Bases:
object
- manager: RESTManager¶
- refresh(**kwargs: Any) None ¶
Refresh a single object from server.
- Parameters:
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Return type:
None
Returns None (updates the object)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabGetError – If the server cannot perform the request
- Parameters:
kwargs (Any)
- Return type:
None
- class gitlab.mixins.SaveMixin¶
Bases:
object
Mixin for RESTObject’s that can be updated.
- manager: RESTManager¶
- class gitlab.mixins.SetMixin¶
Bases:
object
- set(key: str, value: str, **kwargs: Any) RESTObject ¶
Create or update the object.
- Parameters:
key (str) – The key of the object to create/update
value (str) – The value to set for the object
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabSetError – If an error occurred
- Returns:
The created/updated attribute
- Return type:
- class gitlab.mixins.SubscribableMixin¶
Bases:
object
- manager: RESTManager¶
- subscribe(**kwargs: Any) None ¶
Subscribe to the object notifications.
- Parameters:
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabSubscribeError – If the subscription cannot be done
- Return type:
None
- unsubscribe(**kwargs: Any) None ¶
Unsubscribe from the object notifications.
- Parameters:
**kwargs (Any) – Extra options to send to the server (e.g. sudo)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabUnsubscribeError – If the unsubscription cannot be done
- Return type:
None
- class gitlab.mixins.TimeTrackingMixin¶
Bases:
object
- manager: RESTManager¶
- reset_time_estimate(**kwargs: Any) Dict[str, Any] ¶
Resets estimated time for the object to 0 seconds.
- time_estimate(duration: str, **kwargs: Any) Dict[str, Any] ¶
Set an estimated time of work for the object.
- class gitlab.mixins.TodoMixin¶
Bases:
object
- manager: RESTManager¶
- class gitlab.mixins.UpdateMixin¶
Bases:
object
- update(id: int | str | None = None, new_data: Dict[str, Any] | None = None, **kwargs: Any) Dict[str, Any] ¶
Update an object on the server.
- Parameters:
- Returns:
The new object data (not a RESTObject)
- Raises:
GitlabAuthenticationError – If authentication is not correct
GitlabUpdateError – If the server cannot perform the request
- Return type:
Dict[str, Any]
gitlab.utils module¶
- class gitlab.utils.EncodedId(value: str | int | EncodedId)¶
Bases:
str
A custom str class that will return the URL-encoded value of the string.
Using it recursively will only url-encode the value once.
Can accept either str or int as input value.
Can be used in an f-string and output the URL-encoded string.
Reference to documentation on why this is necessary.
See:
https://docs.gitlab.com/ee/api/index.html#namespaced-path-encoding https://docs.gitlab.com/ee/api/index.html#path-parameters
- class gitlab.utils.MaskingFormatter(fmt: str | None = '%(levelname)s:%(name)s:%(message)s', datefmt: str | None = None, style: Literal['%', '{', '$'] = '%', validate: bool = True, masked: str | None = None)¶
Bases:
Formatter
A logging formatter that can mask credentials
- Parameters:
fmt (str | None)
datefmt (str | None)
style (Literal['%', '{', '$'])
validate (bool)
masked (str | None)
- format(record: LogRecord) str ¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- Parameters:
record (LogRecord)
- Return type:
str
- class gitlab.utils.WarnMessageData(message: str, show_caller: bool)¶
Bases:
object
- Parameters:
message (str)
show_caller (bool)
- message: str¶
- show_caller: bool¶
- gitlab.utils.get_content_type(content_type: str | None) str ¶
- Parameters:
content_type (str | None)
- Return type:
str
- gitlab.utils.response_content(response: Response, streamed: bool, action: Callable[[bytes], None] | None, chunk_size: int, *, iterator: bool) bytes | Iterator[Any] | None ¶
- Parameters:
response (Response)
streamed (bool)
action (Callable[[bytes], None] | None)
chunk_size (int)
iterator (bool)
- Return type:
bytes | Iterator[Any] | None
- gitlab.utils.warn(message: str, *, category: Type[Warning] | None = None, source: Any | None = None, show_caller: bool = True) None ¶
This warnings.warn wrapper function attempts to show the location causing the warning in the user code that called the library.
It does this by walking up the stack trace to find the first frame located outside the gitlab/ directory. This is helpful to users as it shows them their code that is causing the warning.
- Parameters:
message (str)
category (Type[Warning] | None)
source (Any | None)
show_caller (bool)
- Return type:
None