Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
python-gitlabv6.1.0
python-gitlabv6.1.0

Table of Contents

Back to top

API reference (gitlab package)

Module contents

Wrapper for the GitLab API.

classgitlab.AsyncGraphQL(url:str|None=None,*,token:str|None=None,ssl_verify:bool|str=True,client:AsyncClient|None=None,timeout:float|None=None,user_agent:str='python-gitlab/6.1.0',fetch_schema_from_transport:bool=False,max_retries:int=10,obey_rate_limit:bool=True,retry_transient_errors:bool=False)

Bases:_BaseGraphQL

Parameters:
asyncexecute(request:str|Source,*args:Any,**kwargs:Any)Any
Parameters:
  • request (str |Source)

  • args (Any)

  • kwargs (Any)

Return type:

Any

classgitlab.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/6.1.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 tohttps://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. Ifthe value is a string, it is the path to a CA file used forcertificate 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, 504or 52x responses. Defaults to False.

  • keep_base_url (bool) – keep user-provided base URL for pagination if itdiffers 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)

propertyapi_url:str

The computed API base URL.

propertyapi_version:str

The API version used (4 only).

appearance

SeeApplicationAppearanceManager

applications

SeeApplicationManager

audit_events

SeeAuditEventManager

auth()None

Performs an authentication using private token. Warns the user if apotentially misconfigured URL is detected on the client or server side.

Theuser attribute will hold agitlab.objects.CurrentUser object onsuccess.

Return type:

None

broadcastmessages

SeeBroadcastMessageManager

bulk_import_entities

SeeBulkImportAllEntityManager

bulk_imports

SeeBulkImportManager

ci_lint

SeeCiLintManager

deploykeys

SeeDeployKeyManager

deploytokens

SeeDeployTokenManager

dockerfiles

SeeDockerfileManager

enable_debug(mask_credentials:bool=True)None
Parameters:

mask_credentials (bool)

Return type:

None

events

SeeEventManager

features

SeeFeatureManager

classmethodfrom_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:

Gitlab

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:

Gitlab

geonodes

SeeGeoNodeManager

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

SeeGitignoreManager

gitlabciymls

SeeGitlabciymlManager

groups

SeeGroupManager

headers

Headers that will be used in request to GitLab

hooks

SeeHookManager

http_delete(path:str,**kwargs:Any)Response

Make a DELETE request to the Gitlab server.

Parameters:
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 isnot 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. Ifiterator isTrue and no pagination-related arguments (page,per_page,get_all) are defined then a GitlabList object (generator) is returnedinstead. This object will make API calls when needed to fetch thenext 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 tojson 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 tojson 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 theraw 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 tojson 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,extra_headers:dict[str,Any]|None=None,**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 tojson 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 Requestresponses. Defaults to True.

  • retry_transient_errors (bool |None) – Whether to retry after 500, 502, 503, 504or 52x responses. Defaults to False.

  • max_retries (int) – Max retries after 429 or transient errors,set to -1 to retry forever. Defaults to 10.

  • extra_headers (dict[str,Any]|None) – Add and override HTTP headers for the request.

  • **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

SeeIssueManager

issues_statistics

SeeIssuesStatisticsManager

keys

SeeKeyManager

ldapgroups

SeeLDAPGroupManager

licenses

SeeLicenseManager

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 whengfm 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

member_roles

SeeMergeRequestManager

classmethodmerge_config(options:dict[str,Any],gitlab_id:str|None=None,config_files:list[str]|None=None)Gitlab

Create a Gitlab connection by merging configuration withthe following precedence:

  1. Explicitly provided CLI arguments,

  2. Environment variables,

  3. Configuration files:
    1. explicitly defined config files:
      1. via the–config-file CLI argument,

      2. via thePYTHON_GITLAB_CFG environment variable,

    2. user-specific config file,

    3. system-level config file,

  4. 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:

(gitlab.Gitlab)

Raises:

gitlab.config.GitlabDataError – If the configuration is not correct.

mergerequests

SeeMergeRequestManager

namespaces

SeeNamespaceManager

notificationsettings

SeeNotificationSettingsManager

pagesdomains

SeePagesDomainManager

personal_access_tokens

SeePersonalAccessTokenManager

projects

SeeProjectManager

registry_repositories

SeeRegistryRepositoryManager

runners

SeeRunnerManager

runners_all

SeeRunnerManager

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

SeeApplicationSettingsManager

sidekiq

SeeSidekiqManager

snippets

SeeSnippetManager

ssl_verify

Whether SSL certificates should be validated

statistics

SeeApplicationStatisticsManager

timeout

Timeout to use for requests to gitlab server

todos

SeeTodoManager

topics

SeeTopicManager

propertyurl:str

The user-provided server URL.

user_activities

SeeUserActivitiesManager

users

SeeUserManager

variables

SeeVariableManager

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 gitlabobject.

Returns:

The server version and server revision.

(‘unknown’, ‘unknown’) if the server doesn’t perform as expected.

Return type:

tuple[str, str]

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.GitlabHookTestError(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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

classgitlab.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 callthe API again when needed.

Parameters:
  • gl (Gitlab)

  • url (str)

  • query_data (dict[str,Any])

  • get_next (bool)

  • kwargs (Any)

propertycurrent_page:int

The current page number.

next()dict[str,Any]
Return type:

dict[str,Any]

propertynext_page:int|None

The next page number.

If None, the current page is the last.

propertyper_page:int|None

The number of items per page.

propertyprev_page:int|None

The previous page number.

If None, the current page is the first.

propertytotal:int|None

The total number of items.

propertytotal_pages:int|None

The total number of pages.

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

classgitlab.GraphQL(url:str|None=None,*,token:str|None=None,ssl_verify:bool|str=True,client:Client|None=None,timeout:float|None=None,user_agent:str='python-gitlab/6.1.0',fetch_schema_from_transport:bool=False,max_retries:int=10,obey_rate_limit:bool=True,retry_transient_errors:bool=False)

Bases:_BaseGraphQL

Parameters:
execute(request:str|Source,*args:Any,**kwargs:Any)Any
Parameters:
  • request (str |Source)

  • args (Any)

  • kwargs (Any)

Return type:

Any

exceptiongitlab.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

classgitlab.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/6.1.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 tohttps://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. Ifthe value is a string, it is the path to a CA file used forcertificate 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, 504or 52x responses. Defaults to False.

  • keep_base_url (bool) – keep user-provided base URL for pagination if itdiffers 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)

propertyapi_url:str

The computed API base URL.

propertyapi_version:str

The API version used (4 only).

appearance

SeeApplicationAppearanceManager

applications

SeeApplicationManager

audit_events

SeeAuditEventManager

auth()None

Performs an authentication using private token. Warns the user if apotentially misconfigured URL is detected on the client or server side.

Theuser attribute will hold agitlab.objects.CurrentUser object onsuccess.

Return type:

None

broadcastmessages

SeeBroadcastMessageManager

bulk_import_entities

SeeBulkImportAllEntityManager

bulk_imports

SeeBulkImportManager

ci_lint

SeeCiLintManager

deploykeys

SeeDeployKeyManager

deploytokens

SeeDeployTokenManager

dockerfiles

SeeDockerfileManager

enable_debug(mask_credentials:bool=True)None
Parameters:

mask_credentials (bool)

Return type:

None

events

SeeEventManager

features

SeeFeatureManager

classmethodfrom_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:

Gitlab

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:

Gitlab

geonodes

SeeGeoNodeManager

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

SeeGitignoreManager

gitlabciymls

SeeGitlabciymlManager

groups

SeeGroupManager

headers

Headers that will be used in request to GitLab

hooks

SeeHookManager

http_delete(path:str,**kwargs:Any)Response

Make a DELETE request to the Gitlab server.

Parameters:
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 isnot 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. Ifiterator isTrue and no pagination-related arguments (page,per_page,get_all) are defined then a GitlabList object (generator) is returnedinstead. This object will make API calls when needed to fetch thenext 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 tojson 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 tojson 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 theraw 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 tojson 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,extra_headers:dict[str,Any]|None=None,**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 tojson 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 Requestresponses. Defaults to True.

  • retry_transient_errors (bool |None) – Whether to retry after 500, 502, 503, 504or 52x responses. Defaults to False.

  • max_retries (int) – Max retries after 429 or transient errors,set to -1 to retry forever. Defaults to 10.

  • extra_headers (dict[str,Any]|None) – Add and override HTTP headers for the request.

  • **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

SeeIssueManager

issues_statistics

SeeIssuesStatisticsManager

keys

SeeKeyManager

ldapgroups

SeeLDAPGroupManager

licenses

SeeLicenseManager

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 whengfm 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

member_roles

SeeMergeRequestManager

classmethodmerge_config(options:dict[str,Any],gitlab_id:str|None=None,config_files:list[str]|None=None)Gitlab

Create a Gitlab connection by merging configuration withthe following precedence:

  1. Explicitly provided CLI arguments,

  2. Environment variables,

  3. Configuration files:
    1. explicitly defined config files:
      1. via the–config-file CLI argument,

      2. via thePYTHON_GITLAB_CFG environment variable,

    2. user-specific config file,

    3. system-level config file,

  4. 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:

(gitlab.Gitlab)

Raises:

gitlab.config.GitlabDataError – If the configuration is not correct.

mergerequests

SeeMergeRequestManager

namespaces

SeeNamespaceManager

notificationsettings

SeeNotificationSettingsManager

pagesdomains

SeePagesDomainManager

personal_access_tokens

SeePersonalAccessTokenManager

projects

SeeProjectManager

registry_repositories

SeeRegistryRepositoryManager

runners

SeeRunnerManager

runners_all

SeeRunnerManager

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

SeeApplicationSettingsManager

sidekiq

SeeSidekiqManager

snippets

SeeSnippetManager

ssl_verify

Whether SSL certificates should be validated

statistics

SeeApplicationStatisticsManager

timeout

Timeout to use for requests to gitlab server

todos

SeeTodoManager

topics

SeeTopicManager

propertyurl:str

The user-provided server URL.

user:objects.CurrentUser|None
user_activities

SeeUserActivitiesManager

users

SeeUserManager

variables

SeeVariableManager

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 gitlabobject.

Returns:

The server version and server revision.

(‘unknown’, ‘unknown’) if the server doesn’t perform as expected.

Return type:

tuple[str, str]

classgitlab.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 callthe API again when needed.

Parameters:
  • gl (Gitlab)

  • url (str)

  • query_data (dict[str,Any])

  • get_next (bool)

  • kwargs (Any)

propertycurrent_page:int

The current page number.

next()dict[str,Any]
Return type:

dict[str,Any]

propertynext_page:int|None

The next page number.

If None, the current page is the last.

propertyper_page:int|None

The number of items per page.

propertyprev_page:int|None

The previous page number.

If None, the current page is the first.

propertytotal:int|None

The total number of items.

propertytotal_pages:int|None

The total number of pages.

Subpackages

Submodules

gitlab.base module

classgitlab.base.RESTManager(gl:Gitlab,parent:RESTObject|None=None)

Bases:Generic[TObjCls]

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:
gitlab:Gitlab
propertyparent_attrs:dict[str,Any]|None
propertypath:str
classgitlab.base.RESTObject(manager:RESTManager[Any],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 inanother. This allows smart updates, if the object allows it.

You can redefine_id_attr in child classes to specify which attributemust be used as the unique ID.None means that the object can be updatedwithout ID in the url.

Likewise, you can define a_repr_attr in subclasses to specify whichattribute should be added as a human-readable identifier when called in theobject’s__repr__() method.

Parameters:
  • manager (RESTManager[Any])

  • 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]

propertyattributes:dict[str,Any]
propertyencoded_id:int|str|None

Ensure that the ID is url-encoded so that it can be safely used in a URLpath

get_id()int|str|None

Returns the id of the resource.

Return type:

int | str | None

manager:RESTManager[Any]
pformat()str
Return type:

str

pprint()None
Return type:

None

to_json(*,with_parent_attrs:bool=False,**kwargs:Any)str
Parameters:
  • with_parent_attrs (bool)

  • kwargs (Any)

Return type:

str

classgitlab.base.RESTObjectList(manager:RESTManager[TObjCls],obj_cls:type[TObjCls],_list:GitlabList)

Bases:Generic[TObjCls]

Generator object representing a list of RESTObject’s.

This generator uses the Gitlab pagination system to fetch new data whenrequired.

Note: you should not instantiate such objects, they are returned by callsto RESTManager.list()

Parameters:
  • manager (RESTManager[TObjCls]) – Manager to attach to the created objects

  • obj_cls (type[TObjCls]) – Type of objects to create from the json data

  • _list (GitlabList) – A GitlabList object

propertycurrent_page:int

The current page number.

next()TObjCls
Return type:

TObjCls

propertynext_page:int|None

The next page number.

If None, the current page is the last.

propertyper_page:int|None

The number of items per page.

propertyprev_page:int|None

The previous page number.

If None, the current page is the first.

propertytotal:int|None

The total number of items.

propertytotal_pages:int|None

The total number of pages.

gitlab.cli module

classgitlab.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:type[RESTObject])str
Parameters:

cls (type[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 needto 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

exceptiongitlab.config.ConfigError

Bases:Exception

exceptiongitlab.config.GitlabConfigHelperError

Bases:ConfigError

exceptiongitlab.config.GitlabConfigMissingError

Bases:ConfigError

classgitlab.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)

exceptiongitlab.config.GitlabDataError

Bases:ConfigError

exceptiongitlab.config.GitlabIDError

Bases:ConfigError

gitlab.const module

classgitlab.const.AccessLevel(value)

Bases:IntEnum

ADMIN=60
DEVELOPER=30
GUEST=10
MAINTAINER=40
MINIMAL_ACCESS=5
NO_ACCESS=0
OWNER=50
PLANNER=15
REPORTER=20
classgitlab.const.NotificationLevel(value)

Bases:GitlabEnum

CUSTOM='custom'
DISABLED='disabled'
GLOBAL='global'
MENTION='mention'
PARTICIPATING='participating'
WATCH='watch'
classgitlab.const.SearchScope(value)

Bases:GitlabEnum

BLOBS='blobs'
COMMITS='commits'
GLOBAL_SNIPPET_TITLES='snippet_titles'
ISSUES='issues'
MERGE_REQUESTS='merge_requests'
MILESTONES='milestones'
PROJECTS='projects'
PROJECT_NOTES='notes'
USERS='users'
WIKI_BLOBS='wiki_blobs'
classgitlab.const.Visibility(value)

Bases:GitlabEnum

INTERNAL='internal'
PRIVATE='private'
PUBLIC='public'

gitlab.exceptions module

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.exceptions.GitlabHookTestError(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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

exceptiongitlab.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

classgitlab.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[Any]
classgitlab.mixins.BadgeRenderMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:RESTManager[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

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]

classgitlab.mixins.CRUDMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:GetMixin[TObjCls],ListMixin[TObjCls],CreateMixin[TObjCls],UpdateMixin[TObjCls],DeleteMixin[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

classgitlab.mixins.CreateMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:RESTManager[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

create(data:dict[str,Any]|None=None,**kwargs:Any)TObjCls

Create a new object.

Parameters:
  • data (dict[str,Any]|None) – parameters to send to the server to create theresource

  • **kwargs (Any) – Extra options to send to the server (e.g. sudo)

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:

TObjCls

classgitlab.mixins.DeleteMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:RESTManager[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

delete(id:str|int|None=None,**kwargs:Any)None

Delete an object on the server.

Parameters:
  • id (str |int |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

classgitlab.mixins.DownloadMixin

Bases:object

download(streamed:Literal[False]=False,action:None=None,chunk_size:int=1024,*,iterator:Literal[False]=False,**kwargs:Any)bytes
download(streamed:bool=False,action:None=None,chunk_size:int=1024,*,iterator:Literal[True]=True,**kwargs:Any)Iterator[Any]
download(streamed:Literal[True]=True,action:Callable[[bytes],Any]|None=None,chunk_size:int=1024,*,iterator:Literal[False]=False,**kwargs:Any)None

Download the archive of a resource export.

Parameters:
  • streamed – If True the data will be processed by chunks ofchunk_size and each chunk is passed toaction fortreatment

  • iterator – If True directly return the underlying responseiterator

  • action – Callable responsible of dealing with chunk ofdata

  • chunk_size – Size of each chunk

  • **kwargs – 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

manager:RESTManager[Any]
classgitlab.mixins.GetMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:HeadMixin[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

get(id:str|int,lazy:bool=False,**kwargs:Any)TObjCls

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 ashallow object giving access to the managers. This isuseful 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:

TObjCls

classgitlab.mixins.GetWithoutIdMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:HeadMixin[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

get(**kwargs:Any)TObjCls

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:

TObjCls

classgitlab.mixins.ListMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:HeadMixin[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

list(*,iterator:Literal[False]=False,**kwargs:Any)list[base.TObjCls]
list(*,iterator:Literal[True]=True,**kwargs:Any)base.RESTObjectList[base.TObjCls]
list(*,iterator:bool=False,**kwargs:Any)base.RESTObjectList[base.TObjCls]|list[base.TObjCls]

Retrieve a list of objects.

Parameters:
  • get_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 isdefined, return a generator instead of a list

  • **kwargs – Extra options to send to the server (e.g. sudo)

Returns:

The list of objects, or a generator ifiterator is True

Raises:
  • GitlabAuthenticationError – If authentication is not correct

  • GitlabListError – If the server cannot perform the request

classgitlab.mixins.NoUpdateMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:GetMixin[TObjCls],ListMixin[TObjCls],CreateMixin[TObjCls],DeleteMixin[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

classgitlab.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[Any]
classgitlab.mixins.ParticipantsMixin

Bases:object

manager:RESTManager[Any]
participants(**kwargs:Any)GitlabList|list[dict[str,Any]]

List the participants.

Parameters:
  • get_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]]

classgitlab.mixins.RefreshMixin

Bases:object

manager:RESTManager[Any]
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

classgitlab.mixins.RetrieveMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:ListMixin[TObjCls],GetMixin[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

classgitlab.mixins.SaveMixin

Bases:object

Mixin for RESTObject’s that can be updated.

manager:RESTManager[Any]
save(**kwargs:Any)dict[str,Any]|None

Save the changes made to the object to the server.

The object is updated to match what the server returns.

Parameters:

**kwargs (Any) – Extra options to send to the server (e.g. sudo)

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] | None

classgitlab.mixins.SetMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:RESTManager[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

set(key:str,value:str,**kwargs:Any)TObjCls

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:

TObjCls

classgitlab.mixins.SubscribableMixin

Bases:object

manager:RESTManager[Any]
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

classgitlab.mixins.TimeTrackingMixin

Bases:object

add_spent_time(duration:str,**kwargs:Any)dict[str,Any]

Add time spent working on the object.

Parameters:
  • duration (str) – Duration in human format (e.g. 3h30)

  • **kwargs (Any) – Extra options to send to the server (e.g. sudo)

Raises:
  • GitlabAuthenticationError – If authentication is not correct

  • GitlabTimeTrackingError – If the time tracking update cannot be done

Return type:

dict[str,Any]

manager:RESTManager[Any]
reset_spent_time(**kwargs:Any)dict[str,Any]

Resets the time spent working on the object.

Parameters:

**kwargs (Any) – Extra options to send to the server (e.g. sudo)

Raises:
  • GitlabAuthenticationError – If authentication is not correct

  • GitlabTimeTrackingError – If the time tracking update cannot be done

Return type:

dict[str,Any]

reset_time_estimate(**kwargs:Any)dict[str,Any]

Resets estimated time for the object to 0 seconds.

Parameters:

**kwargs (Any) – Extra options to send to the server (e.g. sudo)

Raises:
  • GitlabAuthenticationError – If authentication is not correct

  • GitlabTimeTrackingError – If the time tracking update cannot be done

Return type:

dict[str,Any]

time_estimate(duration:str,**kwargs:Any)dict[str,Any]

Set an estimated time of work for the object.

Parameters:
  • duration (str) – Duration in human format (e.g. 3h30)

  • **kwargs (Any) – Extra options to send to the server (e.g. sudo)

Raises:
  • GitlabAuthenticationError – If authentication is not correct

  • GitlabTimeTrackingError – If the time tracking update cannot be done

Return type:

dict[str,Any]

time_stats(**kwargs:Any)dict[str,Any]

Get time stats for the object.

Parameters:

**kwargs (Any) – Extra options to send to the server (e.g. sudo)

Raises:
  • GitlabAuthenticationError – If authentication is not correct

  • GitlabTimeTrackingError – If the time tracking update cannot be done

Return type:

dict[str,Any]

classgitlab.mixins.TodoMixin

Bases:object

manager:RESTManager[Any]
todo(**kwargs:Any)None

Create a todo associated to the object.

Parameters:

**kwargs (Any) – Extra options to send to the server (e.g. sudo)

Raises:
  • GitlabAuthenticationError – If authentication is not correct

  • GitlabTodoError – If the todo cannot be set

Return type:

None

classgitlab.mixins.UpdateMixin(gl:Gitlab,parent:RESTObject|None=None)

Bases:RESTManager[TObjCls]

Parameters:
  • gl (Gitlab)

  • parent (RESTObject |None)

update(id:str|int|None=None,new_data:dict[str,Any]|None=None,**kwargs:Any)dict[str,Any]

Update an object on the server.

Parameters:
  • id (str |int |None) – ID of the object to update (can be None if not required)

  • new_data (dict[str,Any]|None) – the update data for the object

  • **kwargs (Any) – Extra options to send to the server (e.g. sudo)

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]

classgitlab.mixins.UserAgentDetailMixin

Bases:object

manager:RESTManager[Any]
user_agent_detail(**kwargs:Any)dict[str,Any]

Get the user agent detail.

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

Return type:

dict[str,Any]

gitlab.utils module

classgitlab.utils.EncodedId(value:str|int|EncodedId)

Bases:str

A customstr class that will return the URL-encoded value of the string.

  • Using it recursively will only url-encode the value once.

  • Can accept eitherstr orint 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-encodinghttps://docs.gitlab.com/ee/api/index.html#path-parameters
Parameters:

value (str |int |EncodedId)

Return type:

EncodedId

classgitlab.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 astring formatting operation which yields the returned string.Before formatting the dictionary, a couple of preparatory stepsare carried out. The message attribute of the record is computedusing LogRecord.getMessage(). If the formatting string uses thetime (as determined by a call to usesTime(), formatTime() iscalled 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

classgitlab.utils.Retry(max_retries:int,obey_rate_limit:bool|None=True,retry_transient_errors:bool|None=False)

Bases:object

Parameters:
  • max_retries (int)

  • obey_rate_limit (bool |None)

  • retry_transient_errors (bool |None)

handle_retry()bool
Return type:

bool

handle_retry_on_status(status_code:int|None,headers:MutableMapping[str,str]|None=None,reason:str='')bool
Parameters:
  • status_code (int |None)

  • headers (MutableMapping[str,str]|None)

  • reason (str)

Return type:

bool

classgitlab.utils.WarnMessageData(message:'str',show_caller:'bool')

Bases:object

Parameters:
  • message (str)

  • show_caller (bool)

message:str
show_caller:bool
gitlab.utils.copy_dict(*,src:dict[str,Any],dest:dict[str,Any])None
Parameters:
  • src (dict[str,Any])

  • dest (dict[str,Any])

Return type:

None

gitlab.utils.get_base_url(url:str|None=None)str

Return the base URL with the trailing slash stripped.If the URL is a Falsy value, return the default URL.:returns: The base URL

Parameters:

url (str |None)

Return type:

str

gitlab.utils.get_content_type(content_type:str|None)str
Parameters:

content_type (str |None)

Return type:

str

gitlab.utils.remove_none_from_dict(data:dict[str,Any])dict[str,Any]
Parameters:

data (dict[str,Any])

Return type:

dict[str,Any]

gitlab.utils.response_content(response:Response,streamed:bool,action:Callable[[bytes],Any]|None,chunk_size:int,*,iterator:bool)bytes|Iterator[Any]|None
Parameters:
  • response (Response)

  • streamed (bool)

  • action (Callable[[bytes],Any]|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

Thiswarnings.warn wrapper function attempts to show the location causing thewarning in the user code that called the library.

It does this by walking up the stack trace to find the first frame located outsidethegitlab/ directory. This is helpful to users as it shows them their code thatis causing the warning.

Parameters:
  • message (str)

  • category (type[Warning]|None)

  • source (Any |None)

  • show_caller (bool)

Return type:

None

On this page

[8]ページ先頭

©2009-2025 Movatter.jp