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.
- infrahub/actions/constants.py +130 -0
- infrahub/actions/gather.py +114 -0
- infrahub/actions/models.py +243 -0
- infrahub/actions/parsers.py +104 -0
- infrahub/actions/schema.py +393 -0
- infrahub/actions/tasks.py +119 -0
- infrahub/actions/triggers.py +21 -0
- infrahub/branch/__init__.py +0 -0
- infrahub/branch/tasks.py +29 -0
- infrahub/branch/triggers.py +22 -0
- infrahub/cli/db.py +3 -4
- infrahub/computed_attribute/gather.py +3 -1
- infrahub/computed_attribute/tasks.py +23 -29
- infrahub/core/account.py +24 -47
- infrahub/core/attribute.py +13 -15
- infrahub/core/constants/__init__.py +10 -0
- infrahub/core/constants/database.py +1 -0
- infrahub/core/constants/infrahubkind.py +9 -0
- infrahub/core/constraint/node/runner.py +3 -1
- infrahub/core/convert_object_type/__init__.py +0 -0
- infrahub/core/convert_object_type/conversion.py +124 -0
- infrahub/core/convert_object_type/schema_mapping.py +56 -0
- infrahub/core/diff/coordinator.py +8 -1
- infrahub/core/diff/query/all_conflicts.py +1 -5
- infrahub/core/diff/query/artifact.py +10 -20
- infrahub/core/diff/query/delete_query.py +8 -4
- infrahub/core/diff/query/diff_get.py +3 -6
- infrahub/core/diff/query/field_specifiers.py +1 -1
- infrahub/core/diff/query/field_summary.py +2 -4
- infrahub/core/diff/query/merge.py +72 -125
- infrahub/core/diff/query/save.py +83 -68
- infrahub/core/diff/query/summary_counts_enricher.py +34 -54
- infrahub/core/diff/query/time_range_query.py +0 -1
- infrahub/core/diff/repository/repository.py +4 -0
- infrahub/core/graph/__init__.py +1 -1
- infrahub/core/manager.py +14 -11
- infrahub/core/migrations/graph/__init__.py +6 -0
- infrahub/core/migrations/graph/m003_relationship_parent_optional.py +1 -2
- infrahub/core/migrations/graph/m012_convert_account_generic.py +1 -1
- infrahub/core/migrations/graph/m013_convert_git_password_credential.py +2 -6
- infrahub/core/migrations/graph/m015_diff_format_update.py +1 -2
- infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +1 -2
- infrahub/core/migrations/graph/m019_restore_rels_to_time.py +11 -22
- infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -6
- infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +1 -2
- infrahub/core/migrations/graph/m023_deduplicate_cardinality_one_relationships.py +2 -2
- infrahub/core/migrations/graph/m024_missing_hierarchy_backfill.py +1 -2
- infrahub/core/migrations/graph/m028_delete_diffs.py +1 -2
- infrahub/core/migrations/graph/m029_duplicates_cleanup.py +662 -0
- infrahub/core/migrations/graph/m030_illegal_edges.py +82 -0
- infrahub/core/migrations/query/attribute_add.py +14 -11
- infrahub/core/migrations/query/attribute_rename.py +6 -11
- infrahub/core/migrations/query/delete_element_in_schema.py +19 -17
- infrahub/core/migrations/query/node_duplicate.py +19 -21
- infrahub/core/migrations/query/relationship_duplicate.py +19 -18
- infrahub/core/migrations/schema/node_attribute_remove.py +4 -8
- infrahub/core/migrations/schema/node_remove.py +19 -20
- infrahub/core/models.py +29 -2
- infrahub/core/node/__init__.py +131 -28
- infrahub/core/node/base.py +1 -1
- infrahub/core/node/create.py +211 -0
- infrahub/core/node/resource_manager/number_pool.py +31 -5
- infrahub/core/node/standard.py +6 -1
- infrahub/core/path.py +15 -1
- infrahub/core/protocols.py +57 -0
- infrahub/core/protocols_base.py +3 -0
- infrahub/core/query/__init__.py +2 -2
- infrahub/core/query/delete.py +3 -3
- infrahub/core/query/diff.py +19 -32
- infrahub/core/query/ipam.py +10 -20
- infrahub/core/query/node.py +29 -47
- infrahub/core/query/relationship.py +55 -34
- infrahub/core/query/resource_manager.py +1 -2
- infrahub/core/query/standard_node.py +19 -5
- infrahub/core/query/subquery.py +2 -4
- infrahub/core/relationship/constraints/count.py +10 -9
- infrahub/core/relationship/constraints/interface.py +2 -1
- infrahub/core/relationship/constraints/peer_kind.py +2 -1
- infrahub/core/relationship/constraints/peer_parent.py +56 -0
- infrahub/core/relationship/constraints/peer_relatives.py +72 -0
- infrahub/core/relationship/constraints/profiles_kind.py +1 -1
- infrahub/core/relationship/model.py +4 -1
- infrahub/core/schema/__init__.py +2 -1
- infrahub/core/schema/attribute_parameters.py +160 -0
- infrahub/core/schema/attribute_schema.py +130 -7
- infrahub/core/schema/basenode_schema.py +27 -3
- infrahub/core/schema/definitions/core/__init__.py +29 -1
- infrahub/core/schema/definitions/core/group.py +45 -0
- infrahub/core/schema/definitions/core/resource_pool.py +9 -0
- infrahub/core/schema/definitions/internal.py +43 -5
- infrahub/core/schema/generated/attribute_schema.py +16 -3
- infrahub/core/schema/generated/relationship_schema.py +11 -1
- infrahub/core/schema/manager.py +7 -2
- infrahub/core/schema/schema_branch.py +109 -12
- infrahub/core/validators/__init__.py +15 -2
- infrahub/core/validators/attribute/choices.py +1 -3
- infrahub/core/validators/attribute/enum.py +1 -3
- infrahub/core/validators/attribute/kind.py +1 -3
- infrahub/core/validators/attribute/length.py +13 -7
- infrahub/core/validators/attribute/min_max.py +118 -0
- infrahub/core/validators/attribute/number_pool.py +106 -0
- infrahub/core/validators/attribute/optional.py +1 -4
- infrahub/core/validators/attribute/regex.py +5 -6
- infrahub/core/validators/attribute/unique.py +1 -3
- infrahub/core/validators/determiner.py +18 -2
- infrahub/core/validators/enum.py +12 -0
- infrahub/core/validators/node/hierarchy.py +3 -6
- infrahub/core/validators/query.py +1 -3
- infrahub/core/validators/relationship/count.py +6 -12
- infrahub/core/validators/relationship/optional.py +2 -4
- infrahub/core/validators/relationship/peer.py +177 -12
- infrahub/core/validators/tasks.py +1 -1
- infrahub/core/validators/uniqueness/query.py +5 -9
- infrahub/database/__init__.py +12 -4
- infrahub/database/validation.py +100 -0
- infrahub/dependencies/builder/constraint/grouped/node_runner.py +4 -0
- infrahub/dependencies/builder/constraint/relationship_manager/peer_parent.py +8 -0
- infrahub/dependencies/builder/constraint/relationship_manager/peer_relatives.py +8 -0
- infrahub/dependencies/builder/constraint/schema/aggregated.py +2 -0
- infrahub/dependencies/builder/constraint/schema/relationship_peer.py +8 -0
- infrahub/dependencies/builder/diff/deserializer.py +1 -1
- infrahub/dependencies/registry.py +4 -0
- infrahub/events/group_action.py +1 -0
- infrahub/events/models.py +1 -1
- infrahub/git/base.py +5 -3
- infrahub/git/integrator.py +96 -5
- infrahub/git/tasks.py +1 -0
- infrahub/graphql/analyzer.py +139 -18
- infrahub/graphql/manager.py +4 -0
- infrahub/graphql/mutations/action.py +164 -0
- infrahub/graphql/mutations/convert_object_type.py +71 -0
- infrahub/graphql/mutations/main.py +25 -176
- infrahub/graphql/mutations/proposed_change.py +20 -17
- infrahub/graphql/mutations/relationship.py +32 -0
- infrahub/graphql/mutations/resource_manager.py +63 -7
- infrahub/graphql/queries/convert_object_type_mapping.py +34 -0
- infrahub/graphql/queries/resource_manager.py +7 -1
- infrahub/graphql/resolvers/many_relationship.py +1 -1
- infrahub/graphql/resolvers/resolver.py +2 -2
- infrahub/graphql/resolvers/single_relationship.py +1 -1
- infrahub/graphql/schema.py +6 -0
- infrahub/menu/menu.py +34 -2
- infrahub/message_bus/messages/__init__.py +0 -10
- infrahub/message_bus/operations/__init__.py +0 -8
- infrahub/message_bus/operations/refresh/registry.py +4 -7
- infrahub/patch/queries/delete_duplicated_edges.py +45 -39
- infrahub/pools/models.py +14 -0
- infrahub/pools/number.py +5 -3
- infrahub/pools/registration.py +22 -0
- infrahub/pools/tasks.py +126 -0
- infrahub/prefect_server/models.py +1 -19
- infrahub/proposed_change/models.py +68 -3
- infrahub/proposed_change/tasks.py +911 -34
- infrahub/schema/__init__.py +0 -0
- infrahub/schema/tasks.py +27 -0
- infrahub/schema/triggers.py +23 -0
- infrahub/task_manager/models.py +10 -6
- infrahub/trigger/catalogue.py +6 -0
- infrahub/trigger/models.py +23 -6
- infrahub/trigger/setup.py +26 -2
- infrahub/trigger/tasks.py +4 -2
- infrahub/types.py +6 -0
- infrahub/webhook/tasks.py +6 -9
- infrahub/workflows/catalogue.py +103 -1
- infrahub_sdk/client.py +43 -10
- infrahub_sdk/ctl/generator.py +4 -4
- infrahub_sdk/ctl/repository.py +1 -1
- infrahub_sdk/node/__init__.py +39 -0
- infrahub_sdk/node/attribute.py +122 -0
- infrahub_sdk/node/constants.py +21 -0
- infrahub_sdk/{node.py → node/node.py} +158 -803
- infrahub_sdk/node/parsers.py +15 -0
- infrahub_sdk/node/property.py +24 -0
- infrahub_sdk/node/related_node.py +266 -0
- infrahub_sdk/node/relationship.py +302 -0
- infrahub_sdk/protocols.py +112 -0
- infrahub_sdk/protocols_base.py +34 -2
- infrahub_sdk/pytest_plugin/items/python_transform.py +2 -1
- infrahub_sdk/query_groups.py +17 -5
- infrahub_sdk/schema/main.py +1 -0
- infrahub_sdk/schema/repository.py +16 -0
- infrahub_sdk/spec/object.py +1 -1
- infrahub_sdk/store.py +1 -1
- infrahub_sdk/testing/schemas/car_person.py +1 -0
- infrahub_sdk/utils.py +7 -20
- infrahub_sdk/yaml.py +6 -5
- {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/METADATA +5 -5
- {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/RECORD +197 -168
- {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/WHEEL +1 -1
- infrahub_testcontainers/container.py +239 -65
- infrahub_testcontainers/docker-compose-cluster.test.yml +321 -0
- infrahub_testcontainers/docker-compose.test.yml +2 -1
- infrahub_testcontainers/helpers.py +23 -3
- infrahub_testcontainers/plugin.py +9 -0
- infrahub/message_bus/messages/check_generator_run.py +0 -26
- infrahub/message_bus/messages/finalize_validator_execution.py +0 -15
- infrahub/message_bus/messages/proposed_change/base_with_diff.py +0 -16
- infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +0 -11
- infrahub/message_bus/messages/request_generatordefinition_check.py +0 -20
- infrahub/message_bus/messages/request_proposedchange_pipeline.py +0 -23
- infrahub/message_bus/operations/check/__init__.py +0 -3
- infrahub/message_bus/operations/check/generator.py +0 -156
- infrahub/message_bus/operations/finalize/__init__.py +0 -3
- infrahub/message_bus/operations/finalize/validator.py +0 -133
- infrahub/message_bus/operations/requests/__init__.py +0 -9
- infrahub/message_bus/operations/requests/generator_definition.py +0 -140
- infrahub/message_bus/operations/requests/proposed_change.py +0 -629
- infrahub/patch/queries/consolidate_duplicated_nodes.py +0 -109
- /infrahub/{message_bus/messages/proposed_change → actions}/__init__.py +0 -0
- {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/LICENSE.txt +0 -0
- {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
from ..models import EdgeToAdd, EdgeToDelete, PatchPlan, VertexToDelete
|
|
2
|
-
from .base import PatchQuery
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class ConsolidateDuplicatedNodesPatchQuery(PatchQuery):
|
|
6
|
-
"""
|
|
7
|
-
Find any groups of nodes with the same labels and properties, move all the edges to one of the duplicated nodes,
|
|
8
|
-
then delete the other duplicated nodes
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
@property
|
|
12
|
-
def name(self) -> str:
|
|
13
|
-
return "consolidate-duplicated-nodes"
|
|
14
|
-
|
|
15
|
-
async def plan(self) -> PatchPlan:
|
|
16
|
-
query = """
|
|
17
|
-
//------------
|
|
18
|
-
// Find nodes with the same labels and UUID
|
|
19
|
-
//------------
|
|
20
|
-
MATCH (n:Node)
|
|
21
|
-
WITH n.uuid AS node_uuid, count(*) as num_nodes_with_uuid
|
|
22
|
-
WHERE num_nodes_with_uuid > 1
|
|
23
|
-
WITH DISTINCT node_uuid
|
|
24
|
-
MATCH (n:Node {uuid: node_uuid})
|
|
25
|
-
CALL {
|
|
26
|
-
WITH n
|
|
27
|
-
WITH labels(n) AS n_labels
|
|
28
|
-
UNWIND n_labels AS n_label
|
|
29
|
-
WITH n_label
|
|
30
|
-
ORDER BY n_label ASC
|
|
31
|
-
RETURN collect(n_label) AS sorted_labels
|
|
32
|
-
}
|
|
33
|
-
WITH n.uuid AS n_uuid, sorted_labels, collect(n) AS duplicate_nodes
|
|
34
|
-
WHERE size(duplicate_nodes) > 1
|
|
35
|
-
WITH n_uuid, head(duplicate_nodes) AS node_to_keep, tail(duplicate_nodes) AS nodes_to_delete
|
|
36
|
-
UNWIND nodes_to_delete AS node_to_delete
|
|
37
|
-
//------------
|
|
38
|
-
// Find the edges that we need to move to the selected node_to_keep
|
|
39
|
-
//------------
|
|
40
|
-
CALL {
|
|
41
|
-
WITH node_to_keep, node_to_delete
|
|
42
|
-
MATCH (node_to_delete)-[edge_to_delete]->(peer)
|
|
43
|
-
RETURN {
|
|
44
|
-
from_id: %(id_func_name)s(node_to_keep),
|
|
45
|
-
to_id: %(id_func_name)s(peer),
|
|
46
|
-
edge_type: type(edge_to_delete),
|
|
47
|
-
after_props: properties(edge_to_delete)
|
|
48
|
-
} AS edge_to_create
|
|
49
|
-
UNION
|
|
50
|
-
WITH node_to_keep, node_to_delete
|
|
51
|
-
MATCH (node_to_delete)<-[edge_to_delete]-(peer)
|
|
52
|
-
RETURN {
|
|
53
|
-
from_id: %(id_func_name)s(peer),
|
|
54
|
-
to_id: %(id_func_name)s(node_to_keep),
|
|
55
|
-
edge_type: type(edge_to_delete),
|
|
56
|
-
after_props: properties(edge_to_delete)
|
|
57
|
-
} AS edge_to_create
|
|
58
|
-
}
|
|
59
|
-
WITH node_to_delete, collect(edge_to_create) AS edges_to_create
|
|
60
|
-
//------------
|
|
61
|
-
// Find the edges that we need to remove from the duplicated nodes
|
|
62
|
-
//------------
|
|
63
|
-
CALL {
|
|
64
|
-
WITH node_to_delete
|
|
65
|
-
MATCH (node_to_delete)-[e]->(peer)
|
|
66
|
-
RETURN {
|
|
67
|
-
db_id: %(id_func_name)s(e),
|
|
68
|
-
from_id: %(id_func_name)s(node_to_delete),
|
|
69
|
-
to_id: %(id_func_name)s(peer),
|
|
70
|
-
edge_type: type(e),
|
|
71
|
-
before_props: properties(e)
|
|
72
|
-
} AS edge_to_delete
|
|
73
|
-
UNION
|
|
74
|
-
WITH node_to_delete
|
|
75
|
-
MATCH (node_to_delete)<-[e]-(peer)
|
|
76
|
-
RETURN {
|
|
77
|
-
db_id: %(id_func_name)s(e),
|
|
78
|
-
from_id: %(id_func_name)s(peer),
|
|
79
|
-
to_id: %(id_func_name)s(node_to_delete),
|
|
80
|
-
edge_type: type(e),
|
|
81
|
-
before_props: properties(e)
|
|
82
|
-
} AS edge_to_delete
|
|
83
|
-
}
|
|
84
|
-
WITH node_to_delete, edges_to_create, collect(edge_to_delete) AS edges_to_delete
|
|
85
|
-
RETURN
|
|
86
|
-
{db_id: %(id_func_name)s(node_to_delete), labels: labels(node_to_delete), before_props: properties(node_to_delete)} AS vertex_to_delete,
|
|
87
|
-
edges_to_create,
|
|
88
|
-
edges_to_delete
|
|
89
|
-
""" % {"id_func_name": self.db.get_id_function_name()}
|
|
90
|
-
results = await self.db.execute_query(query=query)
|
|
91
|
-
vertices_to_delete: list[VertexToDelete] = []
|
|
92
|
-
edges_to_delete: list[EdgeToDelete] = []
|
|
93
|
-
edges_to_add: list[EdgeToAdd] = []
|
|
94
|
-
for result in results:
|
|
95
|
-
serial_vertex_to_delete = result.get("vertex_to_delete")
|
|
96
|
-
if serial_vertex_to_delete:
|
|
97
|
-
vertex_to_delete = VertexToDelete(**serial_vertex_to_delete)
|
|
98
|
-
vertices_to_delete.append(vertex_to_delete)
|
|
99
|
-
for serial_edge_to_delete in result.get("edges_to_delete"):
|
|
100
|
-
edge_to_delete = EdgeToDelete(**serial_edge_to_delete)
|
|
101
|
-
edges_to_delete.append(edge_to_delete)
|
|
102
|
-
for serial_edge_to_create in result.get("edges_to_create"):
|
|
103
|
-
edges_to_add.append(EdgeToAdd(**serial_edge_to_create))
|
|
104
|
-
return PatchPlan(
|
|
105
|
-
name=self.name,
|
|
106
|
-
vertices_to_delete=vertices_to_delete,
|
|
107
|
-
edges_to_add=edges_to_add,
|
|
108
|
-
edges_to_delete=edges_to_delete,
|
|
109
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|