@@ -75,6 +75,8 @@ class Gitlab:
75
75
or 52x responses. Defaults to False.
76
76
keep_base_url: keep user-provided base URL for pagination if it
77
77
differs from response headers
78
+ tls_client_cert: provide client TLS certificate
79
+ tls_client_key: provide client TLS key
78
80
79
81
Keyword Args:
80
82
requests.Session session: HTTP Requests Session
@@ -98,6 +100,8 @@ def __init__(
98
100
user_agent : str = gitlab .const .USER_AGENT ,
99
101
retry_transient_errors : bool = False ,
100
102
keep_base_url : bool = False ,
103
+ tls_client_cert : Optiona [str ] = None ,
104
+ tls_client_key : Optiona [str ] = None ,
101
105
** kwargs : Any ,
102
106
) -> None :
103
107
self ._api_version = str (api_version )
@@ -109,6 +113,7 @@ def __init__(
109
113
self .timeout = timeout
110
114
self .retry_transient_errors = retry_transient_errors
111
115
self .keep_base_url = keep_base_url
116
+
112
117
#: Headers that will be used in request to GitLab
113
118
self .headers = {"User-Agent" : user_agent }
114
119
@@ -129,6 +134,13 @@ def __init__(
129
134
self ._backend = _backend (** kwargs )
130
135
self .session = self ._backend .client
131
136
137
+ if tls_client_cert and tls_client_key :
138
+ self .session .cert = (tls_client_cert , tls_client_key )
139
+ elif tls_client_cert or tls_client_key :
140
+ raise ValueError (
141
+ "tls_client_cert and tls_client_key must be provided together"
142
+ )
143
+
132
144
self .per_page = per_page
133
145
self .pagination = pagination
134
146
self .order_by = order_by
@@ -304,6 +316,8 @@ def from_config(
304
316
user_agent = config .user_agent ,
305
317
retry_transient_errors = config .retry_transient_errors ,
306
318
keep_base_url = config .keep_base_url ,
319
+ tls_client_cert = config .tls_client_cert ,
320
+ tls_client_key = config .tls_client_key ,
307
321
** kwargs ,
308
322
)
309
323
@@ -360,6 +374,9 @@ def merge_config(
360
374
pagination = options .get ("pagination" ) or config .pagination ,
361
375
order_by = options .get ("order_by" ) or config .order_by ,
362
376
user_agent = options .get ("user_agent" ) or config .user_agent ,
377
+ keep_base_url = config .keep_base_url ,
378
+ tls_client_cert = config .tls_client_cert ,
379
+ tls_client_key = config .tls_client_key ,
363
380
)
364
381
365
382
@staticmethod
0 commit comments