1# Generated by scripts/unasync.py from src/wow/_async/resources/mount.py. Do not edit.
2"""Routes of the Mount API."""
3
4from typing import TYPE_CHECKING
5
6from wow._sync._resource import Resource
7from wow.models.mount import Mount, MountIndex, MountSearchData
8from wow.search import MAX_PAGE_SIZE
9
10if TYPE_CHECKING:
11 from collections.abc import Iterator, Mapping, Sequence
12
13 from wow.models._common import SearchPage, SearchResult
14 from wow.search import FilterValue
15
16__all__ = ["Mounts"]
17
18
[docs]
19class Mounts(Resource):
20 """``client.mounts``: mounts."""
21
22 __slots__ = ()
23
[docs]
24 def index(self) -> MountIndex:
25 """List every mount."""
26 return self._get("static", "/data/wow/mount/index", MountIndex)
27
[docs]
28 def get(self, mount_id: int) -> Mount:
29 """Get one mount by id."""
30 return self._get("static", f"/data/wow/mount/{mount_id}", Mount)
31
[docs]
32 def search(
33 self,
34 *,
35 name: str | None = None,
36 filters: Mapping[str, FilterValue] | None = None,
37 order_by: str | Sequence[str] | None = None,
38 page: int = 1,
39 page_size: int = 100,
40 ) -> SearchPage[MountSearchData]:
41 """Search mounts.
42
43 Args:
44 name: Match this text in the client's locale.
45 filters: Field filters, such as ``{"faction.type": "ALLIANCE"}``.
46 order_by: Field name(s) to sort by, each optionally suffixed ``:desc``.
47 page: The page to fetch, starting at 1.
48 page_size: Results per page.
49 """
50 return self._search(
51 "static",
52 "mount",
53 MountSearchData,
54 filters=self._localized_name(name, filters),
55 order_by=order_by,
56 page=page,
57 page_size=page_size,
58 )
59
[docs]
60 def search_all(
61 self,
62 *,
63 name: str | None = None,
64 filters: Mapping[str, FilterValue] | None = None,
65 order_by: str | Sequence[str] | None = None,
66 page_size: int = MAX_PAGE_SIZE,
67 ) -> Iterator[SearchResult[MountSearchData]]:
68 """Iterate over every result across pages (Battle.net stops at 1,000).
69
70 Args:
71 name: Match this text in the client's locale.
72 filters: Field filters, such as ``{"faction.type": "ALLIANCE"}``.
73 order_by: Field name(s) to sort by, each optionally suffixed ``:desc``.
74 page_size: Results per page.
75 """
76 return self._search_all(
77 "static",
78 "mount",
79 MountSearchData,
80 filters=self._localized_name(name, filters),
81 order_by=order_by,
82 page_size=page_size,
83 )