Skip to content

Commit eeb6d8e

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(zero_trust_organization): swap to upsert for creation (#2186)
1 parent e727768 commit eeb6d8e

File tree

9 files changed

+263
-507
lines changed

9 files changed

+263
-507
lines changed

api.md

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 6 deletions
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/types/api_gateway/__init__.py

Lines changed: 1 addition & 2 deletions
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
Lines changed: 227 additions & 0 deletions
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

src/cloudflare/types/api_gateway/api_shield_operation.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/cloudflare/types/api_gateway/api_shield_operation_param.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/cloudflare/types/api_gateway/operation_create_params.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,29 @@
33
from __future__ import annotations
44

55
from typing import Iterable
6-
from typing_extensions import Required, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

8-
from .api_shield_operation_param import APIShieldOperationParam
9-
10-
__all__ = ["OperationCreateParams"]
8+
__all__ = ["OperationCreateParams", "Body"]
119

1210

1311
class OperationCreateParams(TypedDict, total=False):
1412
zone_id: Required[str]
1513
"""Identifier"""
1614

17-
body: Required[Iterable[APIShieldOperationParam]]
15+
body: Required[Iterable[Body]]
16+
17+
18+
class Body(TypedDict, total=False):
19+
endpoint: Required[str]
20+
"""
21+
The endpoint which can contain path parameter templates in curly braces, each
22+
will be replaced from left to right with {varN}, starting with {var1}, during
23+
insertion. This will further be Cloudflare-normalized upon insertion. See:
24+
https://developers.cloudflare.com/rules/normalization/how-it-works/.
25+
"""
26+
27+
host: Required[str]
28+
"""RFC3986-compliant host."""
29+
30+
method: Required[Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"]]
31+
"""The HTTP method used to access the endpoint."""

0 commit comments

Comments
 (0)