Skip to content

Commit 09acf0a

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): api update (#2188)
1 parent d55a879 commit 09acf0a

File tree

15 files changed

+319
-513
lines changed

15 files changed

+319
-513
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1448
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e5080619b47b3f7e1f23ae1b0eeab82ade944ccf1123e1374de38d83e95951d7.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4acaaed718bd08d16e3866d5ad032fbf2bbfeb978df2cf5164edb81fe41e4f89.yml

api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2680,7 +2680,7 @@ Types:
26802680

26812681
```python
26822682
from cloudflare.types.api_gateway import (
2683-
APIShieldOperation,
2683+
APIShield,
26842684
OperationCreateResponse,
26852685
OperationListResponse,
26862686
OperationDeleteResponse,

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131
SchemaValidationResourceWithStreamingResponse,
3232
AsyncSchemaValidationResourceWithStreamingResponse,
3333
)
34-
from ....types.api_gateway import operation_get_params, operation_list_params
34+
from ....types.api_gateway import operation_get_params, operation_list_params, operation_create_params
3535
from ....types.api_gateway.operation_get_response import OperationGetResponse
3636
from ....types.api_gateway.operation_list_response import OperationListResponse
3737
from ....types.api_gateway.operation_create_response import OperationCreateResponse
3838
from ....types.api_gateway.operation_delete_response import OperationDeleteResponse
39-
from ....types.api_gateway.api_shield_operation_param import APIShieldOperationParam
4039
from ....types.api_gateway.operation_bulk_delete_response import OperationBulkDeleteResponse
4140

4241
__all__ = ["OperationsResource", "AsyncOperationsResource"]
@@ -70,7 +69,7 @@ def create(
7069
self,
7170
*,
7271
zone_id: str,
73-
body: Iterable[APIShieldOperationParam],
72+
body: Iterable[operation_create_params.Body],
7473
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
7574
# The extra values given here take precedence over values defined on the client or passed to this method.
7675
extra_headers: Headers | None = None,
@@ -101,7 +100,7 @@ def create(
101100
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
102101
return self._post(
103102
f"/zones/{zone_id}/api_gateway/operations",
104-
body=maybe_transform(body, Iterable[APIShieldOperationParam]),
103+
body=maybe_transform(body, Iterable[operation_create_params.Body]),
105104
options=make_request_options(
106105
extra_headers=extra_headers,
107106
extra_query=extra_query,
@@ -345,7 +344,7 @@ async def create(
345344
self,
346345
*,
347346
zone_id: str,
348-
body: Iterable[APIShieldOperationParam],
347+
body: Iterable[operation_create_params.Body],
349348
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
350349
# The extra values given here take precedence over values defined on the client or passed to this method.
351350
extra_headers: Headers | None = None,
@@ -376,7 +375,7 @@ async def create(
376375
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
377376
return await self._post(
378377
f"/zones/{zone_id}/api_gateway/operations",
379-
body=await async_maybe_transform(body, Iterable[APIShieldOperationParam]),
378+
body=await async_maybe_transform(body, Iterable[operation_create_params.Body]),
380379
options=make_request_options(
381380
extra_headers=extra_headers,
382381
extra_query=extra_query,

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

+24-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def create(
5050
script_name: str,
5151
*,
5252
account_id: str,
53-
enabled: bool | NotGiven = NOT_GIVEN,
53+
enabled: bool,
54+
previews_enabled: bool | NotGiven = NOT_GIVEN,
5455
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5556
# The extra values given here take precedence over values defined on the client or passed to this method.
5657
extra_headers: Headers | None = None,
@@ -68,6 +69,9 @@ def create(
6869
6970
enabled: Whether the Worker should be available on the workers.dev subdomain.
7071
72+
previews_enabled: Whether the Worker's Preview URLs should be available on the workers.dev
73+
subdomain.
74+
7175
extra_headers: Send extra headers
7276
7377
extra_query: Add additional query parameters to the request
@@ -82,7 +86,13 @@ def create(
8286
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
8387
return self._post(
8488
f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain",
85-
body=maybe_transform({"enabled": enabled}, subdomain_create_params.SubdomainCreateParams),
89+
body=maybe_transform(
90+
{
91+
"enabled": enabled,
92+
"previews_enabled": previews_enabled,
93+
},
94+
subdomain_create_params.SubdomainCreateParams,
95+
),
8696
options=make_request_options(
8797
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
8898
),
@@ -155,7 +165,8 @@ async def create(
155165
script_name: str,
156166
*,
157167
account_id: str,
158-
enabled: bool | NotGiven = NOT_GIVEN,
168+
enabled: bool,
169+
previews_enabled: bool | NotGiven = NOT_GIVEN,
159170
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
160171
# The extra values given here take precedence over values defined on the client or passed to this method.
161172
extra_headers: Headers | None = None,
@@ -173,6 +184,9 @@ async def create(
173184
174185
enabled: Whether the Worker should be available on the workers.dev subdomain.
175186
187+
previews_enabled: Whether the Worker's Preview URLs should be available on the workers.dev
188+
subdomain.
189+
176190
extra_headers: Send extra headers
177191
178192
extra_query: Add additional query parameters to the request
@@ -187,7 +201,13 @@ async def create(
187201
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
188202
return await self._post(
189203
f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain",
190-
body=await async_maybe_transform({"enabled": enabled}, subdomain_create_params.SubdomainCreateParams),
204+
body=await async_maybe_transform(
205+
{
206+
"enabled": enabled,
207+
"previews_enabled": previews_enabled,
208+
},
209+
subdomain_create_params.SubdomainCreateParams,
210+
),
191211
options=make_request_options(
192212
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
193213
),

src/cloudflare/types/api_gateway/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
from .message import Message as Message
66
from .settings import Settings as Settings
7+
from .api_shield import APIShield as APIShield
78
from .configuration import Configuration as Configuration
89
from .public_schema import PublicSchema as PublicSchema
910
from .schema_upload import SchemaUpload as SchemaUpload
1011
from .schema_list_params import SchemaListParams as SchemaListParams
1112
from .discovery_operation import DiscoveryOperation as DiscoveryOperation
12-
from .api_shield_operation import APIShieldOperation as APIShieldOperation
1313
from .operation_get_params import OperationGetParams as OperationGetParams
1414
from .schema_list_response import SchemaListResponse as SchemaListResponse
1515
from .operation_list_params import OperationListParams as OperationListParams
@@ -24,7 +24,6 @@
2424
from .operation_create_response import OperationCreateResponse as OperationCreateResponse
2525
from .operation_delete_response import OperationDeleteResponse as OperationDeleteResponse
2626
from .user_schema_create_params import UserSchemaCreateParams as UserSchemaCreateParams
27-
from .api_shield_operation_param import APIShieldOperationParam as APIShieldOperationParam
2827
from .configuration_update_params import ConfigurationUpdateParams as ConfigurationUpdateParams
2928
from .user_schema_delete_response import UserSchemaDeleteResponse as UserSchemaDeleteResponse
3029
from .configuration_update_response import ConfigurationUpdateResponse as ConfigurationUpdateResponse
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Union, Optional
4+
from datetime import datetime
5+
from typing_extensions import Literal, TypeAlias
6+
7+
from ..._models import BaseModel
8+
9+
__all__ = [
10+
"APIShield",
11+
"Features",
12+
"FeaturesAPIShieldOperationFeatureThresholds",
13+
"FeaturesAPIShieldOperationFeatureThresholdsThresholds",
14+
"FeaturesAPIShieldOperationFeatureParameterSchemas",
15+
"FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas",
16+
"FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas",
17+
"FeaturesAPIShieldOperationFeatureAPIRouting",
18+
"FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting",
19+
"FeaturesAPIShieldOperationFeatureConfidenceIntervals",
20+
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals",
21+
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold",
22+
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals",
23+
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90",
24+
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95",
25+
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99",
26+
"FeaturesAPIShieldOperationFeatureSchemaInfo",
27+
"FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo",
28+
"FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema",
29+
]
30+
31+
32+
class FeaturesAPIShieldOperationFeatureThresholdsThresholds(BaseModel):
33+
auth_id_tokens: Optional[int] = None
34+
"""The total number of auth-ids seen across this calculation."""
35+
36+
data_points: Optional[int] = None
37+
"""The number of data points used for the threshold suggestion calculation."""
38+
39+
last_updated: Optional[datetime] = None
40+
41+
p50: Optional[int] = None
42+
"""The p50 quantile of requests (in period_seconds)."""
43+
44+
p90: Optional[int] = None
45+
"""The p90 quantile of requests (in period_seconds)."""
46+
47+
p99: Optional[int] = None
48+
"""The p99 quantile of requests (in period_seconds)."""
49+
50+
period_seconds: Optional[int] = None
51+
"""The period over which this threshold is suggested."""
52+
53+
requests: Optional[int] = None
54+
"""The estimated number of requests covered by these calculations."""
55+
56+
suggested_threshold: Optional[int] = None
57+
"""The suggested threshold in requests done by the same auth_id or period_seconds."""
58+
59+
60+
class FeaturesAPIShieldOperationFeatureThresholds(BaseModel):
61+
thresholds: Optional[FeaturesAPIShieldOperationFeatureThresholdsThresholds] = None
62+
63+
64+
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas(BaseModel):
65+
parameters: Optional[List[object]] = None
66+
"""An array containing the learned parameter schemas."""
67+
68+
responses: Optional[object] = None
69+
"""An empty response object.
70+
71+
This field is required to yield a valid operation schema.
72+
"""
73+
74+
75+
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel):
76+
last_updated: Optional[datetime] = None
77+
78+
parameter_schemas: Optional[FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas] = (
79+
None
80+
)
81+
"""An operation schema object containing a response."""
82+
83+
84+
class FeaturesAPIShieldOperationFeatureParameterSchemas(BaseModel):
85+
parameter_schemas: FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas
86+
87+
88+
class FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting(BaseModel):
89+
last_updated: Optional[datetime] = None
90+
91+
route: Optional[str] = None
92+
"""Target route."""
93+
94+
95+
class FeaturesAPIShieldOperationFeatureAPIRouting(BaseModel):
96+
api_routing: Optional[FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting] = None
97+
"""API Routing settings on endpoint."""
98+
99+
100+
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90(
101+
BaseModel
102+
):
103+
lower: Optional[float] = None
104+
"""Lower bound for percentile estimate"""
105+
106+
upper: Optional[float] = None
107+
"""Upper bound for percentile estimate"""
108+
109+
110+
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95(
111+
BaseModel
112+
):
113+
lower: Optional[float] = None
114+
"""Lower bound for percentile estimate"""
115+
116+
upper: Optional[float] = None
117+
"""Upper bound for percentile estimate"""
118+
119+
120+
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99(
121+
BaseModel
122+
):
123+
lower: Optional[float] = None
124+
"""Lower bound for percentile estimate"""
125+
126+
upper: Optional[float] = None
127+
"""Upper bound for percentile estimate"""
128+
129+
130+
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals(
131+
BaseModel
132+
):
133+
p90: Optional[
134+
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90
135+
] = None
136+
"""Upper and lower bound for percentile estimate"""
137+
138+
p95: Optional[
139+
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95
140+
] = None
141+
"""Upper and lower bound for percentile estimate"""
142+
143+
p99: Optional[
144+
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99
145+
] = None
146+
"""Upper and lower bound for percentile estimate"""
147+
148+
149+
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold(BaseModel):
150+
confidence_intervals: Optional[
151+
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals
152+
] = None
153+
154+
mean: Optional[float] = None
155+
"""Suggested threshold."""
156+
157+
158+
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals(BaseModel):
159+
last_updated: Optional[datetime] = None
160+
161+
suggested_threshold: Optional[
162+
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold
163+
] = None
164+
165+
166+
class FeaturesAPIShieldOperationFeatureConfidenceIntervals(BaseModel):
167+
confidence_intervals: Optional[FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals] = None
168+
169+
170+
class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema(BaseModel):
171+
id: Optional[str] = None
172+
"""UUID"""
173+
174+
created_at: Optional[datetime] = None
175+
176+
is_learned: Optional[bool] = None
177+
"""True if schema is Cloudflare-provided."""
178+
179+
name: Optional[str] = None
180+
"""Schema file name."""
181+
182+
183+
class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo(BaseModel):
184+
active_schema: Optional[FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema] = None
185+
"""Schema active on endpoint."""
186+
187+
learned_available: Optional[bool] = None
188+
"""True if a Cloudflare-provided learned schema is available for this endpoint."""
189+
190+
mitigation_action: Optional[Literal["none", "log", "block"]] = None
191+
"""Action taken on requests failing validation."""
192+
193+
194+
class FeaturesAPIShieldOperationFeatureSchemaInfo(BaseModel):
195+
schema_info: Optional[FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo] = None
196+
197+
198+
Features: TypeAlias = Union[
199+
FeaturesAPIShieldOperationFeatureThresholds,
200+
FeaturesAPIShieldOperationFeatureParameterSchemas,
201+
FeaturesAPIShieldOperationFeatureAPIRouting,
202+
FeaturesAPIShieldOperationFeatureConfidenceIntervals,
203+
FeaturesAPIShieldOperationFeatureSchemaInfo,
204+
]
205+
206+
207+
class APIShield(BaseModel):
208+
endpoint: str
209+
"""
210+
The endpoint which can contain path parameter templates in curly braces, each
211+
will be replaced from left to right with {varN}, starting with {var1}, during
212+
insertion. This will further be Cloudflare-normalized upon insertion. See:
213+
https://developers.cloudflare.com/rules/normalization/how-it-works/.
214+
"""
215+
216+
host: str
217+
"""RFC3986-compliant host."""
218+
219+
last_updated: datetime
220+
221+
method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"]
222+
"""The HTTP method used to access the endpoint."""
223+
224+
operation_id: str
225+
"""UUID"""
226+
227+
features: Optional[Features] = None

0 commit comments

Comments
 (0)