8000 feat(api): api update · GameRoMan/cloudflare-python@3632e3d · GitHub
[go: up one dir, main page]

Skip to content
65E8

Commit 3632e3d

Browse files
feat(api): api update
1 parent 540aead commit 3632e3d

File tree

9 files changed

+54
-26
lines changed

9 files changed

+54
-26
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1739
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b703804ec51b092cdb8f680f7afccdd9623219207156ccdc5f31b1a3599178ef.yml
3-
openapi_spec_hash: 2e5f51ee368408895edaa6eb63921ebf
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-860d686b9ba8ed4d6c414bc93efbe53f1ac1b561676e2a3c2e3d0f9365ac51f7.yml
3+
openapi_spec_hash: 8231937451a371976d0602420017941a
44
config_hash: 7e270b3449efce600e3469937a344c2d

src/cloudflare/resources/workers/routes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def create(
5454
*,
5555
zone_id: str,
5656
pattern: str,
57-
script: str,
57+
script: str | NotGiven = NOT_GIVEN,
5858
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5959
# The extra values given here take precedence over values defined on the client or passed to this method.
6060
extra_headers: Headers | None = None,
@@ -108,7 +108,7 @@ def update(
108108
*,
109109
zone_id: str,
110110
pattern: str,
111-
script: str,
111+
script: str | NotGiven = NOT_GIVEN,
112112
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
113113
# The extra values given here take precedence over values defined on the client or passed to this method.
114114
extra_headers: Headers | None = None,
@@ -310,7 +310,7 @@ async def create(
310310
*,
311311
zone_id: str,
312312
pattern: str,
313-
script: str,
313+
script: str | NotGiven = NOT_GIVEN,
314314
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
315315
# The extra values given here take precedence over values defined on the client or passed to this method.
316316
extra_headers: Headers | None = None,
@@ -364,7 +364,7 @@ async def update(
364364
*,
365365
zone_id: str,
366366
pattern: str,
367-
script: str,
367+
script: str | NotGiven = NOT_GIVEN,
368368
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
369369
# The extra values given here take precedence over values defined on the client or passed to this method.
370370
extra_headers: Headers | None = None,

src/cloudflare/types/workers/route_create_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ class RouteCreateParams(TypedDict, total=False):
1717
[Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
1818
"""
1919

20-
script: Required[str]
20+
script: str
2121
"""Name of the script to run if the route matches."""

src/cloudflare/types/workers/route_create_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from typing import Optional
4+
35
from ..._models import BaseModel
46

57
__all__ = ["RouteCreateResponse"]
@@ -15,5 +17,5 @@ class RouteCreateResponse(BaseModel):
1517
[Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
1618
"""
1719

18-
script: str
20+
script: Optional[str] = None
1921
"""Name of the script to run if the route matches."""

src/cloudflare/types/workers/route_get_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from typing import Optional
4+
35
from ..._models import BaseModel
46

57
__all__ = ["RouteGetResponse"]
@@ -15,5 +17,5 @@ class RouteGetResponse(BaseModel):
1517
[Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
1618
"""
1719

18-
script: str
20+
script: Optional[str] = None
1921
"""Name of the script to run if the route matches."""

src/cloudflare/types/workers/route_list_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from typing import Optional
4+
35
from ..._models import BaseModel
46

57
__all__ = ["RouteListResponse"]
@@ -15,5 +17,5 @@ class RouteListResponse(BaseModel):
1517
[Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
1618
"""
1719

18-
script: str
20+
script: Optional[str] = None
1921
"""Name of the script to run if the route matches."""

src/cloudflare/types/workers/route_update_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ class RouteUpdateParams(TypedDict, total=False):
1717
[Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
1818
"""
1919

20-
script: Required[str]
20+
script: str
2121
"""Name of the script to run if the route matches."""

src/cloudflare/types/workers/route_update_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from typing import Optional
4+
35
from ..._models import BaseModel
46

57
__all__ = ["RouteUpdateResponse"]
@@ -15,5 +17,5 @@ class RouteUpdateResponse(BaseModel):
1517
[Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
1618
"""
1719

18-
script: str
20+
script: Optional[str] = None
1921
"""Name of the script to run if the route matches."""

tests/api_resources/workers/test_routes.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ class TestRoutes:
2626

2727
@parametrize
2828
def test_method_create(self, client: Cloudflare) -> None:
29+
route = client.workers.routes.create(
30+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
31+
pattern="example.com/*",
32+
)
33+
assert_matches_type(RouteCreateResponse, route, path=["response"])
34+
35+
@parametrize
36+
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
2937
route = client.workers.routes.create(
3038
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
3139
pattern="example.com/*",
@@ -38,7 +46,6 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
3846
response = client.workers.routes.with_raw_response.create(
3947
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
4048
pattern="example.com/*",
41-
script="my-workers-script",
4249
)
4350

4451
assert response.is_closed is True
@@ -51,7 +58,6 @@ def test_streaming_response_create(self, client: Cloudflare) -> None:
5158
with client.workers.routes.with_streaming_response.create(
5259
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
5360
pattern="example.com/*",
54-
script="my-workers-script",
5561
) as response:
5662
assert not response.is_closed
5763
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -67,11 +73,19 @@ def test_path_params_create(self, client: Cloudflare) -> None:
6773
client.workers.routes.with_raw_response.create(
6874
zone_id="",
6975
pattern="example.com/*",
70-
script="my-workers-script",
7176
)
7277

7378
@parametrize
7479
def test_method_update(self, client: Cloudflare) -> None:
80+
route = client.workers.routes.update(
81+
route_id="023e105f4ecef8ad9ca31a8372d0c353",
82+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
83+
pattern="example.com/*",
84+
)
85+
assert_matches_type(RouteUpdateResponse, route, path=["response"])
86+
87+
@parametrize
88+
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
7589
route = client.workers.routes.update(
7690
route_id="023e105f4ecef8ad9ca31a8372d0c353",
7791
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
@@ -86,7 +100,6 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
86100
route_id="023e105f4ecef8ad9ca31a8372d0c353",
87101
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
88102
pattern="example.com/*",
89-
script="my-workers-script",
90103
)
91104

92105
assert response.is_closed is True
@@ -100,7 +113,6 @@ def test_streaming_response_update(self, client: Cloudflare) -> None:
100113
route_id="023e105f4ecef8ad9ca31a8372d0c353",
101114
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
102115
pattern="example.com/*",
103-
script="my-workers-script",
104116
) as response:
105117
assert not response.is_closed
106118
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -117,15 +129,13 @@ def test_path_params_update(self, client: Cloudflare) -> None:
117129
route_id="023e105f4ecef8ad9ca31a8372d0c353",
118130
zone_id="",
119131
pattern="example.com/*",
120-
script="my-workers-script",
121132
)
122133

123134
with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_id` but received ''"):
124135
client.workers.routes.with_raw_response.update(
125136
route_id="",
126137
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
127138
pattern="example.com/*",
128-
script="my-workers-script",
129139
)
130140

131141
@parametrize
@@ -268,6 +278,14 @@ class TestAsyncRoutes:
268278

269279
@parametrize
270280
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
281+
route = await async_client.workers.routes.create(
282+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
283+
pattern="example.com/*",
284+
)
285+
assert_matches_type(RouteCreateResponse, route, path=["response"])
286+
287+
@parametrize
288+
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
271289
route = await async_client.workers.routes.create(
272290
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
273291
pattern="example.com/*",
@@ -280,7 +298,6 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
280298
response = await async_client.workers.routes.with_raw_response.create(
281299
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
282300
pattern="example.com/*",
283-
script="my-workers-script",
284301
)
285302

286303
assert response.is_closed is True
@@ -293,7 +310,6 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) ->
293310
async with async_client.workers.routes.with_streaming_response.create(
294311
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
295312
pattern="example.com/*",
296-
script="my-workers-script",
297313
) as response:
298314
assert not response.is_closed
299315
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -309,11 +325,19 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
309325
await async_client.workers.routes.with_raw_response.create(
310326
zone_id="",
311327
pattern="example.com/*",
312-
script="my-workers-script",
313328
)
314329

315330
@parametrize
316331
async def test_method_update(self, async_client: AsyncCloudflare) -> None:
332+
route = await async_client.workers.routes.update(
333+
route_id="023e105f4ecef8ad9ca31a8372d0c353",
334+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
335+
pattern="example.com/*",
336+
)
337+
assert_matches_type(RouteUpdateResponse, route, path=["response"])
338+
339+
@parametrize
340+
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
317341
route = await async_client.workers.routes.update(
318342
route_id="023e105f4ecef8ad9ca31a8372d0c353",
319343
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
@@ -328,7 +352,6 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
328352
route_id="023e105f4ecef8ad9ca31a8372d0c353",
329353
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
330354
pattern="example.com/*",
331-
script="my-workers-script",
332355
)
333356

334357
assert response.is_closed is True
@@ -342,7 +365,6 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) ->
342365
route_id="023e105f4ecef8ad9ca31a8372d0c353",
343366
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
344367
pattern="example.com/*",
345-
script="my-workers-script",
346368
) as response:
347369
assert not response.is_closed
348370
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -359,15 +381,13 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
359381
route_id="023e105f4ecef8ad9ca31a8372d0c353",
360382
zone_id="",
361383
pattern="example.com/*",
362-
script="my-workers-script",
363384
)
364385

365386
with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_id` but received ''"):
366387
await async_client.workers.routes.with_raw_response.update(
367388
route_id="",
368389
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
369390
pattern="example.com/*",
370-
script="my-workers-script",
371391
)
372392

373393
@parametrize

0 commit comments

Comments
 (0)
0