@@ -231,7 +231,17 @@ def list(self, **kwargs: Any) -> Union[base.RESTObjectList, List[base.RESTObject
231231 for attr_name , type_cls in self ._types .items ():
232232 if attr_name in data .keys ():
233233 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 ()
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 if isinstance (type_obj , g_types .FileAttribute ):
314324 k = type_obj .get_file_name (attr_name )
315325 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 ()
316335 else :
317336 data [attr_name ] = type_obj .get_for_api ()
318337
@@ -409,6 +428,15 @@ def update(
409428 if isinstance (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+ 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 ()
412440 else :
413441 new_data [attr_name ] = type_obj .get_for_api ()
414442
0 commit comments