Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

220 wiersze
5.7 KiB

  1. from http import HTTPStatus
  2. from typing import Any, Optional, Union, cast
  3. import httpx
  4. from ... import errors
  5. from ...client import AuthenticatedClient, Client
  6. from ...models.plan_item import PlanItem
  7. from ...types import UNSET, Response, Unset
  8. def _get_kwargs(
  9. *,
  10. id: Union[Unset, str] = UNSET,
  11. search_string: Union[Unset, str] = UNSET,
  12. skip: Union[Unset, int] = UNSET,
  13. limit: Union[Unset, int] = UNSET,
  14. ) -> dict[str, Any]:
  15. params: dict[str, Any] = {}
  16. params["id"] = id
  17. params["searchString"] = search_string
  18. params["skip"] = skip
  19. params["limit"] = limit
  20. params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
  21. _kwargs: dict[str, Any] = {
  22. "method": "get",
  23. "url": "/getPlans",
  24. "params": params,
  25. }
  26. return _kwargs
  27. def _parse_response(
  28. *, client: Union[AuthenticatedClient, Client], response: httpx.Response
  29. ) -> Optional[Union[Any, list["PlanItem"]]]:
  30. if response.status_code == 200:
  31. response_200 = []
  32. _response_200 = response.json()
  33. for response_200_item_data in _response_200:
  34. response_200_item = PlanItem.from_dict(response_200_item_data)
  35. response_200.append(response_200_item)
  36. return response_200
  37. if response.status_code == 400:
  38. response_400 = cast(Any, None)
  39. return response_400
  40. if client.raise_on_unexpected_status:
  41. raise errors.UnexpectedStatus(response.status_code, response.content)
  42. else:
  43. return None
  44. def _build_response(
  45. *, client: Union[AuthenticatedClient, Client], response: httpx.Response
  46. ) -> Response[Union[Any, list["PlanItem"]]]:
  47. return Response(
  48. status_code=HTTPStatus(response.status_code),
  49. content=response.content,
  50. headers=response.headers,
  51. parsed=_parse_response(client=client, response=response),
  52. )
  53. def sync_detailed(
  54. *,
  55. client: Union[AuthenticatedClient, Client],
  56. id: Union[Unset, str] = UNSET,
  57. search_string: Union[Unset, str] = UNSET,
  58. skip: Union[Unset, int] = UNSET,
  59. limit: Union[Unset, int] = UNSET,
  60. ) -> Response[Union[Any, list["PlanItem"]]]:
  61. """Get the plans
  62. Get the plans
  63. Args:
  64. id (Union[Unset, str]):
  65. search_string (Union[Unset, str]):
  66. skip (Union[Unset, int]):
  67. limit (Union[Unset, int]):
  68. Raises:
  69. errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
  70. httpx.TimeoutException: If the request takes longer than Client.timeout.
  71. Returns:
  72. Response[Union[Any, list['PlanItem']]]
  73. """
  74. kwargs = _get_kwargs(
  75. id=id,
  76. search_string=search_string,
  77. skip=skip,
  78. limit=limit,
  79. )
  80. response = client.get_httpx_client().request(
  81. **kwargs,
  82. )
  83. return _build_response(client=client, response=response)
  84. def sync(
  85. *,
  86. client: Union[AuthenticatedClient, Client],
  87. id: Union[Unset, str] = UNSET,
  88. search_string: Union[Unset, str] = UNSET,
  89. skip: Union[Unset, int] = UNSET,
  90. limit: Union[Unset, int] = UNSET,
  91. ) -> Optional[Union[Any, list["PlanItem"]]]:
  92. """Get the plans
  93. Get the plans
  94. Args:
  95. id (Union[Unset, str]):
  96. search_string (Union[Unset, str]):
  97. skip (Union[Unset, int]):
  98. limit (Union[Unset, int]):
  99. Raises:
  100. errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
  101. httpx.TimeoutException: If the request takes longer than Client.timeout.
  102. Returns:
  103. Union[Any, list['PlanItem']]
  104. """
  105. return sync_detailed(
  106. client=client,
  107. id=id,
  108. search_string=search_string,
  109. skip=skip,
  110. limit=limit,
  111. ).parsed
  112. async def asyncio_detailed(
  113. *,
  114. client: Union[AuthenticatedClient, Client],
  115. id: Union[Unset, str] = UNSET,
  116. search_string: Union[Unset, str] = UNSET,
  117. skip: Union[Unset, int] = UNSET,
  118. limit: Union[Unset, int] = UNSET,
  119. ) -> Response[Union[Any, list["PlanItem"]]]:
  120. """Get the plans
  121. Get the plans
  122. Args:
  123. id (Union[Unset, str]):
  124. search_string (Union[Unset, str]):
  125. skip (Union[Unset, int]):
  126. limit (Union[Unset, int]):
  127. Raises:
  128. errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
  129. httpx.TimeoutException: If the request takes longer than Client.timeout.
  130. Returns:
  131. Response[Union[Any, list['PlanItem']]]
  132. """
  133. kwargs = _get_kwargs(
  134. id=id,
  135. search_string=search_string,
  136. skip=skip,
  137. limit=limit,
  138. )
  139. response = await client.get_async_httpx_client().request(**kwargs)
  140. return _build_response(client=client, response=response)
  141. async def asyncio(
  142. *,
  143. client: Union[AuthenticatedClient, Client],
  144. id: Union[Unset, str] = UNSET,
  145. search_string: Union[Unset, str] = UNSET,
  146. skip: Union[Unset, int] = UNSET,
  147. limit: Union[Unset, int] = UNSET,
  148. ) -> Optional[Union[Any, list["PlanItem"]]]:
  149. """Get the plans
  150. Get the plans
  151. Args:
  152. id (Union[Unset, str]):
  153. search_string (Union[Unset, str]):
  154. skip (Union[Unset, int]):
  155. limit (Union[Unset, int]):
  156. Raises:
  157. errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
  158. httpx.TimeoutException: If the request takes longer than Client.timeout.
  159. Returns:
  160. Union[Any, list['PlanItem']]
  161. """
  162. return (
  163. await asyncio_detailed(
  164. client=client,
  165. id=id,
  166. search_string=search_string,
  167. skip=skip,
  168. limit=limit,
  169. )
  170. ).parsed