Labels

Use ProjectLabel objects to manipulate labels for projects. The gitlab.Gitlab.project_labels and Project.labels manager objects provide helper functions.

Examples

List labels for a project:

labels = gl.project_labels.list(project_id=1)
# or
labels = project.labels.list()

Get a single label:

label = gl.project_labels.get(label_name, project_id=1)
# or
label = project.labels.get(label_name)

Create a label for a project:

label = gl.project_labels.create({'name': 'foo', 'color': '#8899aa'},
                                 project_id=1)
# or
label = project.labels.create({'name': 'foo', 'color': '#8899aa'})

Update a label for a project:

# change the name of the label:
label.new_name = 'bar'
label.save()
# change its color:
label.color = '#112233'
label.save()

Delete a label for a project:

gl.project_labels.delete(label_id, project_id=1)
# or
project.labels.delete(label_id)
# or
label.delete()