Skip to content

Commit e5e2aca

Browse files
committed
Rename OrderModel to Order
1 parent fb268e5 commit e5e2aca

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

infrahub_sdk/client.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
from .schema import InfrahubSchema, InfrahubSchemaSync, NodeSchemaAPI
5252
from .store import NodeStore, NodeStoreSync
5353
from .timestamp import Timestamp
54-
from .types import AsyncRequester, HTTPMethod, OrderModel, SyncRequester
54+
from .types import AsyncRequester, HTTPMethod, Order, SyncRequester
5555
from .utils import decode_json, is_valid_uuid
5656

5757
if TYPE_CHECKING:
@@ -540,7 +540,7 @@ async def all(
540540
fragment: bool = ...,
541541
prefetch_relationships: bool = ...,
542542
property: bool = ...,
543-
order: OrderModel | None = ...,
543+
order: Order | None = ...,
544544
) -> list[SchemaType]: ...
545545

546546
@overload
@@ -558,7 +558,7 @@ async def all(
558558
fragment: bool = ...,
559559
prefetch_relationships: bool = ...,
560560
property: bool = ...,
561-
order: OrderModel | None = ...,
561+
order: Order | None = ...,
562562
) -> list[InfrahubNode]: ...
563563

564564
async def all(
@@ -575,7 +575,7 @@ async def all(
575575
fragment: bool = False,
576576
prefetch_relationships: bool = False,
577577
property: bool = False,
578-
order: OrderModel | None = None,
578+
order: Order | None = None,
579579
) -> list[InfrahubNode] | list[SchemaType]:
580580
"""Retrieve all nodes of a given kind
581581
@@ -591,6 +591,7 @@ async def all(
591591
exclude (list[str], optional): List of attributes or relationships to exclude from the query.
592592
fragment (bool, optional): Flag to use GraphQL fragments for generic schemas.
593593
prefetch_relationships (bool, optional): Flag to indicate whether to prefetch related node data.
594+
order (Order, optional): Ordering related options. Setting `disable=True` enhances performances.
594595
595596
Returns:
596597
list[InfrahubNode]: List of Nodes
@@ -627,7 +628,7 @@ async def filters(
627628
prefetch_relationships: bool = ...,
628629
partial_match: bool = ...,
629630
property: bool = ...,
630-
order: OrderModel | None = ...,
631+
order: Order | None = ...,
631632
**kwargs: Any,
632633
) -> list[SchemaType]: ...
633634

@@ -647,7 +648,7 @@ async def filters(
647648
prefetch_relationships: bool = ...,
648649
partial_match: bool = ...,
649650
property: bool = ...,
650-
order: OrderModel | None = ...,
651+
order: Order | None = ...,
651652
**kwargs: Any,
652653
) -> list[InfrahubNode]: ...
653654

@@ -666,7 +667,7 @@ async def filters(
666667
prefetch_relationships: bool = False,
667668
partial_match: bool = False,
668669
property: bool = False,
669-
order: OrderModel | None = None,
670+
order: Order | None = None,
670671
**kwargs: Any,
671672
) -> list[InfrahubNode] | list[SchemaType]:
672673
"""Retrieve nodes of a given kind based on provided filters.
@@ -684,6 +685,7 @@ async def filters(
684685
fragment (bool, optional): Flag to use GraphQL fragments for generic schemas.
685686
prefetch_relationships (bool, optional): Flag to indicate whether to prefetch related node data.
686687
partial_match (bool, optional): Allow partial match of filter criteria for the query.
688+
order (Order, optional): Ordering related options. Setting `disable=True` enhances performances.
687689
**kwargs (Any): Additional filter criteria for the query.
688690
689691
Returns:
@@ -1572,7 +1574,7 @@ def all(
15721574
fragment: bool = ...,
15731575
prefetch_relationships: bool = ...,
15741576
property: bool = ...,
1575-
order: OrderModel | None = ...,
1577+
order: Order | None = ...,
15761578
) -> list[SchemaTypeSync]: ...
15771579

15781580
@overload
@@ -1590,7 +1592,7 @@ def all(
15901592
fragment: bool = ...,
15911593
prefetch_relationships: bool = ...,
15921594
property: bool = ...,
1593-
order: OrderModel | None = ...,
1595+
order: Order | None = ...,
15941596
) -> list[InfrahubNodeSync]: ...
15951597

15961598
def all(
@@ -1607,7 +1609,7 @@ def all(
16071609
fragment: bool = False,
16081610
prefetch_relationships: bool = False,
16091611
property: bool = False,
1610-
order: OrderModel | None = None,
1612+
order: Order | None = None,
16111613
) -> list[InfrahubNodeSync] | list[SchemaTypeSync]:
16121614
"""Retrieve all nodes of a given kind
16131615
@@ -1623,6 +1625,7 @@ def all(
16231625
exclude (list[str], optional): List of attributes or relationships to exclude from the query.
16241626
fragment (bool, optional): Flag to use GraphQL fragments for generic schemas.
16251627
prefetch_relationships (bool, optional): Flag to indicate whether to prefetch related node data.
1628+
order (Order, optional): Ordering related options. Setting `disable=True` enhances performances.
16261629
16271630
Returns:
16281631
list[InfrahubNodeSync]: List of Nodes
@@ -1694,7 +1697,7 @@ def filters(
16941697
prefetch_relationships: bool = ...,
16951698
partial_match: bool = ...,
16961699
property: bool = ...,
1697-
order: OrderModel | None = ...,
1700+
order: Order | None = ...,
16981701
**kwargs: Any,
16991702
) -> list[SchemaTypeSync]: ...
17001703

@@ -1714,7 +1717,7 @@ def filters(
17141717
prefetch_relationships: bool = ...,
17151718
partial_match: bool = ...,
17161719
property: bool = ...,
1717-
order: OrderModel | None = ...,
1720+
order: Order | None = ...,
17181721
**kwargs: Any,
17191722
) -> list[InfrahubNodeSync]: ...
17201723

@@ -1733,7 +1736,7 @@ def filters(
17331736
prefetch_relationships: bool = False,
17341737
partial_match: bool = False,
17351738
property: bool = False,
1736-
order: OrderModel | None = None,
1739+
order: Order | None = None,
17371740
**kwargs: Any,
17381741
) -> list[InfrahubNodeSync] | list[SchemaTypeSync]:
17391742
"""Retrieve nodes of a given kind based on provided filters.
@@ -1751,6 +1754,7 @@ def filters(
17511754
fragment (bool, optional): Flag to use GraphQL fragments for generic schemas.
17521755
prefetch_relationships (bool, optional): Flag to indicate whether to prefetch related node data.
17531756
partial_match (bool, optional): Allow partial match of filter criteria for the query.
1757+
order (Order, optional): Ordering related options. Setting `disable=True` enhances performances.
17541758
**kwargs (Any): Additional filter criteria for the query.
17551759
17561760
Returns:

infrahub_sdk/node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from .client import InfrahubClient, InfrahubClientSync
2525
from .schema import AttributeSchemaAPI, MainSchemaTypesAPI, RelationshipSchemaAPI
26-
from .types import OrderModel
26+
from .types import Order
2727

2828
# pylint: disable=too-many-lines
2929

@@ -978,7 +978,7 @@ def generate_query_data_init(
978978
include: list[str] | None = None,
979979
exclude: list[str] | None = None,
980980
partial_match: bool = False,
981-
order: OrderModel | None = None,
981+
order: Order | None = None,
982982
) -> dict[str, Any | dict]:
983983
data: dict[str, Any] = {
984984
"count": None,
@@ -1181,7 +1181,7 @@ async def generate_query_data(
11811181
prefetch_relationships: bool = False,
11821182
partial_match: bool = False,
11831183
property: bool = False,
1184-
order: OrderModel | None = None,
1184+
order: Order | None = None,
11851185
) -> dict[str, Any | dict]:
11861186
data = self.generate_query_data_init(
11871187
filters=filters,
@@ -1694,7 +1694,7 @@ def generate_query_data(
16941694
prefetch_relationships: bool = False,
16951695
partial_match: bool = False,
16961696
property: bool = False,
1697-
order: OrderModel | None = None,
1697+
order: Order | None = None,
16981698
) -> dict[str, Any | dict]:
16991699
data = self.generate_query_data_init(
17001700
filters=filters,

infrahub_sdk/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ def exception(self, event: str | None = None, *args: Any, **kw: Any) -> Any:
6868
InfrahubLoggers = Union[InfrahubLogger, Logger]
6969

7070

71-
class OrderModel(BaseModel):
71+
class Order(BaseModel):
7272
disable: bool | None = None

tests/integration/test_infrahub_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from infrahub_sdk.schema import ProfileSchemaAPI
1111
from infrahub_sdk.testing.docker import TestInfrahubDockerClient
1212
from infrahub_sdk.testing.schemas.animal import TESTING_ANIMAL, TESTING_CAT, TESTING_DOG, TESTING_PERSON, SchemaAnimal
13-
from infrahub_sdk.types import OrderModel
13+
from infrahub_sdk.types import Order
1414

1515
if TYPE_CHECKING:
1616
from infrahub_sdk import InfrahubClient
@@ -63,13 +63,13 @@ async def test_get_all(self, client: InfrahubClient, base_dataset):
6363
assert [node.name.value for node in nodes] == ["Bella", "Luna"]
6464

6565
async def test_get_all_no_order(self, client: InfrahubClient, base_dataset):
66-
nodes = await client.all(kind=TESTING_CAT, order=OrderModel(disable=True))
66+
nodes = await client.all(kind=TESTING_CAT, order=Order(disable=True))
6767
assert len(nodes) == 2
6868
assert isinstance(nodes[0], InfrahubNode)
6969
assert {node.name.value for node in nodes} == {"Bella", "Luna"}
7070

7171
async def test_get_filters_no_order(self, client: InfrahubClient, base_dataset):
72-
nodes = await client.filters(kind=TESTING_CAT, order=OrderModel(disable=True))
72+
nodes = await client.filters(kind=TESTING_CAT, order=Order(disable=True))
7373
assert len(nodes) == 2
7474
assert isinstance(nodes[0], InfrahubNode)
7575
assert {node.name.value for node in nodes} == {"Bella", "Luna"}

0 commit comments

Comments
 (0)