infrahub-server 1.7.0b0__py3-none-any.whl → 1.7.0rc0__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 (112) hide show
  1. infrahub/api/exceptions.py +2 -2
  2. infrahub/cli/db.py +48 -22
  3. infrahub/core/account.py +12 -9
  4. infrahub/core/diff/branch_differ.py +1 -1
  5. infrahub/core/diff/conflict_transferer.py +1 -1
  6. infrahub/core/diff/data_check_synchronizer.py +1 -1
  7. infrahub/core/diff/enricher/cardinality_one.py +1 -1
  8. infrahub/core/diff/enricher/hierarchy.py +1 -1
  9. infrahub/core/diff/enricher/labels.py +1 -1
  10. infrahub/core/diff/merger/merger.py +1 -1
  11. infrahub/core/diff/repository/repository.py +3 -1
  12. infrahub/core/graph/constraints.py +1 -1
  13. infrahub/core/ipam/reconciler.py +8 -6
  14. infrahub/core/ipam/utilization.py +8 -15
  15. infrahub/core/manager.py +1 -26
  16. infrahub/core/merge.py +1 -1
  17. infrahub/core/migrations/graph/m012_convert_account_generic.py +12 -12
  18. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +4 -4
  19. infrahub/core/migrations/graph/m041_deleted_dup_edges.py +1 -1
  20. infrahub/core/migrations/graph/m049_remove_is_visible_relationship.py +16 -1
  21. infrahub/core/migrations/query/__init__.py +2 -2
  22. infrahub/core/migrations/query/schema_attribute_update.py +1 -1
  23. infrahub/core/migrations/schema/attribute_name_update.py +1 -1
  24. infrahub/core/migrations/schema/attribute_supports_profile.py +2 -2
  25. infrahub/core/migrations/schema/node_attribute_add.py +1 -1
  26. infrahub/core/migrations/schema/node_attribute_remove.py +1 -1
  27. infrahub/core/migrations/schema/node_kind_update.py +1 -1
  28. infrahub/core/node/__init__.py +1 -1
  29. infrahub/core/node/base.py +9 -5
  30. infrahub/core/node/delete_validator.py +1 -1
  31. infrahub/core/order.py +30 -0
  32. infrahub/core/protocols.py +1 -0
  33. infrahub/core/protocols_base.py +4 -0
  34. infrahub/core/query/__init__.py +8 -5
  35. infrahub/core/query/attribute.py +3 -3
  36. infrahub/core/query/branch.py +1 -1
  37. infrahub/core/query/delete.py +1 -1
  38. infrahub/core/query/diff.py +3 -3
  39. infrahub/core/query/ipam.py +104 -43
  40. infrahub/core/query/node.py +454 -101
  41. infrahub/core/query/relationship.py +83 -26
  42. infrahub/core/query/resource_manager.py +107 -18
  43. infrahub/core/relationship/constraints/count.py +1 -1
  44. infrahub/core/relationship/constraints/peer_kind.py +1 -1
  45. infrahub/core/relationship/constraints/peer_parent.py +1 -1
  46. infrahub/core/relationship/constraints/peer_relatives.py +1 -1
  47. infrahub/core/relationship/constraints/profiles_kind.py +1 -1
  48. infrahub/core/relationship/constraints/profiles_removal.py +1 -1
  49. infrahub/core/schema/attribute_schema.py +0 -13
  50. infrahub/core/schema/basenode_schema.py +3 -0
  51. infrahub/core/schema/definitions/core/__init__.py +8 -2
  52. infrahub/core/schema/definitions/core/account.py +10 -10
  53. infrahub/core/schema/definitions/core/artifact.py +14 -8
  54. infrahub/core/schema/definitions/core/check.py +10 -4
  55. infrahub/core/schema/definitions/core/generator.py +26 -6
  56. infrahub/core/schema/definitions/core/graphql_query.py +1 -1
  57. infrahub/core/schema/definitions/core/group.py +9 -2
  58. infrahub/core/schema/definitions/core/ipam.py +80 -10
  59. infrahub/core/schema/definitions/core/menu.py +41 -7
  60. infrahub/core/schema/definitions/core/permission.py +16 -2
  61. infrahub/core/schema/definitions/core/profile.py +16 -2
  62. infrahub/core/schema/definitions/core/propose_change.py +24 -4
  63. infrahub/core/schema/definitions/core/propose_change_comment.py +23 -11
  64. infrahub/core/schema/definitions/core/propose_change_validator.py +50 -21
  65. infrahub/core/schema/definitions/core/repository.py +10 -0
  66. infrahub/core/schema/definitions/core/resource_pool.py +8 -1
  67. infrahub/core/schema/definitions/core/template.py +19 -2
  68. infrahub/core/schema/definitions/core/transform.py +11 -5
  69. infrahub/core/schema/definitions/core/webhook.py +27 -9
  70. infrahub/core/schema/schema_branch.py +68 -2
  71. infrahub/core/utils.py +3 -3
  72. infrahub/core/validators/aggregated_checker.py +1 -1
  73. infrahub/core/validators/attribute/choices.py +1 -1
  74. infrahub/core/validators/attribute/enum.py +1 -1
  75. infrahub/core/validators/attribute/kind.py +1 -1
  76. infrahub/core/validators/attribute/length.py +1 -1
  77. infrahub/core/validators/attribute/min_max.py +1 -1
  78. infrahub/core/validators/attribute/number_pool.py +1 -1
  79. infrahub/core/validators/attribute/optional.py +1 -1
  80. infrahub/core/validators/attribute/regex.py +1 -1
  81. infrahub/core/validators/node/attribute.py +1 -1
  82. infrahub/core/validators/node/relationship.py +1 -1
  83. infrahub/core/validators/relationship/peer.py +1 -1
  84. infrahub/database/__init__.py +1 -1
  85. infrahub/git/utils.py +1 -1
  86. infrahub/graphql/app.py +2 -2
  87. infrahub/graphql/field_extractor.py +1 -1
  88. infrahub/graphql/manager.py +9 -1
  89. infrahub/graphql/mutations/account.py +1 -1
  90. infrahub/graphql/order.py +14 -0
  91. infrahub/graphql/queries/diff/tree.py +5 -5
  92. infrahub/graphql/queries/resource_manager.py +25 -24
  93. infrahub/graphql/resolvers/ipam.py +3 -3
  94. infrahub/graphql/resolvers/resolver.py +44 -3
  95. infrahub/graphql/types/standard_node.py +8 -4
  96. infrahub/menu/repository.py +1 -1
  97. infrahub/patch/queries/base.py +1 -1
  98. infrahub/pools/number.py +1 -8
  99. infrahub/profiles/node_applier.py +1 -1
  100. infrahub/profiles/queries/get_profile_data.py +1 -1
  101. infrahub/proposed_change/action_checker.py +1 -1
  102. infrahub/services/__init__.py +1 -1
  103. infrahub/services/adapters/cache/nats.py +1 -1
  104. infrahub/webhook/gather.py +1 -1
  105. infrahub/webhook/tasks.py +22 -6
  106. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.0rc0.dist-info}/METADATA +1 -1
  107. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.0rc0.dist-info}/RECORD +111 -110
  108. infrahub_testcontainers/models.py +3 -3
  109. infrahub/graphql/models.py +0 -36
  110. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.0rc0.dist-info}/WHEEL +0 -0
  111. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.0rc0.dist-info}/entry_points.txt +0 -0
  112. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.0rc0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -4,12 +4,12 @@ from infrahub.exceptions import Error
4
4
  class QueryValidationError(Error):
5
5
  HTTP_CODE = 400
6
6
 
7
- def __init__(self, message: str):
7
+ def __init__(self, message: str) -> None:
8
8
  self.message = message
9
9
 
10
10
 
11
11
  class SchemaNotValidError(Error):
12
12
  HTTP_CODE = 422
13
13
 
14
- def __init__(self, message: str):
14
+ def __init__(self, message: str) -> None:
15
15
  self.message = message
infrahub/cli/db.py CHANGED
@@ -65,6 +65,7 @@ def get_timestamp_string() -> str:
65
65
  if TYPE_CHECKING:
66
66
  from infrahub.cli.context import CliContext
67
67
  from infrahub.core.migrations.shared import MigrationTypes
68
+ from infrahub.core.root import Root
68
69
  from infrahub.database import InfrahubDatabase
69
70
  from infrahub.database.index import IndexManagerBase
70
71
 
@@ -93,12 +94,40 @@ def callback() -> None:
93
94
  """
94
95
 
95
96
 
97
+ async def do_migrate(
98
+ db: InfrahubDatabase,
99
+ root_node: Root,
100
+ check: bool = False,
101
+ migration_number: int | None = None,
102
+ ) -> None:
103
+ """Core migration logic that can be called independently of CLI.
104
+
105
+ Args:
106
+ db: The database connection.
107
+ root_node: The root node containing the current graph version.
108
+ check: If True, only check which migrations need to run without applying them.
109
+ migration_number: If provided, run only this specific migration.
110
+ """
111
+ migrations = await detect_migration_to_run(
112
+ current_graph_version=root_node.graph_version, migration_number=migration_number
113
+ )
114
+
115
+ if check or not migrations:
116
+ return
117
+
118
+ await migrate_database(
119
+ db=db, migrations=migrations, initialize=True, update_graph_version=(migration_number is None)
120
+ )
121
+
122
+
96
123
  @app.command(name="migrate")
97
124
  async def migrate_cmd(
98
125
  ctx: typer.Context,
99
126
  check: bool = typer.Option(False, help="Check the state of the database without applying the migrations."),
100
127
  config_file: str = typer.Argument("infrahub.toml", envvar="INFRAHUB_CONFIG"),
101
- migration_number: int | None = typer.Option(None, help="Apply a specific migration by number"),
128
+ migration_number: int | None = typer.Option(
129
+ None, help="Apply a specific migration by number, regardless of current database version"
130
+ ),
102
131
  ) -> None:
103
132
  """Check the current format of the internal graph and apply the necessary migrations"""
104
133
  logging.getLogger("infrahub").setLevel(logging.WARNING)
@@ -111,14 +140,7 @@ async def migrate_cmd(
111
140
  dbdriver = await context.init_db(retry=1)
112
141
 
113
142
  root_node = await get_root_node(db=dbdriver)
114
- migrations = await detect_migration_to_run(
115
- current_graph_version=root_node.graph_version, migration_number=migration_number
116
- )
117
-
118
- if check or not migrations:
119
- return
120
-
121
- await migrate_database(db=dbdriver, migrations=migrations, initialize=True)
143
+ await do_migrate(db=dbdriver, root_node=root_node, check=check, migration_number=migration_number)
122
144
 
123
145
  await dbdriver.close()
124
146
 
@@ -292,18 +314,17 @@ async def detect_migration_to_run(
292
314
  migration = get_migration_by_number(migration_number)
293
315
  migrations.append(migration)
294
316
  if current_graph_version > migration.minimum_version:
317
+ get_migration_console().log(f"Migration {migration_number} will be re-applied.")
318
+ else:
295
319
  get_migration_console().log(
296
- f"Migration {migration_number} already applied. To apply again, run the command without the --check flag."
320
+ f"Migration {migration_number} needs to be applied. Run `infrahub db migrate` to apply all outstanding migrations."
297
321
  )
298
- return []
299
- get_migration_console().log(
300
- f"Migration {migration_number} needs to be applied. Run `infrahub db migrate` to apply all outstanding migrations."
301
- )
302
- else:
303
- migrations.extend(await get_graph_migrations(current_graph_version=current_graph_version))
304
- if not migrations:
305
- get_migration_console().log(f"Database up-to-date (v{current_graph_version}), no migration to execute.")
306
- return []
322
+ return migrations
323
+
324
+ migrations.extend(await get_graph_migrations(current_graph_version=current_graph_version))
325
+ if not migrations:
326
+ get_migration_console().log(f"Database up-to-date (v{current_graph_version}), no migration to execute.")
327
+ return []
307
328
 
308
329
  get_migration_console().log(
309
330
  f"Database needs to be updated (v{current_graph_version} -> v{GRAPH_VERSION}), {len(migrations)} migrations pending"
@@ -312,7 +333,10 @@ async def detect_migration_to_run(
312
333
 
313
334
 
314
335
  async def migrate_database(
315
- db: InfrahubDatabase, migrations: Sequence[MigrationTypes], initialize: bool = False
336
+ db: InfrahubDatabase,
337
+ migrations: Sequence[MigrationTypes],
338
+ initialize: bool = False,
339
+ update_graph_version: bool = True,
316
340
  ) -> bool:
317
341
  """Apply the latest migrations to the database, this function will print the status directly in the console.
318
342
 
@@ -322,6 +346,7 @@ async def migrate_database(
322
346
  db: The database object.
323
347
  migrations: Sequence of migrations to apply.
324
348
  initialize: Whether to initialize the registry before running migrations.
349
+ update_graph_version: Whether to update the graph version after each migration.
325
350
  """
326
351
  if not migrations:
327
352
  return True
@@ -339,8 +364,9 @@ async def migrate_database(
339
364
  validation_result = await migration.validate_migration(db=db)
340
365
  if validation_result.success:
341
366
  get_migration_console().log(f"Migration: {migration.name} {SUCCESS_BADGE}")
342
- root_node.graph_version = migration.minimum_version + 1
343
- await root_node.save(db=db)
367
+ if update_graph_version:
368
+ root_node.graph_version = migration.minimum_version + 1
369
+ await root_node.save(db=db)
344
370
 
345
371
  if not execution_result.success or (validation_result and not validation_result.success):
346
372
  get_migration_console().log(f"Migration: {migration.name} {FAILED_BADGE}")
infrahub/core/account.py CHANGED
@@ -54,11 +54,15 @@ class AccountGlobalPermissionQuery(Query):
54
54
  name: str = "account_global_permissions"
55
55
  type: QueryType = QueryType.READ
56
56
 
57
- def __init__(self, account_id: str, **kwargs: Any):
57
+ def __init__(
58
+ self,
59
+ account_id: str,
60
+ branch: Branch | None = None,
61
+ branch_agnostic: bool = False,
62
+ ) -> None:
63
+ super().__init__(branch=branch, branch_agnostic=branch_agnostic)
58
64
  self.account_id = account_id
59
- super().__init__(**kwargs)
60
65
 
61
- async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa: ARG002
62
66
  self.params["account_id"] = self.account_id
63
67
 
64
68
  branch_filter, branch_params = self.branch.get_query_filter_path(
@@ -66,7 +70,6 @@ class AccountGlobalPermissionQuery(Query):
66
70
  )
67
71
  self.params.update(branch_params)
68
72
 
69
- # ruff: noqa: E501
70
73
  query = """
71
74
  MATCH (account:%(generic_account_node)s)
72
75
  WHERE account.uuid = $account_id
@@ -164,7 +167,7 @@ class AccountObjectPermissionQuery(Query):
164
167
  name: str = "account_object_permissions"
165
168
  type: QueryType = QueryType.READ
166
169
 
167
- def __init__(self, account_id: str, **kwargs: Any):
170
+ def __init__(self, account_id: str, **kwargs: Any) -> None:
168
171
  self.account_id = account_id
169
172
  super().__init__(**kwargs)
170
173
 
@@ -293,7 +296,7 @@ class AccountObjectPermissionQuery(Query):
293
296
 
294
297
 
295
298
  async def fetch_permissions(account_id: str, db: InfrahubDatabase, branch: Branch) -> AssignedPermissions:
296
- query1 = await AccountGlobalPermissionQuery.init(db=db, branch=branch, account_id=account_id, branch_agnostic=True)
299
+ query1 = AccountGlobalPermissionQuery(branch=branch, account_id=account_id, branch_agnostic=True)
297
300
  await query1.execute(db=db)
298
301
  global_permissions = query1.get_permissions()
299
302
 
@@ -308,7 +311,7 @@ class AccountRoleGlobalPermissionQuery(Query):
308
311
  name: str = "account_role_global_permissions"
309
312
  type: QueryType = QueryType.READ
310
313
 
311
- def __init__(self, role_id: str, **kwargs: Any):
314
+ def __init__(self, role_id: str, **kwargs: Any) -> None:
312
315
  self.role_id = role_id
313
316
  super().__init__(**kwargs)
314
317
 
@@ -394,7 +397,7 @@ class AccountRoleObjectPermissionQuery(Query):
394
397
  name: str = "account_role_object_permissions"
395
398
  type: QueryType = QueryType.READ
396
399
 
397
- def __init__(self, role_id: str, **kwargs: Any):
400
+ def __init__(self, role_id: str, **kwargs: Any) -> None:
398
401
  self.role_id = role_id
399
402
  super().__init__(**kwargs)
400
403
 
@@ -515,7 +518,7 @@ class AccountTokenValidateQuery(Query):
515
518
  name: str = "account_token_validate"
516
519
  type: QueryType = QueryType.READ
517
520
 
518
- def __init__(self, token: str, **kwargs: Any):
521
+ def __init__(self, token: str, **kwargs: Any) -> None:
519
522
  self.token = token
520
523
  super().__init__(**kwargs)
521
524
 
@@ -41,7 +41,7 @@ class BranchDiffer:
41
41
  diff_to: str | Timestamp | None = None,
42
42
  db: InfrahubDatabase | None = None,
43
43
  service: InfrahubServices | None = None,
44
- ):
44
+ ) -> None:
45
45
  """_summary_
46
46
 
47
47
  Args:
@@ -9,7 +9,7 @@ from .model.path import (
9
9
 
10
10
 
11
11
  class DiffConflictTransferer:
12
- def __init__(self, diff_combiner: DiffCombiner):
12
+ def __init__(self, diff_combiner: DiffCombiner) -> None:
13
13
  self.diff_combiner = diff_combiner
14
14
 
15
15
  async def transfer(self, earlier: EnrichedDiffRoot, later: EnrichedDiffRoot) -> None:
@@ -29,7 +29,7 @@ class DiffDataCheckSynchronizer:
29
29
  conflicts_extractor: DiffConflictsExtractor,
30
30
  conflict_recorder: ObjectConflictValidatorRecorder,
31
31
  diff_repository: DiffRepository,
32
- ):
32
+ ) -> None:
33
33
  self.db = db
34
34
  self.conflicts_extractor = conflicts_extractor
35
35
  self.conflict_recorder = conflict_recorder
@@ -31,7 +31,7 @@ class DiffCardinalityOneEnricher(DiffEnricherInterface):
31
31
  - changes to properties (IS_PROTECTED, etc) of a cardinality=one relationship are consolidated as well
32
32
  """
33
33
 
34
- def __init__(self, db: InfrahubDatabase):
34
+ def __init__(self, db: InfrahubDatabase) -> None:
35
35
  self.db = db
36
36
  self._node_schema_map: dict[str, MainSchemaTypes] = {}
37
37
 
@@ -24,7 +24,7 @@ log = get_logger()
24
24
  class DiffHierarchyEnricher(DiffEnricherInterface):
25
25
  """Add hierarchy and parent/component nodes to diff even if the higher-level nodes are unchanged"""
26
26
 
27
- def __init__(self, db: InfrahubDatabase, parent_adder: DiffParentNodeAdder):
27
+ def __init__(self, db: InfrahubDatabase, parent_adder: DiffParentNodeAdder) -> None:
28
28
  self.db = db
29
29
  self.parent_adder = parent_adder
30
30
 
@@ -35,7 +35,7 @@ class DisplayLabelRequest:
35
35
  class DiffLabelsEnricher(DiffEnricherInterface):
36
36
  """Add display labels for nodes and labels for relationships"""
37
37
 
38
- def __init__(self, db: InfrahubDatabase):
38
+ def __init__(self, db: InfrahubDatabase) -> None:
39
39
  self.db = db
40
40
  self._base_branch_name: str | None = None
41
41
  self._diff_branch_name: str | None = None
@@ -36,7 +36,7 @@ class DiffMerger:
36
36
  destination_branch: Branch,
37
37
  diff_repository: DiffRepository,
38
38
  serializer: DiffMergeSerializer,
39
- ):
39
+ ) -> None:
40
40
  self.source_branch = source_branch
41
41
  self.destination_branch = destination_branch
42
42
  self.db = db
@@ -49,7 +49,9 @@ log = get_logger()
49
49
 
50
50
 
51
51
  class DiffRepository:
52
- def __init__(self, db: InfrahubDatabase, deserializer: EnrichedDiffDeserializer, max_save_batch_size: int = 1000):
52
+ def __init__(
53
+ self, db: InfrahubDatabase, deserializer: EnrichedDiffDeserializer, max_save_batch_size: int = 1000
54
+ ) -> None:
53
55
  self.db = db
54
56
  self.deserializer = deserializer
55
57
  self.max_save_batch_size = max_save_batch_size
@@ -165,7 +165,7 @@ class ConstraintManagerBase:
165
165
  constraint_node_class: Optional[type[ConstraintItem]] = ConstraintItem
166
166
  constraint_rel_class: Optional[type[ConstraintItem]] = ConstraintItem
167
167
 
168
- def __init__(self, db: InfrahubDatabase):
168
+ def __init__(self, db: InfrahubDatabase) -> None:
169
169
  self.db = db
170
170
 
171
171
  self.nodes: list[ConstraintItem] = []
@@ -101,16 +101,18 @@ class IpamReconciler:
101
101
  )
102
102
  await query.execute(db=self.db)
103
103
 
104
- ip_node_uuid = query.get_ip_node_uuid()
105
- if not ip_node_uuid:
104
+ data = query.get_data()
105
+ if not data or not data.ip_node_uuid:
106
106
  node_type = InfrahubKind.IPPREFIX
107
107
  if isinstance(ip_value, ipaddress.IPv6Interface | ipaddress.IPv4Interface):
108
108
  node_type = InfrahubKind.IPADDRESS
109
109
  raise NodeNotFoundError(node_type=node_type, identifier=str(ip_value))
110
- current_parent_uuid = query.get_current_parent_uuid()
111
- calculated_parent_uuid = query.get_calculated_parent_uuid()
112
- current_children_uuids = set(query.get_current_children_uuids())
113
- calculated_children_uuids = set(query.get_calculated_children_uuids())
110
+
111
+ ip_node_uuid = data.ip_node_uuid
112
+ current_parent_uuid = data.current_parent_uuid
113
+ calculated_parent_uuid = data.calculated_parent_uuid
114
+ current_children_uuids = set(data.current_children_uuids)
115
+ calculated_children_uuids = set(data.calculated_children_uuids)
114
116
 
115
117
  all_uuids: set[str] = set()
116
118
  all_uuids = (all_uuids | {ip_node_uuid}) if ip_node_uuid else all_uuids
@@ -40,25 +40,18 @@ class PrefixUtilizationGetter:
40
40
  )
41
41
  await query.execute(db=self.db)
42
42
 
43
- for result in query.get_results():
44
- prefix_node = result.get_node("pfx")
45
- prefix_id = str(prefix_node.get("uuid"))
46
- branch_name = str(result.get("branch"))
47
- child_node = result.get_node("child")
48
- if InfrahubKind.IPADDRESS in child_node.labels:
43
+ for item in query.get_data():
44
+ if InfrahubKind.IPADDRESS in item.child_labels:
49
45
  child_type = PrefixMemberType.ADDRESS
50
46
  else:
51
47
  child_type = PrefixMemberType.PREFIX
52
- child_value_node = result.get_node("av")
53
- child_prefixlen = child_value_node.get("prefixlen")
54
- child_ip_value = child_value_node.get("value")
55
48
 
56
- if prefix_id not in self._results_by_prefix_id:
57
- self._results_by_prefix_id[prefix_id] = {}
58
- if branch_name not in self._results_by_prefix_id[prefix_id]:
59
- self._results_by_prefix_id[prefix_id][branch_name] = []
60
- self._results_by_prefix_id[prefix_id][branch_name].append(
61
- PrefixChildDetails(child_type=child_type, prefixlen=child_prefixlen, ip_value=child_ip_value)
49
+ if item.prefix_uuid not in self._results_by_prefix_id:
50
+ self._results_by_prefix_id[item.prefix_uuid] = {}
51
+ if item.branch not in self._results_by_prefix_id[item.prefix_uuid]:
52
+ self._results_by_prefix_id[item.prefix_uuid][item.branch] = []
53
+ self._results_by_prefix_id[item.prefix_uuid][item.branch].append(
54
+ PrefixChildDetails(child_type=child_type, prefixlen=item.prefixlen, ip_value=item.ip_value)
62
55
  )
63
56
 
64
57
  async def get_children(
infrahub/core/manager.py CHANGED
@@ -15,6 +15,7 @@ from infrahub.core.constants import (
15
15
  from infrahub.core.metadata.model import MetadataQueryOptions
16
16
  from infrahub.core.node import Node
17
17
  from infrahub.core.node.delete_validator import NodeDeleteValidator
18
+ from infrahub.core.order import OrderModel
18
19
  from infrahub.core.query.node import (
19
20
  AttributeFromDB,
20
21
  GroupedPeerNodes,
@@ -39,7 +40,6 @@ from infrahub.core.schema import (
39
40
  )
40
41
  from infrahub.core.timestamp import Timestamp
41
42
  from infrahub.exceptions import NodeNotFoundError, ProcessingError, SchemaNotFoundError
42
- from infrahub.graphql.models import OrderModel
43
43
 
44
44
  if TYPE_CHECKING:
45
45
  from infrahub.core.branch import Branch
@@ -98,7 +98,6 @@ class NodeManager:
98
98
  branch: Branch | str | None = ...,
99
99
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
100
100
  prefetch_relationships: bool = ...,
101
- account=...,
102
101
  partial_match: bool = ...,
103
102
  branch_agnostic: bool = ...,
104
103
  order: OrderModel | None = ...,
@@ -118,7 +117,6 @@ class NodeManager:
118
117
  branch: Branch | str | None = ...,
119
118
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
120
119
  prefetch_relationships: bool = ...,
121
- account=...,
122
120
  partial_match: bool = ...,
123
121
  branch_agnostic: bool = ...,
124
122
  order: OrderModel | None = ...,
@@ -137,7 +135,6 @@ class NodeManager:
137
135
  branch: Branch | str | None = None,
138
136
  include_metadata: MetadataQueryOptions | MetadataOptions = MetadataOptions.NONE,
139
137
  prefetch_relationships: bool = False,
140
- account=None,
141
138
  partial_match: bool = False,
142
139
  branch_agnostic: bool = False,
143
140
  order: OrderModel | None = None,
@@ -171,7 +168,6 @@ class NodeManager:
171
168
  branch=branch,
172
169
  include_metadata=include_metadata,
173
170
  prefetch_relationships=prefetch_relationships,
174
- account=account,
175
171
  branch_agnostic=branch_agnostic,
176
172
  )
177
173
  return [node] if node else []
@@ -230,7 +226,6 @@ class NodeManager:
230
226
  filters: dict | None = None,
231
227
  at: Timestamp | str | None = None,
232
228
  branch: Branch | str | None = None,
233
- account=None, # noqa: ARG003
234
229
  partial_match: bool = False,
235
230
  branch_agnostic: bool = False,
236
231
  ) -> int:
@@ -534,7 +529,6 @@ class NodeManager:
534
529
  branch: Branch | str | None = ...,
535
530
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
536
531
  prefetch_relationships: bool = ...,
537
- account=...,
538
532
  branch_agnostic: bool = ...,
539
533
  ) -> SchemaProtocol | None: ...
540
534
 
@@ -551,7 +545,6 @@ class NodeManager:
551
545
  branch: Branch | str | None = ...,
552
546
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
553
547
  prefetch_relationships: bool = ...,
554
- account=...,
555
548
  branch_agnostic: bool = ...,
556
549
  ) -> SchemaProtocol: ...
557
550
 
@@ -568,7 +561,6 @@ class NodeManager:
568
561
  branch: Branch | str | None = ...,
569
562
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
570
563
  prefetch_relationships: bool = ...,
571
- account=...,
572
564
  branch_agnostic: bool = ...,
573
565
  ) -> SchemaProtocol | None: ...
574
566
 
@@ -585,7 +577,6 @@ class NodeManager:
585
577
  branch: Branch | str | None = ...,
586
578
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
587
579
  prefetch_relationships: bool = ...,
588
- account=...,
589
580
  branch_agnostic: bool = ...,
590
581
  ) -> Node | None: ...
591
582
 
@@ -602,7 +593,6 @@ class NodeManager:
602
593
  branch: Branch | str | None = ...,
603
594
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
604
595
  prefetch_relationships: bool = ...,
605
- account=...,
606
596
  branch_agnostic: bool = ...,
607
597
  ) -> Node: ...
608
598
 
@@ -619,7 +609,6 @@ class NodeManager:
619
609
  branch: Branch | str | None = ...,
620
610
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
621
611
  prefetch_relationships: bool = ...,
622
- account=...,
623
612
  branch_agnostic: bool = ...,
624
613
  ) -> Node | None: ...
625
614
 
@@ -635,7 +624,6 @@ class NodeManager:
635
624
  branch: Branch | str | None = None,
636
625
  include_metadata: MetadataQueryOptions | MetadataOptions = MetadataOptions.NONE,
637
626
  prefetch_relationships: bool = False,
638
- account=None,
639
627
  branch_agnostic: bool = False,
640
628
  ) -> Node | SchemaProtocol | None:
641
629
  branch = await registry.get_branch(branch=branch, db=db)
@@ -657,7 +645,6 @@ class NodeManager:
657
645
  at=at,
658
646
  include_metadata=include_metadata,
659
647
  prefetch_relationships=prefetch_relationships,
660
- account=account,
661
648
  branch_agnostic=branch_agnostic,
662
649
  order=OrderModel(disable=True),
663
650
  )
@@ -694,7 +681,6 @@ class NodeManager:
694
681
  branch: Branch | str | None = ...,
695
682
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
696
683
  prefetch_relationships: bool = ...,
697
- account=...,
698
684
  ) -> SchemaProtocol | None: ...
699
685
 
700
686
  @overload
@@ -710,7 +696,6 @@ class NodeManager:
710
696
  branch: Branch | str | None = ...,
711
697
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
712
698
  prefetch_relationships: bool = ...,
713
- account=...,
714
699
  branch_agnostic: bool = ...,
715
700
  ) -> SchemaProtocol: ...
716
701
 
@@ -727,7 +712,6 @@ class NodeManager:
727
712
  branch: Branch | str | None = ...,
728
713
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
729
714
  prefetch_relationships: bool = ...,
730
- account=...,
731
715
  branch_agnostic: bool = ...,
732
716
  ) -> SchemaProtocol | None: ...
733
717
 
@@ -744,7 +728,6 @@ class NodeManager:
744
728
  branch: Branch | str | None = ...,
745
729
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
746
730
  prefetch_relationships: bool = ...,
747
- account=...,
748
731
  branch_agnostic: bool = ...,
749
732
  ) -> Node: ...
750
733
 
@@ -761,7 +744,6 @@ class NodeManager:
761
744
  branch: Branch | str | None = ...,
762
745
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
763
746
  prefetch_relationships: bool = ...,
764
- account=...,
765
747
  branch_agnostic: bool = ...,
766
748
  ) -> Node | None: ...
767
749
 
@@ -778,7 +760,6 @@ class NodeManager:
778
760
  branch: Branch | str | None = ...,
779
761
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
780
762
  prefetch_relationships: bool = ...,
781
- account=...,
782
763
  branch_agnostic: bool = ...,
783
764
  ) -> Node | None: ...
784
765
 
@@ -794,7 +775,6 @@ class NodeManager:
794
775
  branch: Branch | str | None = None,
795
776
  include_metadata: MetadataQueryOptions | MetadataOptions = MetadataOptions.NONE,
796
777
  prefetch_relationships: bool = False,
797
- account=None,
798
778
  branch_agnostic: bool = False,
799
779
  ) -> Node | SchemaProtocol | None:
800
780
  branch = await registry.get_branch(branch=branch, db=db)
@@ -844,7 +824,6 @@ class NodeManager:
844
824
  at=at,
845
825
  include_metadata=include_metadata,
846
826
  prefetch_relationships=prefetch_relationships,
847
- account=account,
848
827
  branch_agnostic=branch_agnostic,
849
828
  order=OrderModel(disable=True),
850
829
  )
@@ -876,7 +855,6 @@ class NodeManager:
876
855
  branch: Branch | str | None = ...,
877
856
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
878
857
  prefetch_relationships: bool = ...,
879
- account=...,
880
858
  branch_agnostic: bool = ...,
881
859
  ) -> SchemaProtocol: ...
882
860
 
@@ -892,7 +870,6 @@ class NodeManager:
892
870
  branch: Branch | str | None = ...,
893
871
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
894
872
  prefetch_relationships: bool = ...,
895
- account=...,
896
873
  branch_agnostic: bool = ...,
897
874
  ) -> Any: ...
898
875
 
@@ -907,7 +884,6 @@ class NodeManager:
907
884
  branch: Branch | str | None = None,
908
885
  include_metadata: MetadataQueryOptions | MetadataOptions = MetadataOptions.NONE,
909
886
  prefetch_relationships: bool = False,
910
- account=None,
911
887
  branch_agnostic: bool = False,
912
888
  ) -> Any:
913
889
  branch = await registry.get_branch(branch=branch, db=db)
@@ -935,7 +911,6 @@ class NodeManager:
935
911
  branch=branch,
936
912
  include_metadata=include_metadata,
937
913
  prefetch_relationships=prefetch_relationships,
938
- account=account,
939
914
  branch_agnostic=branch_agnostic,
940
915
  )
941
916
  if not node:
infrahub/core/merge.py CHANGED
@@ -43,7 +43,7 @@ class BranchMerger:
43
43
  diff_locker: DiffLocker,
44
44
  destination_branch: Branch | None = None,
45
45
  workflow: InfrahubWorkflow | None = None,
46
- ):
46
+ ) -> None:
47
47
  self.source_branch = source_branch
48
48
  self.destination_branch: Branch = destination_branch or registry.get_branch_from_registry()
49
49
  self.db = db