summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2017-05-20 10:24:08 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2017-05-23 15:41:54 +0200
commitc02dabd25507a14d666e85c7f1ea7831c64d0394 (patch)
treeb44597e02ee6811764b54ae123f315caee007969 /gitlab
parentce3dd0d1ac3fbed3cf671720e273470fb1ccdbc6 (diff)
downloadgitlab-c02dabd25507a14d666e85c7f1ea7831c64d0394.tar.gz
Initial, non-functional v4 support
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/__init__.py10
-rw-r--r--gitlab/config.py9
2 files changed, 15 insertions, 4 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 1db03b0..edefd89 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -69,9 +69,10 @@ class Gitlab(object):
def __init__(self, url, private_token=None, email=None, password=None,
ssl_verify=True, http_username=None, http_password=None,
- timeout=None):
+ timeout=None, api_version='3'):
- self._url = '%s/api/v3' % url
+ self._api_version = str(api_version)
+ self._url = '%s/api/v%s' % (url, api_version)
#: Timeout to use for requests to gitlab server
self.timeout = timeout
#: Headers that will be used in request to GitLab
@@ -152,7 +153,8 @@ class Gitlab(object):
return Gitlab(config.url, private_token=config.token,
ssl_verify=config.ssl_verify, timeout=config.timeout,
http_username=config.http_username,
- http_password=config.http_password)
+ http_password=config.http_password,
+ api_version=config.api_version)
def auth(self):
"""Performs an authentication.
@@ -212,7 +214,7 @@ class Gitlab(object):
Args:
url (str): Base URL of the GitLab server.
"""
- self._url = '%s/api/v3' % url
+ self._url = '%s/api/v%s' % (url, self._api_version)
def _construct_url(self, id_, obj, parameters, action=None):
if 'next_url' in parameters:
diff --git a/gitlab/config.py b/gitlab/config.py
index 3ef2efb..9af804d 100644
--- a/gitlab/config.py
+++ b/gitlab/config.py
@@ -88,3 +88,12 @@ class GitlabConfigParser(object):
'http_password')
except Exception:
pass
+
+ self.api_version = '3'
+ try:
+ self.api_version = self._config.get(self.gitlab_id, 'api_version')
+ except Exception:
+ pass
+ if self.api_version not in ('3', '4'):
+ raise GitlabDataError("Unsupported API version: %s" %
+ self.api_version)