@@ -833,6 +833,53 @@ class GroupIssueManager(ListMixin, RESTManager):
833833 _types = {"labels" : types .ListAttribute }
834834
835835
836+ class GroupLabel (SubscribableMixin , SaveMixin , ObjectDeleteMixin , RESTObject ):
837+ _id_attr = "name"
838+
839+ # Update without ID, but we need an ID to get from list.
840+ @exc .on_http_error (exc .GitlabUpdateError )
841+ def save (self , ** kwargs ):
842+ """Saves the changes made to the object to the server.
843+
844+ The object is updated to match what the server returns.
845+
846+ Args:
847+ **kwargs: Extra options to send to the server (e.g. sudo)
848+
849+ Raises:
850+ GitlabAuthenticationError: If authentication is not correct.
851+ GitlabUpdateError: If the server cannot perform the request.
852+ """
853+ updated_data = self ._get_updated_data ()
854+
855+ # call the manager
856+ server_data = self .manager .update (None , updated_data , ** kwargs )
857+ self ._update_attrs (server_data )
858+
859+
860+ class GroupLabelManager (ListMixin , CreateMixin , UpdateMixin , DeleteMixin , RESTManager ):
861+ _path = "/groups/%(group_id)s/labels"
862+ _obj_cls = GroupLabel
863+ _from_parent_attrs = {"group_id" : "id" }
864+ _create_attrs = (("name" , "color" ), ("description" , "priority" ))
865+ _update_attrs = (("name" ,), ("new_name" , "color" , "description" , "priority" ))
866+
867+ # Delete without ID.
868+ @exc .on_http_error (exc .GitlabDeleteError )
869+ def delete (self , name , ** kwargs ):
870+ """Delete a Label on the server.
871+
872+ Args:
873+ name: The name of the label
874+ **kwargs: Extra options to send to the server (e.g. sudo)
875+
876+ Raises:
877+ GitlabAuthenticationError: If authentication is not correct
878+ GitlabDeleteError: If the server cannot perform the request
879+ """
880+ self .gitlab .http_delete (self .path , query_data = {"name" : name }, ** kwargs )
881+
882+
836883class GroupMember (SaveMixin , ObjectDeleteMixin , RESTObject ):
837884 _short_print_attr = "username"
838885
@@ -1042,6 +1089,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
10421089 ("customattributes" , "GroupCustomAttributeManager" ),
10431090 ("epics" , "GroupEpicManager" ),
10441091 ("issues" , "GroupIssueManager" ),
1092+ ("labels" , "GroupLabelManager" ),
10451093 ("members" , "GroupMemberManager" ),
10461094 ("mergerequests" , "GroupMergeRequestManager" ),
10471095 ("milestones" , "GroupMilestoneManager" ),
0 commit comments