Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e1bc8d

Browse files
committed
Update custom client to match TS
1 parent7f411db commit6e1bc8d

File tree

1 file changed

+59
-21
lines changed

1 file changed

+59
-21
lines changed

‎src/pipedream/pipedream.py‎

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
importos
2-
fromstringimportTemplate
2+
fromtypingimport (
3+
Literal,
4+
Optional,
5+
)
36

47
from .clientimport (
58
AsyncClient,
@@ -8,37 +11,72 @@
811
from .environmentimportPipedreamEnvironment
912

1013

14+
classOAuthCredentials:
15+
16+
def__init__(
17+
self,
18+
client_id:Optional[str]=None,
19+
client_secret:Optional[str]=None,
20+
):
21+
self.client_id=client_idoros.getenv("PIPEDREAM_CLIENT_ID")
22+
self.client_secret=client_secretoros.getenv(
23+
"PIPEDREAM_CLIENT_SECRET")
24+
25+
ifnotself.client_idornotself.client_secret:
26+
raiseValueError("OAuth client ID and secret are required")
27+
28+
1129
classPipedream(Client):
30+
1231
def__init__(
1332
self,
14-
project_id:str,
15-
environment:PipedreamEnvironment=PipedreamEnvironment.PROD,
16-
*args,
33+
*,
34+
credentials:OAuthCredentials=OAuthCredentials(),
35+
project_id:Optional[str]=None,
36+
environment:Literal["production","development"]="production",
37+
api_environment:PipedreamEnvironment=PipedreamEnvironment.PROD,
1738
**kwargs,
1839
):
19-
super().__init__(base_url=_get_base_url(environment),*args,**kwargs)
20-
self.project_id=project_id
40+
project_id=project_idoros.getenv("PIPEDREAM_PROJECT_ID")
41+
ifnotproject_id:
42+
raiseValueError("Project ID is required")
43+
44+
ifnotcredentials.client_idornotcredentials.client_secret:
45+
raiseValueError("OAuth client ID and secret are required")
46+
47+
super().__init__(
48+
client_id=credentials.client_id,
49+
client_secret=credentials.client_secret,
50+
environment=api_environment,
51+
project_id=project_id,
52+
x_pd_environment=environment,
53+
**kwargs,
54+
)
2155

2256

2357
classAsyncPipedream(AsyncClient):
58+
2459
def__init__(
2560
self,
26-
project_id:str,
27-
environment:PipedreamEnvironment=PipedreamEnvironment.PROD,
28-
*args,
61+
*,
62+
credentials:OAuthCredentials=OAuthCredentials(),
63+
project_id:Optional[str]=None,
64+
environment:Literal["production","development"]="production",
65+
api_environment:PipedreamEnvironment=PipedreamEnvironment.PROD,
2966
**kwargs,
3067
):
31-
super().__init__(base_url=_get_base_url(environment),*args,**kwargs)
32-
self.project_id=project_id
33-
68+
project_id=project_idoros.getenv("PIPEDREAM_PROJECT_ID")
69+
ifnotproject_id:
70+
raiseValueError("Project ID is required")
3471

35-
def_get_base_url(environment:PipedreamEnvironment)->str:
36-
ifnotenvironment:
37-
raiseException("Please pass environment to construct the client")
72+
ifnotcredentials.client_idornotcredentials.client_secret:
73+
raiseValueError("OAuth client ID and secret are required")
3874

39-
user=os.getenv("DEV_NAMESPACE","")
40-
returnTemplate(environment.value).substitute(
41-
{
42-
"user":user,
43-
}
44-
)
75+
super().__init__(
76+
client_id=credentials.client_id,
77+
client_secret=credentials.client_secret,
78+
environment=api_environment,
79+
project_id=project_id,
80+
x_pd_environment=environment,
81+
**kwargs,
82+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp