We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
2 parents9da5d69 +23b5b6e commit20fdbe8Copy full SHA for 20fdbe8
gitlab/objects.py
@@ -378,6 +378,22 @@ def __init__(self, gl, data=None, **kwargs):
378
data=self.gitlab.get(self.__class__,data,**kwargs)
379
self._from_api=True
380
381
+# the API returned a list because custom kwargs where used
382
+# instead of the id to request an object. Usually parameters
383
+# other than an id return ambiguous results. However in the
384
+# gitlab universe iids together with a project_id are
385
+# unambiguous for merge requests and issues, too.
386
+# So if there is only one element we can use it as our data
387
+# source.
388
+if'iid'inkwargsandisinstance(data,list):
389
+iflen(data)<1:
390
+raiseGitlabGetError('Not found')
391
+eliflen(data)==1:
392
+data=data[0]
393
+else:
394
+raiseGitlabGetError('Impossible! You found multiple'
395
+' elements with the same iid.')
396
+
397
self._set_from_dict(data,**kwargs)
398
399
ifkwargs: