@@ -345,166 +345,6 @@ user. For example:
345345
346346 p = gl.projects.create({'name': 'awesome_project'}, sudo='user1')
347347
348- Advanced HTTP configuration
349- ===========================
350-
351- python-gitlab relies on ``requests`` ``Session`` objects to perform all the
352- HTTP requests to the Gitlab servers.
353-
354- You can provide your own ``Session`` object with custom configuration when
355- you create a ``Gitlab`` object.
356-
357- Context manager
358- ---------------
359-
360- You can use ``Gitlab`` objects as context managers. This makes sure that the
361- ``requests.Session`` object associated with a ``Gitlab`` instance is always
362- properly closed when you exit a ``with`` block:
363-
364- .. code-block:: python
365-
366- with gitlab.Gitlab(host, token) as gl:
367- gl.projects.list()
368-
369- .. warning::
370-
371- The context manager will also close the custom ``Session`` object you might
372- have used to build the ``Gitlab`` instance.
373-
374- Proxy configuration
375- -------------------
376-
377- The following sample illustrates how to define a proxy configuration when using
378- python-gitlab:
379-
380- .. code-block:: python
381-
382- import os
383- import gitlab
384- import requests
385-
386- session = requests.Session()
387- session.proxies = {
388- 'https': os.environ.get('https_proxy'),
389- 'http': os.environ.get('http_proxy'),
390- }
391- gl = gitlab.gitlab(url, token, api_version=4, session=session)
392-
393- Reference:
394- https://requests.readthedocs.io/en/latest/user/advanced/#proxies
395-
396- SSL certificate verification
397- ----------------------------
398-
399- python-gitlab relies on the CA certificate bundle in the `certifi` package
400- that comes with the requests library.
401-
402- If you need python-gitlab to use your system CA store instead, you can provide
403- the path to the CA bundle in the `REQUESTS_CA_BUNDLE` environment variable.
404-
405- Reference:
406- https://requests.readthedocs.io/en/latest/user/advanced/#ssl-cert-verification
407-
408- Client side certificate
409- -----------------------
410-
411- The following sample illustrates how to use a client-side certificate:
412-
413- .. code-block:: python
414-
415- import gitlab
416- import requests
417-
418- session = requests.Session()
419- session.cert = ('/path/to/client.cert', '/path/to/client.key')
420- gl = gitlab.gitlab(url, token, api_version=4, session=session)
421-
422- Reference:
423- https://requests.readthedocs.io/en/latest/user/advanced/#client-side-certificates
424-
425- Rate limits
426- -----------
427-
428- python-gitlab obeys the rate limit of the GitLab server by default. On
429- receiving a 429 response (Too Many Requests), python-gitlab sleeps for the
430- amount of time in the Retry-After header that GitLab sends back. If GitLab
431- does not return a response with the Retry-After header, python-gitlab will
432- perform an exponential backoff.
433-
434- If you don't want to wait, you can disable the rate-limiting feature, by
435- supplying the ``obey_rate_limit`` argument.
436-
437- .. code-block:: python
438-
439- import gitlab
440- import requests
441-
442- gl = gitlab.gitlab(url, token, api_version=4)
443- gl.projects.list(all=True, obey_rate_limit=False)
444-
445- If you do not disable the rate-limiting feature, you can supply a custom value
446- for ``max_retries``; by default, this is set to 10. To retry without bound when
447- throttled, you can set this parameter to -1. This parameter is ignored if
448- ``obey_rate_limit`` is set to ``False``.
449-
450- .. code-block:: python
451-
452- import gitlab
453- import requests
454-
455- gl = gitlab.gitlab(url, token, api_version=4)
456- gl.projects.list(all=True, max_retries=12)
457-
458- .. warning::
459-
460- You will get an Exception, if you then go over the rate limit of your GitLab instance.
461-
462- Transient errors
463- ----------------
464-
465- GitLab server can sometimes return a transient HTTP error.
466- python-gitlab can automatically retry in such case, when
467- ``retry_transient_errors`` argument is set to ``True``. When enabled,
468- HTTP error codes 500 (Internal Server Error), 502 (502 Bad Gateway),
469- 503 (Service Unavailable), and 504 (Gateway Timeout) are retried. It will retry until reaching
470- the `max_retries` value. By default, `retry_transient_errors` is set to `False` and an exception
471- is raised for these errors.
472-
473- .. code-block:: python
474-
475- import gitlab
476- import requests
477-
478- gl = gitlab.gitlab(url, token, api_version=4)
479- gl.projects.list(all=True, retry_transient_errors=True)
480-
481- The default ``retry_transient_errors`` can also be set on the ``Gitlab`` object
482- and overridden by individual API calls.
483-
484- .. code-block:: python
485-
486- import gitlab
487- import requests
488- gl = gitlab.gitlab(url, token, api_version=4, retry_transient_errors=True)
489- gl.projects.list(all=True) # retries due to default value
490- gl.projects.list(all=True, retry_transient_errors=False) # does not retry
491-
492- Timeout
493- -------
494-
495- python-gitlab will by default use the ``timeout`` option from it's configuration
496- for all requests. This is passed downwards to the ``requests`` module at the
497- time of making the HTTP request. However if you would like to override the
498- global timeout parameter for a particular call, you can provide the ``timeout``
499- parameter to that API invocation:
500-
501- .. code-block:: python
502-
503- import gitlab
504-
505- gl = gitlab.gitlab(url, token, api_version=4)
506- gl.projects.import_github(ACCESS_TOKEN, 123456, "root", timeout=120.0)
507-
508348.. _object_attributes:
509349
510350Attributes in updated objects
0 commit comments