All Projects → doctormo → python-gitlab3

doctormo / python-gitlab3

Licence: LGPL-3.0 license
Python wrapper for the entire GitLab API

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to python-gitlab3

gitlab-configuration-as-code
Manage GitLab configuration as code to make GitLab easily managable, traceable and reproducible.
Stars: ✭ 31 (-29.55%)
Mutual labels:  gitlab, gitlab-api
gitlab-live
Interactive online shell for GitLab API
Stars: ✭ 21 (-52.27%)
Mutual labels:  gitlab, gitlab-api
Python Gitlab
Python wrapper for the GitLab API
Stars: ✭ 1,679 (+3715.91%)
Mutual labels:  gitlab, gitlab-api
gitlab-project-export
Simple python project for exporting GitLab projects with Export Project funkcionality in GitLab API. Import of exported projects is also supported
Stars: ✭ 69 (+56.82%)
Mutual labels:  gitlab, gitlab-api
geet
Command line interface for performing Git hosting service operations
Stars: ✭ 14 (-68.18%)
Mutual labels:  gitlab, gitlab-api
gitlabctl
Cross platform Gitlab management cli written in Go. Download the executable with no dependencies!
Stars: ✭ 41 (-6.82%)
Mutual labels:  gitlab, gitlab-api
gitlab.cr
Gitlab.cr is a GitLab API wrapper written by Crystal
Stars: ✭ 29 (-34.09%)
Mutual labels:  gitlab, gitlab-api
GitLabCLI
Cross platform GitLab CLI tool
Stars: ✭ 28 (-36.36%)
Mutual labels:  gitlab
DoAnFullstack-ui
Currently on Offline mode for saving budget
Stars: ✭ 20 (-54.55%)
Mutual labels:  gitlab
YappyGitLab
A GitLab monitor bot for Discord
Stars: ✭ 51 (+15.91%)
Mutual labels:  gitlab
gitlabr
An R client for the GitLab API
Stars: ✭ 31 (-29.55%)
Mutual labels:  gitlab
phpcs-gitlab
Gitlab Report for PHP_CodeSniffer (display the violations in the Gitlab CI/CD Code Quality Report)
Stars: ✭ 29 (-34.09%)
Mutual labels:  gitlab
gitlabform
🏗 Specialized "configuration as a code" tool for GitLab
Stars: ✭ 332 (+654.55%)
Mutual labels:  gitlab
react-unleash-flags
React Component for Gitlab or Unleash Feature Flags
Stars: ✭ 36 (-18.18%)
Mutual labels:  gitlab
OctoPrint-GitFiles
With this plugin, you can use a github/gitlab repository for keeping your OctoPrint Files collection up-to-date.
Stars: ✭ 28 (-36.36%)
Mutual labels:  gitlab
gitcolombo
🧬 Extract and analyze contributors info from git repos
Stars: ✭ 55 (+25%)
Mutual labels:  gitlab
git-squash
Locally squash commits on a branch without resolving any conflicts (a'la squash and merge)
Stars: ✭ 123 (+179.55%)
Mutual labels:  gitlab
10-days-of-git-and-github
asabeneh.github.io/10-days-of-git-and-github/
Stars: ✭ 786 (+1686.36%)
Mutual labels:  gitlab
Git-for-bio-scientists
Presentation about digital lab journalling with Git
Stars: ✭ 30 (-31.82%)
Mutual labels:  gitlab
MergeRequestsCI
👀 UI to see all GitLab merge requests of your teams in one place
Stars: ✭ 14 (-68.18%)
Mutual labels:  gitlab

IMPORTANT!

Martin Owens (@doctormo) has kindly taken over maintenance of this project.

python-gitlab3

A Python wrapper for GitLab API v3.

There are existing python wrappers (notably, http://github.com/gpocentek/python-gitlab and http://github.com/Itxaka/python-gitlab), but I'm not fond of their interface/usage. In addition, this provides complete coverage of the GitLab API (and is easily maintainable).

Dependencies

Installation

$ sudo pip install gitlab3

Documentation

See http://alexvh.github.io/python-gitlab3/ for complete API information (also contained in the doc directory). Ancient-looking, Epydoc-generated html since it organizes this project more clearly than Sphinx does.

Example Usage

import gitlab3

gl = gitlab3.GitLab('http://example.com/', 'token')
# Alternatively:
gl = gitlab3.GitLab('http://example.com/')
if not gl.login('username_or_email', 'password'):
    print "Login failed"

#
# Example usage involving listing objects
#
for project in gl.projects():  # all of the current user's projects
    print project.name

for event in gl.project(1).events(limit=10):  # 10 most recent events
    print event.action_name

for project in gl.projects(page=1, per_page=10):  # pagination
    print project.issues(limit=1)[0].title  # (assume issue[0] exists...)

#
# Sudo usage examples (GitLab v6.1+)
# All functions accept an optional, undocumented, 'sudo' argument
# specifiying a username or user id to act as.
#
gl.get_current_user(sudo='other_user')  # => 'other_user' CurrentUser object
gl.projects(sudo=2)  # => list of user 2's projects
# Alternatively, a 'with' statement can be used as follows:
with gl.sudo('other_user'):
    gl.get_current_user()  # => 'other_user' CurrentUser object
    gl.projects()  # => list of 'other_users's projects

#
# Example usage involving users
#
user = gl.add_user('[email protected]', 'passwd', 'username',
                   'real name', project_limit=50, bio='bio')
print type(user)  # => '<class 'gitlab3.User'>'
print type(user.created_at)  # => '<type 'datetime.datetime'>'

user = gl.user(1)  # or gl.get_user(1) - get_<name>() aliases <name>()
user.email = '[email protected]'
user.save()  # or gl.update_user(user)

user.delete()  # or gl.delete_user(user)


#
# Example usage involving projects
#
project = gl.project(1)  # or gl.get_project(1)
print project.description
project.events(limit=10)

# Adding projects
gl.add_project('my project', description='description', public=True)
gl.add_project_for_user('user_id', 'test project', description='description')

# Branches and tags
branch = project.branch('master')
branch.protect()
project.unprotect_branch('master')
tags = project.tags()

# Members
member = project.add_member('user_id', gitlab3.ACCESS_LEVEL_GUEST)
member.access_level = gitlab3.ACCESS_LEVEL_DEVELOPER
member.save()  # or project.update_member(member)
project.delete_member(member)

# Issues
issues = project.issues(limit=10)
issue = project.add_issue('title', description='description')
issue.add_note('note body')
issue.close()
issue.reopen()

# Snippets
snippet = project.add_snippet('title', 'file_name', 'code')
snippet.delete()  # or project.delete_snippet(snippet)
snippet = project.snippet(1)
snippet_notes = snippet.notes()

# Files and commits
project.commits() # list of commits in master branch
project.files()  # list of files in master branch
project.files(ref_name='other_branch')
readme_contents = project.get_blob('master', 'README')


#
# Example usage involving user teams
#
teams = gl.teams()

team = gl.add_team('team name', 'path')
team.add_member('user_id', gitlab3.ACCESS_LEVEL_GUEST)
team.add_project('project_id', gitlab3.ACCESS_LEVEL_MASTER)


#
# Find function examples
# All objects that can be listed and obtained by an id have find functions.
#
# The find functions are simple, o(n), mostly unoptimized, and will request a
# listing of objects on every call unless given a cached list.
#
gl.find_project(name='python-gitlab3')  # params can be any property of object

projects = gl.projects()
gl.find_project(cached=projects, name='python-gitlab3')
gl.find_project(cached=projects, find_all=True, public=True)  # public projects
gl.find_project(cached=projects, find_all=True,
                public=True, wiki_enabled=True)  # public projects with wikis

gl.find_user(email='[email protected]')

project = gl.project(1)
project.find_member(username='user')

# The GitLab API has support for more efficient searching of projects by name:
gl.find_projects_by_name('name_query')  # Server-side search
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].