Table of Contents
gitlab package)gitlab command)It is likely that you used aMergeRequest,GroupMergeRequest,Issue orGroupIssue object. These objects cannot be edited. But youcan create a newProjectMergeRequest orProjectIssue object toapply changes. For example:
issue=gl.issues.list(get_all=False)[0]project=gl.projects.get(issue.project_id,lazy=True)editable_issue=project.issues.get(issue.iid,lazy=True)# you can now edit the object
See themerge requests example and theissues examples.
python-gitlab does not provide an API to clone a project. You have to use agit library or call thegit command.
The git URI is exposed in thessh_url_to_repo attribute ofProjectobjects.
Example:
importsubprocessproject=gl.projects.create(data)# or gl.projects.get(project_id)print(project.attributes)# displays all the attributesgit_url=project.ssh_url_to_reposubprocess.call(['git','clone',git_url])
If you’ve passedall=True to the API and still cannot see all items returned,useget_all=True (or--get-all via the CLI) instead. SeePagination for more details.
AttributeError when accessing object attributes retrieved vialist()¶Fetching a list of objects does not always include all attributes in the objects.To retrieve an object with all attributes, use aget() call.
Example with projects:
forprojectingl.projects.list(iterator=True):# Retrieve project object with all attributesproject=gl.projects.get(project.id)
AttributeError when accessing attributes aftersave() orrefresh()¶You are most likely trying to access an attribute that was not returnedby the server on the second request. Please look at the documentation inAttributes in updated objects to see how to avoid this.
TypeError when accessing object attributes¶When you encounter errors such asobjectisnotiterable orobjectisnotsubscriptablewhen trying to access object attributes returned from the server, you are most likely trying toaccess an attribute that is shadowed by python-gitlab’s own methods or managers.
You can use the object’sattributes dictionary to access it directly instead.See theGitlab Objects section for more details on how attributes are exposed.
path (or some other parameter) as it conflicts with the library¶path is used by the python-gitlab library and cannot be used as a parameterif wanting to send it to the GitLab instance. You can use thequery_parameters argument to send arguments that would conflict with pythonor python-gitlab when using them as kwargs:
## invalid, as ``path`` is interpreted by python-gitlab as the Path or full## URL to query ('/projects' or 'http://whatever/v4/api/projects')project.commits.list(path='some_file_path',iterator=True)project.commits.list(query_parameters={'path':'some_file_path'},iterator=True)# OK
SeeConflicting Parameters for more information.