Skip to content

Commit 1b5d480

Browse files
author
Gauvain Pocentek
committed
Document the Gitlab session parameter
Provide a proxy setup example. Closes #341
1 parent b23e344 commit 1b5d480

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/api-usage.rst

+24
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,27 @@ user. For example:
234234
.. code-block:: python
235235
236236
p = gl.projects.create({'name': 'awesome_project'}, sudo='user1')
237+
238+
Advanced HTTP configuration
239+
===========================
240+
241+
python-gitlab relies on ``requests`` ``Session`` objects to perform all the
242+
HTTP requests to the Gitlab servers.
243+
244+
You can provide your own ``Session`` object with custom configuration when
245+
you create a ``Gitlab`` object.
246+
247+
The following sample illustrates how to define a proxy configuration when using
248+
python-gitlab:
249+
250+
.. code-block:: python
251+
252+
import gitlab
253+
import requests
254+
255+
session = requests.Session()
256+
session.proxies = {
257+
'https': os.environ.get('https_proxy'),
258+
'http': os.environ.get('http_proxy'),
259+
}
260+
gl = gitlab.gitlab(url, token, api_version=4, session=session)

0 commit comments

Comments
 (0)