Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1572d87

Browse files
WIP: Trying to solve array issue
1 parent2cd15ac commit1572d87

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

‎gitlab/mixins.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,17 @@ def list(self, **kwargs: Any) -> Union[base.RESTObjectList, List[base.RESTObject
231231
forattr_name,type_clsinself._types.items():
232232
ifattr_nameindata.keys():
233233
type_obj=type_cls(data[attr_name])
234-
data[attr_name]=type_obj.get_for_api()
234+
ifisinstance(type_obj,g_types.ListAttribute):
235+
# NOTE(jlvillal): Array values are supposed to be
236+
# passed in the form of 'key[]=value1&key[]=value2'
237+
# https://docs.gitlab.com/ee/api/#array
238+
# But at the moment we haven't determined an elegant
239+
# way to do that. So for now just add the '[]' to the
240+
# key we send in the request.
241+
deldata[attr_name]
242+
data[f"{attr_name}[]"]=type_obj.get_for_api()
243+
else:
244+
data[attr_name]=type_obj.get_for_api()
235245

236246
# Allow to overwrite the path, handy for custom listings
237247
path=data.pop("path",self.path)
@@ -313,6 +323,15 @@ def create(
313323
ifisinstance(type_obj,g_types.FileAttribute):
314324
k=type_obj.get_file_name(attr_name)
315325
files[attr_name]= (k,data.pop(attr_name))
326+
elifisinstance(type_obj,g_types.ListAttribute):
327+
# NOTE(jlvillal): Array values are supposed to be
328+
# passed in the form of 'key[]=value1&key[]=value2'
329+
# https://docs.gitlab.com/ee/api/#array
330+
# But at the moment we haven't determined an elegant
331+
# way to do that. So for now just add the '[]' to the
332+
# key we send in the request.
333+
deldata[attr_name]
334+
data[f"{attr_name}[]"]=type_obj.get_for_api()
316335
else:
317336
data[attr_name]=type_obj.get_for_api()
318337

@@ -409,6 +428,15 @@ def update(
409428
ifisinstance(type_obj,g_types.FileAttribute):
410429
k=type_obj.get_file_name(attr_name)
411430
files[attr_name]= (k,new_data.pop(attr_name))
431+
elifisinstance(type_obj,g_types.ListAttribute):
432+
# NOTE(jlvillal): Array values are supposed to be
433+
# passed in the form of 'key[]=value1&key[]=value2'
434+
# https://docs.gitlab.com/ee/api/#array
435+
# But at the moment we haven't determined an elegant
436+
# way to do that. So for now just add the '[]' to the
437+
# key we send in the request.
438+
deldata[attr_name]
439+
data[f"{attr_name}[]"]=type_obj.get_for_api()
412440
else:
413441
new_data[attr_name]=type_obj.get_for_api()
414442

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp