Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,7 @@ Types:

```python
from cloudflare.types.api_gateway import (
APIShieldOperation,
APIShield,
OperationCreateResponse,
OperationListResponse,
OperationDeleteResponse,
Expand Down
11 changes: 5 additions & 6 deletions src/cloudflare/resources/api_gateway/operations/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
SchemaValidationResourceWithStreamingResponse,
AsyncSchemaValidationResourceWithStreamingResponse,
)
from ....types.api_gateway import operation_get_params, operation_list_params
from ....types.api_gateway import operation_get_params, operation_list_params, operation_create_params
from ....types.api_gateway.operation_get_response import OperationGetResponse
from ....types.api_gateway.operation_list_response import OperationListResponse
from ....types.api_gateway.operation_create_response import OperationCreateResponse
from ....types.api_gateway.operation_delete_response import OperationDeleteResponse
from ....types.api_gateway.api_shield_operation_param import APIShieldOperationParam
from ....types.api_gateway.operation_bulk_delete_response import OperationBulkDeleteResponse

__all__ = ["OperationsResource", "AsyncOperationsResource"]
Expand Down Expand Up @@ -70,7 +69,7 @@ def create(
self,
*,
zone_id: str,
body: Iterable[APIShieldOperationParam],
body: Iterable[operation_create_params.Body],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -101,7 +100,7 @@ def create(
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._post(
f"/zones/{zone_id}/api_gateway/operations",
body=maybe_transform(body, Iterable[APIShieldOperationParam]),
body=maybe_transform(body, Iterable[operation_create_params.Body]),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -345,7 +344,7 @@ async def create(
self,
*,
zone_id: str,
body: Iterable[APIShieldOperationParam],
body: Iterable[operation_create_params.Body],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -376,7 +375,7 @@ async def create(
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return await self._post(
f"/zones/{zone_id}/api_gateway/operations",
body=await async_maybe_transform(body, Iterable[APIShieldOperationParam]),
body=await async_maybe_transform(body, Iterable[operation_create_params.Body]),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
3 changes: 1 addition & 2 deletions src/cloudflare/types/api_gateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from .message import Message as Message
from .settings import Settings as Settings
from .api_shield import APIShield as APIShield
from .configuration import Configuration as Configuration
from .public_schema import PublicSchema as PublicSchema
from .schema_upload import SchemaUpload as SchemaUpload
from .schema_list_params import SchemaListParams as SchemaListParams
from .discovery_operation import DiscoveryOperation as DiscoveryOperation
from .api_shield_operation import APIShieldOperation as APIShieldOperation
from .operation_get_params import OperationGetParams as OperationGetParams
from .schema_list_response import SchemaListResponse as SchemaListResponse
from .operation_list_params import OperationListParams as OperationListParams
Expand All @@ -24,7 +24,6 @@
from .operation_create_response import OperationCreateResponse as OperationCreateResponse
from .operation_delete_response import OperationDeleteResponse as OperationDeleteResponse
from .user_schema_create_params import UserSchemaCreateParams as UserSchemaCreateParams
from .api_shield_operation_param import APIShieldOperationParam as APIShieldOperationParam
from .configuration_update_params import ConfigurationUpdateParams as ConfigurationUpdateParams
from .user_schema_delete_response import UserSchemaDeleteResponse as UserSchemaDeleteResponse
from .configuration_update_response import ConfigurationUpdateResponse as ConfigurationUpdateResponse
Expand Down
227 changes: 227 additions & 0 deletions src/cloudflare/types/api_gateway/api_shield.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Union, Optional
from datetime import datetime
from typing_extensions import Literal, TypeAlias

from ..._models import BaseModel

__all__ = [
"APIShield",
"Features",
"FeaturesAPIShieldOperationFeatureThresholds",
"FeaturesAPIShieldOperationFeatureThresholdsThresholds",
"FeaturesAPIShieldOperationFeatureParameterSchemas",
"FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas",
"FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas",
"FeaturesAPIShieldOperationFeatureAPIRouting",
"FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting",
"FeaturesAPIShieldOperationFeatureConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99",
"FeaturesAPIShieldOperationFeatureSchemaInfo",
"FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo",
"FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema",
]


class FeaturesAPIShieldOperationFeatureThresholdsThresholds(BaseModel):
auth_id_tokens: Optional[int] = None
"""The total number of auth-ids seen across this calculation."""

data_points: Optional[int] = None
"""The number of data points used for the threshold suggestion calculation."""

last_updated: Optional[datetime] = None

p50: Optional[int] = None
"""The p50 quantile of requests (in period_seconds)."""

p90: Optional[int] = None
"""The p90 quantile of requests (in period_seconds)."""

p99: Optional[int] = None
"""The p99 quantile of requests (in period_seconds)."""

period_seconds: Optional[int] = None
"""The period over which this threshold is suggested."""

requests: Optional[int] = None
"""The estimated number of requests covered by these calculations."""

suggested_threshold: Optional[int] = None
"""The suggested threshold in requests done by the same auth_id or period_seconds."""


class FeaturesAPIShieldOperationFeatureThresholds(BaseModel):
thresholds: Optional[FeaturesAPIShieldOperationFeatureThresholdsThresholds] = None


class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas(BaseModel):
parameters: Optional[List[object]] = None
"""An array containing the learned parameter schemas."""

responses: Optional[object] = None
"""An empty response object.

This field is required to yield a valid operation schema.
"""


class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel):
last_updated: Optional[datetime] = None

parameter_schemas: Optional[FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas] = (
None
)
"""An operation schema object containing a response."""


class FeaturesAPIShieldOperationFeatureParameterSchemas(BaseModel):
parameter_schemas: FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas


class FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting(BaseModel):
last_updated: Optional[datetime] = None

route: Optional[str] = None
"""Target route."""


class FeaturesAPIShieldOperationFeatureAPIRouting(BaseModel):
api_routing: Optional[FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting] = None
"""API Routing settings on endpoint."""


class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""

upper: Optional[float] = None
"""Upper bound for percentile estimate"""


class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""

upper: Optional[float] = None
"""Upper bound for percentile estimate"""


class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""

upper: Optional[float] = None
"""Upper bound for percentile estimate"""


class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals(
BaseModel
):
p90: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90
] = None
"""Upper and lower bound for percentile estimate"""

p95: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95
] = None
"""Upper and lower bound for percentile estimate"""

p99: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99
] = None
"""Upper and lower bound for percentile estimate"""


class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold(BaseModel):
confidence_intervals: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals
] = None

mean: Optional[float] = None
"""Suggested threshold."""


class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals(BaseModel):
last_updated: Optional[datetime] = None

suggested_threshold: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold
] = None


class FeaturesAPIShieldOperationFeatureConfidenceIntervals(BaseModel):
confidence_intervals: Optional[FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals] = None


class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema(BaseModel):
id: Optional[str] = None
"""UUID"""

created_at: Optional[datetime] = None

is_learned: Optional[bool] = None
"""True if schema is Cloudflare-provided."""

name: Optional[str] = None
"""Schema file name."""


class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo(BaseModel):
active_schema: Optional[FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema] = None
"""Schema active on endpoint."""

learned_available: Optional[bool] = None
"""True if a Cloudflare-provided learned schema is available for this endpoint."""

mitigation_action: Optional[Literal["none", "log", "block"]] = None
"""Action taken on requests failing validation."""


class FeaturesAPIShieldOperationFeatureSchemaInfo(BaseModel):
schema_info: Optional[FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo] = None


Features: TypeAlias = Union[
FeaturesAPIShieldOperationFeatureThresholds,
FeaturesAPIShieldOperationFeatureParameterSchemas,
FeaturesAPIShieldOperationFeatureAPIRouting,
FeaturesAPIShieldOperationFeatureConfidenceIntervals,
FeaturesAPIShieldOperationFeatureSchemaInfo,
]


class APIShield(BaseModel):
endpoint: str
"""
The endpoint which can contain path parameter templates in curly braces, each
will be replaced from left to right with {varN}, starting with {var1}, during
insertion. This will further be Cloudflare-normalized upon insertion. See:
https://developers.cloudflare.com/rules/normalization/how-it-works/.
"""

host: str
"""RFC3986-compliant host."""

last_updated: datetime

method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"]
"""The HTTP method used to access the endpoint."""

operation_id: str
"""UUID"""

features: Optional[Features] = None
23 changes: 0 additions & 23 deletions src/cloudflare/types/api_gateway/api_shield_operation.py

This file was deleted.

23 changes: 0 additions & 23 deletions src/cloudflare/types/api_gateway/api_shield_operation_param.py

This file was deleted.

24 changes: 19 additions & 5 deletions src/cloudflare/types/api_gateway/operation_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@
from __future__ import annotations

from typing import Iterable
from typing_extensions import Required, TypedDict
from typing_extensions import Literal, Required, TypedDict

from .api_shield_operation_param import APIShieldOperationParam

__all__ = ["OperationCreateParams"]
__all__ = ["OperationCreateParams", "Body"]


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

body: Required[Iterable[APIShieldOperationParam]]
body: Required[Iterable[Body]]


class Body(TypedDict, total=False):
endpoint: Required[str]
"""
The endpoint which can contain path parameter templates in curly braces, each
will be replaced from left to right with {varN}, starting with {var1}, during
insertion. This will further be Cloudflare-normalized upon insertion. See:
https://developers.cloudflare.com/rules/normalization/how-it-works/.
"""

host: Required[str]
"""RFC3986-compliant host."""

method: Required[Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"]]
"""The HTTP method used to access the endpoint."""
Loading