@@ -69,9 +69,10 @@ class Gitlab(object):
6969
7070 def __init__ (self , url , private_token = None , email = None , password = None ,
7171 ssl_verify = True , http_username = None , http_password = None ,
72- timeout = None ):
72+ timeout = None , api_version = '3' ):
7373
74- self ._url = '%s/api/v3' % url
74+ self ._api_version = str (api_version )
75+ self ._url = '%s/api/v%s' % (url , api_version )
7576 #: Timeout to use for requests to gitlab server
7677 self .timeout = timeout
7778 #: Headers that will be used in request to GitLab
@@ -152,7 +153,8 @@ def from_config(gitlab_id=None, config_files=None):
152153 return Gitlab (config .url , private_token = config .token ,
153154 ssl_verify = config .ssl_verify , timeout = config .timeout ,
154155 http_username = config .http_username ,
155- http_password = config .http_password )
156+ http_password = config .http_password ,
157+ api_version = config .api_version )
156158
157159 def auth (self ):
158160 """Performs an authentication.
@@ -212,7 +214,7 @@ def set_url(self, url):
212214 Args:
213215 url (str): Base URL of the GitLab server.
214216 """
215- self ._url = '%s/api/v3 ' % url
217+ self ._url = '%s/api/v%s ' % ( url , self . _api_version )
216218
217219 def _construct_url (self , id_ , obj , parameters , action = None ):
218220 if 'next_url' in parameters :
0 commit comments