infrahub-server 1.1.1__py3-none-any.whl → 1.1.3__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 (137) hide show
  1. infrahub/api/__init__.py +13 -5
  2. infrahub/api/artifact.py +9 -15
  3. infrahub/api/auth.py +7 -1
  4. infrahub/api/dependencies.py +15 -2
  5. infrahub/api/diff/diff.py +13 -7
  6. infrahub/api/file.py +5 -10
  7. infrahub/api/internal.py +19 -6
  8. infrahub/api/menu.py +8 -6
  9. infrahub/api/oauth2.py +25 -10
  10. infrahub/api/oidc.py +26 -10
  11. infrahub/api/query.py +2 -2
  12. infrahub/api/schema.py +48 -59
  13. infrahub/api/storage.py +8 -8
  14. infrahub/api/transformation.py +6 -5
  15. infrahub/auth.py +1 -26
  16. infrahub/cli/__init__.py +1 -1
  17. infrahub/cli/context.py +5 -8
  18. infrahub/cli/db.py +6 -6
  19. infrahub/cli/git_agent.py +1 -1
  20. infrahub/computed_attribute/models.py +1 -1
  21. infrahub/computed_attribute/tasks.py +1 -1
  22. infrahub/config.py +5 -5
  23. infrahub/core/account.py +2 -10
  24. infrahub/core/attribute.py +22 -0
  25. infrahub/core/branch/models.py +1 -1
  26. infrahub/core/branch/tasks.py +4 -3
  27. infrahub/core/diff/calculator.py +14 -0
  28. infrahub/core/diff/combiner.py +6 -2
  29. infrahub/core/diff/conflicts_enricher.py +2 -2
  30. infrahub/core/diff/coordinator.py +296 -87
  31. infrahub/core/diff/data_check_synchronizer.py +33 -4
  32. infrahub/core/diff/enricher/cardinality_one.py +3 -3
  33. infrahub/core/diff/enricher/hierarchy.py +4 -1
  34. infrahub/core/diff/merger/merger.py +11 -1
  35. infrahub/core/diff/merger/serializer.py +5 -29
  36. infrahub/core/diff/model/path.py +88 -4
  37. infrahub/core/diff/query/field_specifiers.py +35 -0
  38. infrahub/core/diff/query/roots_metadata.py +48 -0
  39. infrahub/core/diff/query/save.py +1 -0
  40. infrahub/core/diff/query_parser.py +27 -11
  41. infrahub/core/diff/repository/deserializer.py +7 -3
  42. infrahub/core/diff/repository/repository.py +100 -9
  43. infrahub/core/diff/tasks.py +1 -1
  44. infrahub/core/graph/__init__.py +1 -1
  45. infrahub/core/integrity/object_conflict/conflict_recorder.py +6 -1
  46. infrahub/core/ipam/utilization.py +6 -1
  47. infrahub/core/manager.py +8 -0
  48. infrahub/core/merge.py +6 -1
  49. infrahub/core/migrations/graph/__init__.py +2 -0
  50. infrahub/core/migrations/graph/m014_remove_index_attr_value.py +1 -1
  51. infrahub/core/migrations/graph/m015_diff_format_update.py +1 -1
  52. infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +1 -1
  53. infrahub/core/migrations/graph/m018_uniqueness_nulls.py +101 -0
  54. infrahub/core/migrations/query/attribute_add.py +5 -5
  55. infrahub/core/migrations/schema/tasks.py +2 -2
  56. infrahub/core/migrations/shared.py +3 -3
  57. infrahub/core/node/__init__.py +8 -2
  58. infrahub/core/node/constraints/grouped_uniqueness.py +9 -2
  59. infrahub/core/query/__init__.py +5 -2
  60. infrahub/core/query/diff.py +32 -19
  61. infrahub/core/query/ipam.py +30 -22
  62. infrahub/core/query/node.py +91 -40
  63. infrahub/core/schema/generated/attribute_schema.py +2 -2
  64. infrahub/core/schema/generated/base_node_schema.py +2 -2
  65. infrahub/core/schema/generated/relationship_schema.py +1 -1
  66. infrahub/core/schema/schema_branch_computed.py +1 -1
  67. infrahub/core/task/task_log.py +1 -1
  68. infrahub/core/validators/attribute/kind.py +1 -1
  69. infrahub/core/validators/interface.py +1 -2
  70. infrahub/core/validators/models/violation.py +1 -14
  71. infrahub/core/validators/shared.py +2 -2
  72. infrahub/core/validators/tasks.py +7 -4
  73. infrahub/core/validators/uniqueness/index.py +2 -4
  74. infrahub/database/index.py +1 -1
  75. infrahub/dependencies/builder/constraint/schema/aggregated.py +2 -0
  76. infrahub/dependencies/builder/constraint/schema/attribute_kind.py +8 -0
  77. infrahub/dependencies/builder/diff/data_check_synchronizer.py +2 -0
  78. infrahub/git/base.py +3 -3
  79. infrahub/git/integrator.py +1 -1
  80. infrahub/graphql/api/endpoints.py +12 -3
  81. infrahub/graphql/app.py +2 -2
  82. infrahub/graphql/auth/query_permission_checker/default_branch_checker.py +2 -17
  83. infrahub/graphql/auth/query_permission_checker/merge_operation_checker.py +1 -12
  84. infrahub/graphql/auth/query_permission_checker/object_permission_checker.py +6 -40
  85. infrahub/graphql/auth/query_permission_checker/super_admin_checker.py +5 -8
  86. infrahub/graphql/enums.py +2 -2
  87. infrahub/graphql/initialization.py +27 -8
  88. infrahub/graphql/manager.py +9 -3
  89. infrahub/graphql/models.py +6 -0
  90. infrahub/graphql/mutations/account.py +14 -10
  91. infrahub/graphql/mutations/computed_attribute.py +11 -22
  92. infrahub/graphql/mutations/diff.py +2 -0
  93. infrahub/graphql/mutations/main.py +5 -16
  94. infrahub/graphql/mutations/proposed_change.py +11 -20
  95. infrahub/graphql/mutations/resource_manager.py +6 -3
  96. infrahub/graphql/mutations/schema.py +8 -7
  97. infrahub/graphql/mutations/tasks.py +1 -1
  98. infrahub/graphql/permissions.py +3 -4
  99. infrahub/graphql/queries/account.py +2 -11
  100. infrahub/graphql/queries/resource_manager.py +21 -10
  101. infrahub/graphql/query.py +3 -1
  102. infrahub/graphql/resolvers/resolver.py +5 -1
  103. infrahub/graphql/types/task.py +14 -2
  104. infrahub/menu/generator.py +6 -18
  105. infrahub/message_bus/messages/event_node_mutated.py +2 -2
  106. infrahub/message_bus/operations/check/repository.py +2 -4
  107. infrahub/message_bus/operations/event/branch.py +2 -4
  108. infrahub/message_bus/operations/requests/proposed_change.py +1 -1
  109. infrahub/message_bus/operations/requests/repository.py +3 -5
  110. infrahub/message_bus/types.py +1 -1
  111. infrahub/permissions/__init__.py +12 -3
  112. infrahub/permissions/backend.py +2 -17
  113. infrahub/permissions/constants.py +12 -8
  114. infrahub/permissions/local_backend.py +5 -102
  115. infrahub/permissions/manager.py +135 -0
  116. infrahub/permissions/report.py +14 -25
  117. infrahub/permissions/types.py +6 -0
  118. infrahub/proposed_change/tasks.py +1 -1
  119. infrahub/task_manager/models.py +34 -5
  120. infrahub/task_manager/task.py +14 -6
  121. infrahub/visuals.py +1 -3
  122. infrahub_sdk/client.py +204 -43
  123. infrahub_sdk/ctl/cli_commands.py +106 -6
  124. infrahub_sdk/data.py +3 -2
  125. infrahub_sdk/graphql.py +5 -0
  126. infrahub_sdk/node.py +21 -2
  127. infrahub_sdk/queries.py +69 -0
  128. infrahub_sdk/schema/main.py +1 -0
  129. infrahub_sdk/testing/schemas/animal.py +1 -0
  130. infrahub_sdk/types.py +6 -0
  131. infrahub_sdk/utils.py +17 -0
  132. {infrahub_server-1.1.1.dist-info → infrahub_server-1.1.3.dist-info}/METADATA +1 -1
  133. {infrahub_server-1.1.1.dist-info → infrahub_server-1.1.3.dist-info}/RECORD +136 -131
  134. infrahub/core/diff/query/empty_roots.py +0 -33
  135. {infrahub_server-1.1.1.dist-info → infrahub_server-1.1.3.dist-info}/LICENSE.txt +0 -0
  136. {infrahub_server-1.1.1.dist-info → infrahub_server-1.1.3.dist-info}/WHEEL +0 -0
  137. {infrahub_server-1.1.1.dist-info → infrahub_server-1.1.3.dist-info}/entry_points.txt +0 -0
infrahub_sdk/node.py CHANGED
@@ -23,6 +23,7 @@ if TYPE_CHECKING:
23
23
 
24
24
  from .client import InfrahubClient, InfrahubClientSync
25
25
  from .schema import AttributeSchemaAPI, MainSchemaTypesAPI, RelationshipSchemaAPI
26
+ from .types import Order
26
27
 
27
28
  # pylint: disable=too-many-lines
28
29
 
@@ -977,6 +978,7 @@ class InfrahubNodeBase:
977
978
  include: list[str] | None = None,
978
979
  exclude: list[str] | None = None,
979
980
  partial_match: bool = False,
981
+ order: Order | None = None,
980
982
  ) -> dict[str, Any | dict]:
981
983
  data: dict[str, Any] = {
982
984
  "count": None,
@@ -985,6 +987,9 @@ class InfrahubNodeBase:
985
987
 
986
988
  data["@filters"] = filters or {}
987
989
 
990
+ if order:
991
+ data["@filters"]["order"] = order
992
+
988
993
  if offset:
989
994
  data["@filters"]["offset"] = offset
990
995
 
@@ -1176,9 +1181,16 @@ class InfrahubNode(InfrahubNodeBase):
1176
1181
  prefetch_relationships: bool = False,
1177
1182
  partial_match: bool = False,
1178
1183
  property: bool = False,
1184
+ order: Order | None = None,
1179
1185
  ) -> dict[str, Any | dict]:
1180
1186
  data = self.generate_query_data_init(
1181
- filters=filters, offset=offset, limit=limit, include=include, exclude=exclude, partial_match=partial_match
1187
+ filters=filters,
1188
+ offset=offset,
1189
+ limit=limit,
1190
+ include=include,
1191
+ exclude=exclude,
1192
+ partial_match=partial_match,
1193
+ order=order,
1182
1194
  )
1183
1195
  data["edges"]["node"].update(
1184
1196
  await self.generate_query_data_node(
@@ -1682,9 +1694,16 @@ class InfrahubNodeSync(InfrahubNodeBase):
1682
1694
  prefetch_relationships: bool = False,
1683
1695
  partial_match: bool = False,
1684
1696
  property: bool = False,
1697
+ order: Order | None = None,
1685
1698
  ) -> dict[str, Any | dict]:
1686
1699
  data = self.generate_query_data_init(
1687
- filters=filters, offset=offset, limit=limit, include=include, exclude=exclude, partial_match=partial_match
1700
+ filters=filters,
1701
+ offset=offset,
1702
+ limit=limit,
1703
+ include=include,
1704
+ exclude=exclude,
1705
+ partial_match=partial_match,
1706
+ order=order,
1688
1707
  )
1689
1708
  data["edges"]["node"].update(
1690
1709
  self.generate_query_data_node(
infrahub_sdk/queries.py CHANGED
@@ -42,3 +42,72 @@ query {
42
42
  }
43
43
  }
44
44
  """
45
+
46
+ QUERY_USER = """
47
+ query GET_PROFILE_DETAILS {
48
+ AccountProfile {
49
+ id
50
+ display_label
51
+ account_type {
52
+ value
53
+ __typename
54
+ updated_at
55
+ }
56
+ status {
57
+ label
58
+ value
59
+ updated_at
60
+ __typename
61
+ }
62
+ description {
63
+ value
64
+ updated_at
65
+ __typename
66
+ }
67
+ label {
68
+ value
69
+ updated_at
70
+ __typename
71
+ }
72
+ member_of_groups {
73
+ count
74
+ edges {
75
+ node {
76
+ display_label
77
+ group_type {
78
+ value
79
+ }
80
+ ... on CoreAccountGroup {
81
+ id
82
+ roles {
83
+ count
84
+ edges {
85
+ node {
86
+ permissions {
87
+ count
88
+ edges {
89
+ node {
90
+ display_label
91
+ identifier {
92
+ value
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
100
+ display_label
101
+ }
102
+ }
103
+ }
104
+ }
105
+ __typename
106
+ name {
107
+ value
108
+ updated_at
109
+ __typename
110
+ }
111
+ }
112
+ }
113
+ """
@@ -264,6 +264,7 @@ class BaseSchema(BaseModel):
264
264
  icon: str | None = None
265
265
  uniqueness_constraints: list[list[str]] | None = None
266
266
  documentation: str | None = None
267
+ order_by: list[str] | None = None
267
268
 
268
269
  @property
269
270
  def kind(self) -> str:
@@ -81,6 +81,7 @@ class SchemaAnimal:
81
81
  include_in_menu=True,
82
82
  inherit_from=[TESTING_ANIMAL],
83
83
  display_labels=["name__value", "breed__value", "color__value"],
84
+ order_by=["name__value"],
84
85
  attributes=[
85
86
  Attr(name="breed", kind=AttributeKind.TEXT, optional=False),
86
87
  Attr(name="color", kind=AttributeKind.COLOR, default_value="#555555", optional=True),
infrahub_sdk/types.py CHANGED
@@ -4,6 +4,8 @@ import enum
4
4
  from logging import Logger
5
5
  from typing import TYPE_CHECKING, Any, Protocol, Union, runtime_checkable
6
6
 
7
+ from pydantic import BaseModel
8
+
7
9
  if TYPE_CHECKING:
8
10
  import httpx
9
11
 
@@ -64,3 +66,7 @@ class InfrahubLogger(Protocol):
64
66
 
65
67
 
66
68
  InfrahubLoggers = Union[InfrahubLogger, Logger]
69
+
70
+
71
+ class Order(BaseModel):
72
+ disable: bool | None = None
infrahub_sdk/utils.py CHANGED
@@ -335,3 +335,20 @@ def write_to_file(path: Path, value: Any) -> bool:
335
335
  written = path.write_text(to_write)
336
336
 
337
337
  return written is not None
338
+
339
+
340
+ def get_user_permissions(data: list[dict]) -> dict:
341
+ groups = {}
342
+ for group in data:
343
+ group_name = group["node"]["display_label"]
344
+ permissions = []
345
+
346
+ roles = group["node"].get("roles", {}).get("edges", [])
347
+ for role in roles:
348
+ role_permissions = role["node"].get("permissions", {}).get("edges", [])
349
+ for permission in role_permissions:
350
+ permissions.append(permission["node"]["identifier"]["value"])
351
+
352
+ groups[group_name] = permissions
353
+
354
+ return groups
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: infrahub-server
3
- Version: 1.1.1
3
+ Version: 1.1.3
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