diff --git a/docs/api-usage.rst b/docs/api-usage.rst index 764f29467..2a40cfa19 100644 --- a/docs/api-usage.rst +++ b/docs/api-usage.rst @@ -26,6 +26,9 @@ To connect to a GitLab server, create a ``gitlab.Gitlab`` object: # anonymous gitlab instance, read-only for public resources gl = gitlab.Gitlab('http://10.0.0.1') + # Define your own custom user agent for requests + gl = gitlab.Gitlab('http://10.0.0.1', user_agent='my-package/1.0.0') + # make an API request to create the gl.user object. This is mandatory if you # use the username/password authentication. gl.auth() diff --git a/docs/cli-usage.rst b/docs/cli-usage.rst index 21a4baf69..1c24824c8 100644 --- a/docs/cli-usage.rst +++ b/docs/cli-usage.rst @@ -78,6 +78,9 @@ parameters. You can override the values in each GitLab server section. - Integer between 1 and 100 - The number of items to return in listing queries. GitLab limits the value at 100. + * - ``user_agent`` + - ``str`` + - A string defining a custom user agent to use when ``gitlab`` makes requests. You must define the ``url`` in each GitLab server section. diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 5cdcef278..a9cbf8901 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -65,6 +65,7 @@ class Gitlab(object): api_version (str): Gitlab API version to use (support for 4 only) pagination (str): Can be set to 'keyset' to use keyset pagination order_by (str): Set order_by globally + user_agent (str): A custom user agent to use for making HTTP requests. """ def __init__(