infrahub-server 1.2.0b1__py3-none-any.whl → 1.2.1__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 (297) hide show
  1. infrahub/api/dependencies.py +6 -6
  2. infrahub/api/diff/validation_models.py +7 -7
  3. infrahub/api/schema.py +1 -1
  4. infrahub/artifacts/models.py +1 -3
  5. infrahub/artifacts/tasks.py +1 -3
  6. infrahub/cli/__init__.py +13 -9
  7. infrahub/cli/constants.py +3 -0
  8. infrahub/cli/db.py +165 -183
  9. infrahub/cli/upgrade.py +146 -0
  10. infrahub/computed_attribute/gather.py +185 -0
  11. infrahub/computed_attribute/models.py +239 -11
  12. infrahub/computed_attribute/tasks.py +77 -442
  13. infrahub/computed_attribute/triggers.py +11 -45
  14. infrahub/config.py +43 -32
  15. infrahub/context.py +14 -0
  16. infrahub/core/account.py +4 -4
  17. infrahub/core/attribute.py +57 -57
  18. infrahub/core/branch/tasks.py +12 -9
  19. infrahub/core/changelog/diff.py +16 -8
  20. infrahub/core/changelog/models.py +189 -26
  21. infrahub/core/constants/__init__.py +5 -1
  22. infrahub/core/constants/infrahubkind.py +2 -0
  23. infrahub/core/constraint/node/runner.py +9 -8
  24. infrahub/core/diff/branch_differ.py +10 -10
  25. infrahub/core/diff/ipam_diff_parser.py +4 -5
  26. infrahub/core/diff/model/diff.py +27 -27
  27. infrahub/core/diff/model/path.py +3 -3
  28. infrahub/core/diff/query/merge.py +20 -17
  29. infrahub/core/diff/query_parser.py +4 -4
  30. infrahub/core/graph/__init__.py +1 -1
  31. infrahub/core/initialization.py +1 -10
  32. infrahub/core/ipam/constants.py +3 -4
  33. infrahub/core/ipam/reconciler.py +12 -12
  34. infrahub/core/ipam/utilization.py +10 -13
  35. infrahub/core/manager.py +34 -34
  36. infrahub/core/merge.py +7 -7
  37. infrahub/core/migrations/__init__.py +2 -3
  38. infrahub/core/migrations/graph/__init__.py +9 -4
  39. infrahub/core/migrations/graph/m017_add_core_profile.py +1 -5
  40. infrahub/core/migrations/graph/m018_uniqueness_nulls.py +4 -4
  41. infrahub/core/migrations/graph/m020_duplicate_edges.py +160 -0
  42. infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +51 -0
  43. infrahub/core/migrations/graph/{m020_add_generate_template_attr.py → m022_add_generate_template_attr.py} +3 -3
  44. infrahub/core/migrations/graph/m023_deduplicate_cardinality_one_relationships.py +96 -0
  45. infrahub/core/migrations/query/attribute_add.py +2 -2
  46. infrahub/core/migrations/query/node_duplicate.py +18 -21
  47. infrahub/core/migrations/query/schema_attribute_update.py +2 -2
  48. infrahub/core/migrations/schema/models.py +19 -4
  49. infrahub/core/migrations/schema/tasks.py +2 -2
  50. infrahub/core/migrations/shared.py +16 -16
  51. infrahub/core/models.py +15 -6
  52. infrahub/core/node/__init__.py +29 -28
  53. infrahub/core/node/base.py +2 -4
  54. infrahub/core/node/constraints/attribute_uniqueness.py +2 -2
  55. infrahub/core/node/constraints/grouped_uniqueness.py +99 -47
  56. infrahub/core/node/constraints/interface.py +1 -2
  57. infrahub/core/node/delete_validator.py +3 -5
  58. infrahub/core/node/ipam.py +4 -4
  59. infrahub/core/node/permissions.py +7 -7
  60. infrahub/core/node/resource_manager/ip_address_pool.py +6 -6
  61. infrahub/core/node/resource_manager/ip_prefix_pool.py +6 -6
  62. infrahub/core/node/resource_manager/number_pool.py +3 -3
  63. infrahub/core/path.py +12 -12
  64. infrahub/core/property.py +11 -11
  65. infrahub/core/protocols.py +5 -0
  66. infrahub/core/protocols_base.py +21 -21
  67. infrahub/core/query/__init__.py +33 -33
  68. infrahub/core/query/attribute.py +6 -4
  69. infrahub/core/query/diff.py +3 -3
  70. infrahub/core/query/node.py +82 -32
  71. infrahub/core/query/relationship.py +24 -24
  72. infrahub/core/query/resource_manager.py +2 -0
  73. infrahub/core/query/standard_node.py +3 -3
  74. infrahub/core/query/subquery.py +9 -9
  75. infrahub/core/registry.py +13 -15
  76. infrahub/core/relationship/constraints/count.py +3 -4
  77. infrahub/core/relationship/constraints/peer_kind.py +3 -4
  78. infrahub/core/relationship/constraints/profiles_kind.py +2 -2
  79. infrahub/core/relationship/model.py +40 -46
  80. infrahub/core/schema/attribute_schema.py +9 -9
  81. infrahub/core/schema/basenode_schema.py +93 -44
  82. infrahub/core/schema/computed_attribute.py +3 -3
  83. infrahub/core/schema/definitions/core/__init__.py +13 -19
  84. infrahub/core/schema/definitions/core/account.py +151 -148
  85. infrahub/core/schema/definitions/core/artifact.py +122 -113
  86. infrahub/core/schema/definitions/core/builtin.py +19 -16
  87. infrahub/core/schema/definitions/core/check.py +61 -53
  88. infrahub/core/schema/definitions/core/core.py +17 -0
  89. infrahub/core/schema/definitions/core/generator.py +89 -85
  90. infrahub/core/schema/definitions/core/graphql_query.py +72 -70
  91. infrahub/core/schema/definitions/core/group.py +96 -93
  92. infrahub/core/schema/definitions/core/ipam.py +176 -235
  93. infrahub/core/schema/definitions/core/lineage.py +18 -16
  94. infrahub/core/schema/definitions/core/menu.py +42 -40
  95. infrahub/core/schema/definitions/core/permission.py +144 -142
  96. infrahub/core/schema/definitions/core/profile.py +16 -27
  97. infrahub/core/schema/definitions/core/propose_change.py +88 -79
  98. infrahub/core/schema/definitions/core/propose_change_comment.py +170 -165
  99. infrahub/core/schema/definitions/core/propose_change_validator.py +290 -288
  100. infrahub/core/schema/definitions/core/repository.py +231 -225
  101. infrahub/core/schema/definitions/core/resource_pool.py +156 -166
  102. infrahub/core/schema/definitions/core/template.py +27 -12
  103. infrahub/core/schema/definitions/core/transform.py +85 -76
  104. infrahub/core/schema/definitions/core/webhook.py +127 -101
  105. infrahub/core/schema/definitions/internal.py +16 -16
  106. infrahub/core/schema/dropdown.py +3 -4
  107. infrahub/core/schema/generated/attribute_schema.py +15 -18
  108. infrahub/core/schema/generated/base_node_schema.py +12 -14
  109. infrahub/core/schema/generated/node_schema.py +3 -5
  110. infrahub/core/schema/generated/relationship_schema.py +9 -11
  111. infrahub/core/schema/generic_schema.py +2 -2
  112. infrahub/core/schema/manager.py +20 -9
  113. infrahub/core/schema/node_schema.py +4 -2
  114. infrahub/core/schema/relationship_schema.py +7 -7
  115. infrahub/core/schema/schema_branch.py +276 -138
  116. infrahub/core/schema/schema_branch_computed.py +41 -4
  117. infrahub/core/task/task.py +3 -3
  118. infrahub/core/task/user_task.py +15 -15
  119. infrahub/core/utils.py +20 -18
  120. infrahub/core/validators/__init__.py +1 -3
  121. infrahub/core/validators/aggregated_checker.py +2 -2
  122. infrahub/core/validators/attribute/choices.py +2 -2
  123. infrahub/core/validators/attribute/enum.py +2 -2
  124. infrahub/core/validators/attribute/kind.py +2 -2
  125. infrahub/core/validators/attribute/length.py +2 -2
  126. infrahub/core/validators/attribute/optional.py +2 -2
  127. infrahub/core/validators/attribute/regex.py +2 -2
  128. infrahub/core/validators/attribute/unique.py +2 -2
  129. infrahub/core/validators/checks_runner.py +25 -2
  130. infrahub/core/validators/determiner.py +1 -3
  131. infrahub/core/validators/interface.py +6 -2
  132. infrahub/core/validators/model.py +22 -3
  133. infrahub/core/validators/models/validate_migration.py +17 -4
  134. infrahub/core/validators/node/attribute.py +2 -2
  135. infrahub/core/validators/node/generate_profile.py +2 -2
  136. infrahub/core/validators/node/hierarchy.py +3 -5
  137. infrahub/core/validators/node/inherit_from.py +27 -5
  138. infrahub/core/validators/node/relationship.py +2 -2
  139. infrahub/core/validators/relationship/count.py +4 -4
  140. infrahub/core/validators/relationship/optional.py +2 -2
  141. infrahub/core/validators/relationship/peer.py +2 -2
  142. infrahub/core/validators/shared.py +2 -2
  143. infrahub/core/validators/tasks.py +8 -0
  144. infrahub/core/validators/uniqueness/checker.py +22 -21
  145. infrahub/core/validators/uniqueness/index.py +2 -2
  146. infrahub/core/validators/uniqueness/model.py +11 -11
  147. infrahub/database/__init__.py +26 -22
  148. infrahub/database/metrics.py +7 -1
  149. infrahub/dependencies/builder/constraint/grouped/node_runner.py +1 -3
  150. infrahub/dependencies/component/registry.py +2 -2
  151. infrahub/events/__init__.py +25 -2
  152. infrahub/events/artifact_action.py +13 -25
  153. infrahub/events/branch_action.py +26 -18
  154. infrahub/events/generator.py +71 -0
  155. infrahub/events/group_action.py +10 -24
  156. infrahub/events/models.py +10 -16
  157. infrahub/events/node_action.py +87 -32
  158. infrahub/events/repository_action.py +5 -18
  159. infrahub/events/schema_action.py +4 -9
  160. infrahub/events/utils.py +16 -0
  161. infrahub/events/validator_action.py +55 -0
  162. infrahub/exceptions.py +23 -24
  163. infrahub/generators/models.py +1 -3
  164. infrahub/git/base.py +7 -7
  165. infrahub/git/integrator.py +26 -25
  166. infrahub/git/models.py +22 -9
  167. infrahub/git/repository.py +3 -3
  168. infrahub/git/tasks.py +67 -49
  169. infrahub/git/utils.py +48 -0
  170. infrahub/git/worktree.py +1 -2
  171. infrahub/git_credential/askpass.py +1 -2
  172. infrahub/graphql/analyzer.py +12 -0
  173. infrahub/graphql/app.py +13 -15
  174. infrahub/graphql/context.py +6 -0
  175. infrahub/graphql/initialization.py +3 -0
  176. infrahub/graphql/loaders/node.py +2 -12
  177. infrahub/graphql/loaders/peers.py +77 -0
  178. infrahub/graphql/loaders/shared.py +13 -0
  179. infrahub/graphql/manager.py +13 -10
  180. infrahub/graphql/mutations/artifact_definition.py +5 -5
  181. infrahub/graphql/mutations/computed_attribute.py +4 -5
  182. infrahub/graphql/mutations/graphql_query.py +5 -5
  183. infrahub/graphql/mutations/ipam.py +50 -70
  184. infrahub/graphql/mutations/main.py +164 -141
  185. infrahub/graphql/mutations/menu.py +5 -5
  186. infrahub/graphql/mutations/models.py +2 -4
  187. infrahub/graphql/mutations/node_getter/by_default_filter.py +10 -10
  188. infrahub/graphql/mutations/node_getter/by_hfid.py +1 -3
  189. infrahub/graphql/mutations/node_getter/by_id.py +1 -3
  190. infrahub/graphql/mutations/node_getter/interface.py +1 -2
  191. infrahub/graphql/mutations/proposed_change.py +7 -7
  192. infrahub/graphql/mutations/relationship.py +67 -35
  193. infrahub/graphql/mutations/repository.py +8 -8
  194. infrahub/graphql/mutations/resource_manager.py +3 -3
  195. infrahub/graphql/mutations/schema.py +4 -4
  196. infrahub/graphql/mutations/webhook.py +137 -0
  197. infrahub/graphql/parser.py +4 -4
  198. infrahub/graphql/queries/diff/tree.py +4 -4
  199. infrahub/graphql/queries/ipam.py +2 -2
  200. infrahub/graphql/queries/relationship.py +2 -2
  201. infrahub/graphql/queries/search.py +2 -2
  202. infrahub/graphql/resolvers/many_relationship.py +264 -0
  203. infrahub/graphql/resolvers/resolver.py +13 -110
  204. infrahub/graphql/subscription/graphql_query.py +2 -0
  205. infrahub/graphql/types/event.py +20 -11
  206. infrahub/graphql/types/node.py +2 -2
  207. infrahub/graphql/utils.py +2 -2
  208. infrahub/groups/ancestors.py +29 -0
  209. infrahub/groups/parsers.py +107 -0
  210. infrahub/menu/generator.py +7 -7
  211. infrahub/menu/menu.py +0 -10
  212. infrahub/menu/models.py +117 -16
  213. infrahub/menu/repository.py +111 -0
  214. infrahub/menu/utils.py +5 -8
  215. infrahub/message_bus/messages/__init__.py +1 -11
  216. infrahub/message_bus/messages/check_generator_run.py +2 -0
  217. infrahub/message_bus/messages/finalize_validator_execution.py +3 -0
  218. infrahub/message_bus/messages/request_generatordefinition_check.py +2 -0
  219. infrahub/message_bus/operations/__init__.py +0 -2
  220. infrahub/message_bus/operations/check/generator.py +1 -0
  221. infrahub/message_bus/operations/event/__init__.py +2 -2
  222. infrahub/message_bus/operations/finalize/validator.py +51 -1
  223. infrahub/message_bus/operations/requests/generator_definition.py +19 -19
  224. infrahub/message_bus/operations/requests/proposed_change.py +3 -1
  225. infrahub/pools/number.py +2 -4
  226. infrahub/proposed_change/tasks.py +37 -28
  227. infrahub/pytest_plugin.py +13 -10
  228. infrahub/server.py +1 -2
  229. infrahub/services/adapters/event/__init__.py +1 -1
  230. infrahub/task_manager/event.py +23 -9
  231. infrahub/tasks/artifact.py +2 -4
  232. infrahub/telemetry/__init__.py +0 -0
  233. infrahub/telemetry/constants.py +9 -0
  234. infrahub/telemetry/database.py +86 -0
  235. infrahub/telemetry/models.py +65 -0
  236. infrahub/telemetry/task_manager.py +77 -0
  237. infrahub/{tasks/telemetry.py → telemetry/tasks.py} +49 -56
  238. infrahub/telemetry/utils.py +11 -0
  239. infrahub/trace.py +4 -4
  240. infrahub/transformations/tasks.py +2 -2
  241. infrahub/trigger/catalogue.py +2 -5
  242. infrahub/trigger/constants.py +0 -8
  243. infrahub/trigger/models.py +14 -1
  244. infrahub/trigger/setup.py +90 -0
  245. infrahub/trigger/tasks.py +35 -90
  246. infrahub/utils.py +11 -1
  247. infrahub/validators/__init__.py +0 -0
  248. infrahub/validators/events.py +42 -0
  249. infrahub/validators/tasks.py +41 -0
  250. infrahub/webhook/gather.py +17 -0
  251. infrahub/webhook/models.py +22 -5
  252. infrahub/webhook/tasks.py +44 -19
  253. infrahub/webhook/triggers.py +22 -5
  254. infrahub/workers/infrahub_async.py +2 -2
  255. infrahub/workers/utils.py +2 -2
  256. infrahub/workflows/catalogue.py +28 -20
  257. infrahub/workflows/initialization.py +1 -3
  258. infrahub/workflows/models.py +1 -1
  259. infrahub/workflows/utils.py +10 -1
  260. infrahub_sdk/client.py +27 -8
  261. infrahub_sdk/config.py +3 -0
  262. infrahub_sdk/context.py +13 -0
  263. infrahub_sdk/exceptions.py +6 -0
  264. infrahub_sdk/generator.py +4 -1
  265. infrahub_sdk/graphql.py +45 -13
  266. infrahub_sdk/node.py +69 -20
  267. infrahub_sdk/protocols_base.py +32 -11
  268. infrahub_sdk/query_groups.py +6 -35
  269. infrahub_sdk/schema/__init__.py +55 -26
  270. infrahub_sdk/schema/main.py +8 -0
  271. infrahub_sdk/task/__init__.py +10 -0
  272. infrahub_sdk/task/manager.py +12 -6
  273. infrahub_sdk/testing/schemas/animal.py +9 -0
  274. infrahub_sdk/timestamp.py +12 -4
  275. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/METADATA +3 -2
  276. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/RECORD +289 -260
  277. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/entry_points.txt +1 -0
  278. infrahub_testcontainers/constants.py +2 -0
  279. infrahub_testcontainers/container.py +157 -12
  280. infrahub_testcontainers/docker-compose.test.yml +31 -6
  281. infrahub_testcontainers/helpers.py +18 -73
  282. infrahub_testcontainers/host.py +41 -0
  283. infrahub_testcontainers/measurements.py +93 -0
  284. infrahub_testcontainers/models.py +38 -0
  285. infrahub_testcontainers/performance_test.py +166 -0
  286. infrahub_testcontainers/plugin.py +136 -0
  287. infrahub_testcontainers/prometheus.yml +30 -0
  288. infrahub/message_bus/messages/event_branch_create.py +0 -11
  289. infrahub/message_bus/messages/event_branch_delete.py +0 -11
  290. infrahub/message_bus/messages/event_branch_rebased.py +0 -9
  291. infrahub/message_bus/messages/event_node_mutated.py +0 -15
  292. infrahub/message_bus/messages/event_schema_update.py +0 -9
  293. infrahub/message_bus/operations/event/node.py +0 -20
  294. infrahub/message_bus/operations/event/schema.py +0 -17
  295. infrahub/webhook/constants.py +0 -1
  296. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/LICENSE.txt +0 -0
  297. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/WHEEL +0 -0
@@ -4,165 +4,168 @@ from infrahub.core.constants import (
4
4
  BranchSupportType,
5
5
  InfrahubKind,
6
6
  )
7
+ from infrahub.core.constants import RelationshipCardinality as Cardinality
7
8
 
8
- core_account = {
9
- "name": "Account",
10
- "namespace": "Core",
11
- "description": "User Account for Infrahub",
12
- "include_in_menu": False,
13
- "label": "Account",
14
- "icon": "mdi:account",
15
- "default_filter": "name__value",
16
- "order_by": ["name__value"],
17
- "display_labels": ["label__value"],
18
- "generate_profile": False,
19
- "branch": BranchSupportType.AGNOSTIC.value,
20
- "inherit_from": [InfrahubKind.LINEAGEOWNER, InfrahubKind.LINEAGESOURCE, InfrahubKind.GENERICACCOUNT],
21
- }
9
+ from ...attribute_schema import AttributeSchema as Attr
10
+ from ...dropdown import DropdownChoice
11
+ from ...generic_schema import GenericSchema
12
+ from ...node_schema import NodeSchema
13
+ from ...relationship_schema import (
14
+ RelationshipSchema as Rel,
15
+ )
16
+
17
+ core_account = NodeSchema(
18
+ name="Account",
19
+ namespace="Core",
20
+ description="User Account for Infrahub",
21
+ include_in_menu=False,
22
+ label="Account",
23
+ icon="mdi:account",
24
+ default_filter="name__value",
25
+ order_by=["name__value"],
26
+ display_labels=["label__value"],
27
+ generate_profile=False,
28
+ branch=BranchSupportType.AGNOSTIC,
29
+ inherit_from=[InfrahubKind.LINEAGEOWNER, InfrahubKind.LINEAGESOURCE, InfrahubKind.GENERICACCOUNT],
30
+ )
22
31
 
23
- core_account_token = {
24
- "name": "AccountToken",
25
- "namespace": "Internal",
26
- "description": "Token for User Account",
27
- "include_in_menu": False,
28
- "label": "Account Token",
29
- "default_filter": "token__value",
30
- "display_labels": ["token__value"],
31
- "generate_profile": False,
32
- "branch": BranchSupportType.AGNOSTIC.value,
33
- "uniqueness_constraints": [["token__value"]],
34
- "documentation": "/topics/auth",
35
- "attributes": [
36
- {"name": "name", "kind": "Text", "optional": True},
37
- {"name": "token", "kind": "Text", "unique": True},
38
- {"name": "expiration", "kind": "DateTime", "optional": True},
32
+ core_account_token = NodeSchema(
33
+ name="AccountToken",
34
+ namespace="Internal",
35
+ description="Token for User Account",
36
+ include_in_menu=False,
37
+ label="Account Token",
38
+ default_filter="token__value",
39
+ display_labels=["token__value"],
40
+ generate_profile=False,
41
+ branch=BranchSupportType.AGNOSTIC,
42
+ uniqueness_constraints=[["token__value"]],
43
+ documentation="/topics/auth",
44
+ attributes=[
45
+ Attr(name="name", kind="Text", optional=True),
46
+ Attr(name="token", kind="Text", unique=True),
47
+ Attr(name="expiration", kind="DateTime", optional=True),
39
48
  ],
40
- "relationships": [
41
- {
42
- "name": "account",
43
- "peer": InfrahubKind.GENERICACCOUNT,
44
- "optional": False,
45
- "cardinality": "one",
46
- "identifier": "account__token",
47
- },
49
+ relationships=[
50
+ Rel(
51
+ name="account",
52
+ peer=InfrahubKind.GENERICACCOUNT,
53
+ optional=False,
54
+ cardinality=Cardinality.ONE,
55
+ identifier="account__token",
56
+ ),
48
57
  ],
49
- }
58
+ )
50
59
 
51
- core_password_credential = {
52
- "name": "PasswordCredential",
53
- "namespace": "Core",
54
- "description": "Username/Password based credential",
55
- "include_in_menu": False,
56
- "label": "Username / Password",
57
- "generate_profile": False,
58
- "branch": BranchSupportType.AGNOSTIC.value,
59
- "inherit_from": [InfrahubKind.CREDENTIAL],
60
- "attributes": [
61
- {
62
- "name": "username",
63
- "kind": "Text",
64
- "optional": True,
65
- "branch": BranchSupportType.AGNOSTIC.value,
66
- "order_weight": 6000,
67
- },
68
- {
69
- "name": "password",
70
- "kind": "Password",
71
- "optional": True,
72
- "branch": BranchSupportType.AGNOSTIC.value,
73
- "order_weight": 7000,
74
- },
60
+ core_password_credential = NodeSchema(
61
+ name="PasswordCredential",
62
+ namespace="Core",
63
+ description="Username/Password based credential",
64
+ include_in_menu=False,
65
+ label="Username / Password",
66
+ generate_profile=False,
67
+ branch=BranchSupportType.AGNOSTIC,
68
+ inherit_from=[InfrahubKind.CREDENTIAL],
69
+ attributes=[
70
+ Attr(name="username", kind="Text", optional=True, branch=BranchSupportType.AGNOSTIC, order_weight=6000),
71
+ Attr(
72
+ name="password",
73
+ kind="Password",
74
+ optional=True,
75
+ branch=BranchSupportType.AGNOSTIC,
76
+ order_weight=7000,
77
+ ),
75
78
  ],
76
- }
79
+ )
77
80
 
78
- core_refresh_token = {
79
- "name": "RefreshToken",
80
- "namespace": "Internal",
81
- "description": "Refresh Token",
82
- "include_in_menu": False,
83
- "label": "Refresh Token",
84
- "display_labels": [],
85
- "generate_profile": False,
86
- "branch": BranchSupportType.AGNOSTIC.value,
87
- "attributes": [
88
- {"name": "expiration", "kind": "DateTime", "optional": False},
81
+ core_refresh_token = NodeSchema(
82
+ name="RefreshToken",
83
+ namespace="Internal",
84
+ description="Refresh Token",
85
+ include_in_menu=False,
86
+ label="Refresh Token",
87
+ display_labels=[],
88
+ generate_profile=False,
89
+ branch=BranchSupportType.AGNOSTIC,
90
+ attributes=[
91
+ Attr(name="expiration", kind="DateTime", optional=False),
89
92
  ],
90
- "relationships": [
91
- {
92
- "name": "account",
93
- "peer": InfrahubKind.GENERICACCOUNT,
94
- "optional": False,
95
- "cardinality": "one",
96
- "identifier": "account__refreshtoken",
97
- },
93
+ relationships=[
94
+ Rel(
95
+ name="account",
96
+ peer=InfrahubKind.GENERICACCOUNT,
97
+ optional=False,
98
+ cardinality=Cardinality.ONE,
99
+ identifier="account__refreshtoken",
100
+ ),
98
101
  ],
99
- }
102
+ )
100
103
 
101
- core_credential = {
102
- "name": "Credential",
103
- "namespace": "Core",
104
- "description": "A credential that could be referenced to access external services.",
105
- "include_in_menu": False,
106
- "label": "Credential",
107
- "default_filter": "name__value",
108
- "order_by": ["name__value"],
109
- "display_labels": ["label__value"],
110
- "icon": "mdi:key-variant",
111
- "human_friendly_id": ["name__value"],
112
- "branch": BranchSupportType.AGNOSTIC.value,
113
- "uniqueness_constraints": [["name__value"]],
114
- "documentation": "/topics/auth",
115
- "attributes": [
116
- {"name": "name", "kind": "Text", "unique": True, "order_weight": 1000},
117
- {"name": "label", "kind": "Text", "optional": True, "order_weight": 2000},
118
- {"name": "description", "kind": "Text", "optional": True, "order_weight": 3000},
104
+ core_credential = GenericSchema(
105
+ name="Credential",
106
+ namespace="Core",
107
+ description="A credential that could be referenced to access external services.",
108
+ include_in_menu=False,
109
+ label="Credential",
110
+ default_filter="name__value",
111
+ order_by=["name__value"],
112
+ display_labels=["label__value"],
113
+ icon="mdi:key-variant",
114
+ human_friendly_id=["name__value"],
115
+ branch=BranchSupportType.AGNOSTIC,
116
+ uniqueness_constraints=[["name__value"]],
117
+ documentation="/topics/auth",
118
+ attributes=[
119
+ Attr(name="name", kind="Text", unique=True, order_weight=1000),
120
+ Attr(name="label", kind="Text", optional=True, order_weight=2000),
121
+ Attr(name="description", kind="Text", optional=True, order_weight=3000),
119
122
  ],
120
- }
123
+ )
121
124
 
122
- core_generic_account = {
123
- "name": "GenericAccount",
124
- "namespace": "Core",
125
- "description": "User Account for Infrahub",
126
- "include_in_menu": False,
127
- "label": "Account",
128
- "icon": "mdi:account",
129
- "default_filter": "name__value",
130
- "order_by": ["name__value"],
131
- "display_labels": ["label__value"],
132
- "human_friendly_id": ["name__value"],
133
- "branch": BranchSupportType.AGNOSTIC.value,
134
- "documentation": "/topics/auth",
135
- "uniqueness_constraints": [["name__value"]],
136
- "attributes": [
137
- {"name": "name", "kind": "Text", "unique": True},
138
- {"name": "password", "kind": "HashedPassword", "unique": False},
139
- {"name": "label", "kind": "Text", "optional": True},
140
- {"name": "description", "kind": "Text", "optional": True},
141
- {
142
- "name": "account_type",
143
- "kind": "Text",
144
- "default_value": AccountType.USER.value,
145
- "enum": AccountType.available_types(),
146
- },
147
- {
148
- "name": "status",
149
- "kind": "Dropdown",
150
- "choices": [
151
- {
152
- "name": AccountStatus.ACTIVE.value,
153
- "label": "Active",
154
- "description": "Account is allowed to login",
155
- "color": "#52be80",
156
- },
157
- {
158
- "name": AccountStatus.INACTIVE.value,
159
- "label": "Inactive",
160
- "description": "Account is not allowed to login",
161
- "color": "#e74c3c",
162
- },
125
+ core_generic_account = GenericSchema(
126
+ name="GenericAccount",
127
+ namespace="Core",
128
+ description="User Account for Infrahub",
129
+ include_in_menu=False,
130
+ label="Account",
131
+ icon="mdi:account",
132
+ default_filter="name__value",
133
+ order_by=["name__value"],
134
+ display_labels=["label__value"],
135
+ human_friendly_id=["name__value"],
136
+ branch=BranchSupportType.AGNOSTIC,
137
+ documentation="/topics/auth",
138
+ uniqueness_constraints=[["name__value"]],
139
+ attributes=[
140
+ Attr(name="name", kind="Text", unique=True),
141
+ Attr(name="password", kind="HashedPassword", unique=False),
142
+ Attr(name="label", kind="Text", optional=True),
143
+ Attr(name="description", kind="Text", optional=True),
144
+ Attr(
145
+ name="account_type",
146
+ kind="Text",
147
+ default_value=AccountType.USER.value,
148
+ enum=AccountType.available_types(),
149
+ ),
150
+ Attr(
151
+ name="status",
152
+ kind="Dropdown",
153
+ choices=[
154
+ DropdownChoice(
155
+ name=AccountStatus.ACTIVE.value,
156
+ label="Active",
157
+ description="Account is allowed to login",
158
+ color="#52be80",
159
+ ),
160
+ DropdownChoice(
161
+ name=AccountStatus.INACTIVE.value,
162
+ label="Inactive",
163
+ description="Account is not allowed to login",
164
+ color="#e74c3c",
165
+ ),
163
166
  ],
164
- "default_value": AccountStatus.ACTIVE.value,
165
- },
167
+ default_value=AccountStatus.ACTIVE.value,
168
+ ),
166
169
  ],
167
- "relationships": [{"name": "tokens", "peer": InfrahubKind.ACCOUNTTOKEN, "optional": True, "cardinality": "many"}],
168
- }
170
+ relationships=[Rel(name="tokens", peer=InfrahubKind.ACCOUNTTOKEN, optional=True, cardinality=Cardinality.MANY)],
171
+ )
@@ -4,124 +4,133 @@ from infrahub.core.constants import (
4
4
  ContentType,
5
5
  InfrahubKind,
6
6
  )
7
+ from infrahub.core.constants import RelationshipCardinality as Cardinality
8
+ from infrahub.core.constants import RelationshipKind as RelKind
7
9
 
8
- core_artifact_target = {
9
- "name": "ArtifactTarget",
10
- "include_in_menu": False,
11
- "namespace": "Core",
12
- "description": "Extend a node to be associated with artifacts",
13
- "label": "Artifact Target",
14
- "relationships": [
15
- {
16
- "name": "artifacts",
17
- "peer": InfrahubKind.ARTIFACT,
18
- "optional": True,
19
- "cardinality": "many",
20
- "kind": "Generic",
21
- "identifier": "artifact__node",
22
- },
10
+ from ...attribute_schema import AttributeSchema as Attr
11
+ from ...generic_schema import GenericSchema
12
+ from ...node_schema import NodeSchema
13
+ from ...relationship_schema import (
14
+ RelationshipSchema as Rel,
15
+ )
16
+
17
+ core_artifact_target = GenericSchema(
18
+ name="ArtifactTarget",
19
+ include_in_menu=False,
20
+ namespace="Core",
21
+ description="Extend a node to be associated with artifacts",
22
+ label="Artifact Target",
23
+ relationships=[
24
+ Rel(
25
+ name="artifacts",
26
+ peer=InfrahubKind.ARTIFACT,
27
+ optional=True,
28
+ cardinality=Cardinality.MANY,
29
+ kind=RelKind.GENERIC,
30
+ identifier="artifact__node",
31
+ ),
23
32
  ],
24
- }
33
+ )
25
34
 
26
- core_artifact = {
27
- "name": "Artifact",
28
- "namespace": "Core",
29
- "label": "Artifact",
30
- "include_in_menu": False,
31
- "icon": "mdi:file-document-outline",
32
- "default_filter": "name__value",
33
- "order_by": ["name__value"],
34
- "display_labels": ["name__value"],
35
- "branch": BranchSupportType.LOCAL.value,
36
- "generate_profile": False,
37
- "inherit_from": [InfrahubKind.TASKTARGET],
38
- "documentation": "/topics/artifact",
39
- "attributes": [
40
- {"name": "name", "kind": "Text"},
41
- {
42
- "name": "status",
43
- "kind": "Text",
44
- "enum": ArtifactStatus.available_types(),
45
- },
46
- {
47
- "name": "content_type",
48
- "kind": "Text",
49
- "enum": ContentType.available_types(),
50
- },
51
- {
52
- "name": "checksum",
53
- "kind": "Text",
54
- "optional": True,
55
- },
56
- {
57
- "name": "storage_id",
58
- "kind": "Text",
59
- "optional": True,
60
- "description": "ID of the file in the object store",
61
- },
62
- {"name": "parameters", "kind": "JSON", "optional": True},
35
+ core_artifact = NodeSchema(
36
+ name="Artifact",
37
+ namespace="Core",
38
+ label="Artifact",
39
+ include_in_menu=False,
40
+ icon="mdi:file-document-outline",
41
+ default_filter="name__value",
42
+ order_by=["name__value"],
43
+ display_labels=["name__value"],
44
+ branch=BranchSupportType.LOCAL,
45
+ generate_profile=False,
46
+ inherit_from=[InfrahubKind.TASKTARGET],
47
+ documentation="/topics/artifact",
48
+ attributes=[
49
+ Attr(name="name", kind="Text"),
50
+ Attr(
51
+ name="status",
52
+ kind="Text",
53
+ enum=ArtifactStatus.available_types(),
54
+ ),
55
+ Attr(
56
+ name="content_type",
57
+ kind="Text",
58
+ enum=ContentType.available_types(),
59
+ ),
60
+ Attr(
61
+ name="checksum",
62
+ kind="Text",
63
+ optional=True,
64
+ ),
65
+ Attr(
66
+ name="storage_id",
67
+ kind="Text",
68
+ optional=True,
69
+ description="ID of the file in the object store",
70
+ ),
71
+ Attr(
72
+ name="parameters",
73
+ kind="JSON",
74
+ optional=True,
75
+ ),
63
76
  ],
64
- "relationships": [
65
- {
66
- "name": "object",
67
- "peer": InfrahubKind.ARTIFACTTARGET,
68
- "kind": "Attribute",
69
- "identifier": "artifact__node",
70
- "cardinality": "one",
71
- "optional": False,
72
- },
73
- {
74
- "name": "definition",
75
- "peer": InfrahubKind.ARTIFACTDEFINITION,
76
- "kind": "Attribute",
77
- "identifier": "artifact__artifact_definition",
78
- "cardinality": "one",
79
- "optional": False,
80
- },
77
+ relationships=[
78
+ Rel(
79
+ name="object",
80
+ peer=InfrahubKind.ARTIFACTTARGET,
81
+ kind=RelKind.ATTRIBUTE,
82
+ identifier="artifact__node",
83
+ cardinality=Cardinality.ONE,
84
+ optional=False,
85
+ ),
86
+ Rel(
87
+ name="definition",
88
+ peer=InfrahubKind.ARTIFACTDEFINITION,
89
+ kind=RelKind.ATTRIBUTE,
90
+ identifier="artifact__artifact_definition",
91
+ cardinality=Cardinality.ONE,
92
+ optional=False,
93
+ ),
81
94
  ],
82
- }
95
+ )
83
96
 
84
- core_artifact_definition = {
85
- "name": "ArtifactDefinition",
86
- "namespace": "Core",
87
- "include_in_menu": False,
88
- "icon": "mdi:file-document-multiple-outline",
89
- "label": "Artifact Definition",
90
- "default_filter": "name__value",
91
- "order_by": ["name__value"],
92
- "display_labels": ["name__value"],
93
- "branch": BranchSupportType.AWARE.value,
94
- "generate_profile": False,
95
- "uniqueness_constraints": [["name__value"]],
96
- "inherit_from": [InfrahubKind.TASKTARGET],
97
- "documentation": "/topics/artifact",
98
- "attributes": [
99
- {"name": "name", "kind": "Text", "unique": True},
100
- {"name": "artifact_name", "kind": "Text"},
101
- {"name": "description", "kind": "Text", "optional": True},
102
- {"name": "parameters", "kind": "JSON"},
103
- {
104
- "name": "content_type",
105
- "kind": "Text",
106
- "enum": ContentType.available_types(),
107
- },
97
+ core_artifact_definition = NodeSchema(
98
+ name="ArtifactDefinition",
99
+ namespace="Core",
100
+ include_in_menu=False,
101
+ icon="mdi:file-document-multiple-outline",
102
+ label="Artifact Definition",
103
+ default_filter="name__value",
104
+ order_by=["name__value"],
105
+ display_labels=["name__value"],
106
+ branch=BranchSupportType.AWARE,
107
+ generate_profile=False,
108
+ uniqueness_constraints=[["name__value"]],
109
+ inherit_from=[InfrahubKind.TASKTARGET],
110
+ documentation="/topics/artifact",
111
+ attributes=[
112
+ Attr(name="name", kind="Text", unique=True),
113
+ Attr(name="artifact_name", kind="Text"),
114
+ Attr(name="description", kind="Text", optional=True),
115
+ Attr(name="parameters", kind="JSON"),
116
+ Attr(name="content_type", kind="Text", enum=ContentType.available_types()),
108
117
  ],
109
- "relationships": [
110
- {
111
- "name": "targets",
112
- "peer": InfrahubKind.GENERICGROUP,
113
- "kind": "Attribute",
114
- "identifier": "artifact_definition___group",
115
- "cardinality": "one",
116
- "optional": False,
117
- },
118
- {
119
- "name": "transformation",
120
- "peer": InfrahubKind.TRANSFORM,
121
- "kind": "Attribute",
122
- "identifier": "artifact_definition___transformation",
123
- "cardinality": "one",
124
- "optional": False,
125
- },
118
+ relationships=[
119
+ Rel(
120
+ name="targets",
121
+ peer=InfrahubKind.GENERICGROUP,
122
+ kind=RelKind.ATTRIBUTE,
123
+ identifier="artifact_definition___group",
124
+ cardinality=Cardinality.ONE,
125
+ optional=False,
126
+ ),
127
+ Rel(
128
+ name="transformation",
129
+ peer=InfrahubKind.TRANSFORM,
130
+ kind=RelKind.ATTRIBUTE,
131
+ identifier="artifact_definition___transformation",
132
+ cardinality=Cardinality.ONE,
133
+ optional=False,
134
+ ),
126
135
  ],
127
- }
136
+ )
@@ -2,20 +2,23 @@ from infrahub.core.constants import (
2
2
  BranchSupportType,
3
3
  )
4
4
 
5
- builtin_tag = {
6
- "name": "Tag",
7
- "namespace": "Builtin",
8
- "description": "Standard Tag object to attached to other objects to provide some context.",
9
- "include_in_menu": True,
10
- "icon": "mdi:tag-multiple",
11
- "label": "Tag",
12
- "default_filter": "name__value",
13
- "order_by": ["name__value"],
14
- "display_labels": ["name__value"],
15
- "branch": BranchSupportType.AWARE.value,
16
- "uniqueness_constraints": [["name__value"]],
17
- "attributes": [
18
- {"name": "name", "kind": "Text", "unique": True},
19
- {"name": "description", "kind": "Text", "optional": True},
5
+ from ...attribute_schema import AttributeSchema as Attr
6
+ from ...node_schema import NodeSchema
7
+
8
+ builtin_tag = NodeSchema(
9
+ name="Tag",
10
+ namespace="Builtin",
11
+ description="Standard Tag object to attached to other objects to provide some context.",
12
+ include_in_menu=True,
13
+ icon="mdi:tag-multiple",
14
+ label="Tag",
15
+ default_filter="name__value",
16
+ order_by=["name__value"],
17
+ display_labels=["name__value"],
18
+ branch=BranchSupportType.AWARE,
19
+ uniqueness_constraints=[["name__value"]],
20
+ attributes=[
21
+ Attr(name="name", kind="Text", unique=True),
22
+ Attr(name="description", kind="Text", optional=True),
20
23
  ],
21
- }
24
+ )