|
| 1 | +from typing import Any, Dict, List, Optional, Union |
| 2 | + |
| 3 | +import httpx |
| 4 | + |
| 5 | +from ...client import Client |
| 6 | +from ...models.building_search_results import BuildingSearchResults |
| 7 | +from ...types import UNSET, Response, Unset |
| 8 | + |
| 9 | + |
| 10 | +def _get_kwargs( |
| 11 | + *, |
| 12 | + client: Client, |
| 13 | + page: int = 0, |
| 14 | + page_size: int = 100, |
| 15 | + sort: Union[Unset, None, List[str]] = UNSET, |
| 16 | + filter_: Union[Unset, None, str] = "", |
| 17 | +) -> Dict[str, Any]: |
| 18 | + url = "{}/v1/buildings".format(client.base_url) |
| 19 | + |
| 20 | + headers: Dict[str, str] = client.get_headers() |
| 21 | + cookies: Dict[str, Any] = client.get_cookies() |
| 22 | + |
| 23 | + params: Dict[str, Any] = {} |
| 24 | + params["page"] = page |
| 25 | + |
| 26 | + params["page-size"] = page_size |
| 27 | + |
| 28 | + json_sort: Union[Unset, None, List[str]] = UNSET |
| 29 | + if not isinstance(sort, Unset): |
| 30 | + if sort is None: |
| 31 | + json_sort = None |
| 32 | + else: |
| 33 | + json_sort = sort |
| 34 | + |
| 35 | + params["sort"] = json_sort |
| 36 | + |
| 37 | + params["filter"] = filter_ |
| 38 | + |
| 39 | + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} |
| 40 | + |
| 41 | + return { |
| 42 | + "method": "get", |
| 43 | + "url": url, |
| 44 | + "headers": headers, |
| 45 | + "cookies": cookies, |
| 46 | + "timeout": client.get_timeout(), |
| 47 | + "params": params, |
| 48 | + } |
| 49 | + |
| 50 | + |
| 51 | +def _parse_response(*, response: httpx.Response) -> Optional[BuildingSearchResults]: |
| 52 | + if response.status_code == 200: |
| 53 | + response_200 = BuildingSearchResults.from_dict(response.json()) |
| 54 | + |
| 55 | + return response_200 |
| 56 | + return None |
| 57 | + |
| 58 | + |
| 59 | +def _build_response(*, response: httpx.Response) -> Response[BuildingSearchResults]: |
| 60 | + return Response( |
| 61 | + status_code=response.status_code, |
| 62 | + content=response.content, |
| 63 | + headers=response.headers, |
| 64 | + parsed=_parse_response(response=response), |
| 65 | + ) |
| 66 | + |
| 67 | + |
| 68 | +def sync_detailed( |
| 69 | + *, |
| 70 | + client: Client, |
| 71 | + page: int = 0, |
| 72 | + page_size: int = 100, |
| 73 | + sort: Union[Unset, None, List[str]] = UNSET, |
| 74 | + filter_: Union[Unset, None, str] = "", |
| 75 | +) -> Response[BuildingSearchResults]: |
| 76 | + """Search for sorted and paged Buildings |
| 77 | +
|
| 78 | + Search for sorted and paged buildings |
| 79 | +
|
| 80 | + Args: |
| 81 | + page (int): |
| 82 | + page_size (int): Default: 100. |
| 83 | + sort (Union[Unset, None, List[str]]): |
| 84 | + filter_ (Union[Unset, None, str]): Default: ''. |
| 85 | +
|
| 86 | + Returns: |
| 87 | + Response[BuildingSearchResults] |
| 88 | + """ |
| 89 | + |
| 90 | + kwargs = _get_kwargs( |
| 91 | + client=client, |
| 92 | + page=page, |
| 93 | + page_size=page_size, |
| 94 | + sort=sort, |
| 95 | + filter_=filter_, |
| 96 | + ) |
| 97 | + |
| 98 | + response = httpx.request( |
| 99 | + verify=client.verify_ssl, |
| 100 | + **kwargs, |
| 101 | + ) |
| 102 | + |
| 103 | + return _build_response(response=response) |
| 104 | + |
| 105 | + |
| 106 | +def sync( |
| 107 | + *, |
| 108 | + client: Client, |
| 109 | + page: int = 0, |
| 110 | + page_size: int = 100, |
| 111 | + sort: Union[Unset, None, List[str]] = UNSET, |
| 112 | + filter_: Union[Unset, None, str] = "", |
| 113 | +) -> Optional[BuildingSearchResults]: |
| 114 | + """Search for sorted and paged Buildings |
| 115 | +
|
| 116 | + Search for sorted and paged buildings |
| 117 | +
|
| 118 | + Args: |
| 119 | + page (int): |
| 120 | + page_size (int): Default: 100. |
| 121 | + sort (Union[Unset, None, List[str]]): |
| 122 | + filter_ (Union[Unset, None, str]): Default: ''. |
| 123 | +
|
| 124 | + Returns: |
| 125 | + Response[BuildingSearchResults] |
| 126 | + """ |
| 127 | + |
| 128 | + return sync_detailed( |
| 129 | + client=client, |
| 130 | + page=page, |
| 131 | + page_size=page_size, |
| 132 | + sort=sort, |
| 133 | + filter_=filter_, |
| 134 | + ).parsed |
| 135 | + |
| 136 | + |
| 137 | +async def asyncio_detailed( |
| 138 | + *, |
| 139 | + client: Client, |
| 140 | + page: int = 0, |
| 141 | + page_size: int = 100, |
| 142 | + sort: Union[Unset, None, List[str]] = UNSET, |
| 143 | + filter_: Union[Unset, None, str] = "", |
| 144 | +) -> Response[BuildingSearchResults]: |
| 145 | + """Search for sorted and paged Buildings |
| 146 | +
|
| 147 | + Search for sorted and paged buildings |
| 148 | +
|
| 149 | + Args: |
| 150 | + page (int): |
| 151 | + page_size (int): Default: 100. |
| 152 | + sort (Union[Unset, None, List[str]]): |
| 153 | + filter_ (Union[Unset, None, str]): Default: ''. |
| 154 | +
|
| 155 | + Returns: |
| 156 | + Response[BuildingSearchResults] |
| 157 | + """ |
| 158 | + |
| 159 | + kwargs = _get_kwargs( |
| 160 | + client=client, |
| 161 | + page=page, |
| 162 | + page_size=page_size, |
| 163 | + sort=sort, |
| 164 | + filter_=filter_, |
| 165 | + ) |
| 166 | + |
| 167 | + async with httpx.AsyncClient(verify=client.verify_ssl) as _client: |
| 168 | + response = await _client.request(**kwargs) |
| 169 | + |
| 170 | + return _build_response(response=response) |
| 171 | + |
| 172 | + |
| 173 | +async def asyncio( |
| 174 | + *, |
| 175 | + client: Client, |
| 176 | + page: int = 0, |
| 177 | + page_size: int = 100, |
| 178 | + sort: Union[Unset, None, List[str]] = UNSET, |
| 179 | + filter_: Union[Unset, None, str] = "", |
| 180 | +) -> Optional[BuildingSearchResults]: |
| 181 | + """Search for sorted and paged Buildings |
| 182 | +
|
| 183 | + Search for sorted and paged buildings |
| 184 | +
|
| 185 | + Args: |
| 186 | + page (int): |
| 187 | + page_size (int): Default: 100. |
| 188 | + sort (Union[Unset, None, List[str]]): |
| 189 | + filter_ (Union[Unset, None, str]): Default: ''. |
| 190 | +
|
| 191 | + Returns: |
| 192 | + Response[BuildingSearchResults] |
| 193 | + """ |
| 194 | + |
| 195 | + return ( |
| 196 | + await asyncio_detailed( |
| 197 | + client=client, |
| 198 | + page=page, |
| 199 | + page_size=page_size, |
| 200 | + sort=sort, |
| 201 | + filter_=filter_, |
| 202 | + ) |
| 203 | + ).parsed |
0 commit comments