aio_taginfo.api.v4.tag.projects

/api/4/tag/projects endpoint.

  1"""`/api/4/tag/projects` endpoint."""
  2
  3from enum import Enum
  4
  5from aio_taginfo.api.v4 import ObjectType, Response, SortOrder
  6from aio_taginfo.api.v4._internal import (
  7    NonEmptyString,
  8    OptionalHttpUrl,
  9    OptionalNonEmptyString,
 10    api_get_json,
 11    api_params,
 12)
 13
 14from aiohttp import ClientSession
 15from pydantic import Field
 16from pydantic.dataclasses import dataclass
 17
 18
 19__all__ = (
 20    "call",
 21    "TagProject",
 22    "TagProjectSorting",
 23)
 24
 25
 26@dataclass(kw_only=True, frozen=True)
 27class TagProject:
 28    """
 29    TODO: https://wiki.openstreetmap.org/wiki/Taginfo/Projects.
 30
 31    Attributes:
 32        project_id: Project ID
 33        project_name: Project name
 34        project_icon_url: Project icon URL
 35        key: Key
 36        value: Value
 37        on_node: For nodes?
 38        on_way: For ways?
 39        on_relation: For relations?
 40        on_relation: For areas?
 41        description: Description
 42        doc_url: Documentation URL
 43        icon_url: Icon URL
 44    """
 45
 46    project_id: str = Field(min_length=1, repr=True)
 47    project_name: str = Field(min_length=1, repr=True)
 48    project_icon_url: OptionalHttpUrl = Field(repr=False)
 49    key: str = Field(min_length=1, repr=True)
 50    value: str | None = Field(min_length=1, repr=True)  # TODO: surprised this can be None
 51    on_node: bool = Field(repr=False)
 52    on_way: bool = Field(repr=False)
 53    on_relation: bool = Field(repr=False)
 54    on_area: bool = Field(repr=False)
 55    description: OptionalNonEmptyString = Field(repr=False)
 56    doc_url: OptionalHttpUrl = Field(repr=False)
 57    icon_url: OptionalHttpUrl = Field(repr=False)
 58
 59
 60class TagProjectSorting(str, Enum):
 61    """Sort options for tag projects."""
 62
 63    PROJECT_NAME = "project_name"
 64    TAG = "tag"
 65
 66
 67@dataclass(kw_only=True, frozen=True)
 68class _Params:
 69    key: NonEmptyString = Field(repr=True)
 70    value: NonEmptyString = Field(repr=True)
 71    query: NonEmptyString | None = Field(repr=True)
 72    sortname: TagProjectSorting = Field(repr=True)
 73    sortorder: SortOrder = Field(repr=True)
 74    filter: ObjectType = Field(repr=True)
 75    page: int = Field(gt=0, repr=True)
 76    rp: int = Field(ge=0, repr=True)
 77
 78
 79async def call(
 80    key: str,
 81    value: str,
 82    query: str | None = None,
 83    sortname: TagProjectSorting = TagProjectSorting.PROJECT_NAME,
 84    sortorder: SortOrder = SortOrder.ASC,
 85    filter: ObjectType = ObjectType.ALL,  # noqa: A002
 86    page: int = 1,
 87    rp: int = 0,
 88    session: ClientSession | None = None,
 89) -> Response[list[TagProject]]:
 90    """
 91    Get projects using a given tag.
 92
 93    https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_tag_projects
 94
 95    Args:
 96        key: tag key
 97        value: tag value
 98        query: Only show results where the project name matches this query (substring match)
 99        sortname: what field to sort by
100        sortorder: sort order
101        filter: can be used to filter only values on tags used on nodes/ways/relations
102        page: page number (starting at 1)
103        rp: results per page
104        session: request client session
105
106    Raises:
107        TaginfoError
108    """
109    params = api_params(
110        _Params,
111        key=key,
112        value=value,
113        query=query,
114        sortname=sortname,
115        sortorder=sortorder,
116        filter=filter,
117        page=page,
118        rp=rp,
119    )
120    return await api_get_json(
121        path="tag/projects",
122        cls=Response[list[TagProject]],
123        session=session,
124        params=params,
125    )
126
127
128__docformat__ = "google"
async def call( key: str, value: str, query: str | None = None, sortname: TagProjectSorting = <TagProjectSorting.PROJECT_NAME: 'project_name'>, sortorder: aio_taginfo.api.v4.SortOrder = <SortOrder.ASC: 'asc'>, filter: aio_taginfo.api.v4.ObjectType = <ObjectType.ALL: 'all'>, page: int = 1, rp: int = 0, session: aiohttp.client.ClientSession | None = None) -> aio_taginfo.api.v4.Response[list[TagProject]]:
 80async def call(
 81    key: str,
 82    value: str,
 83    query: str | None = None,
 84    sortname: TagProjectSorting = TagProjectSorting.PROJECT_NAME,
 85    sortorder: SortOrder = SortOrder.ASC,
 86    filter: ObjectType = ObjectType.ALL,  # noqa: A002
 87    page: int = 1,
 88    rp: int = 0,
 89    session: ClientSession | None = None,
 90) -> Response[list[TagProject]]:
 91    """
 92    Get projects using a given tag.
 93
 94    https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_tag_projects
 95
 96    Args:
 97        key: tag key
 98        value: tag value
 99        query: Only show results where the project name matches this query (substring match)
100        sortname: what field to sort by
101        sortorder: sort order
102        filter: can be used to filter only values on tags used on nodes/ways/relations
103        page: page number (starting at 1)
104        rp: results per page
105        session: request client session
106
107    Raises:
108        TaginfoError
109    """
110    params = api_params(
111        _Params,
112        key=key,
113        value=value,
114        query=query,
115        sortname=sortname,
116        sortorder=sortorder,
117        filter=filter,
118        page=page,
119        rp=rp,
120    )
121    return await api_get_json(
122        path="tag/projects",
123        cls=Response[list[TagProject]],
124        session=session,
125        params=params,
126    )

Get projects using a given tag.

https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_tag_projects

Arguments:
  • key: tag key
  • value: tag value
  • query: Only show results where the project name matches this query (substring match)
  • sortname: what field to sort by
  • sortorder: sort order
  • filter: can be used to filter only values on tags used on nodes/ways/relations
  • page: page number (starting at 1)
  • rp: results per page
  • session: request client session
Raises:
  • TaginfoError
@dataclass(kw_only=True, frozen=True)
class TagProject:
27@dataclass(kw_only=True, frozen=True)
28class TagProject:
29    """
30    TODO: https://wiki.openstreetmap.org/wiki/Taginfo/Projects.
31
32    Attributes:
33        project_id: Project ID
34        project_name: Project name
35        project_icon_url: Project icon URL
36        key: Key
37        value: Value
38        on_node: For nodes?
39        on_way: For ways?
40        on_relation: For relations?
41        on_relation: For areas?
42        description: Description
43        doc_url: Documentation URL
44        icon_url: Icon URL
45    """
46
47    project_id: str = Field(min_length=1, repr=True)
48    project_name: str = Field(min_length=1, repr=True)
49    project_icon_url: OptionalHttpUrl = Field(repr=False)
50    key: str = Field(min_length=1, repr=True)
51    value: str | None = Field(min_length=1, repr=True)  # TODO: surprised this can be None
52    on_node: bool = Field(repr=False)
53    on_way: bool = Field(repr=False)
54    on_relation: bool = Field(repr=False)
55    on_area: bool = Field(repr=False)
56    description: OptionalNonEmptyString = Field(repr=False)
57    doc_url: OptionalHttpUrl = Field(repr=False)
58    icon_url: OptionalHttpUrl = Field(repr=False)

TODO: https://wiki.openstreetmap.org/wiki/Taginfo/Projects.

Attributes:
  • project_id: Project ID
  • project_name: Project name
  • project_icon_url: Project icon URL
  • key: Key
  • value: Value
  • on_node: For nodes?
  • on_way: For ways?
  • on_relation: For relations?
  • on_relation: For areas?
  • description: Description
  • doc_url: Documentation URL
  • icon_url: Icon URL
TagProject(*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)
project_id: str = FieldInfo(annotation=str, required=True, metadata=[MinLen(min_length=1)])
project_name: str = FieldInfo(annotation=str, required=True, metadata=[MinLen(min_length=1)])
project_icon_url: Annotated[Optional[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)]], BeforeValidator(func=<function _empty_str_to_none at 0x7f88f4d21c60>)] = FieldInfo(annotation=Union[Annotated[Url, UrlConstraints(max_length=2083, allowed_schemes=['http', 'https'], host_required=None, default_host=None, default_port=None, default_path=None)], NoneType], required=True, repr=False, metadata=[BeforeValidator(func=<function _empty_str_to_none>), BeforeValidator(func=<function _empty_str_to_none>)])
key: str = FieldInfo(annotation=str, required=True, metadata=[MinLen(min_length=1)])
value: str | None = FieldInfo(annotation=Union[str, NoneType], required=True, metadata=[MinLen(min_length=1)])
on_node: bool = FieldInfo(annotation=bool, required=True, repr=False)
on_way: bool = FieldInfo(annotation=bool, required=True, repr=False)
on_relation: bool = FieldInfo(annotation=bool, required=True, repr=False)
on_area: bool = FieldInfo(annotation=bool, required=True, repr=False)
description: typing.Annotated[str | None, BeforeValidator(func=<function _empty_str_to_none at 0x7f88f4d21c60>)] = FieldInfo(annotation=Union[str, NoneType], required=True, repr=False, metadata=[BeforeValidator(func=<function _empty_str_to_none>), BeforeValidator(func=<function _empty_str_to_none>)])
doc_url: Annotated[Optional[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)]], BeforeValidator(func=<function _empty_str_to_none at 0x7f88f4d21c60>)] = FieldInfo(annotation=Union[Annotated[Url, UrlConstraints(max_length=2083, allowed_schemes=['http', 'https'], host_required=None, default_host=None, default_port=None, default_path=None)], NoneType], required=True, repr=False, metadata=[BeforeValidator(func=<function _empty_str_to_none>), BeforeValidator(func=<function _empty_str_to_none>)])
icon_url: Annotated[Optional[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)]], BeforeValidator(func=<function _empty_str_to_none at 0x7f88f4d21c60>)] = FieldInfo(annotation=Union[Annotated[Url, UrlConstraints(max_length=2083, allowed_schemes=['http', 'https'], host_required=None, default_host=None, default_port=None, default_path=None)], NoneType], required=True, repr=False, metadata=[BeforeValidator(func=<function _empty_str_to_none>), BeforeValidator(func=<function _empty_str_to_none>)])
class TagProjectSorting(builtins.str, enum.Enum):
61class TagProjectSorting(str, Enum):
62    """Sort options for tag projects."""
63
64    PROJECT_NAME = "project_name"
65    TAG = "tag"

Sort options for tag projects.

PROJECT_NAME = <TagProjectSorting.PROJECT_NAME: 'project_name'>
TAG = <TagProjectSorting.TAG: 'tag'>
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