infrahub-server 1.5.5__py3-none-any.whl → 1.6.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 (130) hide show
  1. infrahub/api/artifact.py +5 -3
  2. infrahub/auth.py +5 -6
  3. infrahub/cli/db.py +3 -3
  4. infrahub/cli/db_commands/clean_duplicate_schema_fields.py +2 -2
  5. infrahub/cli/dev.py +30 -0
  6. infrahub/config.py +62 -14
  7. infrahub/constants/database.py +5 -5
  8. infrahub/core/branch/models.py +24 -6
  9. infrahub/core/constants/__init__.py +1 -0
  10. infrahub/core/diff/model/diff.py +2 -2
  11. infrahub/core/graph/constraints.py +2 -2
  12. infrahub/core/manager.py +191 -60
  13. infrahub/core/merge.py +29 -2
  14. infrahub/core/migrations/graph/m041_deleted_dup_edges.py +2 -3
  15. infrahub/core/migrations/shared.py +2 -2
  16. infrahub/core/models.py +5 -6
  17. infrahub/core/node/__init__.py +12 -6
  18. infrahub/core/node/create.py +36 -8
  19. infrahub/core/node/ipam.py +4 -4
  20. infrahub/core/node/node_property_attribute.py +2 -2
  21. infrahub/core/node/standard.py +1 -1
  22. infrahub/core/query/attribute.py +1 -1
  23. infrahub/core/query/branch.py +11 -0
  24. infrahub/core/query/node.py +9 -5
  25. infrahub/core/query/standard_node.py +3 -0
  26. infrahub/core/relationship/model.py +15 -10
  27. infrahub/core/schema/__init__.py +3 -3
  28. infrahub/core/schema/generic_schema.py +1 -1
  29. infrahub/core/schema/schema_branch.py +35 -16
  30. infrahub/core/task/user_task.py +2 -2
  31. infrahub/core/validators/determiner.py +3 -6
  32. infrahub/core/validators/enum.py +2 -2
  33. infrahub/database/__init__.py +1 -1
  34. infrahub/dependencies/interface.py +2 -2
  35. infrahub/events/constants.py +2 -2
  36. infrahub/git/base.py +42 -1
  37. infrahub/git/models.py +2 -1
  38. infrahub/git/repository.py +5 -1
  39. infrahub/git/tasks.py +28 -1
  40. infrahub/git/utils.py +9 -0
  41. infrahub/graphql/analyzer.py +4 -4
  42. infrahub/graphql/loaders/peers.py +6 -0
  43. infrahub/graphql/mutations/computed_attribute.py +1 -1
  44. infrahub/graphql/mutations/convert_object_type.py +1 -1
  45. infrahub/graphql/mutations/display_label.py +1 -1
  46. infrahub/graphql/mutations/hfid.py +1 -1
  47. infrahub/graphql/mutations/ipam.py +1 -1
  48. infrahub/graphql/mutations/profile.py +9 -1
  49. infrahub/graphql/mutations/relationship.py +2 -2
  50. infrahub/graphql/mutations/resource_manager.py +1 -1
  51. infrahub/graphql/queries/__init__.py +2 -1
  52. infrahub/graphql/queries/branch.py +58 -3
  53. infrahub/graphql/queries/ipam.py +9 -4
  54. infrahub/graphql/queries/resource_manager.py +7 -11
  55. infrahub/graphql/queries/search.py +5 -6
  56. infrahub/graphql/resolvers/ipam.py +20 -0
  57. infrahub/graphql/resolvers/many_relationship.py +12 -11
  58. infrahub/graphql/resolvers/resolver.py +6 -2
  59. infrahub/graphql/resolvers/single_relationship.py +1 -11
  60. infrahub/graphql/schema.py +2 -0
  61. infrahub/graphql/types/__init__.py +3 -1
  62. infrahub/graphql/types/branch.py +98 -2
  63. infrahub/lock.py +6 -6
  64. infrahub/log.py +1 -1
  65. infrahub/message_bus/messages/__init__.py +0 -12
  66. infrahub/patch/constants.py +2 -2
  67. infrahub/profiles/node_applier.py +9 -0
  68. infrahub/proposed_change/tasks.py +1 -1
  69. infrahub/task_manager/task.py +4 -4
  70. infrahub/telemetry/constants.py +2 -2
  71. infrahub/trigger/models.py +2 -2
  72. infrahub/trigger/setup.py +6 -9
  73. infrahub/utils.py +19 -1
  74. infrahub/validators/tasks.py +1 -1
  75. infrahub/workers/infrahub_async.py +39 -1
  76. infrahub_sdk/async_typer.py +2 -1
  77. infrahub_sdk/batch.py +2 -2
  78. infrahub_sdk/client.py +121 -10
  79. infrahub_sdk/config.py +2 -2
  80. infrahub_sdk/ctl/branch.py +176 -2
  81. infrahub_sdk/ctl/check.py +3 -3
  82. infrahub_sdk/ctl/cli.py +2 -2
  83. infrahub_sdk/ctl/cli_commands.py +10 -9
  84. infrahub_sdk/ctl/generator.py +2 -2
  85. infrahub_sdk/ctl/graphql.py +3 -4
  86. infrahub_sdk/ctl/importer.py +2 -3
  87. infrahub_sdk/ctl/repository.py +5 -6
  88. infrahub_sdk/ctl/task.py +2 -4
  89. infrahub_sdk/ctl/utils.py +4 -4
  90. infrahub_sdk/ctl/validate.py +1 -2
  91. infrahub_sdk/diff.py +80 -3
  92. infrahub_sdk/graphql/constants.py +14 -1
  93. infrahub_sdk/graphql/renderers.py +5 -1
  94. infrahub_sdk/node/attribute.py +10 -10
  95. infrahub_sdk/node/constants.py +2 -3
  96. infrahub_sdk/node/node.py +54 -11
  97. infrahub_sdk/node/related_node.py +1 -2
  98. infrahub_sdk/node/relationship.py +1 -2
  99. infrahub_sdk/object_store.py +4 -4
  100. infrahub_sdk/operation.py +2 -2
  101. infrahub_sdk/protocols_base.py +0 -1
  102. infrahub_sdk/protocols_generator/generator.py +1 -1
  103. infrahub_sdk/pytest_plugin/items/jinja2_transform.py +1 -1
  104. infrahub_sdk/pytest_plugin/models.py +1 -1
  105. infrahub_sdk/pytest_plugin/plugin.py +1 -1
  106. infrahub_sdk/query_groups.py +2 -2
  107. infrahub_sdk/schema/__init__.py +10 -14
  108. infrahub_sdk/schema/main.py +2 -2
  109. infrahub_sdk/schema/repository.py +2 -2
  110. infrahub_sdk/spec/object.py +2 -2
  111. infrahub_sdk/spec/range_expansion.py +1 -1
  112. infrahub_sdk/template/__init__.py +2 -1
  113. infrahub_sdk/transfer/importer/json.py +3 -3
  114. infrahub_sdk/types.py +2 -2
  115. infrahub_sdk/utils.py +2 -2
  116. {infrahub_server-1.5.5.dist-info → infrahub_server-1.6.0.dist-info}/METADATA +58 -59
  117. {infrahub_server-1.5.5.dist-info → infrahub_server-1.6.0.dist-info}/RECORD +240 -246
  118. {infrahub_server-1.5.5.dist-info → infrahub_server-1.6.0.dist-info}/WHEEL +1 -1
  119. infrahub_server-1.6.0.dist-info/entry_points.txt +12 -0
  120. infrahub_testcontainers/container.py +2 -2
  121. infrahub_testcontainers/docker-compose-cluster.test.yml +1 -1
  122. infrahub_testcontainers/docker-compose.test.yml +1 -1
  123. infrahub/core/schema/generated/__init__.py +0 -0
  124. infrahub/core/schema/generated/attribute_schema.py +0 -133
  125. infrahub/core/schema/generated/base_node_schema.py +0 -111
  126. infrahub/core/schema/generated/genericnode_schema.py +0 -30
  127. infrahub/core/schema/generated/node_schema.py +0 -40
  128. infrahub/core/schema/generated/relationship_schema.py +0 -141
  129. infrahub_server-1.5.5.dist-info/entry_points.txt +0 -13
  130. {infrahub_server-1.5.5.dist-info → infrahub_server-1.6.0.dist-info/licenses}/LICENSE.txt +0 -0
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import warnings
4
4
  from collections.abc import MutableMapping
5
5
  from enum import Enum
6
- from typing import TYPE_CHECKING, Any, Union
6
+ from typing import TYPE_CHECKING, Any
7
7
 
8
8
  from pydantic import BaseModel, ConfigDict, Field
9
9
  from typing_extensions import Self
@@ -11,7 +11,7 @@ from typing_extensions import Self
11
11
  if TYPE_CHECKING:
12
12
  from ..node import InfrahubNode, InfrahubNodeSync
13
13
 
14
- InfrahubNodeTypes = Union[InfrahubNode, InfrahubNodeSync]
14
+ InfrahubNodeTypes = InfrahubNode | InfrahubNodeSync
15
15
 
16
16
 
17
17
  class RelationshipCardinality(str, Enum):
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from pathlib import Path
4
- from typing import TYPE_CHECKING, Any, TypeVar, Union
4
+ from typing import TYPE_CHECKING, Any, TypeVar
5
5
 
6
6
  from pydantic import BaseModel, ConfigDict, Field, field_validator
7
7
 
@@ -18,7 +18,7 @@ from ..utils import duplicates
18
18
  if TYPE_CHECKING:
19
19
  from ..node import InfrahubNode, InfrahubNodeSync
20
20
 
21
- InfrahubNodeTypes = Union[InfrahubNode, InfrahubNodeSync]
21
+ InfrahubNodeTypes = InfrahubNode | InfrahubNodeSync
22
22
 
23
23
  ResourceClass = TypeVar("ResourceClass")
24
24
 
@@ -74,7 +74,7 @@ class RelationshipInfo(BaseModel):
74
74
 
75
75
  @property
76
76
  def is_reference(self) -> bool:
77
- return self.format in [RelationshipDataFormat.ONE_REF, RelationshipDataFormat.MANY_REF]
77
+ return self.format in {RelationshipDataFormat.ONE_REF, RelationshipDataFormat.MANY_REF}
78
78
 
79
79
  def get_context(self, value: Any) -> dict:
80
80
  """Return a dict to insert to the context if the relationship is mandatory"""
@@ -230,7 +230,7 @@ class InfrahubObjectFileData(BaseModel):
230
230
 
231
231
  # First validate if all mandatory fields are present
232
232
  for element in schema.mandatory_input_names:
233
- if not any([element in data.keys(), element in context.keys()]):
233
+ if not any([element in data, element in context]):
234
234
  errors.append(ObjectValidationError(position=position + [element], message=f"{element} is mandatory"))
235
235
 
236
236
  # Validate if all attributes are valid
@@ -69,7 +69,7 @@ def _extract_constants(pattern: str, re_compiled: re.Pattern) -> tuple[list[int]
69
69
  def _expand_interfaces(pattern: str, interface_constant: list[int], cartesian_list: list[list[str]]) -> list[str]:
70
70
  def _pairwise(lst: list[int]) -> list[tuple[int, int]]:
71
71
  it = iter(lst)
72
- return list(zip(it, it))
72
+ return list(zip(it, it, strict=False))
73
73
 
74
74
  if interface_constant[-1] < len(pattern):
75
75
  interface_constant.append(len(pattern))
@@ -1,8 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import linecache
4
+ from collections.abc import Callable
4
5
  from pathlib import Path
5
- from typing import Any, Callable, NoReturn
6
+ from typing import Any, NoReturn
6
7
 
7
8
  import jinja2
8
9
  from jinja2 import meta, nodes
@@ -62,7 +62,7 @@ class LineDelimitedJSONImporter(ImporterInterface):
62
62
 
63
63
  with self.wrapped_task_output("Analyzing import"):
64
64
  import_nodes_by_kind = defaultdict(list)
65
- for graphql_data, kind in zip(table.column("graphql_json"), table.column("kind")):
65
+ for graphql_data, kind in zip(table.column("graphql_json"), table.column("kind"), strict=False):
66
66
  node = await InfrahubNode.from_graphql(self.client, branch, ujson.loads(str(graphql_data)))
67
67
  import_nodes_by_kind[str(kind)].append(node)
68
68
  self.all_nodes[node.id] = node
@@ -109,7 +109,7 @@ class LineDelimitedJSONImporter(ImporterInterface):
109
109
  relationship_schema
110
110
  )
111
111
 
112
- for relationship_name in self.optional_relationships_schemas_by_node_kind[node_kind].keys():
112
+ for relationship_name in self.optional_relationships_schemas_by_node_kind[node_kind]:
113
113
  relationship_value = getattr(node, relationship_name)
114
114
  if isinstance(relationship_value, RelationshipManager):
115
115
  if relationship_value.peer_ids:
@@ -144,7 +144,7 @@ class LineDelimitedJSONImporter(ImporterInterface):
144
144
  await self.execute_batches([update_batch], "Adding optional relationships to nodes")
145
145
 
146
146
  async def update_many_to_many_relationships(self, file: Path) -> None:
147
- relationships = ujson.loads(file.read_text())
147
+ relationships = ujson.loads(file.read_text(encoding="utf-8"))
148
148
  update_batch = await self.client.create_batch(return_exceptions=True)
149
149
 
150
150
  for relationship in relationships:
infrahub_sdk/types.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import enum
4
4
  from logging import Logger
5
- from typing import TYPE_CHECKING, Any, Protocol, Union, runtime_checkable
5
+ from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
6
6
 
7
7
  from pydantic import BaseModel
8
8
 
@@ -65,7 +65,7 @@ class InfrahubLogger(Protocol):
65
65
  """Send an exception event."""
66
66
 
67
67
 
68
- InfrahubLoggers = Union[InfrahubLogger, Logger]
68
+ InfrahubLoggers = InfrahubLogger | Logger
69
69
 
70
70
 
71
71
  class Order(BaseModel):
infrahub_sdk/utils.py CHANGED
@@ -168,7 +168,7 @@ def str_to_bool(value: str) -> bool:
168
168
  if isinstance(value, bool):
169
169
  return value
170
170
 
171
- if isinstance(value, int) and value in [0, 1]:
171
+ if isinstance(value, int) and value in {0, 1}:
172
172
  return bool(value)
173
173
 
174
174
  if not isinstance(value, str):
@@ -318,7 +318,7 @@ def write_to_file(path: Path, value: Any) -> bool:
318
318
  raise FileExistsError(f"{path} is a directory")
319
319
 
320
320
  to_write = str(value)
321
- written = path.write_text(to_write)
321
+ written = path.write_text(to_write, encoding="utf-8")
322
322
 
323
323
  return written is not None
324
324
 
@@ -1,66 +1,66 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: infrahub-server
3
- Version: 1.5.5
3
+ Version: 1.6.0
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
- License: Apache-2.0
6
- Author: OpsMill
7
- Author-email: info@opsmill.com
8
- Requires-Python: >=3.12,<3.13
5
+ Project-URL: Homepage, https://opsmill.com
6
+ Project-URL: Repository, https://github.com/opsmill/infrahub
7
+ Project-URL: Documentation, https://docs.infrahub.app/
8
+ Author-email: OpsMill <info@opsmill.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE.txt
9
11
  Classifier: Intended Audience :: Developers
10
- Classifier: License :: OSI Approved :: Apache Software License
11
12
  Classifier: Programming Language :: Python :: 3
12
13
  Classifier: Programming Language :: Python :: 3.12
13
- Requires-Dist: Jinja2 (>=3,<4)
14
- Requires-Dist: aio-pika (>=9.4,<9.5)
15
- Requires-Dist: aiodataloader (==0.4.0)
16
- Requires-Dist: ariadne-codegen (==0.15.3)
17
- Requires-Dist: asgi-correlation-id (==4.2.0)
18
- Requires-Dist: authlib (==1.6.5)
19
- Requires-Dist: bcrypt (>=4.1,<4.2)
20
- Requires-Dist: boto3 (==1.34.129)
21
- Requires-Dist: cachetools-async (>=0.0.5,<0.0.6)
22
- Requires-Dist: click (==8.1.7)
23
- Requires-Dist: copier (>=9.8.0,<10.0.0)
24
- Requires-Dist: dulwich (>=0.22.7,<0.23.0)
25
- Requires-Dist: email-validator (>=2.1,<2.2)
26
- Requires-Dist: fast-depends (>=2.4.12,<3.0.0)
27
- Requires-Dist: fastapi (==0.121.1)
28
- Requires-Dist: fastapi-storages (>=0.3,<0.4)
29
- Requires-Dist: gitpython (>=3,<4)
30
- Requires-Dist: graphene (>=3.4,<3.5)
31
- Requires-Dist: gunicorn (>=23.0.0,<24.0.0)
32
- Requires-Dist: lunr (>=0.7.0.post1,<0.8.0)
33
- Requires-Dist: nats-py (>=2.7.2,<3.0.0)
34
- Requires-Dist: neo4j (>=5.28,<5.29)
35
- Requires-Dist: neo4j-rust-ext (>=5.28,<5.29)
36
- Requires-Dist: netaddr (==1.3.0)
37
- Requires-Dist: netutils (==1.12.0)
38
- Requires-Dist: numpy (>=1.26.2,<2.0.0)
39
- Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (==1.28.1)
40
- Requires-Dist: opentelemetry-exporter-otlp-proto-http (==1.28.1)
41
- Requires-Dist: opentelemetry-instrumentation-aio-pika (==0.49b1)
42
- Requires-Dist: opentelemetry-instrumentation-fastapi (==0.49b1)
43
- Requires-Dist: prefect (==3.4.23)
44
- Requires-Dist: prefect-redis (==0.2.5)
45
- Requires-Dist: pyarrow (>=14)
46
- Requires-Dist: pydantic (>=2.10,<2.11)
47
- Requires-Dist: pydantic-settings (>=2.8,<2.9)
48
- Requires-Dist: pyjwt (>=2.8,<2.9)
49
- Requires-Dist: pytest (>=7.4,<7.5)
50
- Requires-Dist: python-multipart (==0.0.18)
51
- Requires-Dist: pyyaml (>=6,<7)
52
- Requires-Dist: redis[hiredis] (>=6.0.0,<7.0.0)
53
- Requires-Dist: rich (>=13,<14)
54
- Requires-Dist: starlette-exporter (>=0.23,<0.24)
55
- Requires-Dist: structlog (==24.1.0)
56
- Requires-Dist: tomli (>=1.1.0) ; python_version < "3.11"
57
- Requires-Dist: typer (==0.12.5)
58
- Requires-Dist: ujson (>=5,<6)
59
- Requires-Dist: uvicorn[standard] (>=0.32,<0.33)
60
- Requires-Dist: whenever (==0.7.3)
61
- Project-URL: Documentation, https://docs.infrahub.app/
62
- Project-URL: Homepage, https://opsmill.com
63
- Project-URL: Repository, https://github.com/opsmill/infrahub
14
+ Requires-Python: <3.13,>=3.12
15
+ Requires-Dist: aio-pika<9.5,>=9.4
16
+ Requires-Dist: aiodataloader==0.4.0
17
+ Requires-Dist: ariadne-codegen==0.15.3
18
+ Requires-Dist: asgi-correlation-id==4.2.0
19
+ Requires-Dist: authlib==1.6.5
20
+ Requires-Dist: bcrypt<4.2,>=4.1
21
+ Requires-Dist: boto3==1.34.129
22
+ Requires-Dist: cachetools-async==0.0.5
23
+ Requires-Dist: click==8.1.7
24
+ Requires-Dist: copier==9.8.0
25
+ Requires-Dist: deepdiff==8.6.1
26
+ Requires-Dist: dulwich==0.22.7
27
+ Requires-Dist: email-validator<2.2,>=2.1
28
+ Requires-Dist: fast-depends==2.4.12
29
+ Requires-Dist: fastapi-storages<0.4,>=0.3
30
+ Requires-Dist: fastapi==0.121.1
31
+ Requires-Dist: gitpython<4,>=3
32
+ Requires-Dist: graphene<3.5,>=3.4
33
+ Requires-Dist: gunicorn<24,>=23.0.0
34
+ Requires-Dist: jinja2<4,>=3
35
+ Requires-Dist: lunr<0.8,>=0.7.0.post1
36
+ Requires-Dist: nats-py==2.7.2
37
+ Requires-Dist: neo4j-rust-ext<5.29,>=5.28
38
+ Requires-Dist: neo4j<5.29,>=5.28
39
+ Requires-Dist: netaddr==1.3.0
40
+ Requires-Dist: netutils==1.12.0
41
+ Requires-Dist: numpy==1.26.2
42
+ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc==1.28.1
43
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http==1.28.1
44
+ Requires-Dist: opentelemetry-instrumentation-aio-pika==0.49b1
45
+ Requires-Dist: opentelemetry-instrumentation-fastapi==0.49b1
46
+ Requires-Dist: prefect-redis==0.2.6
47
+ Requires-Dist: prefect==3.5.0
48
+ Requires-Dist: pyarrow<15,>=14
49
+ Requires-Dist: pydantic-settings<2.9,>=2.8
50
+ Requires-Dist: pydantic<2.11,>=2.10
51
+ Requires-Dist: pyjwt<2.9,>=2.8
52
+ Requires-Dist: pytest<7.5,>=7.4
53
+ Requires-Dist: python-multipart==0.0.18
54
+ Requires-Dist: pyyaml<7,>=6
55
+ Requires-Dist: redis[hiredis]==6.0.0
56
+ Requires-Dist: rich<14,>=13
57
+ Requires-Dist: starlette-exporter<0.24,>=0.23
58
+ Requires-Dist: structlog==24.1.0
59
+ Requires-Dist: tomli>=1.1.0; python_version <= '3.11'
60
+ Requires-Dist: typer==0.19.2
61
+ Requires-Dist: ujson<6,>=5
62
+ Requires-Dist: uvicorn[standard]<0.33,>=0.32
63
+ Requires-Dist: whenever==0.7.3
64
64
  Description-Content-Type: text/markdown
65
65
 
66
66
  <h1 align="center">
@@ -137,4 +137,3 @@ To help our community with the creation of contributions, please view our [CONTR
137
137
  ## Security
138
138
 
139
139
  [View our SECURITY](https://github.com/opsmill/infrahub?tab=security-ov-file) policy to find the latest information.
140
-