No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

111 líneas
2.6 KiB

  1. from http import HTTPStatus
  2. from typing import Any, Optional, Union
  3. import httpx
  4. from ... import errors
  5. from ...client import AuthenticatedClient, Client
  6. from ...models.plan_item import PlanItem
  7. from ...types import Response
  8. def _get_kwargs(
  9. *,
  10. body: PlanItem,
  11. ) -> dict[str, Any]:
  12. headers: dict[str, Any] = {}
  13. _kwargs: dict[str, Any] = {
  14. "method": "post",
  15. "url": "/postPlan",
  16. }
  17. _kwargs["json"] = body.to_dict()
  18. headers["Content-Type"] = "application/json"
  19. _kwargs["headers"] = headers
  20. return _kwargs
  21. def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
  22. if response.status_code == 201:
  23. return None
  24. if response.status_code == 400:
  25. return None
  26. if response.status_code == 409:
  27. return None
  28. if client.raise_on_unexpected_status:
  29. raise errors.UnexpectedStatus(response.status_code, response.content)
  30. else:
  31. return None
  32. def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:
  33. return Response(
  34. status_code=HTTPStatus(response.status_code),
  35. content=response.content,
  36. headers=response.headers,
  37. parsed=_parse_response(client=client, response=response),
  38. )
  39. def sync_detailed(
  40. *,
  41. client: Union[AuthenticatedClient, Client],
  42. body: PlanItem,
  43. ) -> Response[Any]:
  44. """Post a plan item
  45. Post a plan
  46. Args:
  47. body (PlanItem): A plan is floor or a space of a building
  48. Raises:
  49. errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
  50. httpx.TimeoutException: If the request takes longer than Client.timeout.
  51. Returns:
  52. Response[Any]
  53. """
  54. kwargs = _get_kwargs(
  55. body=body,
  56. )
  57. response = client.get_httpx_client().request(
  58. **kwargs,
  59. )
  60. return _build_response(client=client, response=response)
  61. async def asyncio_detailed(
  62. *,
  63. client: Union[AuthenticatedClient, Client],
  64. body: PlanItem,
  65. ) -> Response[Any]:
  66. """Post a plan item
  67. Post a plan
  68. Args:
  69. body (PlanItem): A plan is floor or a space of a building
  70. Raises:
  71. errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
  72. httpx.TimeoutException: If the request takes longer than Client.timeout.
  73. Returns:
  74. Response[Any]
  75. """
  76. kwargs = _get_kwargs(
  77. body=body,
  78. )
  79. response = await client.get_async_httpx_client().request(**kwargs)
  80. return _build_response(client=client, response=response)