aio_taginfo.api.v4.key.projects
/api/4/key/projects
endpoint.
1"""`/api/4/key/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 "KeyProject", 22 "KeyProjectSorting", 23) 24 25 26@dataclass(kw_only=True, frozen=True) 27class KeyProject: 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: OptionalNonEmptyString = Field(repr=True) 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 KeyProjectSorting(str, Enum): 61 """Sort options for key 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 query: NonEmptyString | None = Field(repr=True) 71 sortname: KeyProjectSorting = Field(repr=True) 72 sortorder: SortOrder = Field(repr=True) 73 filter: ObjectType = Field(repr=True) 74 page: int = Field(gt=0, repr=True) 75 rp: int = Field(ge=0, repr=True) 76 77 78async def call( 79 key: str, 80 query: str | None = None, 81 sortname: KeyProjectSorting = KeyProjectSorting.PROJECT_NAME, 82 sortorder: SortOrder = SortOrder.ASC, 83 filter: ObjectType = ObjectType.ALL, # noqa: A002 84 page: int = 1, 85 rp: int = 0, 86 session: ClientSession | None = None, 87) -> Response[list[KeyProject]]: 88 """ 89 Get projects using a given key. 90 91 https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_projects 92 93 Args: 94 key: tag key 95 query: only show results where the project name or tag value matches this query 96 (substring match) 97 sortname: what field to sort by 98 sortorder: sort order 99 filter: can be used to filter only values on tags used on nodes/ways/relations 100 page: page number (starting at 1) 101 rp: results per page 102 session: request client session 103 104 Raises: 105 TaginfoError 106 """ 107 params = api_params( 108 _Params, 109 key=key, 110 query=query, 111 sortname=sortname, 112 sortorder=sortorder, 113 filter=filter, 114 page=page, 115 rp=rp, 116 ) 117 return await api_get_json( 118 path="key/projects", 119 cls=Response[list[KeyProject]], 120 session=session, 121 params=params, 122 ) 123 124 125__docformat__ = "google"
async def
call( key: str, query: str | None = None, sortname: KeyProjectSorting = <KeyProjectSorting.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[KeyProject]]:
79async def call( 80 key: str, 81 query: str | None = None, 82 sortname: KeyProjectSorting = KeyProjectSorting.PROJECT_NAME, 83 sortorder: SortOrder = SortOrder.ASC, 84 filter: ObjectType = ObjectType.ALL, # noqa: A002 85 page: int = 1, 86 rp: int = 0, 87 session: ClientSession | None = None, 88) -> Response[list[KeyProject]]: 89 """ 90 Get projects using a given key. 91 92 https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_projects 93 94 Args: 95 key: tag key 96 query: only show results where the project name or tag value matches this query 97 (substring match) 98 sortname: what field to sort by 99 sortorder: sort order 100 filter: can be used to filter only values on tags used on nodes/ways/relations 101 page: page number (starting at 1) 102 rp: results per page 103 session: request client session 104 105 Raises: 106 TaginfoError 107 """ 108 params = api_params( 109 _Params, 110 key=key, 111 query=query, 112 sortname=sortname, 113 sortorder=sortorder, 114 filter=filter, 115 page=page, 116 rp=rp, 117 ) 118 return await api_get_json( 119 path="key/projects", 120 cls=Response[list[KeyProject]], 121 session=session, 122 params=params, 123 )
Get projects using a given key.
https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_projects
Arguments:
- key: tag key
- query: only show results where the project name or tag value 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
KeyProject:
27@dataclass(kw_only=True, frozen=True) 28class KeyProject: 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: OptionalNonEmptyString = Field(repr=True) 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
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>)])
value: typing.Annotated[str | None, BeforeValidator(func=<function _empty_str_to_none at 0x7f88f4d21c60>)] =
FieldInfo(annotation=Union[str, NoneType], required=True, metadata=[BeforeValidator(func=<function _empty_str_to_none>), BeforeValidator(func=<function _empty_str_to_none>)])
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
KeyProjectSorting(builtins.str, enum.Enum):
61class KeyProjectSorting(str, Enum): 62 """Sort options for key projects.""" 63 64 PROJECT_NAME = "project_name" 65 TAG = "tag"
Sort options for key projects.
PROJECT_NAME =
<KeyProjectSorting.PROJECT_NAME: 'project_name'>
TAG =
<KeyProjectSorting.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