@@ -374,6 +374,11 @@ def _getListOrObject(self, cls, id, **kwargs):
374
374
raise GitlabGetError
375
375
376
376
return cls .list (self .gitlab , ** kwargs )
377
+ elif isinstance (id , dict ):
378
+ if not cls .canCreate :
379
+ raise GitlabCreateError
380
+
381
+ return cls (self .gitlab , id , ** kwargs )
377
382
else :
378
383
if not cls .canGet :
379
384
raise GitlabGetError
@@ -536,28 +541,28 @@ class ProjectCommit(GitlabObject):
536
541
class ProjectKey (GitlabObject ):
537
542
_url = '/projects/%(project_id)d/keys'
538
543
canUpdate = False
539
- requiredCreateAttrs = ['title' , 'key' ]
544
+ requiredCreateAttrs = ['project_id' , ' title' , 'key' ]
540
545
541
546
542
547
class ProjectHook (GitlabObject ):
543
548
_url = '/projects/%(project_id)d/hooks'
544
- requiredCreateAttrs = ['url' ]
549
+ requiredCreateAttrs = ['project_id' , ' url' ]
545
550
546
551
547
552
class ProjectIssueNote (GitlabObject ):
548
553
_url = '/projects/%(project_id)d/issues/%(issue_id)d/notes'
549
554
_constructorTypes = {'author' : 'User' }
550
555
canUpdate = False
551
556
canDelete = False
552
- requiredCreateAttrs = ['body' ]
557
+ requiredCreateAttrs = ['project_id' , ' body' ]
553
558
554
559
555
560
class ProjectIssue (GitlabObject ):
556
561
_url = '/projects/%(project_id)s/issues/'
557
562
_constructorTypes = {'author' : 'User' , 'assignee' : 'User' ,
558
563
'milestone' : 'ProjectMilestone' }
559
564
canDelete = False
560
- requiredCreateAttrs = ['title' ]
565
+ requiredCreateAttrs = ['project_id' , ' title' ]
561
566
optionalCreateAttrs = ['description' , 'assignee_id' , 'milestone_id' ,
562
567
'labels' ]
563
568
@@ -571,15 +576,15 @@ def Note(self, id=None, **kwargs):
571
576
class ProjectMember (GitlabObject ):
572
577
_url = '/projects/%(project_id)d/members'
573
578
_returnClass = User
574
- requiredCreateAttrs = ['user_id' , 'access_level' ]
579
+ requiredCreateAttrs = ['project_id' , ' user_id' , 'access_level' ]
575
580
576
581
577
582
class ProjectNote (GitlabObject ):
578
583
_url = '/projects/%(project_id)d/notes'
579
584
_constructorTypes = {'author' : 'User' }
580
585
canUpdate = False
581
586
canDelete = False
582
- requiredCreateAttrs = ['body' ]
587
+ requiredCreateAttrs = ['project_id' , ' body' ]
583
588
584
589
585
590
class ProjectTag (GitlabObject ):
@@ -603,7 +608,7 @@ class ProjectMergeRequest(GitlabObject):
603
608
_url = '/projects/%(project_id)d/merge_request'
604
609
_constructorTypes = {'author' : 'User' , 'assignee' : 'User' }
605
610
canDelete = False
606
- requiredCreateAttrs = ['source_branch' , 'target_branch' , 'title' ]
611
+ requiredCreateAttrs = ['project_id' , ' source_branch' , 'target_branch' , 'title' ]
607
612
optionalCreateAttrs = ['assignee_id' ]
608
613
609
614
def Note (self , id = None , ** kwargs ):
@@ -616,7 +621,7 @@ def Note(self, id=None, **kwargs):
616
621
class ProjectMilestone (GitlabObject ):
617
622
_url = '/projects/%(project_id)s/milestones'
618
623
canDelete = False
619
- requiredCreateAttrs = ['title' ]
624
+ requiredCreateAttrs = ['project_id' , ' title' ]
620
625
optionalCreateAttrs = ['description' , 'due_date' ]
621
626
622
627
@@ -625,13 +630,13 @@ class ProjectSnippetNote(GitlabObject):
625
630
_constructorTypes = {'author' : 'User' }
626
631
canUpdate = False
627
632
canDelete = False
628
- requiredCreateAttrs = ['body' ]
633
+ requiredCreateAttrs = ['project_id' , 'snippet_id' , ' body' ]
629
634
630
635
631
636
class ProjectSnippet (GitlabObject ):
632
637
_url = '/projects/%(project_id)d/snippets'
633
638
_constructorTypes = {'author' : 'User' }
634
- requiredCreateAttrs = ['title' , 'file_name' , 'code' ]
639
+ requiredCreateAttrs = ['project_id' , ' title' , 'file_name' , 'code' ]
635
640
optionalCreateAttrs = ['lifetime' ]
636
641
637
642
def Note (self , id = None , ** kwargs ):
0 commit comments