Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions src/pipedream/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

import os
import typing

import httpx
Expand All @@ -8,6 +9,7 @@
from .app_categories.client import AppCategoriesClient, AsyncAppCategoriesClient
from .apps.client import AppsClient, AsyncAppsClient
from .components.client import AsyncComponentsClient, ComponentsClient
from .core.api_error import ApiError
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .core.oauth_token_provider import OAuthTokenProvider
from .deployed_triggers.client import AsyncDeployedTriggersClient, DeployedTriggersClient
Expand Down Expand Up @@ -40,8 +42,8 @@ class Client:

project_id : str
x_pd_environment : typing.Optional[str]
client_id : str
client_secret : str
client_id : typing.Optional[str]
client_secret : typing.Optional[str]
_token_getter_override : typing.Optional[typing.Callable[[], str]]
timeout : typing.Optional[float]
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
Expand Down Expand Up @@ -71,8 +73,8 @@ def __init__(
environment: PipedreamEnvironment = PipedreamEnvironment.PROD,
project_id: str,
x_pd_environment: typing.Optional[str] = None,
client_id: str,
client_secret: str,
client_id: typing.Optional[str] = os.getenv("PIPEDREAM_CLIENT_ID"),
client_secret: typing.Optional[str] = os.getenv("PIPEDREAM_CLIENT_SECRET"),
_token_getter_override: typing.Optional[typing.Callable[[], str]] = None,
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
Expand All @@ -81,6 +83,14 @@ def __init__(
_defaulted_timeout = (
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
)
if client_id is None:
raise ApiError(
body="The client must be instantiated be either passing in client_id or setting PIPEDREAM_CLIENT_ID"
)
if client_secret is None:
raise ApiError(
body="The client must be instantiated be either passing in client_secret or setting PIPEDREAM_CLIENT_SECRET"
)
oauth_token_provider = OAuthTokenProvider(
client_id=client_id,
client_secret=client_secret,
Expand Down Expand Up @@ -140,8 +150,8 @@ class AsyncClient:

project_id : str
x_pd_environment : typing.Optional[str]
client_id : str
client_secret : str
client_id : typing.Optional[str]
client_secret : typing.Optional[str]
_token_getter_override : typing.Optional[typing.Callable[[], str]]
timeout : typing.Optional[float]
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
Expand Down Expand Up @@ -171,8 +181,8 @@ def __init__(
environment: PipedreamEnvironment = PipedreamEnvironment.PROD,
project_id: str,
x_pd_environment: typing.Optional[str] = None,
client_id: str,
client_secret: str,
client_id: typing.Optional[str] = os.getenv("PIPEDREAM_CLIENT_ID"),
client_secret: typing.Optional[str] = os.getenv("PIPEDREAM_CLIENT_SECRET"),
_token_getter_override: typing.Optional[typing.Callable[[], str]] = None,
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
Expand All @@ -181,6 +191,14 @@ def __init__(
_defaulted_timeout = (
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
)
if client_id is None:
raise ApiError(
body="The client must be instantiated be either passing in client_id or setting PIPEDREAM_CLIENT_ID"
)
if client_secret is None:
raise ApiError(
body="The client must be instantiated be either passing in client_secret or setting PIPEDREAM_CLIENT_SECRET"
)
oauth_token_provider = OAuthTokenProvider(
client_id=client_id,
client_secret=client_secret,
Expand Down
14 changes: 2 additions & 12 deletions src/pipedream/pipedream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ def __init__(
client_id: Optional[str] = None,
client_secret: Optional[str] = None,
):
self.client_id = client_id or os.getenv("PIPEDREAM_CLIENT_ID")
self.client_secret = client_secret or os.getenv(
"PIPEDREAM_CLIENT_SECRET")

if not self.client_id or not self.client_secret:
raise ValueError("OAuth client ID and secret are required")
self.client_id = client_id
self.client_secret = client_secret


class Pipedream(Client):
Expand All @@ -41,9 +37,6 @@ def __init__(
if not project_id:
raise ValueError("Project ID is required")

if not credentials.client_id or not credentials.client_secret:
raise ValueError("OAuth client ID and secret are required")

super().__init__(
client_id=credentials.client_id,
client_secret=credentials.client_secret,
Expand All @@ -69,9 +62,6 @@ def __init__(
if not project_id:
raise ValueError("Project ID is required")

if not credentials.client_id or not credentials.client_secret:
raise ValueError("OAuth client ID and secret are required")

super().__init__(
client_id=credentials.client_id,
client_secret=credentials.client_secret,
Expand Down