22
33from typing import TYPE_CHECKING , Any
44
5- from graphene import Boolean , DateTime , Field , Int , Interface , List , NonNull , ObjectType , String
5+ from graphene import Boolean , DateTime , Field , InputObjectType , Int , Interface , List , NonNull , ObjectType , String
66from graphene .types .generic import GenericScalar
77
88from .common import RelatedNode
@@ -21,16 +21,25 @@ class InfrahubMutatedAttribute(ObjectType):
2121
2222
2323class EventNodeInterface (Interface ):
24- id = String (required = True )
25- event = String (required = True )
26- branch = String (required = False )
27- account_id = String (required = False )
28- occurred_at = DateTime (required = True )
29- level = Int (required = True )
30- primary_node = Field (RelatedNode , required = False )
31- related_nodes = List (NonNull (RelatedNode ), required = True )
32- has_children = Boolean (required = True )
33- parent_id = String (required = False )
24+ id = String (required = True , description = "The ID of the event." )
25+ event = String (required = True , description = "The name of the event." )
26+ branch = String (required = False , description = "The branch where the event occurred." )
27+ account_id = String (required = False , description = "The account ID that triggered the event." )
28+ occurred_at = DateTime (required = True , description = "The timestamp when the event occurred." )
29+ level = Int (
30+ required = True ,
31+ description = "The level of the event 0 is a root level event, the child events will have 1 and grand children 2." ,
32+ )
33+ primary_node = Field (
34+ RelatedNode , required = False , description = "The primary Infrahub node this event is associated with."
35+ )
36+ related_nodes = List (
37+ NonNull (RelatedNode ), required = True , description = "Related Infrahub nodes this event is associated with."
38+ )
39+ has_children = Boolean (
40+ required = True , description = "Indicates if the event is expected to have child events under it"
41+ )
42+ parent_id = String (required = False , description = "The event ID of the direct parent to this event." )
3443
3544 @classmethod
3645 def resolve_type (
@@ -47,27 +56,49 @@ class EventNodes(ObjectType):
4756 node = Field (EventNodeInterface )
4857
4958
59+ class BranchEventTypeFilter (InputObjectType ):
60+ branches = List (NonNull (String ), required = True , description = "Name of impacted branches" )
61+
62+
63+ class EventTypeFilter (InputObjectType ):
64+ branch_merged = Field (
65+ BranchEventTypeFilter , required = False , description = "Filters specific to infrahub.branch.merged events"
66+ )
67+
68+
5069# ---------------------------------------
5170# Branch events
5271# ---------------------------------------
5372class BranchCreatedEvent (ObjectType ):
5473 class Meta :
5574 interfaces = (EventNodeInterface ,)
5675
76+ created_branch = String (required = True , description = "The name of the branch that was created" )
5777 payload = Field (GenericScalar , required = True )
5878
5979
80+ class BranchMergedEvent (ObjectType ):
81+ class Meta :
82+ interfaces = (EventNodeInterface ,)
83+
84+ source_branch = String (required = True , description = "The name of the branch that was merged into the default branch" )
85+
86+
6087class BranchRebasedEvent (ObjectType ):
6188 class Meta :
6289 interfaces = (EventNodeInterface ,)
6390
91+ rebased_branch = String (
92+ required = True , description = "The name of the branch that was rebased and aligned with the default branch"
93+ )
6494 payload = Field (GenericScalar , required = True )
6595
6696
6797class BranchDeletedEvent (ObjectType ):
6898 class Meta :
6999 interfaces = (EventNodeInterface ,)
70100
101+ deleted_branch = String (required = True , description = "The name of the branch that was deleted" )
71102 payload = Field (GenericScalar , required = True )
72103
73104
@@ -94,6 +125,7 @@ class Meta:
94125 "infrahub.node.updated" : NodeMutatedEvent ,
95126 "infrahub.node.deleted" : NodeMutatedEvent ,
96127 "infrahub.branch.created" : BranchCreatedEvent ,
128+ "infrahub.branch.merged" : BranchMergedEvent ,
97129 "infrahub.branch.rebased" : BranchRebasedEvent ,
98130 "infrahub.branch.deleted" : BranchDeletedEvent ,
99131 "undefined" : StandardEvent ,
0 commit comments