Skip to content

Commit ad06dcd

Browse files
feat(api): api update
1 parent 8c44db9 commit ad06dcd

8 files changed

Lines changed: 574 additions & 27 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1773
1+
configured_endpoints: 1775
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1ef60e0a6e6ea360f4ec097f02a529dfc8dd8d2d5e84bd506bed4836463090ff.yml
33
openapi_spec_hash: 79fb2f57dc2bbdd283d4238878994551
4-
config_hash: bafeb7666d2b7868c9d4ab8f0cc686e1
4+
config_hash: 4a37da9893560914a7ac1a75cc01202a

api.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,13 +2389,20 @@ Methods:
23892389
Types:
23902390

23912391
```python
2392-
from cloudflare.types.workers.scripts import DeploymentCreateResponse, DeploymentGetResponse
2392+
from cloudflare.types.workers.scripts import (
2393+
DeploymentCreateResponse,
2394+
DeploymentListResponse,
2395+
DeploymentDeleteResponse,
2396+
DeploymentGetResponse,
2397+
)
23932398
```
23942399

23952400
Methods:
23962401

23972402
- <code title="post /accounts/{account_id}/workers/scripts/{script_name}/deployments">client.workers.scripts.deployments.<a href="./src/cloudflare/resources/workers/scripts/deployments.py">create</a>(script_name, \*, account_id, \*\*<a href="src/cloudflare/types/workers/scripts/deployment_create_params.py">params</a>) -> <a href="./src/cloudflare/types/workers/scripts/deployment_create_response.py">DeploymentCreateResponse</a></code>
2398-
- <code title="get /accounts/{account_id}/workers/scripts/{script_name}/deployments">client.workers.scripts.deployments.<a href="./src/cloudflare/resources/workers/scripts/deployments.py">get</a>(script_name, \*, account_id) -> <a href="./src/cloudflare/types/workers/scripts/deployment_get_response.py">DeploymentGetResponse</a></code>
2403+
- <code title="get /accounts/{account_id}/workers/scripts/{script_name}/deployments">client.workers.scripts.deployments.<a href="./src/cloudflare/resources/workers/scripts/deployments.py">list</a>(script_name, \*, account_id) -> <a href="./src/cloudflare/types/workers/scripts/deployment_list_response.py">DeploymentListResponse</a></code>
2404+
- <code title="delete /accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}">client.workers.scripts.deployments.<a href="./src/cloudflare/resources/workers/scripts/deployments.py">delete</a>(deployment_id, \*, account_id, script_name) -> <a href="./src/cloudflare/types/workers/scripts/deployment_delete_response.py">DeploymentDeleteResponse</a></code>
2405+
- <code title="get /accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}">client.workers.scripts.deployments.<a href="./src/cloudflare/resources/workers/scripts/deployments.py">get</a>(deployment_id, \*, account_id, script_name) -> <a href="./src/cloudflare/types/workers/scripts/deployment_get_response.py">DeploymentGetResponse</a></code>
23992406

24002407
### Versions
24012408

src/cloudflare/resources/workers/scripts/deployments.py

Lines changed: 214 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
from ...._base_client import make_request_options
2222
from ....types.workers.scripts import deployment_create_params
2323
from ....types.workers.scripts.deployment_get_response import DeploymentGetResponse
24+
from ....types.workers.scripts.deployment_list_response import DeploymentListResponse
2425
from ....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
)

src/cloudflare/types/workers/scripts/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
from .subdomain_create_params import SubdomainCreateParams as SubdomainCreateParams
2626
from .version_create_response import VersionCreateResponse as VersionCreateResponse
2727
from .deployment_create_params import DeploymentCreateParams as DeploymentCreateParams
28+
from .deployment_list_response import DeploymentListResponse as DeploymentListResponse
2829
from .schedule_update_response import ScheduleUpdateResponse as ScheduleUpdateResponse
2930
from .subdomain_create_response import SubdomainCreateResponse as SubdomainCreateResponse
3031
from .subdomain_delete_response import SubdomainDeleteResponse as SubdomainDeleteResponse
3132
from .deployment_create_response import DeploymentCreateResponse as DeploymentCreateResponse
33+
from .deployment_delete_response import DeploymentDeleteResponse as DeploymentDeleteResponse
3234
from .script_and_version_setting_edit_params import (
3335
ScriptAndVersionSettingEditParams as ScriptAndVersionSettingEditParams,
3436
)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
from typing_extensions import Literal
5+
6+
from ...._models import BaseModel
7+
8+
__all__ = ["DeploymentDeleteResponse", "Error", "ErrorSource", "Message", "MessageSource"]
9+
10+
11+
class ErrorSource(BaseModel):
12+
pointer: Optional[str] = None
13+
14+
15+
class Error(BaseModel):
16+
code: int
17+
18+
message: str
19+
20+
documentation_url: Optional[str] = None
21+
22+
source: Optional[ErrorSource] = None
23+
24+
25+
class MessageSource(BaseModel):
26+
pointer: Optional[str] = None
27+
28+
29+
class Message(BaseModel):
30+
code: int
31+
32+
message: str
33+
34+
documentation_url: Optional[str] = None
35+
36+
source: Optional[MessageSource] = None
37+
38+
39+
class DeploymentDeleteResponse(BaseModel):
40+
errors: List[Error]
41+
42+
messages: List[Message]
43+
44+
success: Literal[True]
45+
"""Whether the API call was successful."""

0 commit comments

Comments
 (0)