25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

111 satır
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.remove_item import RemoveItem
  7. from ...types import Response
  8. def _get_kwargs(
  9. *,
  10. body: RemoveItem,
  11. ) -> dict[str, Any]:
  12. headers: dict[str, Any] = {}
  13. _kwargs: dict[str, Any] = {
  14. "method": "post",
  15. "url": "/removeGateway",
  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: RemoveItem,
  43. ) -> Response[Any]:
  44. """Remove a gateway item
  45. Remove a gateway
  46. Args:
  47. body (RemoveItem): Item to be removed
  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: RemoveItem,
  65. ) -> Response[Any]:
  66. """Remove a gateway item
  67. Remove a gateway
  68. Args:
  69. body (RemoveItem): Item to be removed
  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)