aio_taginfo.api.v4.key.similar
/api/4/key/similar
endpoint.
1"""`/api/4/key/similar` endpoint.""" 2 3from enum import Enum 4 5from aio_taginfo.api.v4 import Response, SortOrder 6from aio_taginfo.api.v4._internal import NonEmptyString, api_get_json, api_params 7 8from aiohttp import ClientSession 9from pydantic import Field 10from pydantic.dataclasses import dataclass 11 12 13__all__ = ( 14 "call", 15 "SimilarKey", 16 "SimilarKeySorting", 17) 18 19 20@dataclass(kw_only=True, frozen=True) 21class SimilarKey: 22 """ 23 Result of a key that is similar to a given key. 24 25 Attributes: 26 other_key: other key 27 count_all: number of objects that have the other key 28 similarity: integer measuring the similarity of the two keys (smaller is more similar) 29 """ 30 31 other_key: str = Field(min_length=1, repr=True) 32 count_all: int = Field(ge=0, repr=True) 33 similarity: int = Field(ge=0, repr=True) 34 35 36class SimilarKeySorting(str, Enum): 37 """Sort options for similar keys.""" 38 39 OTHER_KEY = "other_key" 40 COUNT_ALL = "count_all" 41 SIMILARITY = "similarity" 42 43 44@dataclass(kw_only=True, frozen=True) 45class _Params: 46 key: NonEmptyString = Field(repr=True) 47 query: NonEmptyString | None = Field(repr=True) 48 sortname: SimilarKeySorting = Field(repr=True) 49 sortorder: SortOrder = Field(repr=True) 50 page: int = Field(gt=0, repr=True) 51 rp: int = Field(ge=0, repr=True) 52 53 54async def call( 55 key: str, 56 query: str | None = None, 57 sortname: SimilarKeySorting = SimilarKeySorting.OTHER_KEY, 58 sortorder: SortOrder = SortOrder.ASC, 59 page: int = 1, 60 rp: int = 0, 61 session: ClientSession | None = None, 62) -> Response[list[SimilarKey]]: 63 """ 64 Find keys that are similar to a given key. 65 66 https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_similar 67 68 Args: 69 key: tag key 70 query: only show results where the ``other_key`` matches this query (substring match) 71 sortname: what field to sort by 72 sortorder: sort order 73 page: page number (starting at 1) 74 rp: results per page 75 session: request client session 76 77 Raises: 78 TaginfoError 79 """ 80 params = api_params( 81 _Params, key=key, query=query, sortname=sortname, sortorder=sortorder, page=page, rp=rp 82 ) 83 return await api_get_json( 84 path="key/similar", 85 cls=Response[list[SimilarKey]], 86 session=session, 87 params=params, 88 ) 89 90 91__docformat__ = "google"
async def
call( key: str, query: str | None = None, sortname: SimilarKeySorting = <SimilarKeySorting.OTHER_KEY: 'other_key'>, sortorder: aio_taginfo.api.v4.SortOrder = <SortOrder.ASC: 'asc'>, page: int = 1, rp: int = 0, session: aiohttp.client.ClientSession | None = None) -> aio_taginfo.api.v4.Response[list[SimilarKey]]:
55async def call( 56 key: str, 57 query: str | None = None, 58 sortname: SimilarKeySorting = SimilarKeySorting.OTHER_KEY, 59 sortorder: SortOrder = SortOrder.ASC, 60 page: int = 1, 61 rp: int = 0, 62 session: ClientSession | None = None, 63) -> Response[list[SimilarKey]]: 64 """ 65 Find keys that are similar to a given key. 66 67 https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_similar 68 69 Args: 70 key: tag key 71 query: only show results where the ``other_key`` matches this query (substring match) 72 sortname: what field to sort by 73 sortorder: sort order 74 page: page number (starting at 1) 75 rp: results per page 76 session: request client session 77 78 Raises: 79 TaginfoError 80 """ 81 params = api_params( 82 _Params, key=key, query=query, sortname=sortname, sortorder=sortorder, page=page, rp=rp 83 ) 84 return await api_get_json( 85 path="key/similar", 86 cls=Response[list[SimilarKey]], 87 session=session, 88 params=params, 89 )
Find keys that are similar to a given key.
https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_similar
Arguments:
- key: tag key
- query: only show results where the
other_key
matches this query (substring match) - sortname: what field to sort by
- sortorder: sort order
- page: page number (starting at 1)
- rp: results per page
- session: request client session
Raises:
- TaginfoError
@dataclass(kw_only=True, frozen=True)
class
SimilarKey:
21@dataclass(kw_only=True, frozen=True) 22class SimilarKey: 23 """ 24 Result of a key that is similar to a given key. 25 26 Attributes: 27 other_key: other key 28 count_all: number of objects that have the other key 29 similarity: integer measuring the similarity of the two keys (smaller is more similar) 30 """ 31 32 other_key: str = Field(min_length=1, repr=True) 33 count_all: int = Field(ge=0, repr=True) 34 similarity: int = Field(ge=0, repr=True)
Result of a key that is similar to a given key.
Attributes:
- other_key: other key
- count_all: number of objects that have the other key
- similarity: integer measuring the similarity of the two keys (smaller is more similar)
class
SimilarKeySorting(builtins.str, enum.Enum):
37class SimilarKeySorting(str, Enum): 38 """Sort options for similar keys.""" 39 40 OTHER_KEY = "other_key" 41 COUNT_ALL = "count_all" 42 SIMILARITY = "similarity"
Sort options for similar keys.
OTHER_KEY =
<SimilarKeySorting.OTHER_KEY: 'other_key'>
COUNT_ALL =
<SimilarKeySorting.COUNT_ALL: 'count_all'>
SIMILARITY =
<SimilarKeySorting.SIMILARITY: 'similarity'>
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