summaryrefslogtreecommitdiff
path: root/gitlab/mixins.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-01-22 10:47:43 -0800
committerJohn L. Villalovos <john@sodarock.com>2022-01-22 10:47:43 -0800
commit1905548ec251c88bb6a2b6677940dac9c1ab7167 (patch)
tree749471d43b6a8297727c8209330c95a7d3ae0d6a /gitlab/mixins.py
parent8dfed0c362af2c5e936011fd0b488b8b05e8a8a0 (diff)
downloadgitlab-jlvillal/arrays.tar.gz
fix: use the [] after key names for array variablesjlvillal/arrays
1. Create a new CommaSeparatedListAttribute class. This is to indicate types which are sent to the GitLab server as comma-separated-strings (CSV) but we have been allowing users to use a list-of-strings. These values are NOT array values, so adding [] to the key name breaks them. 2. Rename ListAttribute to ArrayAttribute. 3. If a value is of type ArrayAttribute then append '[]' to the name of the value. 4. Move processing of most GitlabAttributes into the client.py:http_request() method. Now we convert our params into a list of tuples so that we can have multiple identical keys but with different values. Fixes: #1698
Diffstat (limited to 'gitlab/mixins.py')
-rw-r--r--gitlab/mixins.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py
index d66b2eb..9f75b54 100644
--- a/gitlab/mixins.py
+++ b/gitlab/mixins.py
@@ -230,8 +230,7 @@ class ListMixin(_RestManagerBase):
if self._types:
for attr_name, type_cls in self._types.items():
if attr_name in data.keys():
- type_obj = type_cls(data[attr_name])
- data[attr_name] = type_obj.get_for_api()
+ data[attr_name] = type_cls(data[attr_name])
# Allow to overwrite the path, handy for custom listings
path = data.pop("path", self.path)
@@ -307,14 +306,13 @@ class CreateMixin(_RestManagerBase):
for attr_name, type_cls in self._types.items():
if attr_name in data.keys():
type_obj = type_cls(data[attr_name])
-
# if the type if FileAttribute we need to pass the data as
# file
if isinstance(type_obj, g_types.FileAttribute):
k = type_obj.get_file_name(attr_name)
files[attr_name] = (k, data.pop(attr_name))
else:
- data[attr_name] = type_obj.get_for_api()
+ data[attr_name] = type_obj
# Handle specific URL for creation
path = kwargs.pop("path", self.path)
@@ -410,7 +408,7 @@ class UpdateMixin(_RestManagerBase):
k = type_obj.get_file_name(attr_name)
files[attr_name] = (k, new_data.pop(attr_name))
else:
- new_data[attr_name] = type_obj.get_for_api()
+ new_data[attr_name] = type_obj
http_method = self._get_update_method()
result = http_method(path, post_data=new_data, files=files, **kwargs)