| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4fd00f8 commit 31882b8
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,7 @@ API objects manipulation | |||
| 12 | 12 | gl_objects/environments | |
| 13 | 13 | gl_objects/groups | |
| 14 | 14 | gl_objects/issues | |
| 15 | + gl_objects/labels | ||
| 15 | 16 | gl_objects/namespaces | |
| 16 | 17 | gl_objects/projects | |
| 17 | 18 | gl_objects/runners | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,35 @@ | |||
| 1 | + # list | ||
| 2 | + labels = gl.project_labels.list(project_id=1) | ||
| 3 | + # or | ||
| 4 | + labels = project.labels.list() | ||
| 5 | + # end list | ||
| 6 | + | ||
| 7 | + # get | ||
| 8 | + label = gl.project_labels.get(label_name, project_id=1) | ||
| 9 | + # or | ||
| 10 | + label = project.labels.get(label_name) | ||
| 11 | + # end get | ||
| 12 | + | ||
| 13 | + # create | ||
| 14 | + label = gl.project_labels.create({'name': 'foo', 'color': '#8899aa'}, | ||
| 15 | + project_id=1) | ||
| 16 | + # or | ||
| 17 | + label = project.labels.create({'name': 'foo', 'color': '#8899aa'}) | ||
| 18 | + # end create | ||
| 19 | + | ||
| 20 | + # update | ||
| 21 | + # change the name of the label: | ||
| 22 | + label.new_name = 'bar' | ||
| 23 | + label.save() | ||
| 24 | + # change its color: | ||
| 25 | + label.color = '#112233' | ||
| 26 | + label.save() | ||
| 27 | + # end update | ||
| 28 | + | ||
| 29 | + # delete | ||
| 30 | + gl.project_labels.delete(label_id, project_id=1) | ||
| 31 | + # or | ||
| 32 | + project.labels.list(label_id) | ||
| 33 | + # or | ||
| 34 | + label.delete() | ||
| 35 | + # end delete | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,40 @@ | |||
| 1 | + ###### | ||
| 2 | + Labels | ||
| 3 | + ###### | ||
| 4 | + | ||
| 5 | + Use :class:`~gitlab.objects.ProjectLabel` objects to manipulate labels for | ||
| 6 | + projects. The :attr:`gitlab.Gitlab.project_labels` and :attr:`Project.labels | ||
| 7 | + <gitlab.objects.Project.labels>` manager objects provide helper functions. | ||
| 8 | + | ||
| 9 | + Examples | ||
| 10 | + -------- | ||
| 11 | + | ||
| 12 | + List labels for a project: | ||
| 13 | + | ||
| 14 | + .. literalinclude:: labels.py | ||
| 15 | + :start-after: # list | ||
| 16 | + :end-before: # end list | ||
| 17 | + | ||
| 18 | + Get a single label: | ||
| 19 | + | ||
| 20 | + .. literalinclude:: labels.py | ||
| 21 | + :start-after: # get | ||
| 22 | + :end-before: # end get | ||
| 23 | + | ||
| 24 | + Create a label for a project: | ||
| 25 | + | ||
| 26 | + .. literalinclude:: labels.py | ||
| 27 | + :start-after: # create | ||
| 28 | + :end-before: # end create | ||
| 29 | + | ||
| 30 | + Update a label for a project: | ||
| 31 | + | ||
| 32 | + .. literalinclude:: labels.py | ||
| 33 | + :start-after: # update | ||
| 34 | + :end-before: # end update | ||
| 35 | + | ||
| 36 | + Delete a label for a project: | ||
| 37 | + | ||
| 38 | + .. literalinclude:: labels.py | ||
| 39 | + :start-after: # delete | ||
| 40 | + :end-before: # end delete | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments