@@ -108,9 +108,21 @@ def list(self, **kwargs):
108108 GitlabListError: If the server cannot perform the request
109109 """
110110
111+ # Duplicate data to avoid messing with what the user sent us
112+ data = kwargs .copy ()
113+
114+ # We get the attributes that need some special transformation
115+ types = getattr (self ,'_types' , {})
116+ if types :
117+ for attr_name ,type_cls in types .items ():
118+ if attr_name in data .keys ():
119+ type_obj = type_cls (data [attr_name ])
120+ data [attr_name ]= type_obj .get_for_api ()
121+
111122# Allow to overwrite the path, handy for custom listings
112- path = kwargs .pop ('path' ,self .path )
113- obj = self .gitlab .http_list (path ,** kwargs )
123+ path = data .pop ('path' ,self .path )
124+
125+ obj = self .gitlab .http_list (path ,** data )
114126if isinstance (obj ,list ):
115127return [self ._obj_cls (self ,item )for item in obj ]
116128else :
@@ -187,8 +199,22 @@ def create(self, data, **kwargs):
187199 GitlabCreateError: If the server cannot perform the request
188200 """
189201self ._check_missing_create_attrs (data )
202+
203+ # special handling of the object if needed
190204if hasattr (self ,'_sanitize_data' ):
191205data = self ._sanitize_data (data ,'create' )
206+
207+ # We get the attributes that need some special transformation
208+ types = getattr (self ,'_types' , {})
209+
210+ if types :
211+ # Duplicate data to avoid messing with what the user sent us
212+ data = data .copy ()
213+ for attr_name ,type_cls in types .items ():
214+ if attr_name in data .keys ():
215+ type_obj = type_cls (data [attr_name ])
216+ data [attr_name ]= type_obj .get_for_api ()
217+
192218# Handle specific URL for creation
193219path = kwargs .pop ('path' ,self .path )
194220server_data = self .gitlab .http_post (path ,post_data = data ,** kwargs )
@@ -238,11 +264,20 @@ def update(self, id=None, new_data={}, **kwargs):
238264path = '%s/%s' % (self .path ,id )
239265
240266self ._check_missing_update_attrs (new_data )
267+
268+ # special handling of the object if needed
241269if hasattr (self ,'_sanitize_data' ):
242270data = self ._sanitize_data (new_data ,'update' )
243271else :
244272data = new_data
245273
274+ # We get the attributes that need some special transformation
275+ types = getattr (self ,'_types' , {})
276+ for attr_name ,type_cls in types .items ():
277+ if attr_name in data .keys ():
278+ type_obj = type_cls (data [attr_name ])
279+ data [attr_name ]= type_obj .get_for_api ()
280+
246281return self .gitlab .http_put (path ,post_data = data ,** kwargs )
247282
248283