@@ -231,7 +231,17 @@ def list(self, **kwargs: Any) -> Union[base.RESTObjectList, List[base.RESTObject
231
231
for attr_name , type_cls in self ._types .items ():
232
232
if attr_name in data .keys ():
233
233
type_obj = type_cls (data [attr_name ])
234
- data [attr_name ] = type_obj .get_for_api ()
234
+ if isinstance (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
+ del data [attr_name ]
242
+ data [f"{ attr_name } []" ] = type_obj .get_for_api ()
243
+ else :
244
+ data [attr_name ] = type_obj .get_for_api ()
235
245
236
246
# Allow to overwrite the path, handy for custom listings
237
247
path = data .pop ("path" , self .path )
@@ -313,6 +323,15 @@ def create(
313
323
if isinstance (type_obj , g_types .FileAttribute ):
314
324
k = type_obj .get_file_name (attr_name )
315
325
files [attr_name ] = (k , data .pop (attr_name ))
326
+ elif isinstance (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
+ del data [attr_name ]
334
+ data [f"{ attr_name } []" ] = type_obj .get_for_api ()
316
335
else :
317
336
data [attr_name ] = type_obj .get_for_api ()
318
337
@@ -409,6 +428,15 @@ def update(
409
428
if isinstance (type_obj , g_types .FileAttribute ):
410
429
k = type_obj .get_file_name (attr_name )
411
430
files [attr_name ] = (k , new_data .pop (attr_name ))
431
+ elif isinstance (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
+ del new_data [attr_name ]
439
+ new_data [f"{ attr_name } []" ] = type_obj .get_for_api ()
412
440
else :
413
441
new_data [attr_name ] = type_obj .get_for_api ()
414
442
0 commit comments