diff --git a/.stats.yml b/.stats.yml index 623ace85fb3..71dc4743573 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1448 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e5080619b47b3f7e1f23ae1b0eeab82ade944ccf1123e1374de38d83e95951d7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4acaaed718bd08d16e3866d5ad032fbf2bbfeb978df2cf5164edb81fe41e4f89.yml diff --git a/api.md b/api.md index 7fbeb7b3180..692bfb6d3d5 100644 --- a/api.md +++ b/api.md @@ -2680,7 +2680,7 @@ Types: ```python from cloudflare.types.api_gateway import ( - APIShieldOperation, + APIShield, OperationCreateResponse, OperationListResponse, OperationDeleteResponse, diff --git a/src/cloudflare/resources/api_gateway/operations/operations.py b/src/cloudflare/resources/api_gateway/operations/operations.py index 5ac50872179..4e2c044805e 100644 --- a/src/cloudflare/resources/api_gateway/operations/operations.py +++ b/src/cloudflare/resources/api_gateway/operations/operations.py @@ -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"] @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/src/cloudflare/resources/workers/scripts/subdomain.py b/src/cloudflare/resources/workers/scripts/subdomain.py index f07507c706c..3ab95584ebd 100644 --- a/src/cloudflare/resources/workers/scripts/subdomain.py +++ b/src/cloudflare/resources/workers/scripts/subdomain.py @@ -50,7 +50,8 @@ def create( script_name: str, *, account_id: str, - enabled: bool | NotGiven = NOT_GIVEN, + enabled: bool, + previews_enabled: bool | NotGiven = NOT_GIVEN, # 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, @@ -68,6 +69,9 @@ def create( enabled: Whether the Worker should be available on the workers.dev subdomain. + previews_enabled: Whether the Worker's Preview URLs should be available on the workers.dev + subdomain. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -82,7 +86,13 @@ def create( raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._post( f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain", - body=maybe_transform({"enabled": enabled}, subdomain_create_params.SubdomainCreateParams), + body=maybe_transform( + { + "enabled": enabled, + "previews_enabled": previews_enabled, + }, + subdomain_create_params.SubdomainCreateParams, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -155,7 +165,8 @@ async def create( script_name: str, *, account_id: str, - enabled: bool | NotGiven = NOT_GIVEN, + enabled: bool, + previews_enabled: bool | NotGiven = NOT_GIVEN, # 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, @@ -173,6 +184,9 @@ async def create( enabled: Whether the Worker should be available on the workers.dev subdomain. + previews_enabled: Whether the Worker's Preview URLs should be available on the workers.dev + subdomain. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -187,7 +201,13 @@ async def create( raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._post( f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain", - body=await async_maybe_transform({"enabled": enabled}, subdomain_create_params.SubdomainCreateParams), + body=await async_maybe_transform( + { + "enabled": enabled, + "previews_enabled": previews_enabled, + }, + subdomain_create_params.SubdomainCreateParams, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/types/api_gateway/__init__.py b/src/cloudflare/types/api_gateway/__init__.py index 275eb83fab4..272e71c2b78 100644 --- a/src/cloudflare/types/api_gateway/__init__.py +++ b/src/cloudflare/types/api_gateway/__init__.py @@ -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 @@ -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 diff --git a/src/cloudflare/types/api_gateway/api_shield.py b/src/cloudflare/types/api_gateway/api_shield.py new file mode 100644 index 00000000000..f884d96b96c --- /dev/null +++ b/src/cloudflare/types/api_gateway/api_shield.py @@ -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 diff --git a/src/cloudflare/types/api_gateway/api_shield_operation.py b/src/cloudflare/types/api_gateway/api_shield_operation.py deleted file mode 100644 index a7c1e2c4011..00000000000 --- a/src/cloudflare/types/api_gateway/api_shield_operation.py +++ /dev/null @@ -1,23 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["APIShieldOperation"] - - -class APIShieldOperation(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.""" - - method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"] - """The HTTP method used to access the endpoint.""" diff --git a/src/cloudflare/types/api_gateway/api_shield_operation_param.py b/src/cloudflare/types/api_gateway/api_shield_operation_param.py deleted file mode 100644 index 5124aa6963f..00000000000 --- a/src/cloudflare/types/api_gateway/api_shield_operation_param.py +++ /dev/null @@ -1,23 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["APIShieldOperationParam"] - - -class APIShieldOperationParam(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.""" diff --git a/src/cloudflare/types/api_gateway/operation_create_params.py b/src/cloudflare/types/api_gateway/operation_create_params.py index 6a76b839b6f..dbfa97bf6e8 100644 --- a/src/cloudflare/types/api_gateway/operation_create_params.py +++ b/src/cloudflare/types/api_gateway/operation_create_params.py @@ -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.""" diff --git a/src/cloudflare/types/api_gateway/operation_create_response.py b/src/cloudflare/types/api_gateway/operation_create_response.py index f259f867239..23d0751ec12 100644 --- a/src/cloudflare/types/api_gateway/operation_create_response.py +++ b/src/cloudflare/types/api_gateway/operation_create_response.py @@ -1,239 +1,10 @@ # 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 typing import List +from typing_extensions import TypeAlias -from ..._models import BaseModel +from .api_shield import APIShield -__all__ = [ - "OperationCreateResponse", - "OperationCreateResponseItem", - "OperationCreateResponseItemFeatures", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureThresholds", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureThresholdsThresholds", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemas", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRouting", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervals", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfo", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo", - "OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema", -] +__all__ = ["OperationCreateResponse"] - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureThresholdsThresholds(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 OperationCreateResponseItemFeaturesAPIShieldOperationFeatureThresholds(BaseModel): - thresholds: Optional[OperationCreateResponseItemFeaturesAPIShieldOperationFeatureThresholdsThresholds] = None - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas( - 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 OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel): - last_updated: Optional[datetime] = None - - parameter_schemas: Optional[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas - ] = None - """An operation schema object containing a response.""" - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemas(BaseModel): - parameter_schemas: OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting(BaseModel): - last_updated: Optional[datetime] = None - - route: Optional[str] = None - """Target route.""" - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRouting(BaseModel): - api_routing: Optional[OperationCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting] = None - """API Routing settings on endpoint.""" - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90( - BaseModel -): - lower: Optional[float] = None - """Lower bound for percentile estimate""" - - upper: Optional[float] = None - """Upper bound for percentile estimate""" - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95( - BaseModel -): - lower: Optional[float] = None - """Lower bound for percentile estimate""" - - upper: Optional[float] = None - """Upper bound for percentile estimate""" - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99( - BaseModel -): - lower: Optional[float] = None - """Lower bound for percentile estimate""" - - upper: Optional[float] = None - """Upper bound for percentile estimate""" - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals( - BaseModel -): - p90: Optional[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90 - ] = None - """Upper and lower bound for percentile estimate""" - - p95: Optional[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95 - ] = None - """Upper and lower bound for percentile estimate""" - - p99: Optional[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99 - ] = None - """Upper and lower bound for percentile estimate""" - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold( - BaseModel -): - confidence_intervals: Optional[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals - ] = None - - mean: Optional[float] = None - """Suggested threshold.""" - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals(BaseModel): - last_updated: Optional[datetime] = None - - suggested_threshold: Optional[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold - ] = None - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervals(BaseModel): - confidence_intervals: Optional[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals - ] = None - - -class OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema(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 OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo(BaseModel): - active_schema: Optional[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema - ] = 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 OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfo(BaseModel): - schema_info: Optional[OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo] = None - - -OperationCreateResponseItemFeatures: TypeAlias = Union[ - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureThresholds, - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureParameterSchemas, - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureAPIRouting, - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureConfidenceIntervals, - OperationCreateResponseItemFeaturesAPIShieldOperationFeatureSchemaInfo, -] - - -class OperationCreateResponseItem(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[OperationCreateResponseItemFeatures] = None - - -OperationCreateResponse: TypeAlias = List[OperationCreateResponseItem] +OperationCreateResponse: TypeAlias = List[APIShield] diff --git a/src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py b/src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py index fa984a5b255..3149155c055 100644 --- a/src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py +++ b/src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py @@ -1,216 +1,15 @@ # 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 import Union from typing_extensions import Literal, TypeAlias -from .. import api_shield_operation from ...._models import BaseModel +from ..api_shield import APIShield -__all__ = [ - "OperationListResponse", - "APIShieldOperation", - "APIShieldOperationFeatures", - "APIShieldOperationFeaturesAPIShieldOperationFeatureThresholds", - "APIShieldOperationFeaturesAPIShieldOperationFeatureThresholdsThresholds", - "APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemas", - "APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas", - "APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas", - "APIShieldOperationFeaturesAPIShieldOperationFeatureAPIRouting", - "APIShieldOperationFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting", - "APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervals", - "APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals", - "APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold", - "APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals", - "APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90", - "APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95", - "APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99", - "APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfo", - "APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo", - "APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema", -] +__all__ = ["OperationListResponse", "APIShieldBasicOperation"] -class APIShieldOperationFeaturesAPIShieldOperationFeatureThresholdsThresholds(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 APIShieldOperationFeaturesAPIShieldOperationFeatureThresholds(BaseModel): - thresholds: Optional[APIShieldOperationFeaturesAPIShieldOperationFeatureThresholdsThresholds] = None - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas(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 APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel): - last_updated: Optional[datetime] = None - - parameter_schemas: Optional[ - APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas - ] = None - """An operation schema object containing a response.""" - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemas(BaseModel): - parameter_schemas: APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting(BaseModel): - last_updated: Optional[datetime] = None - - route: Optional[str] = None - """Target route.""" - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureAPIRouting(BaseModel): - api_routing: Optional[APIShieldOperationFeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting] = None - """API Routing settings on endpoint.""" - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90( - BaseModel -): - lower: Optional[float] = None - """Lower bound for percentile estimate""" - - upper: Optional[float] = None - """Upper bound for percentile estimate""" - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95( - BaseModel -): - lower: Optional[float] = None - """Lower bound for percentile estimate""" - - upper: Optional[float] = None - """Upper bound for percentile estimate""" - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99( - BaseModel -): - lower: Optional[float] = None - """Lower bound for percentile estimate""" - - upper: Optional[float] = None - """Upper bound for percentile estimate""" - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals( - BaseModel -): - p90: Optional[ - APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90 - ] = None - """Upper and lower bound for percentile estimate""" - - p95: Optional[ - APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95 - ] = None - """Upper and lower bound for percentile estimate""" - - p99: Optional[ - APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99 - ] = None - """Upper and lower bound for percentile estimate""" - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold( - BaseModel -): - confidence_intervals: Optional[ - APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals - ] = None - - mean: Optional[float] = None - """Suggested threshold.""" - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals(BaseModel): - last_updated: Optional[datetime] = None - - suggested_threshold: Optional[ - APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold - ] = None - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervals(BaseModel): - confidence_intervals: Optional[ - APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals - ] = None - - -class APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema(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 APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo(BaseModel): - active_schema: Optional[APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema] = 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 APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfo(BaseModel): - schema_info: Optional[APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo] = None - - -APIShieldOperationFeatures: TypeAlias = Union[ - APIShieldOperationFeaturesAPIShieldOperationFeatureThresholds, - APIShieldOperationFeaturesAPIShieldOperationFeatureParameterSchemas, - APIShieldOperationFeaturesAPIShieldOperationFeatureAPIRouting, - APIShieldOperationFeaturesAPIShieldOperationFeatureConfidenceIntervals, - APIShieldOperationFeaturesAPIShieldOperationFeatureSchemaInfo, -] - - -class APIShieldOperation(BaseModel): +class APIShieldBasicOperation(BaseModel): endpoint: str """ The endpoint which can contain path parameter templates in curly braces, each @@ -222,15 +21,8 @@ class APIShieldOperation(BaseModel): 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[APIShieldOperationFeatures] = None - -OperationListResponse: TypeAlias = Union[APIShieldOperation, api_shield_operation.APIShieldOperation] +OperationListResponse: TypeAlias = Union[APIShield, APIShieldBasicOperation] diff --git a/src/cloudflare/types/workers/scripts/subdomain_create_params.py b/src/cloudflare/types/workers/scripts/subdomain_create_params.py index fe29506c463..741d3cdcf54 100644 --- a/src/cloudflare/types/workers/scripts/subdomain_create_params.py +++ b/src/cloudflare/types/workers/scripts/subdomain_create_params.py @@ -11,5 +11,11 @@ class SubdomainCreateParams(TypedDict, total=False): account_id: Required[str] """Identifier""" - enabled: bool + enabled: Required[bool] """Whether the Worker should be available on the workers.dev subdomain.""" + + previews_enabled: bool + """ + Whether the Worker's Preview URLs should be available on the workers.dev + subdomain. + """ diff --git a/src/cloudflare/types/workers/scripts/subdomain_create_response.py b/src/cloudflare/types/workers/scripts/subdomain_create_response.py index 15c53be0add..9974134fa0d 100644 --- a/src/cloudflare/types/workers/scripts/subdomain_create_response.py +++ b/src/cloudflare/types/workers/scripts/subdomain_create_response.py @@ -10,3 +10,9 @@ class SubdomainCreateResponse(BaseModel): enabled: Optional[bool] = None """Whether the Worker is available on the workers.dev subdomain.""" + + previews_enabled: Optional[bool] = None + """ + Whether the Worker's Preview URLs should be available on the workers.dev + subdomain. + """ diff --git a/src/cloudflare/types/workers/scripts/subdomain_get_response.py b/src/cloudflare/types/workers/scripts/subdomain_get_response.py index 0d2ed6d56c5..bd9a0530a07 100644 --- a/src/cloudflare/types/workers/scripts/subdomain_get_response.py +++ b/src/cloudflare/types/workers/scripts/subdomain_get_response.py @@ -10,3 +10,9 @@ class SubdomainGetResponse(BaseModel): enabled: Optional[bool] = None """Whether the Worker is available on the workers.dev subdomain.""" + + previews_enabled: Optional[bool] = None + """ + Whether the Worker's Preview URLs should be available on the workers.dev + subdomain. + """ diff --git a/tests/api_resources/workers/scripts/test_subdomain.py b/tests/api_resources/workers/scripts/test_subdomain.py index 6d600836439..da7e134d4c2 100644 --- a/tests/api_resources/workers/scripts/test_subdomain.py +++ b/tests/api_resources/workers/scripts/test_subdomain.py @@ -22,6 +22,7 @@ def test_method_create(self, client: Cloudflare) -> None: subdomain = client.workers.scripts.subdomain.create( script_name="this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, ) assert_matches_type(SubdomainCreateResponse, subdomain, path=["response"]) @@ -31,6 +32,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: script_name="this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", enabled=True, + previews_enabled=True, ) assert_matches_type(SubdomainCreateResponse, subdomain, path=["response"]) @@ -39,6 +41,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: response = client.workers.scripts.subdomain.with_raw_response.create( script_name="this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, ) assert response.is_closed is True @@ -51,6 +54,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: with client.workers.scripts.subdomain.with_streaming_response.create( script_name="this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -66,12 +70,14 @@ def test_path_params_create(self, client: Cloudflare) -> None: client.workers.scripts.subdomain.with_raw_response.create( script_name="this-is_my_script-01", account_id="", + enabled=True, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"): client.workers.scripts.subdomain.with_raw_response.create( script_name="", account_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, ) @parametrize @@ -131,6 +137,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: subdomain = await async_client.workers.scripts.subdomain.create( script_name="this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, ) assert_matches_type(SubdomainCreateResponse, subdomain, path=["response"]) @@ -140,6 +147,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare script_name="this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", enabled=True, + previews_enabled=True, ) assert_matches_type(SubdomainCreateResponse, subdomain, path=["response"]) @@ -148,6 +156,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.workers.scripts.subdomain.with_raw_response.create( script_name="this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, ) assert response.is_closed is True @@ -160,6 +169,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> async with async_client.workers.scripts.subdomain.with_streaming_response.create( script_name="this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -175,12 +185,14 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: await async_client.workers.scripts.subdomain.with_raw_response.create( script_name="this-is_my_script-01", account_id="", + enabled=True, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"): await async_client.workers.scripts.subdomain.with_raw_response.create( script_name="", account_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, ) @parametrize