aio_taginfo.api.v4

/api/4/ endpoints.

  1"""`/api/4/` endpoints."""
  2
  3from datetime import datetime
  4from enum import Enum
  5from typing import Generic, TypeVar
  6
  7from pydantic import Field, HttpUrl, model_validator
  8from pydantic.dataclasses import dataclass
  9
 10
 11__all__ = (
 12    "key",  # pyright: ignore[reportUnsupportedDunderAll]
 13    "keys",  # pyright: ignore[reportUnsupportedDunderAll]
 14    "languages",  # pyright: ignore[reportUnsupportedDunderAll]
 15    "project",  # pyright: ignore[reportUnsupportedDunderAll]
 16    "projects",  # pyright: ignore[reportUnsupportedDunderAll]
 17    "relation",  # pyright: ignore[reportUnsupportedDunderAll]
 18    "relations",  # pyright: ignore[reportUnsupportedDunderAll]
 19    "search",  # pyright: ignore[reportUnsupportedDunderAll]
 20    "site",  # pyright: ignore[reportUnsupportedDunderAll]
 21    "tag",  # pyright: ignore[reportUnsupportedDunderAll]
 22    "tags",  # pyright: ignore[reportUnsupportedDunderAll]
 23    "unicode",  # pyright: ignore[reportUnsupportedDunderAll]
 24    "wiki",  # pyright: ignore[reportUnsupportedDunderAll]
 25    "wikidata",  # pyright: ignore[reportUnsupportedDunderAll]
 26    "Response",
 27    "PngResponse",
 28    "SortOrder",
 29    "ObjectType",
 30    "PrintingDirection",
 31)
 32
 33
 34T = TypeVar("T")
 35
 36
 37@dataclass(kw_only=True, frozen=True)
 38class Response(Generic[T]):
 39    """
 40    JSON data response.
 41
 42    Attributes:
 43        data: Payload specific to the called endpoint
 44        data_until: All changes in the source until this date are reflected in this taginfo result
 45        url: URL of the request
 46        total: Total number of results
 47        page: Result page number (first has page number 1)
 48        rp: Results per page
 49    """
 50
 51    data: T = Field(repr=True)
 52    data_until: datetime = Field(repr=False)
 53    url: HttpUrl = Field(repr=False)
 54    total: int = Field(ge=0, repr=True)
 55    page: int | None = Field(default=None, gt=0, repr=True)
 56    rp: int | None = Field(default=None, gt=0, repr=True)
 57
 58
 59@dataclass(kw_only=True, repr=False)
 60class PngResponse:
 61    """
 62    PNG image response.
 63
 64    Attributes:
 65        data: PNG data
 66    """
 67
 68    data: bytes = Field(repr=False)
 69
 70    @model_validator(mode="after")  # pyright: ignore[reportArgumentType]
 71    def post_root(self) -> "PngResponse":
 72        """Basic PNG validation by checking for magic bytes."""
 73        if not self.data.startswith(_PNG_MAGIC):
 74            msg = "did not find PNG magic bytes"
 75            raise AssertionError(msg)
 76        return self
 77
 78    def __repr__(self) -> str:
 79        """String representation that includes the size of the image."""
 80        return f"{self.__class__.__name__}(len(data)={len(self.data)})"
 81
 82
 83_PNG_MAGIC = bytes([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])
 84
 85
 86class SortOrder(str, Enum):
 87    """Sort order parameter (ascending by default)."""
 88
 89    ASC = "asc"
 90    DESC = "desc"
 91
 92
 93class ObjectType(str, Enum):
 94    """OpenStreetMap element types."""
 95
 96    ALL = "all"
 97    NODES = "nodes"
 98    WAYS = "ways"
 99    RELATIONS = "relations"
100
101
102class PrintingDirection(str, Enum):
103    """Printing direction for native text."""
104
105    AUTO = "auto"
106    LTR = "ltr"
107    RTL = "rtl"
108
109
110__docformat__ = "google"
@dataclass(kw_only=True, frozen=True)
class Response(typing.Generic[~T]):
38@dataclass(kw_only=True, frozen=True)
39class Response(Generic[T]):
40    """
41    JSON data response.
42
43    Attributes:
44        data: Payload specific to the called endpoint
45        data_until: All changes in the source until this date are reflected in this taginfo result
46        url: URL of the request
47        total: Total number of results
48        page: Result page number (first has page number 1)
49        rp: Results per page
50    """
51
52    data: T = Field(repr=True)
53    data_until: datetime = Field(repr=False)
54    url: HttpUrl = Field(repr=False)
55    total: int = Field(ge=0, repr=True)
56    page: int | None = Field(default=None, gt=0, repr=True)
57    rp: int | None = Field(default=None, gt=0, repr=True)

JSON data response.

Attributes:
  • data: Payload specific to the called endpoint
  • data_until: All changes in the source until this date are reflected in this taginfo result
  • url: URL of the request
  • total: Total number of results
  • page: Result page number (first has page number 1)
  • rp: Results per page
Response(*args: Any, **kwargs: Any)
139    def __init__(__dataclass_self__: PydanticDataclass, *args: Any, **kwargs: Any) -> None:
140        __tracebackhide__ = True
141        s = __dataclass_self__
142        s.__pydantic_validator__.validate_python(ArgsKwargs(args, kwargs), self_instance=s)
data: ~T = FieldInfo(annotation=~T, required=True)
data_until: datetime.datetime = FieldInfo(annotation=datetime, required=True, repr=False)
url: typing.Annotated[pydantic_core._pydantic_core.Url, UrlConstraints(max_length=2083, allowed_schemes=['http', 'https'], host_required=None, default_host=None, default_port=None, default_path=None)] = FieldInfo(annotation=Url, required=True, repr=False, metadata=[UrlConstraints(max_length=2083, allowed_schemes=['http', 'https'], host_required=None, default_host=None, default_port=None, default_path=None), UrlConstraints(max_length=2083, allowed_schemes=['http', 'https'], host_required=None, default_host=None, default_port=None, default_path=None)])
total: int = FieldInfo(annotation=int, required=True, metadata=[Ge(ge=0)])
page: int | None = None
rp: int | None = None
@dataclass(kw_only=True, repr=False)
class PngResponse:
60@dataclass(kw_only=True, repr=False)
61class PngResponse:
62    """
63    PNG image response.
64
65    Attributes:
66        data: PNG data
67    """
68
69    data: bytes = Field(repr=False)
70
71    @model_validator(mode="after")  # pyright: ignore[reportArgumentType]
72    def post_root(self) -> "PngResponse":
73        """Basic PNG validation by checking for magic bytes."""
74        if not self.data.startswith(_PNG_MAGIC):
75            msg = "did not find PNG magic bytes"
76            raise AssertionError(msg)
77        return self
78
79    def __repr__(self) -> str:
80        """String representation that includes the size of the image."""
81        return f"{self.__class__.__name__}(len(data)={len(self.data)})"

PNG image response.

Attributes:
  • data: PNG data
PngResponse(*args: Any, **kwargs: Any)
139    def __init__(__dataclass_self__: PydanticDataclass, *args: Any, **kwargs: Any) -> None:
140        __tracebackhide__ = True
141        s = __dataclass_self__
142        s.__pydantic_validator__.validate_python(ArgsKwargs(args, kwargs), self_instance=s)
data: bytes = FieldInfo(annotation=bytes, required=True, repr=False)
@model_validator(mode='after')
def post_root(self) -> PngResponse:
71    @model_validator(mode="after")  # pyright: ignore[reportArgumentType]
72    def post_root(self) -> "PngResponse":
73        """Basic PNG validation by checking for magic bytes."""
74        if not self.data.startswith(_PNG_MAGIC):
75            msg = "did not find PNG magic bytes"
76            raise AssertionError(msg)
77        return self

Basic PNG validation by checking for magic bytes.

class SortOrder(builtins.str, enum.Enum):
87class SortOrder(str, Enum):
88    """Sort order parameter (ascending by default)."""
89
90    ASC = "asc"
91    DESC = "desc"

Sort order parameter (ascending by default).

ASC = <SortOrder.ASC: 'asc'>
DESC = <SortOrder.DESC: 'desc'>
Inherited Members
enum.Enum
name
value
builtins.str
encode
replace
split
rsplit
join
capitalize
casefold
title
center
count
expandtabs
find
partition
index
ljust
lower
lstrip
rfind
rindex
rjust
rstrip
rpartition
splitlines
strip
swapcase
translate
upper
startswith
endswith
removeprefix
removesuffix
isascii
islower
isupper
istitle
isspace
isdecimal
isdigit
isnumeric
isalpha
isalnum
isidentifier
isprintable
zfill
format
format_map
maketrans
class ObjectType(builtins.str, enum.Enum):
 94class ObjectType(str, Enum):
 95    """OpenStreetMap element types."""
 96
 97    ALL = "all"
 98    NODES = "nodes"
 99    WAYS = "ways"
100    RELATIONS = "relations"

OpenStreetMap element types.

ALL = <ObjectType.ALL: 'all'>
NODES = <ObjectType.NODES: 'nodes'>
WAYS = <ObjectType.WAYS: 'ways'>
RELATIONS = <ObjectType.RELATIONS: 'relations'>
Inherited Members
enum.Enum
name
value
builtins.str
encode
replace
split
rsplit
join
capitalize
casefold
title
center
count
expandtabs
find
partition
index
ljust
lower
lstrip
rfind
rindex
rjust
rstrip
rpartition
splitlines
strip
swapcase
translate
upper
startswith
endswith
removeprefix
removesuffix
isascii
islower
isupper
istitle
isspace
isdecimal
isdigit
isnumeric
isalpha
isalnum
isidentifier
isprintable
zfill
format
format_map
maketrans
class PrintingDirection(builtins.str, enum.Enum):
103class PrintingDirection(str, Enum):
104    """Printing direction for native text."""
105
106    AUTO = "auto"
107    LTR = "ltr"
108    RTL = "rtl"

Printing direction for native text.

AUTO = <PrintingDirection.AUTO: 'auto'>
LTR = <PrintingDirection.LTR: 'ltr'>
RTL = <PrintingDirection.RTL: 'rtl'>
Inherited Members
enum.Enum
name
value
builtins.str
encode
replace
split
rsplit
join
capitalize
casefold
title
center
count
expandtabs
find
partition
index
ljust
lower
lstrip
rfind
rindex
rjust
rstrip
rpartition
splitlines
strip
swapcase
translate
upper
startswith
endswith
removeprefix
removesuffix
isascii
islower
isupper
istitle
isspace
isdecimal
isdigit
isnumeric
isalpha
isalnum
isidentifier
isprintable
zfill
format
format_map
maketrans