infrahub-server 1.2.10__py3-none-any.whl → 1.3.0a0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. infrahub/actions/constants.py +86 -0
  2. infrahub/actions/gather.py +114 -0
  3. infrahub/actions/models.py +241 -0
  4. infrahub/actions/parsers.py +104 -0
  5. infrahub/actions/schema.py +382 -0
  6. infrahub/actions/tasks.py +126 -0
  7. infrahub/actions/triggers.py +21 -0
  8. infrahub/cli/db.py +1 -2
  9. infrahub/config.py +9 -0
  10. infrahub/core/account.py +24 -47
  11. infrahub/core/attribute.py +10 -12
  12. infrahub/core/constants/infrahubkind.py +8 -0
  13. infrahub/core/constraint/node/runner.py +1 -1
  14. infrahub/core/convert_object_type/__init__.py +0 -0
  15. infrahub/core/convert_object_type/conversion.py +122 -0
  16. infrahub/core/convert_object_type/schema_mapping.py +56 -0
  17. infrahub/core/diff/query/all_conflicts.py +1 -5
  18. infrahub/core/diff/query/artifact.py +10 -20
  19. infrahub/core/diff/query/diff_get.py +3 -6
  20. infrahub/core/diff/query/field_summary.py +2 -4
  21. infrahub/core/diff/query/merge.py +70 -123
  22. infrahub/core/diff/query/save.py +20 -32
  23. infrahub/core/diff/query/summary_counts_enricher.py +34 -54
  24. infrahub/core/diff/query_parser.py +5 -1
  25. infrahub/core/diff/tasks.py +3 -3
  26. infrahub/core/manager.py +14 -11
  27. infrahub/core/migrations/graph/m003_relationship_parent_optional.py +1 -2
  28. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +2 -4
  29. infrahub/core/migrations/graph/m019_restore_rels_to_time.py +11 -22
  30. infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -6
  31. infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +1 -2
  32. infrahub/core/migrations/graph/m024_missing_hierarchy_backfill.py +1 -2
  33. infrahub/core/migrations/query/attribute_add.py +1 -2
  34. infrahub/core/migrations/query/attribute_rename.py +3 -6
  35. infrahub/core/migrations/query/delete_element_in_schema.py +3 -6
  36. infrahub/core/migrations/query/node_duplicate.py +3 -6
  37. infrahub/core/migrations/query/relationship_duplicate.py +3 -6
  38. infrahub/core/migrations/schema/node_attribute_remove.py +3 -6
  39. infrahub/core/migrations/schema/node_remove.py +3 -6
  40. infrahub/core/models.py +29 -2
  41. infrahub/core/node/__init__.py +18 -4
  42. infrahub/core/node/create.py +211 -0
  43. infrahub/core/protocols.py +51 -0
  44. infrahub/core/protocols_base.py +3 -0
  45. infrahub/core/query/__init__.py +2 -2
  46. infrahub/core/query/diff.py +26 -32
  47. infrahub/core/query/ipam.py +10 -20
  48. infrahub/core/query/node.py +28 -46
  49. infrahub/core/query/relationship.py +51 -28
  50. infrahub/core/query/resource_manager.py +1 -2
  51. infrahub/core/query/subquery.py +2 -4
  52. infrahub/core/relationship/model.py +3 -0
  53. infrahub/core/schema/__init__.py +2 -1
  54. infrahub/core/schema/attribute_parameters.py +36 -0
  55. infrahub/core/schema/attribute_schema.py +83 -8
  56. infrahub/core/schema/basenode_schema.py +25 -1
  57. infrahub/core/schema/definitions/core/__init__.py +21 -0
  58. infrahub/core/schema/definitions/internal.py +13 -3
  59. infrahub/core/schema/generated/attribute_schema.py +9 -3
  60. infrahub/core/schema/schema_branch.py +12 -7
  61. infrahub/core/validators/__init__.py +5 -1
  62. infrahub/core/validators/attribute/choices.py +1 -2
  63. infrahub/core/validators/attribute/enum.py +1 -2
  64. infrahub/core/validators/attribute/kind.py +1 -2
  65. infrahub/core/validators/attribute/length.py +13 -6
  66. infrahub/core/validators/attribute/optional.py +1 -2
  67. infrahub/core/validators/attribute/regex.py +5 -5
  68. infrahub/core/validators/attribute/unique.py +1 -3
  69. infrahub/core/validators/determiner.py +18 -2
  70. infrahub/core/validators/enum.py +7 -0
  71. infrahub/core/validators/node/hierarchy.py +3 -6
  72. infrahub/core/validators/query.py +1 -3
  73. infrahub/core/validators/relationship/count.py +6 -12
  74. infrahub/core/validators/relationship/optional.py +2 -4
  75. infrahub/core/validators/relationship/peer.py +3 -8
  76. infrahub/core/validators/tasks.py +1 -1
  77. infrahub/core/validators/uniqueness/query.py +5 -9
  78. infrahub/database/__init__.py +1 -3
  79. infrahub/events/group_action.py +1 -0
  80. infrahub/graphql/analyzer.py +139 -18
  81. infrahub/graphql/app.py +1 -1
  82. infrahub/graphql/loaders/node.py +1 -1
  83. infrahub/graphql/loaders/peers.py +1 -1
  84. infrahub/graphql/manager.py +4 -0
  85. infrahub/graphql/mutations/action.py +164 -0
  86. infrahub/graphql/mutations/convert_object_type.py +62 -0
  87. infrahub/graphql/mutations/main.py +24 -175
  88. infrahub/graphql/mutations/proposed_change.py +21 -18
  89. infrahub/graphql/queries/convert_object_type_mapping.py +36 -0
  90. infrahub/graphql/queries/relationship.py +1 -1
  91. infrahub/graphql/resolvers/many_relationship.py +4 -4
  92. infrahub/graphql/resolvers/resolver.py +4 -4
  93. infrahub/graphql/resolvers/single_relationship.py +2 -2
  94. infrahub/graphql/schema.py +6 -0
  95. infrahub/graphql/subscription/graphql_query.py +2 -2
  96. infrahub/graphql/types/branch.py +1 -1
  97. infrahub/menu/menu.py +31 -0
  98. infrahub/message_bus/messages/__init__.py +0 -10
  99. infrahub/message_bus/operations/__init__.py +0 -8
  100. infrahub/message_bus/operations/refresh/registry.py +1 -1
  101. infrahub/patch/queries/consolidate_duplicated_nodes.py +3 -6
  102. infrahub/patch/queries/delete_duplicated_edges.py +5 -10
  103. infrahub/prefect_server/models.py +1 -19
  104. infrahub/proposed_change/models.py +68 -3
  105. infrahub/proposed_change/tasks.py +907 -30
  106. infrahub/task_manager/models.py +10 -6
  107. infrahub/telemetry/database.py +1 -1
  108. infrahub/telemetry/tasks.py +1 -1
  109. infrahub/trigger/catalogue.py +2 -0
  110. infrahub/trigger/models.py +18 -2
  111. infrahub/trigger/tasks.py +3 -1
  112. infrahub/workflows/catalogue.py +76 -0
  113. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/METADATA +2 -2
  114. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/RECORD +121 -118
  115. infrahub_testcontainers/container.py +0 -1
  116. infrahub_testcontainers/docker-compose.test.yml +1 -1
  117. infrahub_testcontainers/helpers.py +8 -2
  118. infrahub/message_bus/messages/check_generator_run.py +0 -26
  119. infrahub/message_bus/messages/finalize_validator_execution.py +0 -15
  120. infrahub/message_bus/messages/proposed_change/base_with_diff.py +0 -16
  121. infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +0 -11
  122. infrahub/message_bus/messages/request_generatordefinition_check.py +0 -20
  123. infrahub/message_bus/messages/request_proposedchange_pipeline.py +0 -23
  124. infrahub/message_bus/operations/check/__init__.py +0 -3
  125. infrahub/message_bus/operations/check/generator.py +0 -156
  126. infrahub/message_bus/operations/finalize/__init__.py +0 -3
  127. infrahub/message_bus/operations/finalize/validator.py +0 -133
  128. infrahub/message_bus/operations/requests/__init__.py +0 -9
  129. infrahub/message_bus/operations/requests/generator_definition.py +0 -140
  130. infrahub/message_bus/operations/requests/proposed_change.py +0 -629
  131. /infrahub/{message_bus/messages/proposed_change → actions}/__init__.py +0 -0
  132. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/LICENSE.txt +0 -0
  133. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/WHEEL +0 -0
  134. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/entry_points.txt +0 -0
@@ -109,7 +109,7 @@ class SingleRelationshipResolver:
109
109
  for key, value in kwargs.items()
110
110
  if "__" in key and value or key in ["id", "ids"]
111
111
  }
112
- async with db.start_session() as dbs:
112
+ async with db.start_session(read_only=True) as dbs:
113
113
  objs = await NodeManager.query_peers(
114
114
  db=dbs,
115
115
  ids=[parent_id],
@@ -171,5 +171,5 @@ class SingleRelationshipResolver:
171
171
  node = await loader.load(key=peer_id)
172
172
  if not node:
173
173
  return None
174
- async with db.start_session() as dbs:
174
+ async with db.start_session(read_only=True) as dbs:
175
175
  return await node.to_graphql(db=dbs, fields=node_fields, related_node_ids=related_node_ids)
@@ -16,6 +16,7 @@ from .mutations.branch import (
16
16
  BranchValidate,
17
17
  )
18
18
  from .mutations.computed_attribute import UpdateComputedAttribute
19
+ from .mutations.convert_object_type import ConvertObjectType
19
20
  from .mutations.diff import DiffUpdateMutation
20
21
  from .mutations.diff_conflict import ResolveDiffConflict
21
22
  from .mutations.generator import GeneratorDefinitionRequestRun
@@ -48,6 +49,7 @@ from .queries import (
48
49
  InfrahubStatus,
49
50
  Relationship,
50
51
  )
52
+ from .queries.convert_object_type_mapping import FieldsMappingTypeConversion
51
53
  from .queries.diff.tree import DiffTreeQuery, DiffTreeSummaryQuery
52
54
  from .queries.event import Event
53
55
  from .queries.task import Task, TaskBranchStatus
@@ -77,6 +79,8 @@ class InfrahubBaseQuery(ObjectType):
77
79
  InfrahubResourcePoolAllocated = InfrahubResourcePoolAllocated
78
80
  InfrahubResourcePoolUtilization = InfrahubResourcePoolUtilization
79
81
 
82
+ FieldsMappingTypeConversion = FieldsMappingTypeConversion
83
+
80
84
 
81
85
  class InfrahubBaseMutation(ObjectType):
82
86
  InfrahubAccountTokenCreate = InfrahubAccountTokenCreate.Field()
@@ -109,3 +113,5 @@ class InfrahubBaseMutation(ObjectType):
109
113
  SchemaEnumAdd = SchemaEnumAdd.Field()
110
114
  SchemaEnumRemove = SchemaEnumRemove.Field()
111
115
  ResolveDiffConflict = ResolveDiffConflict.Field()
116
+
117
+ ConvertObjectType = ConvertObjectType.Field()
@@ -29,7 +29,7 @@ async def resolver_graphql_query(
29
29
  graphql_context: GraphqlContext = info.context
30
30
  at = Timestamp()
31
31
 
32
- async with graphql_context.db.start_session() as db:
32
+ async with graphql_context.db.start_session(read_only=True) as db:
33
33
  # Find the GraphQLQuery and the GraphQL Schema
34
34
  graphql_query = await NodeManager.get_one_by_default_filter(
35
35
  db=db, id=name, kind=CoreGraphQLQuery, branch=graphql_context.branch, at=at
@@ -38,7 +38,7 @@ async def resolver_graphql_query(
38
38
  raise ValueError(f"Unable to find the {InfrahubKind.GRAPHQLQUERY} {name}")
39
39
 
40
40
  while True:
41
- async with graphql_context.db.start_session() as db:
41
+ async with graphql_context.db.start_session(read_only=True) as db:
42
42
  result = await graphql(
43
43
  schema=graphql_schema,
44
44
  source=graphql_query.query.value,
@@ -37,7 +37,7 @@ class BranchType(InfrahubObjectType):
37
37
  graphql_context: GraphqlContext,
38
38
  **kwargs: Any,
39
39
  ) -> list[dict[str, Any]]:
40
- async with graphql_context.db.start_session() as db:
40
+ async with graphql_context.db.start_session(read_only=True) as db:
41
41
  objs = await Branch.get_list(db=db, **kwargs)
42
42
 
43
43
  if not objs:
infrahub/menu/menu.py CHANGED
@@ -246,6 +246,37 @@ default_menu = [
246
246
  section=MenuSection.INTERNAL,
247
247
  order_weight=2000,
248
248
  ),
249
+ MenuItemDefinition(
250
+ namespace="Builtin",
251
+ name="TriggerDefinition",
252
+ label="Triggers",
253
+ icon=_extract_node_icon(infrahub_schema.get(InfrahubKind.TRIGGERRULE)),
254
+ protected=True,
255
+ section=MenuSection.INTERNAL,
256
+ order_weight=6000,
257
+ children=[
258
+ MenuItemDefinition(
259
+ namespace="Core",
260
+ name="TriggerRule",
261
+ label="Trigger Rules",
262
+ kind=InfrahubKind.TRIGGERRULE,
263
+ icon=_extract_node_icon(infrahub_schema.get(InfrahubKind.TRIGGERRULE)),
264
+ protected=True,
265
+ section=MenuSection.INTERNAL,
266
+ order_weight=1000,
267
+ ),
268
+ MenuItemDefinition(
269
+ namespace="Core",
270
+ name="Action",
271
+ label="Trigger Actions",
272
+ kind=InfrahubKind.ACTION,
273
+ icon=_extract_node_icon(infrahub_schema.get(InfrahubKind.ACTION)),
274
+ protected=True,
275
+ section=MenuSection.INTERNAL,
276
+ order_weight=2000,
277
+ ),
278
+ ],
279
+ ),
249
280
  ],
250
281
  ),
251
282
  MenuItemDefinition(
@@ -1,28 +1,18 @@
1
1
  from infrahub.message_bus import InfrahubMessage, InfrahubResponse
2
2
 
3
- from .check_generator_run import CheckGeneratorRun
4
- from .finalize_validator_execution import FinalizeValidatorExecution
5
3
  from .git_file_get import GitFileGet, GitFileGetResponse
6
4
  from .git_repository_connectivity import GitRepositoryConnectivity
7
- from .proposed_change.request_proposedchange_refreshartifacts import RequestProposedChangeRefreshArtifacts
8
5
  from .refresh_git_fetch import RefreshGitFetch
9
6
  from .refresh_registry_branches import RefreshRegistryBranches
10
7
  from .refresh_registry_rebasedbranch import RefreshRegistryRebasedBranch
11
- from .request_generatordefinition_check import RequestGeneratorDefinitionCheck
12
- from .request_proposedchange_pipeline import RequestProposedChangePipeline
13
8
  from .send_echo_request import SendEchoRequest, SendEchoRequestResponse
14
9
 
15
10
  MESSAGE_MAP: dict[str, type[InfrahubMessage]] = {
16
- "check.generator.run": CheckGeneratorRun,
17
- "finalize.validator.execution": FinalizeValidatorExecution,
18
11
  "git.file.get": GitFileGet,
19
12
  "git.repository.connectivity": GitRepositoryConnectivity,
20
13
  "refresh.git.fetch": RefreshGitFetch,
21
14
  "refresh.registry.branches": RefreshRegistryBranches,
22
15
  "refresh.registry.rebased_branch": RefreshRegistryRebasedBranch,
23
- "request.generator_definition.check": RequestGeneratorDefinitionCheck,
24
- "request.proposed_change.pipeline": RequestProposedChangePipeline,
25
- "request.proposed_change.refresh_artifacts": RequestProposedChangeRefreshArtifacts,
26
16
  "send.echo.request": SendEchoRequest,
27
17
  }
28
18
 
@@ -3,11 +3,8 @@ from prefect import Flow
3
3
 
4
4
  from infrahub.message_bus import RPCErrorResponse, messages
5
5
  from infrahub.message_bus.operations import (
6
- check,
7
- finalize,
8
6
  git,
9
7
  refresh,
10
- requests,
11
8
  send,
12
9
  )
13
10
  from infrahub.message_bus.types import MessageTTL
@@ -15,16 +12,11 @@ from infrahub.services import InfrahubServices
15
12
  from infrahub.tasks.check import set_check_status
16
13
 
17
14
  COMMAND_MAP = {
18
- "check.generator.run": check.generator.run,
19
- "finalize.validator.execution": finalize.validator.execution,
20
15
  "git.file.get": git.file.get,
21
16
  "git.repository.connectivity": git.repository.connectivity,
22
17
  "refresh.git.fetch": git.repository.fetch,
23
18
  "refresh.registry.branches": refresh.registry.branches,
24
19
  "refresh.registry.rebased_branch": refresh.registry.rebased_branch,
25
- "request.generator_definition.check": requests.generator_definition.check,
26
- "request.proposed_change.pipeline": requests.proposed_change.pipeline,
27
- "request.proposed_change.refresh_artifacts": requests.proposed_change.refresh_artifacts,
28
20
  "send.echo.request": send.echo.request,
29
21
  }
30
22
 
@@ -11,7 +11,7 @@ async def branches(message: messages.RefreshRegistryBranches, service: InfrahubS
11
11
  service.log.info("Ignoring refresh registry refresh request originating from self", worker=WORKER_IDENTITY)
12
12
  return
13
13
 
14
- async with service.database.start_session() as db:
14
+ async with service.database.start_session(read_only=True) as db:
15
15
  await refresh_branches(db=db)
16
16
 
17
17
  await service.component.refresh_schema_hash()
@@ -22,8 +22,7 @@ WITH n.uuid AS node_uuid, count(*) as num_nodes_with_uuid
22
22
  WHERE num_nodes_with_uuid > 1
23
23
  WITH DISTINCT node_uuid
24
24
  MATCH (n:Node {uuid: node_uuid})
25
- CALL {
26
- WITH n
25
+ CALL (n) {
27
26
  WITH labels(n) AS n_labels
28
27
  UNWIND n_labels AS n_label
29
28
  WITH n_label
@@ -37,8 +36,7 @@ UNWIND nodes_to_delete AS node_to_delete
37
36
  //------------
38
37
  // Find the edges that we need to move to the selected node_to_keep
39
38
  //------------
40
- CALL {
41
- WITH node_to_keep, node_to_delete
39
+ CALL (node_to_keep, node_to_delete) {
42
40
  MATCH (node_to_delete)-[edge_to_delete]->(peer)
43
41
  RETURN {
44
42
  from_id: %(id_func_name)s(node_to_keep),
@@ -60,8 +58,7 @@ WITH node_to_delete, collect(edge_to_create) AS edges_to_create
60
58
  //------------
61
59
  // Find the edges that we need to remove from the duplicated nodes
62
60
  //------------
63
- CALL {
64
- WITH node_to_delete
61
+ CALL (node_to_delete) {
65
62
  MATCH (node_to_delete)-[e]->(peer)
66
63
  RETURN {
67
64
  db_id: %(id_func_name)s(e),
@@ -23,11 +23,10 @@ MATCH (node_with_dup_edges:Node)-[edge]->(peer)
23
23
  WITH node_with_dup_edges, type(edge) AS edge_type, edge.status AS edge_status, edge.branch AS edge_branch, peer, count(*) AS num_dup_edges
24
24
  WHERE num_dup_edges > 1
25
25
  WITH DISTINCT node_with_dup_edges, edge_type, edge_branch, peer
26
- CALL {
26
+ CALL (node_with_dup_edges, edge_type, edge_branch, peer) {
27
27
  // ------------
28
28
  // Get the earliest active and deleted edges for this branch
29
29
  // ------------
30
- WITH node_with_dup_edges, edge_type, edge_branch, peer
31
30
  MATCH (node_with_dup_edges)-[active_edge {branch: edge_branch, status: "active"}]->(peer)
32
31
  WHERE type(active_edge) = edge_type
33
32
  WITH node_with_dup_edges, edge_type, edge_branch, peer, active_edge
@@ -40,8 +39,7 @@ CALL {
40
39
  // ------------
41
40
  // Plan one active edge update with correct from and to times
42
41
  // ------------
43
- CALL {
44
- WITH node_with_dup_edges, edge_type, edge_branch, peer, active_from, deleted_from
42
+ CALL (node_with_dup_edges, edge_type, edge_branch, peer, active_from, deleted_from) {
45
43
  MATCH (node_with_dup_edges)-[active_e {branch: edge_branch, status: "active"}]->(peer)
46
44
  WHERE type(active_e) = edge_type
47
45
  WITH node_with_dup_edges, edge_type, edge_branch, peer, active_from, deleted_from, active_e
@@ -57,8 +55,7 @@ CALL {
57
55
  // ------------
58
56
  // Plan deletes for all the other active edges of this type on this branch
59
57
  // ------------
60
- CALL {
61
- WITH node_with_dup_edges, edge_type, edge_branch, peer
58
+ CALL (node_with_dup_edges, edge_type, edge_branch, peer) {
62
59
  MATCH (node_with_dup_edges)-[active_e {branch: edge_branch, status: "active"}]->(peer)
63
60
  WHERE type(active_e) = edge_type
64
61
  WITH node_with_dup_edges, peer, active_e
@@ -77,8 +74,7 @@ CALL {
77
74
  // ------------
78
75
  // Plan one deleted edge update with correct from time
79
76
  // ------------
80
- CALL {
81
- WITH node_with_dup_edges, edge_type, edge_branch, peer, deleted_from
77
+ CALL (node_with_dup_edges, edge_type, edge_branch, peer, deleted_from) {
82
78
  MATCH (node_with_dup_edges)-[deleted_e {branch: edge_branch, status: "deleted"}]->(peer)
83
79
  WHERE type(deleted_e) = edge_type
84
80
  WITH node_with_dup_edges, edge_type, edge_branch, peer, deleted_from, deleted_e
@@ -94,8 +90,7 @@ CALL {
94
90
  // ------------
95
91
  // Plan deletes for all the other deleted edges of this type on this branch
96
92
  // ------------
97
- CALL {
98
- WITH node_with_dup_edges, edge_type, edge_branch, peer
93
+ CALL (node_with_dup_edges, edge_type, edge_branch, peer) {
99
94
  MATCH (node_with_dup_edges)-[deleted_e {branch: edge_branch, status: "deleted"}]->(peer)
100
95
  WHERE type(deleted_e) = edge_type
101
96
  WITH node_with_dup_edges, peer, deleted_e
@@ -1,18 +1,10 @@
1
- from typing import TYPE_CHECKING, Sequence, cast
2
-
3
- from prefect.server.database import PrefectDBInterface, db_injector
4
- from prefect.server.events.filters import EventFilter, EventNameFilter, EventOrder, EventRelatedFilter
1
+ from prefect.server.events.filters import EventFilter, EventNameFilter, EventOrder
5
2
  from prefect.server.events.schemas.events import ReceivedEvent
6
3
  from prefect.server.utilities.schemas import PrefectBaseModel
7
4
  from pydantic import BaseModel, Field
8
5
 
9
- if TYPE_CHECKING:
10
- from sqlalchemy.sql.expression import ColumnExpressionArgument
11
-
12
6
 
13
7
  class InfrahubEventFilter(EventFilter):
14
- matching_related: list[EventRelatedFilter] = Field(default_factory=list)
15
-
16
8
  def set_prefix(self) -> None:
17
9
  if self.event:
18
10
  if self.event.prefix is not None and "infrahub." not in self.event.prefix:
@@ -20,16 +12,6 @@ class InfrahubEventFilter(EventFilter):
20
12
  else:
21
13
  self.event = EventNameFilter(prefix=["infrahub."], name=[], exclude_prefix=None, exclude_name=None)
22
14
 
23
- @db_injector
24
- def build_where_clauses(self, db: PrefectDBInterface) -> Sequence["ColumnExpressionArgument[bool]"]:
25
- result = cast(list["ColumnExpressionArgument[bool]"], super().build_where_clauses())
26
- top_level_filter = self._scoped_event_resources(db)
27
- for matching_related in self.matching_related:
28
- matching_related._top_level_filter = top_level_filter
29
- result.extend(matching_related.build_where_clauses())
30
-
31
- return result
32
-
33
15
  @classmethod
34
16
  def default(cls) -> "InfrahubEventFilter":
35
17
  return cls(event=None, any_resource=None, resource=None, related=None, order=EventOrder.DESC)
@@ -1,10 +1,25 @@
1
+ import uuid
2
+
1
3
  from pydantic import BaseModel, ConfigDict, Field
2
4
 
3
- from infrahub.context import InfrahubContext
4
- from infrahub.message_bus.messages.proposed_change.base_with_diff import BaseProposedChangeWithDiffMessage
5
+ from infrahub.core.constants import CheckType
6
+ from infrahub.generators.models import ProposedChangeGeneratorDefinition
7
+ from infrahub.message_bus import InfrahubMessage
5
8
  from infrahub.message_bus.types import ProposedChangeArtifactDefinition, ProposedChangeBranchDiff
6
9
 
7
10
 
11
+ class BaseProposedChangeWithDiffMessage(InfrahubMessage):
12
+ """Sent trigger the refresh of artifacts that are impacted by the proposed change."""
13
+
14
+ model_config = ConfigDict(arbitrary_types_allowed=True)
15
+
16
+ proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
17
+ source_branch: str = Field(..., description="The source branch of the proposed change")
18
+ source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
19
+ destination_branch: str = Field(..., description="The destination branch of the proposed change")
20
+ branch_diff: ProposedChangeBranchDiff = Field(..., description="The calculated diff between the two branches")
21
+
22
+
8
23
  class RequestProposedChangeDataIntegrity(BaseProposedChangeWithDiffMessage):
9
24
  """Sent trigger data integrity checks for a proposed change"""
10
25
 
@@ -42,4 +57,54 @@ class RequestArtifactDefinitionCheck(BaseModel):
42
57
  source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
43
58
  destination_branch: str = Field(..., description="The target branch")
44
59
 
45
- context: InfrahubContext = Field(..., description="The context of the task")
60
+
61
+ class RunGeneratorAsCheckModel(BaseModel):
62
+ """A check that runs a generator."""
63
+
64
+ generator_definition: ProposedChangeGeneratorDefinition = Field(..., description="The Generator definition")
65
+ generator_instance: str | None = Field(
66
+ default=None, description="The id of the generator instance if it previously existed"
67
+ )
68
+ commit: str = Field(..., description="The commit to target")
69
+ repository_id: str = Field(..., description="The unique ID of the Repository")
70
+ repository_name: str = Field(..., description="The name of the Repository")
71
+ repository_kind: str = Field(..., description="The kind of the Repository")
72
+ branch_name: str = Field(..., description="The branch where the check is run")
73
+ target_id: str = Field(..., description="The ID of the target object for this generator")
74
+ target_name: str = Field(..., description="Name of the generator target")
75
+ query: str = Field(..., description="The name of the query to use when collecting data")
76
+ variables: dict = Field(..., description="Input variables when running the generator")
77
+ validator_id: str = Field(..., description="The ID of the validator")
78
+ proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
79
+
80
+
81
+ class RequestGeneratorDefinitionCheck(BaseModel):
82
+ """Sent to trigger Generators to run for a proposed change."""
83
+
84
+ model_config = ConfigDict(arbitrary_types_allowed=True)
85
+
86
+ generator_definition: ProposedChangeGeneratorDefinition = Field(..., description="The Generator Definition")
87
+ branch_diff: ProposedChangeBranchDiff = Field(..., description="The calculated diff between the two branches")
88
+ proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
89
+ source_branch: str = Field(..., description="The source branch")
90
+ source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
91
+ destination_branch: str = Field(..., description="The target branch")
92
+
93
+
94
+ class RequestProposedChangePipeline(BaseModel):
95
+ """Sent request the start of a pipeline connected to a proposed change."""
96
+
97
+ proposed_change: str = Field(..., description="The unique ID of the proposed change")
98
+ source_branch: str = Field(..., description="The source branch of the proposed change")
99
+ source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
100
+ destination_branch: str = Field(..., description="The destination branch of the proposed change")
101
+ check_type: CheckType = Field(
102
+ default=CheckType.ALL, description="Can be used to restrict the pipeline to a specific type of job"
103
+ )
104
+ pipeline_id: uuid.UUID = Field(
105
+ default_factory=uuid.uuid4, description="The unique ID of the execution of this pipeline"
106
+ )
107
+
108
+
109
+ class RequestProposedChangeRefreshArtifacts(BaseProposedChangeWithDiffMessage):
110
+ """Sent trigger the refresh of artifacts that are impacted by the proposed change."""