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