@@ -926,3 +926,50 @@ def render(self, link_url: str, image_url: str, **kwargs: Any) -> Dict[str, Any]
926926 if TYPE_CHECKING :
927927 assert not isinstance (result , requests .Response )
928928 return result
929+
930+
931+ class PromoteMixin (_RestObjectBase ):
932+ _id_attr : Optional [str ]
933+ _attrs : Dict [str , Any ]
934+ _module : ModuleType
935+ _parent_attrs : Dict [str , Any ]
936+ _updated_attrs : Dict [str , Any ]
937+ _update_uses_post : bool = False
938+ manager : base .RESTManager
939+
940+ def _get_update_method (
941+ self ,
942+ ) -> Callable [..., Union [Dict [str , Any ], requests .Response ]]:
943+ """Return the HTTP method to use.
944+
945+ Returns:
946+ object: http_put (default) or http_post
947+ """
948+ if self ._update_uses_post :
949+ http_method = self .manager .gitlab .http_post
950+ else :
951+ http_method = self .manager .gitlab .http_put
952+ return http_method
953+
954+ @exc .on_http_error (exc .GitlabPromoteError )
955+ def promote (self , ** kwargs : Any ) -> Dict [str , Any ]:
956+ """Promote the item.
957+
958+ Args:
959+ **kwargs: Extra options to send to the server (e.g. sudo)
960+
961+ Raises:
962+ GitlabAuthenticationError: If authentication is not correct
963+ GitlabPromoteError: If the item could not be promoted
964+ GitlabParsingError: If the json data could not be parsed
965+
966+ Returns:
967+ dict: The updated object data (*not* a RESTObject)
968+ """
969+
970+ path = "%s/%s/promote" % (self .manager .path , self .id )
971+ http_method = self ._get_update_method ()
972+ result = http_method (path , ** kwargs )
973+ if TYPE_CHECKING :
974+ assert not isinstance (result , requests .Response )
975+ return result
0 commit comments