infrahub-server 1.2.7__py3-none-any.whl → 1.2.9__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 (85) hide show
  1. infrahub/api/transformation.py +1 -0
  2. infrahub/artifacts/models.py +4 -0
  3. infrahub/cli/db.py +15 -6
  4. infrahub/computed_attribute/tasks.py +34 -12
  5. infrahub/config.py +2 -1
  6. infrahub/constants/__init__.py +0 -0
  7. infrahub/core/branch/tasks.py +0 -2
  8. infrahub/core/constants/__init__.py +1 -0
  9. infrahub/core/diff/calculator.py +4 -3
  10. infrahub/core/diff/combiner.py +1 -2
  11. infrahub/core/diff/coordinator.py +44 -28
  12. infrahub/core/diff/data_check_synchronizer.py +3 -2
  13. infrahub/core/diff/enricher/hierarchy.py +38 -27
  14. infrahub/core/diff/ipam_diff_parser.py +5 -4
  15. infrahub/core/diff/merger/merger.py +20 -18
  16. infrahub/core/diff/model/field_specifiers_map.py +64 -0
  17. infrahub/core/diff/model/path.py +55 -58
  18. infrahub/core/diff/parent_node_adder.py +14 -16
  19. infrahub/core/diff/query/drop_nodes.py +42 -0
  20. infrahub/core/diff/query/field_specifiers.py +8 -7
  21. infrahub/core/diff/query/filters.py +15 -1
  22. infrahub/core/diff/query/save.py +3 -0
  23. infrahub/core/diff/query_parser.py +49 -52
  24. infrahub/core/diff/repository/deserializer.py +36 -23
  25. infrahub/core/diff/repository/repository.py +31 -12
  26. infrahub/core/graph/__init__.py +1 -1
  27. infrahub/core/graph/index.py +3 -1
  28. infrahub/core/initialization.py +23 -7
  29. infrahub/core/manager.py +16 -5
  30. infrahub/core/migrations/graph/__init__.py +2 -0
  31. infrahub/core/migrations/graph/m014_remove_index_attr_value.py +9 -8
  32. infrahub/core/migrations/graph/m027_delete_isolated_nodes.py +50 -0
  33. infrahub/core/protocols.py +1 -0
  34. infrahub/core/query/branch.py +27 -17
  35. infrahub/core/query/diff.py +65 -38
  36. infrahub/core/query/node.py +111 -33
  37. infrahub/core/query/relationship.py +17 -3
  38. infrahub/core/query/subquery.py +2 -2
  39. infrahub/core/schema/definitions/core/builtin.py +2 -4
  40. infrahub/core/schema/definitions/core/transform.py +1 -0
  41. infrahub/core/schema/schema_branch.py +3 -0
  42. infrahub/core/validators/aggregated_checker.py +2 -2
  43. infrahub/core/validators/uniqueness/query.py +30 -9
  44. infrahub/database/__init__.py +1 -16
  45. infrahub/database/index.py +1 -1
  46. infrahub/database/memgraph.py +1 -12
  47. infrahub/database/neo4j.py +1 -13
  48. infrahub/git/integrator.py +27 -3
  49. infrahub/git/models.py +4 -0
  50. infrahub/git/tasks.py +3 -0
  51. infrahub/git_credential/helper.py +2 -2
  52. infrahub/graphql/mutations/computed_attribute.py +5 -1
  53. infrahub/graphql/queries/diff/tree.py +2 -1
  54. infrahub/message_bus/operations/requests/proposed_change.py +6 -0
  55. infrahub/message_bus/types.py +3 -0
  56. infrahub/patch/queries/consolidate_duplicated_nodes.py +109 -0
  57. infrahub/patch/queries/delete_duplicated_edges.py +138 -0
  58. infrahub/proposed_change/tasks.py +1 -0
  59. infrahub/server.py +1 -3
  60. infrahub/transformations/models.py +3 -0
  61. infrahub/transformations/tasks.py +1 -0
  62. infrahub/trigger/models.py +11 -1
  63. infrahub/trigger/setup.py +38 -13
  64. infrahub/trigger/tasks.py +1 -4
  65. infrahub/webhook/models.py +3 -0
  66. infrahub/workflows/initialization.py +1 -3
  67. infrahub_sdk/client.py +4 -4
  68. infrahub_sdk/config.py +17 -0
  69. infrahub_sdk/ctl/cli_commands.py +7 -1
  70. infrahub_sdk/ctl/generator.py +2 -2
  71. infrahub_sdk/generator.py +12 -66
  72. infrahub_sdk/operation.py +80 -0
  73. infrahub_sdk/protocols.py +12 -0
  74. infrahub_sdk/recorder.py +3 -0
  75. infrahub_sdk/schema/repository.py +4 -0
  76. infrahub_sdk/transforms.py +15 -27
  77. {infrahub_server-1.2.7.dist-info → infrahub_server-1.2.9.dist-info}/METADATA +2 -2
  78. {infrahub_server-1.2.7.dist-info → infrahub_server-1.2.9.dist-info}/RECORD +84 -78
  79. infrahub_testcontainers/container.py +1 -0
  80. infrahub_testcontainers/docker-compose.test.yml +5 -1
  81. infrahub/database/manager.py +0 -15
  82. /infrahub/{database/constants.py → constants/database.py} +0 -0
  83. {infrahub_server-1.2.7.dist-info → infrahub_server-1.2.9.dist-info}/LICENSE.txt +0 -0
  84. {infrahub_server-1.2.7.dist-info → infrahub_server-1.2.9.dist-info}/WHEEL +0 -0
  85. {infrahub_server-1.2.7.dist-info → infrahub_server-1.2.9.dist-info}/entry_points.txt +0 -0
infrahub_sdk/protocols.py CHANGED
@@ -154,6 +154,10 @@ class CoreMenu(CoreNode):
154
154
  children: RelationshipManager
155
155
 
156
156
 
157
+ class CoreObjectComponentTemplate(CoreNode):
158
+ template_name: String
159
+
160
+
157
161
  class CoreObjectTemplate(CoreNode):
158
162
  template_name: String
159
163
 
@@ -205,6 +209,7 @@ class CoreWebhook(CoreNode):
205
209
  name: String
206
210
  event_type: Enum
207
211
  branch_scope: Dropdown
212
+ node_kind: StringOptional
208
213
  description: StringOptional
209
214
  url: URL
210
215
  validate_certificates: BooleanOptional
@@ -479,6 +484,7 @@ class CoreTransformJinja2(CoreTransformation):
479
484
  class CoreTransformPython(CoreTransformation):
480
485
  file_path: String
481
486
  class_name: String
487
+ convert_query_response: BooleanOptional
482
488
 
483
489
 
484
490
  class CoreUserValidator(CoreValidator):
@@ -625,6 +631,10 @@ class CoreMenuSync(CoreNodeSync):
625
631
  children: RelationshipManagerSync
626
632
 
627
633
 
634
+ class CoreObjectComponentTemplateSync(CoreNodeSync):
635
+ template_name: String
636
+
637
+
628
638
  class CoreObjectTemplateSync(CoreNodeSync):
629
639
  template_name: String
630
640
 
@@ -676,6 +686,7 @@ class CoreWebhookSync(CoreNodeSync):
676
686
  name: String
677
687
  event_type: Enum
678
688
  branch_scope: Dropdown
689
+ node_kind: StringOptional
679
690
  description: StringOptional
680
691
  url: URL
681
692
  validate_certificates: BooleanOptional
@@ -950,6 +961,7 @@ class CoreTransformJinja2Sync(CoreTransformationSync):
950
961
  class CoreTransformPythonSync(CoreTransformationSync):
951
962
  file_path: String
952
963
  class_name: String
964
+ convert_query_response: BooleanOptional
953
965
 
954
966
 
955
967
  class CoreUserValidatorSync(CoreValidatorSync):
infrahub_sdk/recorder.py CHANGED
@@ -31,6 +31,9 @@ class NoRecorder:
31
31
  def default(cls) -> NoRecorder:
32
32
  return cls()
33
33
 
34
+ def __eq__(self, other: object) -> bool:
35
+ return isinstance(other, NoRecorder)
36
+
34
37
 
35
38
  class JSONRecorder(BaseSettings):
36
39
  model_config = SettingsConfigDict(env_prefix="INFRAHUB_JSON_RECORDER_")
@@ -117,6 +117,10 @@ class InfrahubPythonTransformConfig(InfrahubRepositoryConfigElement):
117
117
  name: str = Field(..., description="The name of the Transform")
118
118
  file_path: Path = Field(..., description="The file within the repository with the transform code.")
119
119
  class_name: str = Field(default="Transform", description="The name of the transform class to run.")
120
+ convert_query_response: bool = Field(
121
+ default=False,
122
+ description="Decide if the transform should convert the result of the GraphQL query to SDK InfrahubNode objects.",
123
+ )
120
124
 
121
125
  def load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubTransform]:
122
126
  module = import_module(module_path=self.file_path, import_root=import_root, relative_path=relative_path)
@@ -5,34 +5,38 @@ import os
5
5
  from abc import abstractmethod
6
6
  from typing import TYPE_CHECKING, Any
7
7
 
8
- from infrahub_sdk.repository import GitRepoManager
9
-
10
- from .exceptions import UninitializedError
8
+ from .operation import InfrahubOperation
11
9
 
12
10
  if TYPE_CHECKING:
13
11
  from . import InfrahubClient
12
+ from .node import InfrahubNode
14
13
 
15
14
  INFRAHUB_TRANSFORM_VARIABLE_TO_IMPORT = "INFRAHUB_TRANSFORMS"
16
15
 
17
16
 
18
- class InfrahubTransform:
17
+ class InfrahubTransform(InfrahubOperation):
19
18
  name: str | None = None
20
19
  query: str
21
20
  timeout: int = 10
22
21
 
23
22
  def __init__(
24
23
  self,
24
+ client: InfrahubClient,
25
+ infrahub_node: type[InfrahubNode],
26
+ convert_query_response: bool = False,
25
27
  branch: str = "",
26
28
  root_directory: str = "",
27
29
  server_url: str = "",
28
- client: InfrahubClient | None = None,
29
30
  ):
30
- self.git: GitRepoManager
31
+ super().__init__(
32
+ client=client,
33
+ infrahub_node=infrahub_node,
34
+ convert_query_response=convert_query_response,
35
+ branch=branch,
36
+ root_directory=root_directory,
37
+ )
31
38
 
32
- self.branch = branch
33
39
  self.server_url = server_url or os.environ.get("INFRAHUB_URL", "http://127.0.0.1:8000")
34
- self.root_directory = root_directory or os.getcwd()
35
-
36
40
  self._client = client
37
41
 
38
42
  if not self.name:
@@ -43,24 +47,7 @@ class InfrahubTransform:
43
47
 
44
48
  @property
45
49
  def client(self) -> InfrahubClient:
46
- if self._client:
47
- return self._client
48
-
49
- raise UninitializedError("The client has not been initialized")
50
-
51
- @property
52
- def branch_name(self) -> str:
53
- """Return the name of the current git branch."""
54
-
55
- if self.branch:
56
- return self.branch
57
-
58
- if not hasattr(self, "git") or not self.git:
59
- self.git = GitRepoManager(self.root_directory)
60
-
61
- self.branch = str(self.git.active_branch)
62
-
63
- return self.branch
50
+ return self._init_client
64
51
 
65
52
  @abstractmethod
66
53
  def transform(self, data: dict) -> Any:
@@ -86,6 +73,7 @@ class InfrahubTransform:
86
73
  data = await self.collect_data()
87
74
 
88
75
  unpacked = data.get("data") or data
76
+ await self.process_nodes(data=unpacked)
89
77
 
90
78
  if asyncio.iscoroutinefunction(self.transform):
91
79
  return await self.transform(data=unpacked)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: infrahub-server
3
- Version: 1.2.7
3
+ Version: 1.2.9
4
4
  Summary: Infrahub is taking a new approach to Infrastructure Management by providing a new generation of datastore to organize and control all the data that defines how an infrastructure should run.
5
5
  Home-page: https://opsmill.com
6
6
  License: AGPL-3.0-only
@@ -39,7 +39,7 @@ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (==1.28.1)
39
39
  Requires-Dist: opentelemetry-exporter-otlp-proto-http (==1.28.1)
40
40
  Requires-Dist: opentelemetry-instrumentation-aio-pika (==0.49b1)
41
41
  Requires-Dist: opentelemetry-instrumentation-fastapi (==0.49b1)
42
- Requires-Dist: prefect (==3.3.4)
42
+ Requires-Dist: prefect (==3.3.7)
43
43
  Requires-Dist: prefect-redis (==0.2.2)
44
44
  Requires-Dist: pyarrow (>=14,<15)
45
45
  Requires-Dist: pydantic (>=2.10,<2.11)