|
| 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