@@ -74,7 +74,7 @@ class GitlabAuthenticationError(Exception):
74
74
75
75
class Gitlab (object ):
76
76
"""Represents a GitLab server connection"""
77
- def __init__ (self , url , private_token = None , email = None , password = None ):
77
+ def __init__ (self , url , private_token = None , email = None , password = None , ssl_verify = True ):
78
78
"""Stores informations about the server
79
79
80
80
url: the URL of the Gitlab server
@@ -86,6 +86,7 @@ def __init__(self, url, private_token=None, email=None, password=None):
86
86
self .private_token = private_token
87
87
self .email = email
88
88
self .password = password
89
+ self .ssl_verify = ssl_verify
89
90
90
91
def auth (self ):
91
92
"""Performs an authentication using either the private token, or the
@@ -139,7 +140,7 @@ def rawGet(self, path, with_token=False):
139
140
url += "?private_token=%s" % self .private_token
140
141
141
142
try :
142
- r = requests .get (url )
143
+ r = requests .get (url , verify = self . ssl_verify )
143
144
except :
144
145
raise GitlabConnectionError (
145
146
"Can't connect to GitLab server (%s)" % self ._url )
@@ -149,7 +150,7 @@ def rawGet(self, path, with_token=False):
149
150
def rawPost (self , path , data ):
150
151
url = '%s%s' % (self ._url , path )
151
152
try :
152
- r = requests .post (url , data )
153
+ r = requests .post (url , data , verify = self . ssl_verify )
153
154
except :
154
155
raise GitlabConnectionError (
155
156
"Can't connect to GitLab server (%s)" % self ._url )
@@ -162,7 +163,7 @@ def rawPut(self, path, with_token=False):
162
163
url += "?private_token=%s" % self .private_token
163
164
164
165
try :
165
- r = requests .put (url )
166
+ r = requests .put (url , verify = self . ssl_verify )
166
167
except :
167
168
raise GitlabConnectionError (
168
169
"Can't connect to GitLab server (%s)" % self ._url )
@@ -187,7 +188,7 @@ def list(self, obj_class, **kwargs):
187
188
["%s=%s" % (k , v ) for k , v in kwargs .items ()]))
188
189
189
190
try :
190
- r = requests .get (url )
191
+ r = requests .get (url , verify = self . ssl_verify )
191
192
except :
192
193
raise GitlabConnectionError (
193
194
"Can't connect to GitLab server (%s)" % self ._url )
@@ -233,7 +234,7 @@ def get(self, obj_class, id=None, **kwargs):
233
234
(self ._url , url , self .private_token )
234
235
235
236
try :
236
- r = requests .get (url )
237
+ r = requests .get (url , verify = self . ssl_verify )
237
238
except :
238
239
raise GitlabConnectionError (
239
240
"Can't connect to GitLab server (%s)" % self ._url )
@@ -253,7 +254,7 @@ def delete(self, obj):
253
254
(self ._url , url , obj .id , self .private_token )
254
255
255
256
try :
256
- r = requests .delete (url )
257
+ r = requests .delete (url , verify = self . ssl_verify )
257
258
except :
258
259
raise GitlabConnectionError (
259
260
"Can't connect to GitLab server (%s)" % self ._url )
@@ -281,7 +282,7 @@ def create(self, obj):
281
282
try :
282
283
# TODO: avoid too much work on the server side by filtering the
283
284
# __dict__ keys
284
- r = requests .post (url , obj .__dict__ )
285
+ r = requests .post (url , obj .__dict__ , verify = self . ssl_verify )
285
286
except :
286
287
raise GitlabConnectionError (
287
288
"Can't connect to GitLab server (%s)" % self ._url )
@@ -305,7 +306,7 @@ def update(self, obj):
305
306
d [k ] = str (v )
306
307
307
308
try :
308
- r = requests .put (url , d )
309
+ r = requests .put (url , d , verify = self . ssl_verify )
309
310
except :
310
311
raise GitlabConnectionError (
311
312
"Can't connect to GitLab server (%s)" % self ._url )
0 commit comments