Skip to content

Commit 61a852b

Browse files
feat(api): update api shield operation endpoint (#2348)
1 parent 1d668f9 commit 61a852b

File tree

6 files changed

+139
-152
lines changed

6 files changed

+139
-152
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1488
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8350198effca1ac1067d67fc3c45dce02b208c323d4be761050af7106222a01f.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f9deb3d75633289ec284d1121ac14327582a8c5e8453fca7f8f5f1cdafb054c9.yml

api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2699,7 +2699,7 @@ from cloudflare.types.api_gateway import (
26992699

27002700
Methods:
27012701

2702-
- <code title="post /zones/{zone_id}/api_gateway/operations">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_create_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/operation_create_response.py">OperationCreateResponse</a></code>
2702+
- <code title="post /zones/{zone_id}/api_gateway/operations/item">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_create_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/operation_create_response.py">OperationCreateResponse</a></code>
27032703
- <code title="get /zones/{zone_id}/api_gateway/operations">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/operation_list_response.py">SyncV4PagePaginationArray[OperationListResponse]</a></code>
27042704
- <code title="delete /zones/{zone_id}/api_gateway/operations/{operation_id}">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">delete</a>(operation_id, \*, zone_id) -> <a href="./src/cloudflare/types/api_gateway/operation_delete_response.py">OperationDeleteResponse</a></code>
27052705
- <code title="delete /zones/{zone_id}/api_gateway/operations">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">bulk_delete</a>(\*, zone_id) -> <a href="./src/cloudflare/types/api_gateway/operation_bulk_delete_response.py">OperationBulkDeleteResponse</a></code>

src/cloudflare/resources/api_gateway/operations/operations.py

+55-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Type, Iterable, cast
5+
from typing import List, Type, cast
66
from typing_extensions import Literal
77

88
import httpx
@@ -69,25 +69,36 @@ def create(
6969
self,
7070
*,
7171
zone_id: str,
72-
operations: Iterable[operation_create_params.Operation],
72+
endpoint: str,
73+
host: str,
74+
method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"],
7375
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
7476
# The extra values given here take precedence over values defined on the client or passed to this method.
7577
extra_headers: Headers | None = None,
7678
extra_query: Query | None = None,
7779
extra_body: Body | None = None,
7880
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
7981
) -> OperationCreateResponse:
80-
"""Add one or more operations to a zone.
82+
"""Add one operation to a zone.
8183
82-
Endpoints can contain path variables.
83-
Host, method, endpoint will be normalized to a canoncial form when creating an
84-
operation and must be unique on the zone. Inserting an operation that matches an
85-
existing one will return the record of the already existing operation and update
86-
its last_updated date.
84+
Endpoints can contain path variables. Host, method,
85+
endpoint will be normalized to a canoncial form when creating an operation and
86+
must be unique on the zone. Inserting an operation that matches an existing one
87+
will return the record of the already existing operation and update its
88+
last_updated date.
8789
8890
Args:
8991
zone_id: Identifier
9092
93+
endpoint: The endpoint which can contain path parameter templates in curly braces, each
94+
will be replaced from left to right with {varN}, starting with {var1}, during
95+
insertion. This will further be Cloudflare-normalized upon insertion. See:
96+
https://developers.cloudflare.com/rules/normalization/how-it-works/.
97+
98+
host: RFC3986-compliant host.
99+
100+
method: The HTTP method used to access the endpoint.
101+
91102
extra_headers: Send extra headers
92103
93104
extra_query: Add additional query parameters to the request
@@ -99,8 +110,15 @@ def create(
99110
if not zone_id:
100111
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
101112
return self._post(
102-
f"/zones/{zone_id}/api_gateway/operations",
103-
body=maybe_transform(operations, Iterable[operation_create_params.Operation]),
113+
f"/zones/{zone_id}/api_gateway/operations/item",
114+
body=maybe_transform(
115+
{
116+
"endpoint": endpoint,
117+
"host": host,
118+
"method": method,
119+
},
120+
operation_create_params.OperationCreateParams,
121+
),
104122
options=make_request_options(
105123
extra_headers=extra_headers,
106124
extra_query=extra_query,
@@ -344,25 +362,36 @@ async def create(
344362
self,
345363
*,
346364
zone_id: str,
347-
operations: Iterable[operation_create_params.Operation],
365+
endpoint: str,
366+
host: str,
367+
method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"],
348368
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
349369
# The extra values given here take precedence over values defined on the client or passed to this method.
350370
extra_headers: Headers | None = None,
351371
extra_query: Query | None = None,
352372
extra_body: Body | None = None,
353373
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
354374
) -> OperationCreateResponse:
355-
"""Add one or more operations to a zone.
375+
"""Add one operation to a zone.
356376
357-
Endpoints can contain path variables.
358-
Host, method, endpoint will be normalized to a canoncial form when creating an
359-
operation and must be unique on the zone. Inserting an operation that matches an
360-
existing one will return the record of the already existing operation and update
361-
its last_updated date.
377+
Endpoints can contain path variables. Host, method,
378+
endpoint will be normalized to a canoncial form when creating an operation and
379+
must be unique on the zone. Inserting an operation that matches an existing one
380+
will return the record of the already existing operation and update its
381+
last_updated date.
362382
363383
Args:
364384
zone_id: Identifier
365385
386+
endpoint: The endpoint which can contain path parameter templates in curly braces, each
387+
will be replaced from left to right with {varN}, starting with {var1}, during
388+
insertion. This will further be Cloudflare-normalized upon insertion. See:
389+
https://developers.cloudflare.com/rules/normalization/how-it-works/.
390+
391+
host: RFC3986-compliant host.
392+
393+
method: The HTTP method used to access the endpoint.
394+
366395
extra_headers: Send extra headers
367396
368397
extra_query: Add additional query parameters to the request
@@ -374,8 +403,15 @@ async def create(
374403
if not zone_id:
375404
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
376405
return await self._post(
377-
f"/zones/{zone_id}/api_gateway/operations",
378-
body=await async_maybe_transform(operations, Iterable[operation_create_params.Operation]),
406+
f"/zones/{zone_id}/api_gateway/operations/item",
407+
body=await async_maybe_transform(
408+
{
409+
"endpoint": endpoint,
410+
"host": host,
411+
"method": method,
412+
},
413+
operation_create_params.OperationCreateParams,
414+
),
379415
options=make_request_options(
380416
extra_headers=extra_headers,
381417
extra_query=extra_query,

src/cloudflare/types/api_gateway/operation_create_params.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@
22

33
from __future__ import annotations
44

5-
from typing import Iterable
65
from typing_extensions import Literal, Required, TypedDict
76

8-
__all__ = ["OperationCreateParams", "Operation"]
7+
__all__ = ["OperationCreateParams"]
98

109

1110
class OperationCreateParams(TypedDict, total=False):
1211
zone_id: Required[str]
1312
"""Identifier"""
1413

15-
operations: Required[Iterable[Operation]]
16-
17-
18-
class Operation(TypedDict, total=False):
1914
endpoint: Required[str]
2015
"""
2116
The endpoint which can contain path parameter templates in curly braces, each

0 commit comments

Comments
 (0)