infrahub-server 1.3.0a0__py3-none-any.whl → 1.3.0b1__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 (68) hide show
  1. infrahub/core/attribute.py +3 -3
  2. infrahub/core/constants/__init__.py +5 -0
  3. infrahub/core/constants/infrahubkind.py +2 -0
  4. infrahub/core/migrations/query/attribute_rename.py +2 -4
  5. infrahub/core/migrations/query/delete_element_in_schema.py +16 -11
  6. infrahub/core/migrations/query/node_duplicate.py +16 -15
  7. infrahub/core/migrations/query/relationship_duplicate.py +16 -11
  8. infrahub/core/migrations/schema/node_attribute_remove.py +1 -2
  9. infrahub/core/migrations/schema/node_remove.py +16 -13
  10. infrahub/core/node/__init__.py +72 -14
  11. infrahub/core/node/resource_manager/ip_address_pool.py +6 -2
  12. infrahub/core/node/resource_manager/ip_prefix_pool.py +6 -2
  13. infrahub/core/node/resource_manager/number_pool.py +31 -5
  14. infrahub/core/node/standard.py +6 -1
  15. infrahub/core/protocols.py +9 -0
  16. infrahub/core/query/relationship.py +2 -4
  17. infrahub/core/schema/attribute_parameters.py +129 -5
  18. infrahub/core/schema/attribute_schema.py +38 -10
  19. infrahub/core/schema/definitions/core/__init__.py +16 -2
  20. infrahub/core/schema/definitions/core/group.py +45 -0
  21. infrahub/core/schema/definitions/core/resource_pool.py +20 -0
  22. infrahub/core/schema/definitions/internal.py +16 -3
  23. infrahub/core/schema/generated/attribute_schema.py +12 -5
  24. infrahub/core/schema/manager.py +3 -0
  25. infrahub/core/schema/schema_branch.py +55 -0
  26. infrahub/core/validators/__init__.py +8 -0
  27. infrahub/core/validators/attribute/choices.py +0 -1
  28. infrahub/core/validators/attribute/enum.py +0 -1
  29. infrahub/core/validators/attribute/kind.py +0 -1
  30. infrahub/core/validators/attribute/length.py +0 -1
  31. infrahub/core/validators/attribute/min_max.py +118 -0
  32. infrahub/core/validators/attribute/number_pool.py +106 -0
  33. infrahub/core/validators/attribute/optional.py +0 -2
  34. infrahub/core/validators/attribute/regex.py +0 -1
  35. infrahub/core/validators/enum.py +5 -0
  36. infrahub/database/__init__.py +15 -3
  37. infrahub/git/base.py +5 -3
  38. infrahub/git/integrator.py +102 -3
  39. infrahub/graphql/mutations/resource_manager.py +62 -6
  40. infrahub/graphql/queries/resource_manager.py +7 -1
  41. infrahub/graphql/queries/task.py +10 -0
  42. infrahub/graphql/types/task_log.py +3 -2
  43. infrahub/menu/menu.py +3 -3
  44. infrahub/pools/number.py +5 -3
  45. infrahub/task_manager/task.py +44 -4
  46. infrahub/types.py +6 -0
  47. infrahub_sdk/client.py +43 -10
  48. infrahub_sdk/node/__init__.py +39 -0
  49. infrahub_sdk/node/attribute.py +122 -0
  50. infrahub_sdk/node/constants.py +21 -0
  51. infrahub_sdk/{node.py → node/node.py} +50 -749
  52. infrahub_sdk/node/parsers.py +15 -0
  53. infrahub_sdk/node/property.py +24 -0
  54. infrahub_sdk/node/related_node.py +266 -0
  55. infrahub_sdk/node/relationship.py +302 -0
  56. infrahub_sdk/protocols.py +112 -0
  57. infrahub_sdk/protocols_base.py +34 -2
  58. infrahub_sdk/query_groups.py +13 -2
  59. infrahub_sdk/schema/main.py +1 -0
  60. infrahub_sdk/schema/repository.py +16 -0
  61. infrahub_sdk/spec/object.py +1 -1
  62. infrahub_sdk/store.py +1 -1
  63. infrahub_sdk/testing/schemas/car_person.py +1 -0
  64. {infrahub_server-1.3.0a0.dist-info → infrahub_server-1.3.0b1.dist-info}/METADATA +3 -3
  65. {infrahub_server-1.3.0a0.dist-info → infrahub_server-1.3.0b1.dist-info}/RECORD +68 -59
  66. {infrahub_server-1.3.0a0.dist-info → infrahub_server-1.3.0b1.dist-info}/WHEEL +1 -1
  67. {infrahub_server-1.3.0a0.dist-info → infrahub_server-1.3.0b1.dist-info}/LICENSE.txt +0 -0
  68. {infrahub_server-1.3.0a0.dist-info → infrahub_server-1.3.0b1.dist-info}/entry_points.txt +0 -0
infrahub_sdk/protocols.py CHANGED
@@ -68,6 +68,12 @@ class BuiltinIPPrefix(CoreNode):
68
68
  children: RelationshipManager
69
69
 
70
70
 
71
+ class CoreAction(CoreNode):
72
+ name: String
73
+ description: StringOptional
74
+ triggers: RelationshipManager
75
+
76
+
71
77
  class CoreArtifactTarget(CoreNode):
72
78
  artifacts: RelationshipManager
73
79
 
@@ -154,6 +160,10 @@ class CoreMenu(CoreNode):
154
160
  children: RelationshipManager
155
161
 
156
162
 
163
+ class CoreNodeTriggerMatch(CoreNode):
164
+ trigger: RelatedNode
165
+
166
+
157
167
  class CoreObjectComponentTemplate(CoreNode):
158
168
  template_name: String
159
169
 
@@ -195,6 +205,14 @@ class CoreTransformation(CoreNode):
195
205
  tags: RelationshipManager
196
206
 
197
207
 
208
+ class CoreTriggerRule(CoreNode):
209
+ name: String
210
+ description: StringOptional
211
+ active: Boolean
212
+ branch_scope: Dropdown
213
+ action: RelatedNode
214
+
215
+
198
216
  class CoreValidator(CoreNode):
199
217
  label: StringOptional
200
218
  state: Enum
@@ -328,6 +346,10 @@ class CoreFileThread(CoreThread):
328
346
  repository: RelatedNode
329
347
 
330
348
 
349
+ class CoreGeneratorAction(CoreAction):
350
+ generator: RelatedNode
351
+
352
+
331
353
  class CoreGeneratorCheck(CoreCheck):
332
354
  instance: String
333
355
 
@@ -382,6 +404,16 @@ class CoreGraphQLQueryGroup(CoreGroup):
382
404
  query: RelatedNode
383
405
 
384
406
 
407
+ class CoreGroupAction(CoreAction):
408
+ add_members: Boolean
409
+ group: RelatedNode
410
+
411
+
412
+ class CoreGroupTriggerRule(CoreTriggerRule):
413
+ members_added: Boolean
414
+ group: RelatedNode
415
+
416
+
385
417
  class CoreIPAddressPool(CoreResourcePool, LineageSource):
386
418
  default_address_type: String
387
419
  default_prefix_length: IntegerOptional
@@ -401,6 +433,25 @@ class CoreMenuItem(CoreMenu):
401
433
  pass
402
434
 
403
435
 
436
+ class CoreNodeTriggerAttributeMatch(CoreNodeTriggerMatch):
437
+ attribute_name: String
438
+ value: StringOptional
439
+ value_previous: StringOptional
440
+ value_match: Dropdown
441
+
442
+
443
+ class CoreNodeTriggerRelationshipMatch(CoreNodeTriggerMatch):
444
+ relationship_name: String
445
+ added: Boolean
446
+ peer: StringOptional
447
+
448
+
449
+ class CoreNodeTriggerRule(CoreTriggerRule):
450
+ node_kind: String
451
+ mutation_action: Enum
452
+ matches: RelationshipManager
453
+
454
+
404
455
  class CoreNumberPool(CoreResourcePool, LineageSource):
405
456
  node: String
406
457
  node_attribute: String
@@ -448,6 +499,11 @@ class CoreRepository(LineageOwner, LineageSource, CoreGenericRepository, CoreTas
448
499
  commit: StringOptional
449
500
 
450
501
 
502
+ class CoreRepositoryGroup(CoreGroup):
503
+ content: Dropdown
504
+ repository: RelatedNode
505
+
506
+
451
507
  class CoreRepositoryValidator(CoreValidator):
452
508
  repository: RelatedNode
453
509
 
@@ -545,6 +601,12 @@ class BuiltinIPPrefixSync(CoreNodeSync):
545
601
  children: RelationshipManagerSync
546
602
 
547
603
 
604
+ class CoreActionSync(CoreNodeSync):
605
+ name: String
606
+ description: StringOptional
607
+ triggers: RelationshipManagerSync
608
+
609
+
548
610
  class CoreArtifactTargetSync(CoreNodeSync):
549
611
  artifacts: RelationshipManagerSync
550
612
 
@@ -631,6 +693,10 @@ class CoreMenuSync(CoreNodeSync):
631
693
  children: RelationshipManagerSync
632
694
 
633
695
 
696
+ class CoreNodeTriggerMatchSync(CoreNodeSync):
697
+ trigger: RelatedNodeSync
698
+
699
+
634
700
  class CoreObjectComponentTemplateSync(CoreNodeSync):
635
701
  template_name: String
636
702
 
@@ -672,6 +738,14 @@ class CoreTransformationSync(CoreNodeSync):
672
738
  tags: RelationshipManagerSync
673
739
 
674
740
 
741
+ class CoreTriggerRuleSync(CoreNodeSync):
742
+ name: String
743
+ description: StringOptional
744
+ active: Boolean
745
+ branch_scope: Dropdown
746
+ action: RelatedNodeSync
747
+
748
+
675
749
  class CoreValidatorSync(CoreNodeSync):
676
750
  label: StringOptional
677
751
  state: Enum
@@ -805,6 +879,10 @@ class CoreFileThreadSync(CoreThreadSync):
805
879
  repository: RelatedNodeSync
806
880
 
807
881
 
882
+ class CoreGeneratorActionSync(CoreActionSync):
883
+ generator: RelatedNodeSync
884
+
885
+
808
886
  class CoreGeneratorCheckSync(CoreCheckSync):
809
887
  instance: String
810
888
 
@@ -859,6 +937,16 @@ class CoreGraphQLQueryGroupSync(CoreGroupSync):
859
937
  query: RelatedNodeSync
860
938
 
861
939
 
940
+ class CoreGroupActionSync(CoreActionSync):
941
+ add_members: Boolean
942
+ group: RelatedNodeSync
943
+
944
+
945
+ class CoreGroupTriggerRuleSync(CoreTriggerRuleSync):
946
+ members_added: Boolean
947
+ group: RelatedNodeSync
948
+
949
+
862
950
  class CoreIPAddressPoolSync(CoreResourcePoolSync, LineageSourceSync):
863
951
  default_address_type: String
864
952
  default_prefix_length: IntegerOptional
@@ -878,6 +966,25 @@ class CoreMenuItemSync(CoreMenuSync):
878
966
  pass
879
967
 
880
968
 
969
+ class CoreNodeTriggerAttributeMatchSync(CoreNodeTriggerMatchSync):
970
+ attribute_name: String
971
+ value: StringOptional
972
+ value_previous: StringOptional
973
+ value_match: Dropdown
974
+
975
+
976
+ class CoreNodeTriggerRelationshipMatchSync(CoreNodeTriggerMatchSync):
977
+ relationship_name: String
978
+ added: Boolean
979
+ peer: StringOptional
980
+
981
+
982
+ class CoreNodeTriggerRuleSync(CoreTriggerRuleSync):
983
+ node_kind: String
984
+ mutation_action: Enum
985
+ matches: RelationshipManagerSync
986
+
987
+
881
988
  class CoreNumberPoolSync(CoreResourcePoolSync, LineageSourceSync):
882
989
  node: String
883
990
  node_attribute: String
@@ -925,6 +1032,11 @@ class CoreRepositorySync(LineageOwnerSync, LineageSourceSync, CoreGenericReposit
925
1032
  commit: StringOptional
926
1033
 
927
1034
 
1035
+ class CoreRepositoryGroupSync(CoreGroupSync):
1036
+ content: Dropdown
1037
+ repository: RelatedNodeSync
1038
+
1039
+
928
1040
  class CoreRepositoryValidatorSync(CoreValidatorSync):
929
1041
  repository: RelatedNodeSync
930
1042
 
@@ -10,11 +10,42 @@ if TYPE_CHECKING:
10
10
 
11
11
 
12
12
  @runtime_checkable
13
- class RelatedNode(Protocol): ...
13
+ class RelatedNodeBase(Protocol):
14
+ @property
15
+ def id(self) -> str | None: ...
16
+
17
+ @property
18
+ def hfid(self) -> list[Any] | None: ...
19
+
20
+ @property
21
+ def hfid_str(self) -> str | None: ...
22
+
23
+ @property
24
+ def is_resource_pool(self) -> bool: ...
25
+
26
+ @property
27
+ def initialized(self) -> bool: ...
28
+
29
+ @property
30
+ def display_label(self) -> str | None: ...
31
+
32
+ @property
33
+ def typename(self) -> str | None: ...
34
+
35
+ def _generate_input_data(self, allocate_from_pool: bool = False) -> dict[str, Any]: ...
36
+
37
+ def _generate_mutation_query(self) -> dict[str, Any]: ...
38
+
39
+ @classmethod
40
+ def _generate_query_data(cls, peer_data: dict[str, Any] | None = None, property: bool = False) -> dict: ...
41
+
42
+
43
+ @runtime_checkable
44
+ class RelatedNode(RelatedNodeBase, Protocol): ...
14
45
 
15
46
 
16
47
  @runtime_checkable
17
- class RelatedNodeSync(Protocol): ...
48
+ class RelatedNodeSync(RelatedNodeBase, Protocol): ...
18
49
 
19
50
 
20
51
  @runtime_checkable
@@ -147,6 +178,7 @@ class CoreNodeBase(Protocol):
147
178
  _internal_id: str
148
179
  id: str # NOTE this is incorrect, should be str | None
149
180
  display_label: str | None
181
+ typename: str | None
150
182
 
151
183
  @property
152
184
  def hfid(self) -> list[str] | None: ...
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING
3
+ from typing import TYPE_CHECKING, Any
4
4
 
5
5
  from .constants import InfrahubClientMode
6
6
  from .exceptions import NodeNotFoundError
@@ -25,6 +25,7 @@ class InfrahubGroupContextBase:
25
25
  self.params: dict[str, str] = {}
26
26
  self.delete_unused_nodes: bool = False
27
27
  self.group_type: str = "CoreStandardGroup"
28
+ self.group_params: dict[str, Any] = {}
28
29
 
29
30
  def set_properties(
30
31
  self,
@@ -32,6 +33,8 @@ class InfrahubGroupContextBase:
32
33
  params: dict[str, str] | None = None,
33
34
  delete_unused_nodes: bool = False,
34
35
  group_type: str | None = None,
36
+ group_params: dict[str, Any] | None = None,
37
+ branch: str | None = None,
35
38
  ) -> None:
36
39
  """Setter method to set the values of identifier and params.
37
40
 
@@ -43,6 +46,8 @@ class InfrahubGroupContextBase:
43
46
  self.params = params or {}
44
47
  self.delete_unused_nodes = delete_unused_nodes
45
48
  self.group_type = group_type or self.group_type
49
+ self.group_params = group_params or {}
50
+ self.branch = branch
46
51
 
47
52
  def _get_params_as_str(self) -> str:
48
53
  """Convert the params in dict format, into a string"""
@@ -87,7 +92,9 @@ class InfrahubGroupContext(InfrahubGroupContextBase):
87
92
  async def get_group(self, store_peers: bool = False) -> InfrahubNode | None:
88
93
  group_name = self._generate_group_name()
89
94
  try:
90
- group = await self.client.get(kind=self.group_type, name__value=group_name, include=["members"])
95
+ group = await self.client.get(
96
+ kind=self.group_type, name__value=group_name, include=["members"], branch=self.branch
97
+ )
91
98
  except NodeNotFoundError:
92
99
  return None
93
100
 
@@ -151,6 +158,8 @@ class InfrahubGroupContext(InfrahubGroupContextBase):
151
158
  name=group_name,
152
159
  description=description,
153
160
  members=members,
161
+ branch=self.branch,
162
+ **self.group_params,
154
163
  )
155
164
  await group.save(allow_upsert=True, update_group_context=False)
156
165
 
@@ -243,6 +252,8 @@ class InfrahubGroupContextSync(InfrahubGroupContextBase):
243
252
  name=group_name,
244
253
  description=description,
245
254
  members=members,
255
+ branch=self.branch,
256
+ **self.group_params,
246
257
  )
247
258
  group.save(allow_upsert=True, update_group_context=False)
248
259
 
@@ -49,6 +49,7 @@ class AttributeKind(str, Enum):
49
49
  TEXTAREA = "TextArea"
50
50
  DATETIME = "DateTime"
51
51
  NUMBER = "Number"
52
+ NUMBERPOOL = "NumberPool"
52
53
  DROPDOWN = "Dropdown"
53
54
  EMAIL = "Email"
54
55
  PASSWORD = "Password" # noqa: S105
@@ -147,6 +147,18 @@ class InfrahubRepositoryGraphQLConfig(InfrahubRepositoryConfigElement):
147
147
  return file.read()
148
148
 
149
149
 
150
+ class InfrahubObjectConfig(InfrahubRepositoryConfigElement):
151
+ model_config = ConfigDict(extra="forbid")
152
+ name: str = Field(..., description="The name associated to the object file")
153
+ file_path: Path = Field(..., description="The file within the repository containing object data.")
154
+
155
+
156
+ class InfrahubMenuConfig(InfrahubRepositoryConfigElement):
157
+ model_config = ConfigDict(extra="forbid")
158
+ name: str = Field(..., description="The name of the menu")
159
+ file_path: Path = Field(..., description="The file within the repository containing menu data.")
160
+
161
+
150
162
  RESOURCE_MAP: dict[Any, str] = {
151
163
  InfrahubJinja2TransformConfig: "jinja2_transforms",
152
164
  InfrahubCheckDefinitionConfig: "check_definitions",
@@ -154,6 +166,8 @@ RESOURCE_MAP: dict[Any, str] = {
154
166
  InfrahubPythonTransformConfig: "python_transforms",
155
167
  InfrahubGeneratorDefinitionConfig: "generator_definitions",
156
168
  InfrahubRepositoryGraphQLConfig: "queries",
169
+ InfrahubObjectConfig: "objects",
170
+ InfrahubMenuConfig: "menus",
157
171
  }
158
172
 
159
173
 
@@ -176,6 +190,8 @@ class InfrahubRepositoryConfig(BaseModel):
176
190
  default_factory=list, description="Generator definitions"
177
191
  )
178
192
  queries: list[InfrahubRepositoryGraphQLConfig] = Field(default_factory=list, description="GraphQL Queries")
193
+ objects: list[Path] = Field(default_factory=list, description="Objects")
194
+ menus: list[Path] = Field(default_factory=list, description="Menus")
179
195
 
180
196
  @field_validator(
181
197
  "check_definitions",
@@ -459,7 +459,7 @@ class InfrahubObjectFileData(BaseModel):
459
459
  await node.save(allow_upsert=True)
460
460
 
461
461
  display_label = node.get_human_friendly_id_as_string() or f"{node.get_kind()} : {node.id}"
462
- client.log.info(f"Node: {display_label}")
462
+ client.log.info(f"Created node: {display_label}")
463
463
 
464
464
  for rel in remaining_rels:
465
465
  context = {}
infrahub_sdk/store.py CHANGED
@@ -4,7 +4,7 @@ import warnings
4
4
  from typing import TYPE_CHECKING, Literal, overload
5
5
 
6
6
  from .exceptions import NodeInvalidError, NodeNotFoundError
7
- from .node import parse_human_friendly_id
7
+ from .node.parsers import parse_human_friendly_id
8
8
 
9
9
  if TYPE_CHECKING:
10
10
  from .client import SchemaType, SchemaTypeSync
@@ -48,6 +48,7 @@ class SchemaCarPerson:
48
48
  namespace=NAMESPACE,
49
49
  include_in_menu=True,
50
50
  label="Person",
51
+ default_filter="name__value",
51
52
  human_friendly_id=["name__value"],
52
53
  attributes=[
53
54
  Attr(name="name", kind=AttributeKind.TEXT, unique=True),
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: infrahub-server
3
- Version: 1.3.0a0
3
+ Version: 1.3.0b1
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
- Home-page: https://opsmill.com
6
5
  License: AGPL-3.0-only
7
6
  Author: OpsMill
8
7
  Author-email: info@opsmill.com
@@ -58,6 +57,7 @@ Requires-Dist: ujson (>=5,<6)
58
57
  Requires-Dist: uvicorn[standard] (>=0.32,<0.33)
59
58
  Requires-Dist: whenever (==0.7.2)
60
59
  Project-URL: Documentation, https://docs.infrahub.app/
60
+ Project-URL: Homepage, https://opsmill.com
61
61
  Project-URL: Repository, https://github.com/opsmill/infrahub
62
62
  Description-Content-Type: text/markdown
63
63