From 1af44ce8761e6ee8a9467a3e192f6c4d19e5cefe Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Wed, 27 Jul 2022 16:08:25 -0700 Subject: 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 --- gitlab/mixins.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'gitlab/mixins.py') 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) -- cgit v1.2.1