@@ -228,6 +228,7 @@ def version(self):
228
228
229
229
return self ._server_version , self ._server_revision
230
230
231
+ @on_http_error (GitlabVerifyError )
231
232
def lint (self , content , ** kwargs ):
232
233
"""Validate a gitlab CI configuration.
233
234
@@ -244,13 +245,10 @@ def lint(self, content, **kwargs):
244
245
otherwise
245
246
"""
246
247
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 )
252
249
return (data ['status' ] == 'valid' , data ['errors' ])
253
250
251
+ @on_http_error (GitlabMarkdownError )
254
252
def markdown (self , text , gfm = False , project = None , ** kwargs ):
255
253
"""Render an arbitrary Markdown document.
256
254
@@ -272,12 +270,43 @@ def markdown(self, text, gfm=False, project=None, **kwargs):
272
270
post_data = {'text' : text , 'gfm' : gfm }
273
271
if project is not None :
274
272
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 )
279
274
return data ['html' ]
280
275
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
+
281
310
def _construct_url (self , id_ , obj , parameters , action = None ):
282
311
if 'next_url' in parameters :
283
312
return parameters ['next_url' ]
0 commit comments