2
2
3
3
from __future__ import annotations
4
4
5
- from typing import Any , cast
5
+ from typing import Type , cast
6
6
7
7
import httpx
8
8
9
- from ......types import Binding
10
9
from ......_types import NOT_GIVEN , Body , Query , Headers , NotGiven
11
10
from ......_compat import cached_property
12
11
from ......_resource import SyncAPIResource , AsyncAPIResource
16
15
async_to_raw_response_wrapper ,
17
16
async_to_streamed_response_wrapper ,
18
17
)
18
+ from ......_wrappers import ResultWrapper
19
19
from ......_base_client import (
20
20
make_request_options ,
21
21
)
22
+ from ......types .workers_for_platforms .dispatch .namespaces .scripts import BindingGetResponse
22
23
23
24
__all__ = ["Bindings" , "AsyncBindings" ]
24
25
@@ -44,7 +45,7 @@ def get(
44
45
extra_query : Query | None = None ,
45
46
extra_body : Body | None = None ,
46
47
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
47
- ) -> Binding :
48
+ ) -> BindingGetResponse :
48
49
"""
49
50
Fetch script bindings from a script uploaded to a Workers for Platforms
50
51
namespace.
@@ -70,15 +71,16 @@ def get(
70
71
raise ValueError (f"Expected a non-empty value for `dispatch_namespace` but received { dispatch_namespace !r} " )
71
72
if not script_name :
72
73
raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
73
- return cast (
74
- Binding ,
75
- self . _get (
76
- f"/accounts/ { account_id } /workers/dispatch/namespaces/ { dispatch_namespace } /scripts/ { script_name } /bindings" ,
77
- options = make_request_options (
78
- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
79
- ) ,
80
- cast_to = cast ( Any , Binding ), # Union types cannot be passed in as arguments in the type system
74
+ return self . _get (
75
+ f"/accounts/ { account_id } /workers/dispatch/namespaces/ { dispatch_namespace } /scripts/ { script_name } /bindings" ,
76
+ options = make_request_options (
77
+ extra_headers = extra_headers ,
78
+ extra_query = extra_query ,
79
+ extra_body = extra_body ,
80
+ timeout = timeout ,
81
+ post_parser = ResultWrapper . _unwrapper ,
81
82
),
83
+ cast_to = cast (Type [BindingGetResponse ], ResultWrapper [BindingGetResponse ]),
82
84
)
83
85
84
86
@@ -103,7 +105,7 @@ async def get(
103
105
extra_query : Query | None = None ,
104
106
extra_body : Body | None = None ,
105
107
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
106
- ) -> Binding :
108
+ ) -> BindingGetResponse :
107
109
"""
108
110
Fetch script bindings from a script uploaded to a Workers for Platforms
109
111
namespace.
@@ -129,15 +131,16 @@ async def get(
129
131
raise ValueError (f"Expected a non-empty value for `dispatch_namespace` but received { dispatch_namespace !r} " )
130
132
if not script_name :
131
133
raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
132
- return cast (
133
- Binding ,
134
- await self . _get (
135
- f"/accounts/ { account_id } /workers/dispatch/namespaces/ { dispatch_namespace } /scripts/ { script_name } /bindings" ,
136
- options = make_request_options (
137
- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
138
- ) ,
139
- cast_to = cast ( Any , Binding ), # Union types cannot be passed in as arguments in the type system
134
+ return await self . _get (
135
+ f"/accounts/ { account_id } /workers/dispatch/namespaces/ { dispatch_namespace } /scripts/ { script_name } /bindings" ,
136
+ options = make_request_options (
137
+ extra_headers = extra_headers ,
138
+ extra_query = extra_query ,
139
+ extra_body = extra_body ,
140
+ timeout = timeout ,
141
+ post_parser = ResultWrapper . _unwrapper ,
140
142
),
143
+ cast_to = cast (Type [BindingGetResponse ], ResultWrapper [BindingGetResponse ]),
141
144
)
142
145
143
146
0 commit comments