diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2019-01-13 13:12:17 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2019-01-13 17:20:34 +0100 |
commit | 4bd027aac41c41f7e22af93c7be0058d2faf7fb4 (patch) | |
tree | 314b738f699f5138d91b79841a53bd17f0e62cc5 /gitlab/__init__.py | |
parent | 89679ce5ee502e57dbe7cec2b78f4f70b85fd3a5 (diff) | |
download | gitlab-no-param-conflicts.tar.gz |
fix(api): avoid parameter conflicts with python and gitlabno-param-conflicts
Provide another way to send data to gitlab with a new `query_parameters`
argument. This parameter can be used to explicitly define the dict of
items to send to the server, so that **kwargs are only used to specify
python-gitlab specific parameters.
Closes #566
Closes #629
Diffstat (limited to 'gitlab/__init__.py')
-rw-r--r-- | gitlab/__init__.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index c280974..4f00603 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -445,7 +445,20 @@ class Gitlab(object): params = {} utils.copy_dict(params, query_data) - utils.copy_dict(params, kwargs) + + # Deal with kwargs: by default a user uses kwargs to send data to the + # gitlab server, but this generates problems (python keyword conflicts + # and python-gitlab/gitlab conflicts). + # So we provide a `query_parameters` key: if it's there we use its dict + # value as arguments for the gitlab server, and ignore the other + # arguments, except pagination ones (per_page and page) + if 'query_parameters' in kwargs: + utils.copy_dict(params, kwargs['query_parameters']) + for arg in ('per_page', 'page'): + if arg in kwargs: + params[arg] = kwargs[arg] + else: + utils.copy_dict(params, kwargs) opts = self._get_session_opts(content_type='application/json') |