@@ -228,6 +228,7 @@ def version(self):
228228
229229 return self ._server_version , self ._server_revision
230230
231+ @on_http_error (GitlabVerifyError )
231232 def lint (self , content , ** kwargs ):
232233 """Validate a gitlab CI configuration.
233234
@@ -244,13 +245,10 @@ def lint(self, content, **kwargs):
244245 otherwise
245246 """
246247 post_data = {'content' : content }
247- try :
248- data = self .http_post ('/ci/lint' , post_data = post_data , ** kwargs )
249- except Exception :
250- raise GitlabVerifyError
251-
248+ data = self .http_post ('/ci/lint' , post_data = post_data , ** kwargs )
252249 return (data ['status' ] == 'valid' , data ['errors' ])
253250
251+ @on_http_error (GitlabMarkdownError )
254252 def markdown (self , text , gfm = False , project = None , ** kwargs ):
255253 """Render an arbitrary Markdown document.
256254
@@ -272,12 +270,43 @@ def markdown(self, text, gfm=False, project=None, **kwargs):
272270 post_data = {'text' : text , 'gfm' : gfm }
273271 if project is not None :
274272 post_data ['project' ] = project
275- try :
276- data = self .http_post ('/markdown' , post_data = post_data , ** kwargs )
277- except Exception :
278- raise GitlabMarkdownError
273+ data = self .http_post ('/markdown' , post_data = post_data , ** kwargs )
279274 return data ['html' ]
280275
276+ @on_http_error (GitlabLicenseError )
277+ def get_license (self , ** kwargs ):
278+ """Retrieve information about the current license.
279+
280+ Args:
281+ **kwargs: Extra options to send to the server (e.g. sudo)
282+
283+ Raises:
284+ GitlabAuthenticationError: If authentication is not correct
285+ GitlabGetError: If the server cannot perform the request
286+
287+ Returns:
288+ dict: The current license information
289+ """
290+ return self .http_get ('/license' , ** kwargs )
291+
292+ @on_http_error (GitlabLicenseError )
293+ def set_license (self , license , ** kwargs ):
294+ """Add a new license.
295+
296+ Args:
297+ license (str): The license string
298+ **kwargs: Extra options to send to the server (e.g. sudo)
299+
300+ Raises:
301+ GitlabAuthenticationError: If authentication is not correct
302+ GitlabPostError: If the server cannot perform the request
303+
304+ Returns:
305+ dict: The new license information
306+ """
307+ data = {'license' : license }
308+ return self .http_post ('/license' , post_data = data , ** kwargs )
309+
281310 def _construct_url (self , id_ , obj , parameters , action = None ):
282311 if 'next_url' in parameters :
283312 return parameters ['next_url' ]
0 commit comments