diff --git a/pyproject.toml b/pyproject.toml index 2dcc934..deca420 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "pipedream" [tool.poetry] name = "pipedream" -version = "0.3.3" +version = "0.3.4" description = "" readme = "README.md" authors = [] diff --git a/src/pipedream/client.py b/src/pipedream/client.py index 24d3539..05f4186 100644 --- a/src/pipedream/client.py +++ b/src/pipedream/client.py @@ -4,7 +4,7 @@ import typing import httpx -from .types.project_environment import ProjectEnvironment +from ._.types.project_environment import ProjectEnvironment from .accounts.client import AccountsClient, AsyncAccountsClient from .actions.client import ActionsClient, AsyncActionsClient from .app_categories.client import AppCategoriesClient, AsyncAppCategoriesClient diff --git a/src/pipedream/core/client_wrapper.py b/src/pipedream/core/client_wrapper.py index 9aa7f23..36ea9e3 100644 --- a/src/pipedream/core/client_wrapper.py +++ b/src/pipedream/core/client_wrapper.py @@ -3,7 +3,7 @@ import typing import httpx -from ..types.project_environment import ProjectEnvironment +from .._.types.project_environment import ProjectEnvironment from .http_client import AsyncHttpClient, HttpClient @@ -27,10 +27,10 @@ def __init__( def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { - "User-Agent": "pipedream/0.3.3", + "User-Agent": "pipedream/0.3.4", "X-Fern-Language": "Python", "X-Fern-SDK-Name": "pipedream", - "X-Fern-SDK-Version": "0.3.3", + "X-Fern-SDK-Version": "0.3.4", **(self.get_custom_headers() or {}), } if self._project_environment is not None: diff --git a/src/pipedream/proxy/raw_client.py b/src/pipedream/proxy/raw_client.py index d82bdae..a935549 100644 --- a/src/pipedream/proxy/raw_client.py +++ b/src/pipedream/proxy/raw_client.py @@ -9,7 +9,6 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions -from ..types.proxy_response import ProxyResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -26,7 +25,7 @@ def get( external_user_id: str, account_id: str, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[ProxyResponse]: + ) -> HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -44,7 +43,7 @@ def get( Returns ------- - HttpResponse[ProxyResponse] + HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = self._client_wrapper.httpx_client.request( @@ -57,13 +56,11 @@ def get( request_options=request_options, ) try: - if _response is None or not _response.text.strip(): - return HttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -81,7 +78,7 @@ def post( account_id: str, request: typing.Dict[str, typing.Optional[typing.Any]], request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[ProxyResponse]: + ) -> HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -101,7 +98,7 @@ def post( Returns ------- - HttpResponse[ProxyResponse] + HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = self._client_wrapper.httpx_client.request( @@ -119,13 +116,11 @@ def post( omit=OMIT, ) try: - if _response is None or not _response.text.strip(): - return HttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -143,7 +138,7 @@ def put( account_id: str, request: typing.Dict[str, typing.Optional[typing.Any]], request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[ProxyResponse]: + ) -> HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -163,7 +158,7 @@ def put( Returns ------- - HttpResponse[ProxyResponse] + HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = self._client_wrapper.httpx_client.request( @@ -181,13 +176,11 @@ def put( omit=OMIT, ) try: - if _response is None or not _response.text.strip(): - return HttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -204,7 +197,7 @@ def delete( external_user_id: str, account_id: str, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[ProxyResponse]: + ) -> HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -222,7 +215,7 @@ def delete( Returns ------- - HttpResponse[ProxyResponse] + HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = self._client_wrapper.httpx_client.request( @@ -235,13 +228,11 @@ def delete( request_options=request_options, ) try: - if _response is None or not _response.text.strip(): - return HttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -259,7 +250,7 @@ def patch( account_id: str, request: typing.Dict[str, typing.Optional[typing.Any]], request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[ProxyResponse]: + ) -> HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -279,7 +270,7 @@ def patch( Returns ------- - HttpResponse[ProxyResponse] + HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = self._client_wrapper.httpx_client.request( @@ -297,13 +288,11 @@ def patch( omit=OMIT, ) try: - if _response is None or not _response.text.strip(): - return HttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -325,7 +314,7 @@ async def get( external_user_id: str, account_id: str, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[ProxyResponse]: + ) -> AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -343,7 +332,7 @@ async def get( Returns ------- - AsyncHttpResponse[ProxyResponse] + AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = await self._client_wrapper.httpx_client.request( @@ -356,13 +345,11 @@ async def get( request_options=request_options, ) try: - if _response is None or not _response.text.strip(): - return AsyncHttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -380,7 +367,7 @@ async def post( account_id: str, request: typing.Dict[str, typing.Optional[typing.Any]], request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[ProxyResponse]: + ) -> AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -400,7 +387,7 @@ async def post( Returns ------- - AsyncHttpResponse[ProxyResponse] + AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = await self._client_wrapper.httpx_client.request( @@ -418,13 +405,11 @@ async def post( omit=OMIT, ) try: - if _response is None or not _response.text.strip(): - return AsyncHttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -442,7 +427,7 @@ async def put( account_id: str, request: typing.Dict[str, typing.Optional[typing.Any]], request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[ProxyResponse]: + ) -> AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -462,7 +447,7 @@ async def put( Returns ------- - AsyncHttpResponse[ProxyResponse] + AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = await self._client_wrapper.httpx_client.request( @@ -480,13 +465,11 @@ async def put( omit=OMIT, ) try: - if _response is None or not _response.text.strip(): - return AsyncHttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -503,7 +486,7 @@ async def delete( external_user_id: str, account_id: str, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[ProxyResponse]: + ) -> AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -521,7 +504,7 @@ async def delete( Returns ------- - AsyncHttpResponse[ProxyResponse] + AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = await self._client_wrapper.httpx_client.request( @@ -534,13 +517,11 @@ async def delete( request_options=request_options, ) try: - if _response is None or not _response.text.strip(): - return AsyncHttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) @@ -558,7 +539,7 @@ async def patch( account_id: str, request: typing.Dict[str, typing.Optional[typing.Any]], request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[ProxyResponse]: + ) -> AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: """ Parameters ---------- @@ -578,7 +559,7 @@ async def patch( Returns ------- - AsyncHttpResponse[ProxyResponse] + AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] proxy request successful """ _response = await self._client_wrapper.httpx_client.request( @@ -596,13 +577,11 @@ async def patch( omit=OMIT, ) try: - if _response is None or not _response.text.strip(): - return AsyncHttpResponse(response=_response, data=None) if 200 <= _response.status_code < 300: _data = typing.cast( - ProxyResponse, + typing.Dict[str, typing.Optional[typing.Any]], parse_obj_as( - type_=ProxyResponse, # type: ignore + type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore object_=_response.json(), ), ) diff --git a/src/pipedream/types/proxy_response.py b/src/pipedream/types/proxy_response.py index 902ac7d..dea284e 100644 --- a/src/pipedream/types/proxy_response.py +++ b/src/pipedream/types/proxy_response.py @@ -2,4 +2,32 @@ import typing -ProxyResponse = typing.Optional[typing.Any] +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class ProxyResponse(UniversalBaseModel): + """ + The parsed response body from a proxied API request + """ + + status: typing.Optional[int] = pydantic.Field(default=None) + """ + HTTP status code + """ + + headers: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + """ + Response headers + """ + + body: typing.Optional[typing.Optional[typing.Any]] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow