14
14
import gitlab .config
15
15
import gitlab .const
16
16
import gitlab .exceptions
17
- from gitlab import utils
17
+ from gitlab import http_engines , utils
18
18
19
19
REDIRECT_MSG = (
20
20
"python-gitlab detected a {status_code} ({reason!r}) redirection. You must update "
@@ -55,6 +55,11 @@ class Gitlab:
55
55
differs from response headers
56
56
"""
57
57
58
+ # The session object is defined here as long as the RequestsEngine is not
59
+ # fully implemented. The long-term goal is to wrap all the http
60
+ # requests/responses by the RequestsEngine class
61
+ session : requests .Session
62
+
58
63
def __init__ (
59
64
self ,
60
65
url : Optional [str ] = None ,
@@ -66,14 +71,20 @@ def __init__(
66
71
http_password : Optional [str ] = None ,
67
72
timeout : Optional [float ] = None ,
68
73
api_version : str = "4" ,
69
- session : Optional [requests .Session ] = None ,
70
74
per_page : Optional [int ] = None ,
71
75
pagination : Optional [str ] = None ,
72
76
order_by : Optional [str ] = None ,
73
77
user_agent : str = gitlab .const .USER_AGENT ,
74
78
retry_transient_errors : bool = False ,
75
79
keep_base_url : bool = False ,
80
+ ** kwargs : Any ,
76
81
) -> None :
82
+ """
83
+ kwargs:-
84
+ :param requests.Session session: (optional). Http Requests Session.
85
+ :param RequestsEngine http_engine: (optional). Engine that will be used
86
+ to make http requests.
87
+ """
77
88
78
89
self ._api_version = str (api_version )
79
90
self ._server_version : Optional [str ] = None
@@ -98,7 +109,9 @@ def __init__(
98
109
self ._set_auth_info ()
99
110
100
111
#: Create a session object for requests
101
- self .session = session or requests .Session ()
112
+ http_engine = kwargs .pop ("http_engine" , http_engines .DefaultEngine )
113
+ self .http_engine = http_engine (** kwargs )
114
+ self .session = self .http_engine .client
102
115
103
116
self .per_page = per_page
104
117
self .pagination = pagination
0 commit comments