@@ -833,6 +833,64 @@ 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+ # Update without ID.
868+ def update (self , name , new_data = {}, ** kwargs ):
869+ """Update a Label on the server.
870+
871+ Args:
872+ name: The name of the label
873+ **kwargs: Extra options to send to the server (e.g. sudo)
874+ """
875+ new_data ["name" ] = name
876+ super ().update (id = None , new_data = new_data , ** kwargs )
877+
878+ # Delete without ID.
879+ @exc .on_http_error (exc .GitlabDeleteError )
880+ def delete (self , name , ** kwargs ):
881+ """Delete a Label on the server.
882+
883+ Args:
884+ name: The name of the label
885+ **kwargs: Extra options to send to the server (e.g. sudo)
886+
887+ Raises:
888+ GitlabAuthenticationError: If authentication is not correct
889+ GitlabDeleteError: If the server cannot perform the request
890+ """
891+ self .gitlab .http_delete (self .path , query_data = {"name" : name }, ** kwargs )
892+
893+
836894class GroupMember (SaveMixin , ObjectDeleteMixin , RESTObject ):
837895 _short_print_attr = "username"
838896
@@ -1042,6 +1100,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
10421100 ("customattributes" , "GroupCustomAttributeManager" ),
10431101 ("epics" , "GroupEpicManager" ),
10441102 ("issues" , "GroupIssueManager" ),
1103+ ("labels" , "GroupLabelManager" ),
10451104 ("members" , "GroupMemberManager" ),
10461105 ("mergerequests" , "GroupMergeRequestManager" ),
10471106 ("milestones" , "GroupMilestoneManager" ),
@@ -2934,6 +2993,17 @@ class ProjectLabelManager(
29342993 _create_attrs = (("name" , "color" ), ("description" , "priority" ))
29352994 _update_attrs = (("name" ,), ("new_name" , "color" , "description" , "priority" ))
29362995
2996+ # Update without ID.
2997+ def update (self , name , new_data = {}, ** kwargs ):
2998+ """Update a Label on the server.
2999+
3000+ Args:
3001+ name: The name of the label
3002+ **kwargs: Extra options to send to the server (e.g. sudo)
3003+ """
3004+ new_data ["name" ] = name
3005+ super ().update (id = None , new_data = new_data , ** kwargs )
3006+
29373007 # Delete without ID.
29383008 @exc .on_http_error (exc .GitlabDeleteError )
29393009 def delete (self , name , ** kwargs ):
0 commit comments