infrahub-server 1.2.11__py3-none-any.whl → 1.3.0__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 (211) hide show
  1. infrahub/actions/constants.py +130 -0
  2. infrahub/actions/gather.py +114 -0
  3. infrahub/actions/models.py +243 -0
  4. infrahub/actions/parsers.py +104 -0
  5. infrahub/actions/schema.py +393 -0
  6. infrahub/actions/tasks.py +119 -0
  7. infrahub/actions/triggers.py +21 -0
  8. infrahub/branch/__init__.py +0 -0
  9. infrahub/branch/tasks.py +29 -0
  10. infrahub/branch/triggers.py +22 -0
  11. infrahub/cli/db.py +3 -4
  12. infrahub/computed_attribute/gather.py +3 -1
  13. infrahub/computed_attribute/tasks.py +23 -29
  14. infrahub/core/account.py +24 -47
  15. infrahub/core/attribute.py +13 -15
  16. infrahub/core/constants/__init__.py +10 -0
  17. infrahub/core/constants/database.py +1 -0
  18. infrahub/core/constants/infrahubkind.py +9 -0
  19. infrahub/core/constraint/node/runner.py +3 -1
  20. infrahub/core/convert_object_type/__init__.py +0 -0
  21. infrahub/core/convert_object_type/conversion.py +124 -0
  22. infrahub/core/convert_object_type/schema_mapping.py +56 -0
  23. infrahub/core/diff/coordinator.py +8 -1
  24. infrahub/core/diff/query/all_conflicts.py +1 -5
  25. infrahub/core/diff/query/artifact.py +10 -20
  26. infrahub/core/diff/query/delete_query.py +8 -4
  27. infrahub/core/diff/query/diff_get.py +3 -6
  28. infrahub/core/diff/query/field_specifiers.py +1 -1
  29. infrahub/core/diff/query/field_summary.py +2 -4
  30. infrahub/core/diff/query/merge.py +72 -125
  31. infrahub/core/diff/query/save.py +83 -68
  32. infrahub/core/diff/query/summary_counts_enricher.py +34 -54
  33. infrahub/core/diff/query/time_range_query.py +0 -1
  34. infrahub/core/diff/repository/repository.py +4 -0
  35. infrahub/core/graph/__init__.py +1 -1
  36. infrahub/core/manager.py +14 -11
  37. infrahub/core/migrations/graph/__init__.py +6 -0
  38. infrahub/core/migrations/graph/m003_relationship_parent_optional.py +1 -2
  39. infrahub/core/migrations/graph/m012_convert_account_generic.py +1 -1
  40. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +2 -6
  41. infrahub/core/migrations/graph/m015_diff_format_update.py +1 -2
  42. infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +1 -2
  43. infrahub/core/migrations/graph/m019_restore_rels_to_time.py +11 -22
  44. infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -6
  45. infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +1 -2
  46. infrahub/core/migrations/graph/m023_deduplicate_cardinality_one_relationships.py +2 -2
  47. infrahub/core/migrations/graph/m024_missing_hierarchy_backfill.py +1 -2
  48. infrahub/core/migrations/graph/m028_delete_diffs.py +1 -2
  49. infrahub/core/migrations/graph/m029_duplicates_cleanup.py +662 -0
  50. infrahub/core/migrations/graph/m030_illegal_edges.py +82 -0
  51. infrahub/core/migrations/query/attribute_add.py +14 -11
  52. infrahub/core/migrations/query/attribute_rename.py +6 -11
  53. infrahub/core/migrations/query/delete_element_in_schema.py +19 -17
  54. infrahub/core/migrations/query/node_duplicate.py +19 -21
  55. infrahub/core/migrations/query/relationship_duplicate.py +19 -18
  56. infrahub/core/migrations/schema/node_attribute_remove.py +4 -8
  57. infrahub/core/migrations/schema/node_remove.py +19 -20
  58. infrahub/core/models.py +29 -2
  59. infrahub/core/node/__init__.py +131 -28
  60. infrahub/core/node/base.py +1 -1
  61. infrahub/core/node/create.py +211 -0
  62. infrahub/core/node/resource_manager/number_pool.py +31 -5
  63. infrahub/core/node/standard.py +6 -1
  64. infrahub/core/path.py +15 -1
  65. infrahub/core/protocols.py +57 -0
  66. infrahub/core/protocols_base.py +3 -0
  67. infrahub/core/query/__init__.py +2 -2
  68. infrahub/core/query/delete.py +3 -3
  69. infrahub/core/query/diff.py +19 -32
  70. infrahub/core/query/ipam.py +10 -20
  71. infrahub/core/query/node.py +29 -47
  72. infrahub/core/query/relationship.py +55 -34
  73. infrahub/core/query/resource_manager.py +1 -2
  74. infrahub/core/query/standard_node.py +19 -5
  75. infrahub/core/query/subquery.py +2 -4
  76. infrahub/core/relationship/constraints/count.py +10 -9
  77. infrahub/core/relationship/constraints/interface.py +2 -1
  78. infrahub/core/relationship/constraints/peer_kind.py +2 -1
  79. infrahub/core/relationship/constraints/peer_parent.py +56 -0
  80. infrahub/core/relationship/constraints/peer_relatives.py +72 -0
  81. infrahub/core/relationship/constraints/profiles_kind.py +1 -1
  82. infrahub/core/relationship/model.py +4 -1
  83. infrahub/core/schema/__init__.py +2 -1
  84. infrahub/core/schema/attribute_parameters.py +160 -0
  85. infrahub/core/schema/attribute_schema.py +130 -7
  86. infrahub/core/schema/basenode_schema.py +27 -3
  87. infrahub/core/schema/definitions/core/__init__.py +29 -1
  88. infrahub/core/schema/definitions/core/group.py +45 -0
  89. infrahub/core/schema/definitions/core/resource_pool.py +9 -0
  90. infrahub/core/schema/definitions/internal.py +43 -5
  91. infrahub/core/schema/generated/attribute_schema.py +16 -3
  92. infrahub/core/schema/generated/relationship_schema.py +11 -1
  93. infrahub/core/schema/manager.py +7 -2
  94. infrahub/core/schema/schema_branch.py +109 -12
  95. infrahub/core/validators/__init__.py +15 -2
  96. infrahub/core/validators/attribute/choices.py +1 -3
  97. infrahub/core/validators/attribute/enum.py +1 -3
  98. infrahub/core/validators/attribute/kind.py +1 -3
  99. infrahub/core/validators/attribute/length.py +13 -7
  100. infrahub/core/validators/attribute/min_max.py +118 -0
  101. infrahub/core/validators/attribute/number_pool.py +106 -0
  102. infrahub/core/validators/attribute/optional.py +1 -4
  103. infrahub/core/validators/attribute/regex.py +5 -6
  104. infrahub/core/validators/attribute/unique.py +1 -3
  105. infrahub/core/validators/determiner.py +18 -2
  106. infrahub/core/validators/enum.py +12 -0
  107. infrahub/core/validators/node/hierarchy.py +3 -6
  108. infrahub/core/validators/query.py +1 -3
  109. infrahub/core/validators/relationship/count.py +6 -12
  110. infrahub/core/validators/relationship/optional.py +2 -4
  111. infrahub/core/validators/relationship/peer.py +177 -12
  112. infrahub/core/validators/tasks.py +1 -1
  113. infrahub/core/validators/uniqueness/query.py +5 -9
  114. infrahub/database/__init__.py +12 -4
  115. infrahub/database/validation.py +100 -0
  116. infrahub/dependencies/builder/constraint/grouped/node_runner.py +4 -0
  117. infrahub/dependencies/builder/constraint/relationship_manager/peer_parent.py +8 -0
  118. infrahub/dependencies/builder/constraint/relationship_manager/peer_relatives.py +8 -0
  119. infrahub/dependencies/builder/constraint/schema/aggregated.py +2 -0
  120. infrahub/dependencies/builder/constraint/schema/relationship_peer.py +8 -0
  121. infrahub/dependencies/builder/diff/deserializer.py +1 -1
  122. infrahub/dependencies/registry.py +4 -0
  123. infrahub/events/group_action.py +1 -0
  124. infrahub/events/models.py +1 -1
  125. infrahub/git/base.py +5 -3
  126. infrahub/git/integrator.py +96 -5
  127. infrahub/git/tasks.py +1 -0
  128. infrahub/graphql/analyzer.py +139 -18
  129. infrahub/graphql/manager.py +4 -0
  130. infrahub/graphql/mutations/action.py +164 -0
  131. infrahub/graphql/mutations/convert_object_type.py +71 -0
  132. infrahub/graphql/mutations/main.py +25 -176
  133. infrahub/graphql/mutations/proposed_change.py +20 -17
  134. infrahub/graphql/mutations/relationship.py +32 -0
  135. infrahub/graphql/mutations/resource_manager.py +63 -7
  136. infrahub/graphql/queries/convert_object_type_mapping.py +34 -0
  137. infrahub/graphql/queries/resource_manager.py +7 -1
  138. infrahub/graphql/resolvers/many_relationship.py +1 -1
  139. infrahub/graphql/resolvers/resolver.py +2 -2
  140. infrahub/graphql/resolvers/single_relationship.py +1 -1
  141. infrahub/graphql/schema.py +6 -0
  142. infrahub/menu/menu.py +34 -2
  143. infrahub/message_bus/messages/__init__.py +0 -10
  144. infrahub/message_bus/operations/__init__.py +0 -8
  145. infrahub/message_bus/operations/refresh/registry.py +4 -7
  146. infrahub/patch/queries/delete_duplicated_edges.py +45 -39
  147. infrahub/pools/models.py +14 -0
  148. infrahub/pools/number.py +5 -3
  149. infrahub/pools/registration.py +22 -0
  150. infrahub/pools/tasks.py +126 -0
  151. infrahub/prefect_server/models.py +1 -19
  152. infrahub/proposed_change/models.py +68 -3
  153. infrahub/proposed_change/tasks.py +911 -34
  154. infrahub/schema/__init__.py +0 -0
  155. infrahub/schema/tasks.py +27 -0
  156. infrahub/schema/triggers.py +23 -0
  157. infrahub/task_manager/models.py +10 -6
  158. infrahub/trigger/catalogue.py +6 -0
  159. infrahub/trigger/models.py +23 -6
  160. infrahub/trigger/setup.py +26 -2
  161. infrahub/trigger/tasks.py +4 -2
  162. infrahub/types.py +6 -0
  163. infrahub/webhook/tasks.py +6 -9
  164. infrahub/workflows/catalogue.py +103 -1
  165. infrahub_sdk/client.py +43 -10
  166. infrahub_sdk/ctl/generator.py +4 -4
  167. infrahub_sdk/ctl/repository.py +1 -1
  168. infrahub_sdk/node/__init__.py +39 -0
  169. infrahub_sdk/node/attribute.py +122 -0
  170. infrahub_sdk/node/constants.py +21 -0
  171. infrahub_sdk/{node.py → node/node.py} +158 -803
  172. infrahub_sdk/node/parsers.py +15 -0
  173. infrahub_sdk/node/property.py +24 -0
  174. infrahub_sdk/node/related_node.py +266 -0
  175. infrahub_sdk/node/relationship.py +302 -0
  176. infrahub_sdk/protocols.py +112 -0
  177. infrahub_sdk/protocols_base.py +34 -2
  178. infrahub_sdk/pytest_plugin/items/python_transform.py +2 -1
  179. infrahub_sdk/query_groups.py +17 -5
  180. infrahub_sdk/schema/main.py +1 -0
  181. infrahub_sdk/schema/repository.py +16 -0
  182. infrahub_sdk/spec/object.py +1 -1
  183. infrahub_sdk/store.py +1 -1
  184. infrahub_sdk/testing/schemas/car_person.py +1 -0
  185. infrahub_sdk/utils.py +7 -20
  186. infrahub_sdk/yaml.py +6 -5
  187. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/METADATA +5 -5
  188. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/RECORD +197 -168
  189. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/WHEEL +1 -1
  190. infrahub_testcontainers/container.py +239 -65
  191. infrahub_testcontainers/docker-compose-cluster.test.yml +321 -0
  192. infrahub_testcontainers/docker-compose.test.yml +2 -1
  193. infrahub_testcontainers/helpers.py +23 -3
  194. infrahub_testcontainers/plugin.py +9 -0
  195. infrahub/message_bus/messages/check_generator_run.py +0 -26
  196. infrahub/message_bus/messages/finalize_validator_execution.py +0 -15
  197. infrahub/message_bus/messages/proposed_change/base_with_diff.py +0 -16
  198. infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +0 -11
  199. infrahub/message_bus/messages/request_generatordefinition_check.py +0 -20
  200. infrahub/message_bus/messages/request_proposedchange_pipeline.py +0 -23
  201. infrahub/message_bus/operations/check/__init__.py +0 -3
  202. infrahub/message_bus/operations/check/generator.py +0 -156
  203. infrahub/message_bus/operations/finalize/__init__.py +0 -3
  204. infrahub/message_bus/operations/finalize/validator.py +0 -133
  205. infrahub/message_bus/operations/requests/__init__.py +0 -9
  206. infrahub/message_bus/operations/requests/generator_definition.py +0 -140
  207. infrahub/message_bus/operations/requests/proposed_change.py +0 -629
  208. infrahub/patch/queries/consolidate_duplicated_nodes.py +0 -109
  209. /infrahub/{message_bus/messages/proposed_change → actions}/__init__.py +0 -0
  210. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/LICENSE.txt +0 -0
  211. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/entry_points.txt +0 -0
@@ -97,8 +97,7 @@ class DeleteNodesRelsQuery(Query):
97
97
  // - on deleted edge branch
98
98
  // - or on any branch and deleted node is agnostic
99
99
  // - or deleted node is aware and rel is agnostic
100
- CALL {
101
- WITH rel, deleted_edge
100
+ CALL (rel, deleted_edge) {
102
101
  OPTIONAL MATCH (rel)-[peer_active_edge {status: "active"}]-(peer_1)
103
102
  WHERE (peer_active_edge.branch = deleted_edge.branch OR (rel.branch_support <> $branch_agnostic AND deleted_edge.branch = $global_branch))
104
103
  AND peer_active_edge.to IS NULL
@@ -160,62 +159,52 @@ class DeleteNodesRelsQuery(Query):
160
159
  // Below CALL subqueries are called once for each rel-peer_2 pair for which we want to create a deleted edge.
161
160
  // Note that with current infrahub relationships edges design, only one of this CALL should be matched per pair.
162
161
 
163
- CALL {
164
- WITH rel, peer_2, branch, branch_level, deleted_time
162
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
165
163
  MATCH (rel)-[:IS_RELATED]->(peer_2)
166
164
  MERGE (rel)-[:IS_RELATED {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
167
165
  }
168
166
 
169
- CALL {
170
- WITH rel, peer_2, branch, branch_level, deleted_time
167
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
171
168
  MATCH (rel)-[:IS_PROTECTED]->(peer_2)
172
169
  MERGE (rel)-[:IS_PROTECTED {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
173
170
  }
174
171
 
175
- CALL {
176
- WITH rel, peer_2, branch, branch_level, deleted_time
172
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
177
173
  MATCH (rel)-[:IS_VISIBLE]->(peer_2)
178
174
  MERGE (rel)-[:IS_VISIBLE {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
179
175
  }
180
176
 
181
- CALL {
182
- WITH rel, peer_2, branch, branch_level, deleted_time
177
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
183
178
  MATCH (rel)-[:HAS_OWNER]->(peer_2)
184
179
  MERGE (rel)-[:HAS_OWNER {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
185
180
  }
186
181
 
187
- CALL {
188
- WITH rel, peer_2, branch, branch_level, deleted_time
182
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
189
183
  MATCH (rel)-[:HAS_SOURCE]->(peer_2)
190
184
  MERGE (rel)-[:HAS_SOURCE {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
191
185
  }
192
186
 
193
- CALL {
194
- WITH rel, peer_2, branch, branch_level, deleted_time
187
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
195
188
  MATCH (rel)<-[:IS_RELATED]-(peer_2)
196
189
  MERGE (rel)<-[:IS_RELATED {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
197
190
  }
198
191
 
199
- CALL {
200
- WITH rel, peer_2, branch, branch_level, deleted_time
192
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
201
193
  MATCH (rel)<-[:IS_PROTECTED]-(peer_2)
202
194
  MERGE (rel)<-[:IS_PROTECTED {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
203
195
  }
204
196
 
205
- CALL {
206
- WITH rel, peer_2, branch, branch_level, deleted_time
197
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
207
198
  MATCH (rel)<-[:IS_VISIBLE]-(peer_2)
208
199
  MERGE (rel)<-[:IS_VISIBLE {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
209
200
  }
210
201
 
211
- CALL {
212
- WITH rel, peer_2, branch, branch_level, deleted_time
202
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
213
203
  MATCH (rel)<-[:HAS_OWNER]-(peer_2)
214
204
  MERGE (rel)<-[:HAS_OWNER {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
215
205
  }
216
206
 
217
- CALL {
218
- WITH rel, peer_2, branch, branch_level, deleted_time
207
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
219
208
  MATCH (rel)<-[:HAS_SOURCE]-(peer_2)
220
209
  MERGE (rel)<-[:HAS_SOURCE {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
221
210
  }
@@ -33,8 +33,7 @@ WHERE num_duplicate_edges > 1
33
33
  // -------------------
34
34
  WITH DISTINCT a, branch, branch_level, status, from, to, attr_val, attr_default
35
35
  WITH attr_val, attr_default, collect([a, branch, branch_level, status, from, to]) AS details_list
36
- CALL {
37
- WITH attr_val, attr_default
36
+ CALL (attr_val, attr_default) {
38
37
  MATCH (av:AttributeValue {value: attr_val, is_default: attr_default})
39
38
  RETURN av AS the_one_av
40
39
  ORDER by %(id_func)s(av) ASC
@@ -53,11 +52,10 @@ WITH a, branch, status, from, to, attr_val, attr_default, %(id_func)s(fresh_e) A
53
52
  // -------------------
54
53
  // get the identical edges for a given set of Attribute node, edge properties, AttributeValue.value
55
54
  // -------------------
56
- CALL {
55
+ CALL (a, branch, status, from, to, attr_val, attr_default, e_id_to_keep) {
57
56
  // -------------------
58
57
  // delete the duplicate edges a given set of Attribute node, edge properties, AttributeValue.value
59
58
  // -------------------
60
- WITH a, branch, status, from, to, attr_val, attr_default, e_id_to_keep
61
59
  MATCH (a)-[e:HAS_VALUE]->(av:AttributeValue {value: attr_val, is_default: attr_default})
62
60
  WHERE %(id_func)s(e) <> e_id_to_keep
63
61
  AND e.branch = branch AND e.status = status AND e.from = from
@@ -99,8 +97,7 @@ WITH DISTINCT a, branch, branch_level, status, from, to, b
99
97
  CREATE (a)-[fresh_e:%(edge_type)s {branch: branch, branch_level: branch_level, status: status, from: from}]->(b)
100
98
  SET fresh_e.to = to
101
99
  WITH a, branch, status, from, to, b, %(id_func)s(fresh_e) AS e_id_to_keep
102
- CALL {
103
- WITH a, branch, status, from, to, b, e_id_to_keep
100
+ CALL (a, branch, status, from, to, b, e_id_to_keep) {
104
101
  MATCH (a)-[e:%(edge_type)s]->(b)
105
102
  WHERE %(id_func)s(e) <> e_id_to_keep
106
103
  AND e.branch = branch AND e.status = status AND e.from = from
@@ -24,8 +24,7 @@ class SetMissingHierarchyQuery(Query):
24
24
  WITH r.default_branch AS default_branch
25
25
  MATCH (n:Node)-[main_e:IS_RELATED {branch: default_branch}]-(rel:Relationship)
26
26
  WHERE main_e.hierarchy IS NULL
27
- CALL {
28
- WITH n, main_e, rel
27
+ CALL (n, main_e, rel) {
29
28
  MATCH (n)-[branch_e:IS_RELATED]-(rel)
30
29
  WHERE branch_e.hierarchy IS NOT NULL
31
30
  AND branch_e.branch <> main_e.branch
@@ -52,7 +52,7 @@ class DedupCardinalityOneRelsQuery(Query):
52
52
  # of a one-to-many BIDIR relationship.
53
53
  query = """
54
54
 
55
- CALL {
55
+ CALL () {
56
56
  MATCH (rel_node: Relationship)-[edge:IS_RELATED]->(n: Node)<-[edge_2:IS_RELATED]-(rel_node_2: Relationship {name: rel_node.name})
57
57
  WHERE rel_node.name in $rel_one_identifiers_inbound[n.kind]
58
58
  AND edge.branch = edge_2.branch
@@ -64,7 +64,7 @@ class DedupCardinalityOneRelsQuery(Query):
64
64
  DETACH DELETE rel_node
65
65
  }
66
66
 
67
- CALL {
67
+ CALL () {
68
68
  MATCH (rel_node_3: Relationship)<-[edge_3:IS_RELATED]-(n: Node)-[edge_4:IS_RELATED]->(rel_node_4: Relationship {name: rel_node_3.name})
69
69
  WHERE rel_node_3.name in $rel_one_identifiers_outbound[n.kind]
70
70
  AND edge_3.branch = edge_4.branch
@@ -39,8 +39,7 @@ class BackfillMissingHierarchyQuery(Query):
39
39
  MATCH (rel:Relationship {name: "parent__child"})-[e:IS_RELATED]-(n:Node)
40
40
  WHERE e.hierarchy IS NULL
41
41
  WITH DISTINCT rel, n, default_branch
42
- CALL {
43
- WITH rel, n, default_branch
42
+ CALL (rel, n, default_branch) {
44
43
  MATCH (rel)-[e:IS_RELATED {branch: default_branch}]-(n)
45
44
  RETURN e
46
45
  ORDER BY e.from DESC
@@ -33,6 +33,5 @@ class Migration028(ArbitraryMigration):
33
33
  component_registry = get_component_registry()
34
34
  diff_repo = await component_registry.get_component(DiffRepository, db=db, branch=default_branch)
35
35
 
36
- diff_roots = await diff_repo.get_roots_metadata()
37
- await diff_repo.delete_diff_roots(diff_root_uuids=[d.uuid for d in diff_roots])
36
+ await diff_repo.delete_all_diff_roots()
38
37
  return MigrationResult()