2121from ...._base_client import make_request_options
2222from ....types .workers .scripts import deployment_create_params
2323from ....types .workers .scripts .deployment_get_response import DeploymentGetResponse
24+ from ....types .workers .scripts .deployment_list_response import DeploymentListResponse
2425from ....types .workers .scripts .deployment_create_response import DeploymentCreateResponse
26+ from ....types .workers .scripts .deployment_delete_response import DeploymentDeleteResponse
2527
2628__all__ = ["DeploymentsResource" , "AsyncDeploymentsResource" ]
2729
@@ -109,7 +111,7 @@ def create(
109111 cast_to = cast (Type [DeploymentCreateResponse ], ResultWrapper [DeploymentCreateResponse ]),
110112 )
111113
112- def get (
114+ def list (
113115 self ,
114116 script_name : str ,
115117 * ,
@@ -120,7 +122,7 @@ def get(
120122 extra_query : Query | None = None ,
121123 extra_body : Body | None = None ,
122124 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
123- ) -> DeploymentGetResponse :
125+ ) -> DeploymentListResponse :
124126 """List of Worker Deployments.
125127
126128 The first deployment in the list is the latest
@@ -145,6 +147,98 @@ def get(
145147 raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
146148 return self ._get (
147149 f"/accounts/{ account_id } /workers/scripts/{ script_name } /deployments" ,
150+ options = make_request_options (
151+ extra_headers = extra_headers ,
152+ extra_query = extra_query ,
153+ extra_body = extra_body ,
154+ timeout = timeout ,
155+ post_parser = ResultWrapper [DeploymentListResponse ]._unwrapper ,
156+ ),
157+ cast_to = cast (Type [DeploymentListResponse ], ResultWrapper [DeploymentListResponse ]),
158+ )
159+
160+ def delete (
161+ self ,
162+ deployment_id : str ,
163+ * ,
164+ account_id : str ,
165+ script_name : str ,
166+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
167+ # The extra values given here take precedence over values defined on the client or passed to this method.
168+ extra_headers : Headers | None = None ,
169+ extra_query : Query | None = None ,
170+ extra_body : Body | None = None ,
171+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
172+ ) -> DeploymentDeleteResponse :
173+ """Delete a Worker Deployment.
174+
175+ The latest deployment, which is actively serving
176+ traffic, cannot be deleted. All other deployments can be deleted.
177+
178+ Args:
179+ account_id: Identifier.
180+
181+ script_name: Name of the script, used in URLs and route configuration.
182+
183+ extra_headers: Send extra headers
184+
185+ extra_query: Add additional query parameters to the request
186+
187+ extra_body: Add additional JSON properties to the request
188+
189+ timeout: Override the client-level default timeout for this request, in seconds
190+ """
191+ if not account_id :
192+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
193+ if not script_name :
194+ raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
195+ if not deployment_id :
196+ raise ValueError (f"Expected a non-empty value for `deployment_id` but received { deployment_id !r} " )
197+ return self ._delete (
198+ f"/accounts/{ account_id } /workers/scripts/{ script_name } /deployments/{ deployment_id } " ,
199+ options = make_request_options (
200+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
201+ ),
202+ cast_to = DeploymentDeleteResponse ,
203+ )
204+
205+ def get (
206+ self ,
207+ deployment_id : str ,
208+ * ,
209+ account_id : str ,
210+ script_name : str ,
211+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
212+ # The extra values given here take precedence over values defined on the client or passed to this method.
213+ extra_headers : Headers | None = None ,
214+ extra_query : Query | None = None ,
215+ extra_body : Body | None = None ,
216+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
217+ ) -> DeploymentGetResponse :
218+ """
219+ Get information about a Worker Deployment.
220+
221+ Args:
222+ account_id: Identifier.
223+
224+ script_name: Name of the script, used in URLs and route configuration.
225+
226+ extra_headers: Send extra headers
227+
228+ extra_query: Add additional query parameters to the request
229+
230+ extra_body: Add additional JSON properties to the request
231+
232+ timeout: Override the client-level default timeout for this request, in seconds
233+ """
234+ if not account_id :
235+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
236+ if not script_name :
237+ raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
238+ if not deployment_id :
239+ raise ValueError (f"Expected a non-empty value for `deployment_id` but received { deployment_id !r} " )
240+ return self ._get (
241+ f"/accounts/{ account_id } /workers/scripts/{ script_name } /deployments/{ deployment_id } " ,
148242 options = make_request_options (
149243 extra_headers = extra_headers ,
150244 extra_query = extra_query ,
@@ -239,7 +333,7 @@ async def create(
239333 cast_to = cast (Type [DeploymentCreateResponse ], ResultWrapper [DeploymentCreateResponse ]),
240334 )
241335
242- async def get (
336+ async def list (
243337 self ,
244338 script_name : str ,
245339 * ,
@@ -250,7 +344,7 @@ async def get(
250344 extra_query : Query | None = None ,
251345 extra_body : Body | None = None ,
252346 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
253- ) -> DeploymentGetResponse :
347+ ) -> DeploymentListResponse :
254348 """List of Worker Deployments.
255349
256350 The first deployment in the list is the latest
@@ -275,6 +369,98 @@ async def get(
275369 raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
276370 return await self ._get (
277371 f"/accounts/{ account_id } /workers/scripts/{ script_name } /deployments" ,
372+ options = make_request_options (
373+ extra_headers = extra_headers ,
374+ extra_query = extra_query ,
375+ extra_body = extra_body ,
376+ timeout = timeout ,
377+ post_parser = ResultWrapper [DeploymentListResponse ]._unwrapper ,
378+ ),
379+ cast_to = cast (Type [DeploymentListResponse ], ResultWrapper [DeploymentListResponse ]),
380+ )
381+
382+ async def delete (
383+ self ,
384+ deployment_id : str ,
385+ * ,
386+ account_id : str ,
387+ script_name : str ,
388+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
389+ # The extra values given here take precedence over values defined on the client or passed to this method.
390+ extra_headers : Headers | None = None ,
391+ extra_query : Query | None = None ,
392+ extra_body : Body | None = None ,
393+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
394+ ) -> DeploymentDeleteResponse :
395+ """Delete a Worker Deployment.
396+
397+ The latest deployment, which is actively serving
398+ traffic, cannot be deleted. All other deployments can be deleted.
399+
400+ Args:
401+ account_id: Identifier.
402+
403+ script_name: Name of the script, used in URLs and route configuration.
404+
405+ extra_headers: Send extra headers
406+
407+ extra_query: Add additional query parameters to the request
408+
409+ extra_body: Add additional JSON properties to the request
410+
411+ timeout: Override the client-level default timeout for this request, in seconds
412+ """
413+ if not account_id :
414+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
415+ if not script_name :
416+ raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
417+ if not deployment_id :
418+ raise ValueError (f"Expected a non-empty value for `deployment_id` but received { deployment_id !r} " )
419+ return await self ._delete (
420+ f"/accounts/{ account_id } /workers/scripts/{ script_name } /deployments/{ deployment_id } " ,
421+ options = make_request_options (
422+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
423+ ),
424+ cast_to = DeploymentDeleteResponse ,
425+ )
426+
427+ async def get (
428+ self ,
429+ deployment_id : str ,
430+ * ,
431+ account_id : str ,
432+ script_name : str ,
433+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
434+ # The extra values given here take precedence over values defined on the client or passed to this method.
435+ extra_headers : Headers | None = None ,
436+ extra_query : Query | None = None ,
437+ extra_body : Body | None = None ,
438+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
439+ ) -> DeploymentGetResponse :
440+ """
441+ Get information about a Worker Deployment.
442+
443+ Args:
444+ account_id: Identifier.
445+
446+ script_name: Name of the script, used in URLs and route configuration.
447+
448+ extra_headers: Send extra headers
449+
450+ extra_query: Add additional query parameters to the request
451+
452+ extra_body: Add additional JSON properties to the request
453+
454+ timeout: Override the client-level default timeout for this request, in seconds
455+ """
456+ if not account_id :
457+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
458+ if not script_name :
459+ raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
460+ if not deployment_id :
461+ raise ValueError (f"Expected a non-empty value for `deployment_id` but received { deployment_id !r} " )
462+ return await self ._get (
463+ f"/accounts/{ account_id } /workers/scripts/{ script_name } /deployments/{ deployment_id } " ,
278464 options = make_request_options (
279465 extra_headers = extra_headers ,
280466 extra_query = extra_query ,
@@ -293,6 +479,12 @@ def __init__(self, deployments: DeploymentsResource) -> None:
293479 self .create = to_raw_response_wrapper (
294480 deployments .create ,
295481 )
482+ self .list = to_raw_response_wrapper (
483+ deployments .list ,
484+ )
485+ self .delete = to_raw_response_wrapper (
486+ deployments .delete ,
487+ )
296488 self .get = to_raw_response_wrapper (
297489 deployments .get ,
298490 )
@@ -305,6 +497,12 @@ def __init__(self, deployments: AsyncDeploymentsResource) -> None:
305497 self .create = async_to_raw_response_wrapper (
306498 deployments .create ,
307499 )
500+ self .list = async_to_raw_response_wrapper (
501+ deployments .list ,
502+ )
503+ self .delete = async_to_raw_response_wrapper (
504+ deployments .delete ,
505+ )
308506 self .get = async_to_raw_response_wrapper (
309507 deployments .get ,
310508 )
@@ -317,6 +515,12 @@ def __init__(self, deployments: DeploymentsResource) -> None:
317515 self .create = to_streamed_response_wrapper (
318516 deployments .create ,
319517 )
518+ self .list = to_streamed_response_wrapper (
519+ deployments .list ,
520+ )
521+ self .delete = to_streamed_response_wrapper (
522+ deployments .delete ,
523+ )
320524 self .get = to_streamed_response_wrapper (
321525 deployments .get ,
322526 )
@@ -329,6 +533,12 @@ def __init__(self, deployments: AsyncDeploymentsResource) -> None:
329533 self .create = async_to_streamed_response_wrapper (
330534 deployments .create ,
331535 )
536+ self .list = async_to_streamed_response_wrapper (
537+ deployments .list ,
538+ )
539+ self .delete = async_to_streamed_response_wrapper (
540+ deployments .delete ,
541+ )
332542 self .get = async_to_streamed_response_wrapper (
333543 deployments .get ,
334544 )
0 commit comments