1"""Regions, locales and namespace kinds shared by every part of the client."""
2
3from enum import StrEnum
4from typing import Final, Literal, TypeIs, get_args
5
6__all__ = ["DEFAULT_LOCALES", "LOCALES", "Locale", "NamespaceKind", "Region", "is_locale"]
7
8
[docs]
9class Region(StrEnum):
10 """A Battle.net API region; each has its own host and its own namespaces.
11
12 China is absent on purpose: it runs on a separate gateway with separate developer accounts, and WoW Forever has
13 not been verified there.
14 """
15
16 US = "us"
17 EU = "eu"
18 KR = "kr"
19 TW = "tw"
20
21
22type Locale = Literal[
23 "en_US",
24 "es_MX",
25 "pt_BR",
26 "de_DE",
27 "en_GB",
28 "es_ES",
29 "fr_FR",
30 "it_IT",
31 "ru_RU",
32 "ko_KR",
33 "zh_TW",
34 "zh_CN",
35]
36"""A locale accepted by the ``locale`` query parameter."""
37
38LOCALES: Final[frozenset[str]] = frozenset(get_args(Locale.__value__))
39
40DEFAULT_LOCALES: Final[dict[Region, Locale]] = {
41 Region.US: "en_US",
42 Region.EU: "en_GB",
43 Region.KR: "ko_KR",
44 Region.TW: "zh_TW",
45}
46"""The locale used for a region when the client is not given one."""
47
48
49def is_locale(value: str) -> TypeIs[Locale]:
50 """Whether ``value`` is a locale Battle.net accepts."""
51 return value in LOCALES
52
53
54type NamespaceKind = Literal["static", "dynamic", "profile"]
55"""Which family of documents a request reads.
56
57``static`` holds game data that only changes with patches, ``dynamic`` holds live state such as realms, and
58``profile`` holds player data. The wire namespace is ``{kind}-forever-{region}``.
59"""