| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 89679ce commit 4bd027a
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,25 @@ Release notes | |||
| 4 | 4 | ||
| 5 | 5 | This page describes important changes between python-gitlab releases. | |
| 6 | 6 | ||
| 7 | + Changes from 1.7 to 1.8 | ||
| 8 | + ======================= | ||
| 9 | + | ||
| 10 | + * You can now use the ``query_parameters`` argument in method calls to define | ||
| 11 | + arguments to send to the GitLab server. This allows to avoid conflicts | ||
| 12 | + between python-gitlab and GitLab server variables, and allows to use the | ||
| 13 | + python reserved keywords as GitLab arguments. | ||
| 14 | + | ||
| 15 | + The following examples make the same GitLab request with the 2 syntaxes:: | ||
| 16 | + | ||
| 17 | + projects = gl.projects.list(owned=True, starred=True) | ||
| 18 | + projects = gl.projects.list(query_parameters={'owned': True, 'starred': True}) | ||
| 19 | + | ||
| 20 | + The following example only works with the new parameter:: | ||
| 21 | + | ||
| 22 | + activities = gl.user_activities.list( | ||
| 23 | + query_parameters={'from': '2019-01-01'}, | ||
| 24 | + all=True) | ||
| 25 | + | ||
| 7 | 26 | Changes from 1.5 to 1.6 | |
| 8 | 27 | ======================= | |
| 9 | 28 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -118,6 +118,25 @@ Some objects also provide managers to access related GitLab resources: | |||
| 118 | 118 | project = gl.projects.get(1) | |
| 119 | 119 | issues = project.issues.list() | |
| 120 | 120 | ||
| 121 | + python-gitlab allows to send any data to the GitLab server when making queries. | ||
| 122 | + In case of invalid or missing arguments python-gitlab will raise an exception | ||
| 123 | + with the GitLab server error message: | ||
| 124 | + | ||
| 125 | + .. code-block:: python | ||
| 126 | + | ||
| 127 | + >>> gl.projects.list(sort='invalid value') | ||
| 128 | + ... | ||
| 129 | + GitlabListError: 400: sort does not have a valid value | ||
| 130 | + | ||
| 131 | + You can use the ``query_parameters`` argument to send arguments that would | ||
| 132 | + conflict with python or python-gitlab when using them as kwargs: | ||
| 133 | + | ||
| 134 | + .. code-block:: python | ||
| 135 | + | ||
| 136 | + gl.user_activities.list(from='2019-01-01') ## invalid | ||
| 137 | + | ||
| 138 | + gl.user_activities.list(query_parameters={'from': '2019-01-01'}) # OK | ||
| 139 | + | ||
| 121 | 140 | Gitlab Objects | |
| 122 | 141 | ============== | |
| 123 | 142 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,14 @@ results:: | |||
| 27 | 27 | commits = project.commits.list(ref_name='my_branch') | |
| 28 | 28 | commits = project.commits.list(since='2016-01-01T00:00:00Z') | |
| 29 | 29 | ||
| 30 | + .. note:: | ||
| 31 | + | ||
| 32 | + The available ``all`` listing argument conflicts with the python-gitlab | ||
| 33 | + argument. Use ``query_parameters`` to avoid the conflict:: | ||
| 34 | + | ||
| 35 | + commits = project.commits.list(all=True, | ||
| 36 | + query_parameters={'ref_name': 'my_branch'}) | ||
| 37 | + | ||
| 30 | 38 | Create a commit:: | |
| 31 | 39 | ||
| 32 | 40 | # See https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -312,4 +312,6 @@ Examples | |||
| 312 | 312 | ||
| 313 | 313 | Get the users activities:: | |
| 314 | 314 | ||
| 315 | - activities = gl.user_activities.list(all=True, as_list=False) | ||
| 315 | + activities = gl.user_activities.list( | ||
| 316 | + query_parameters={'from': '2018-07-01'}, | ||
| 317 | + all=True, as_list=False) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -445,7 +445,20 @@ def http_request(self, verb, path, query_data={}, post_data=None, | |||
| 445 | 445 | ||
| 446 | 446 | params = {} | |
| 447 | 447 | utils.copy_dict(params, query_data) | |
| 448 | - utils.copy_dict(params, kwargs) | ||
| 448 | + | ||
| 449 | + # Deal with kwargs: by default a user uses kwargs to send data to the | ||
| 450 | + # gitlab server, but this generates problems (python keyword conflicts | ||
| 451 | + # and python-gitlab/gitlab conflicts). | ||
| 452 | + # So we provide a `query_parameters` key: if it's there we use its dict | ||
| 453 | + # value as arguments for the gitlab server, and ignore the other | ||
| 454 | + # arguments, except pagination ones (per_page and page) | ||
| 455 | + if 'query_parameters' in kwargs: | ||
| 456 | + utils.copy_dict(params, kwargs['query_parameters']) | ||
| 457 | + for arg in ('per_page', 'page'): | ||
| 458 | + if arg in kwargs: | ||
| 459 | + params[arg] = kwargs[arg] | ||
| 460 | + else: | ||
| 461 | + utils.copy_dict(params, kwargs) | ||
| 449 | 462 | ||
| 450 | 463 | opts = self._get_session_opts(content_type='application/json') | |
| 451 | 464 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -773,7 +773,7 @@ | |||
| 773 | 773 | assert(len(snippets) == 0) | |
| 774 | 774 | ||
| 775 | 775 | # user activities | |
| 776 | - gl.user_activities.list() | ||
| 776 | + gl.user_activities.list(query_parameters={'from': '2019-01-01'}) | ||
| 777 | 777 | ||
| 778 | 778 | # events | |
| 779 | 779 | gl.events.list() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments