summaryrefslogtreecommitdiff
path: root/gitlab/mixins.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-07-27 16:08:25 -0700
committerJohn L. Villalovos <john@sodarock.com>2022-07-27 16:08:25 -0700
commit1af44ce8761e6ee8a9467a3e192f6c4d19e5cefe (patch)
treeda3116aa356818cb2a865b047de9ef160bbfffa7 /gitlab/mixins.py
parent194ee0100c2868c1a9afb161c15f3145efb01c7c (diff)
downloadgitlab-1af44ce8761e6ee8a9467a3e192f6c4d19e5cefe.tar.gz
fix: use the [] after key names for array variables in `params`
1. If a value is of type ArrayAttribute then append '[]' to the name of the value for query parameters (`params`). This is step 3 in a series of steps of our goal to add full support for the GitLab API data types[1]: * array * hash * array of hashes Step one was: commit 5127b1594c00c7364e9af15e42d2e2f2d909449b Step two was: commit a57334f1930752c70ea15847a39324fa94042460 Fixes: #1698 [1] https://docs.gitlab.com/ee/api/#encoding-api-parameters-of-array-and-hash-types
Diffstat (limited to 'gitlab/mixins.py')
-rw-r--r--gitlab/mixins.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py
index f33a1fc..a48c032 100644
--- a/gitlab/mixins.py
+++ b/gitlab/mixins.py
@@ -238,7 +238,12 @@ class ListMixin(HeadMixin, _RestManagerBase):
GitlabListError: If the server cannot perform the request
"""
- data, _ = utils._transform_types(kwargs, self._types, transform_files=False)
+ data, _ = utils._transform_types(
+ data=kwargs,
+ custom_types=self._types,
+ transform_data=True,
+ transform_files=False,
+ )
if self.gitlab.per_page:
data.setdefault("per_page", self.gitlab.per_page)
@@ -303,7 +308,9 @@ class CreateMixin(_RestManagerBase):
data = {}
self._create_attrs.validate_attrs(data=data)
- data, files = utils._transform_types(data, self._types)
+ data, files = utils._transform_types(
+ data=data, custom_types=self._types, transform_data=False
+ )
# Handle specific URL for creation
path = kwargs.pop("path", self.path)
@@ -370,7 +377,9 @@ class UpdateMixin(_RestManagerBase):
if self._obj_cls is not None and self._obj_cls._id_attr is not None:
excludes = [self._obj_cls._id_attr]
self._update_attrs.validate_attrs(data=new_data, excludes=excludes)
- new_data, files = utils._transform_types(new_data, self._types)
+ new_data, files = utils._transform_types(
+ data=new_data, custom_types=self._types, transform_data=False
+ )
http_method = self._get_update_method()
result = http_method(path, post_data=new_data, files=files, **kwargs)