Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 22, 2024
1 parent 77cd2ad commit ac53439
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cloudflare/_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import os
import inspect
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
from datetime import date, datetime
Expand Down Expand Up @@ -38,6 +39,7 @@
is_given,
is_mapping,
parse_date,
coerce_boolean,
parse_datetime,
strip_not_given,
extract_type_arg,
Expand Down Expand Up @@ -74,7 +76,9 @@ class _ConfigProtocol(Protocol):

class BaseModel(pydantic.BaseModel):
if PYDANTIC_V2:
model_config: ClassVar[ConfigDict] = ConfigDict(extra="allow")
model_config: ClassVar[ConfigDict] = ConfigDict(
extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true"))
)
else:

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
__all__ = [
"DigitalExperienceMonitoringHTTPDetails",
"HTTPStats",
"HTTPStatsAvailabilityPct",
"HTTPStatsAvailabilityPctSlot",
"HTTPStatsDNSResponseTimeMs",
"HTTPStatsDNSResponseTimeMsSlot",
"HTTPStatsHTTPStatusCode",
Expand All @@ -18,16 +20,38 @@
"HTTPStatsServerResponseTimeMs",
"HTTPStatsServerResponseTimeMsSlot",
"HTTPStatsByColo",
"HTTPStatsByColoAvailabilityPct",
"HTTPStatsByColoAvailabilityPctSlot",
"HTTPStatsByColoDNSResponseTimeMs",
"HTTPStatsByColoDNSResponseTimeMsSlot",
"HTTPStatsByColoHTTPStatusCode",
"HTTPStatsByColoResourceFetchTimeMs",
"HTTPStatsByColoResourceFetchTimeMsSlot",
"HTTPStatsByColoServerResponseTimeMs",
"HTTPStatsByColoServerResponseTimeMsSlot",
"TargetPolicy",
]


class HTTPStatsAvailabilityPctSlot(BaseModel):
timestamp: str

value: float


class HTTPStatsAvailabilityPct(BaseModel):
slots: List[HTTPStatsAvailabilityPctSlot]

avg: Optional[float] = None
"""average observed in the time period"""

max: Optional[float] = None
"""highest observed in the time period"""

min: Optional[float] = None
"""lowest observed in the time period"""


class HTTPStatsDNSResponseTimeMsSlot(BaseModel):
timestamp: str

Expand Down Expand Up @@ -98,6 +122,8 @@ class HTTPStatsServerResponseTimeMs(BaseModel):


class HTTPStats(BaseModel):
availability_pct: HTTPStatsAvailabilityPct = FieldInfo(alias="availabilityPct")

dns_response_time_ms: HTTPStatsDNSResponseTimeMs = FieldInfo(alias="dnsResponseTimeMs")

http_status_code: List[HTTPStatsHTTPStatusCode] = FieldInfo(alias="httpStatusCode")
Expand All @@ -110,6 +136,25 @@ class HTTPStats(BaseModel):
"""Count of unique devices that have run this test in the given time period"""


class HTTPStatsByColoAvailabilityPctSlot(BaseModel):
timestamp: str

value: float


class HTTPStatsByColoAvailabilityPct(BaseModel):
slots: List[HTTPStatsByColoAvailabilityPctSlot]

avg: Optional[float] = None
"""average observed in the time period"""

max: Optional[float] = None
"""highest observed in the time period"""

min: Optional[float] = None
"""lowest observed in the time period"""


class HTTPStatsByColoDNSResponseTimeMsSlot(BaseModel):
timestamp: str

Expand Down Expand Up @@ -180,6 +225,8 @@ class HTTPStatsByColoServerResponseTimeMs(BaseModel):


class HTTPStatsByColo(BaseModel):
availability_pct: HTTPStatsByColoAvailabilityPct = FieldInfo(alias="availabilityPct")

colo: str

dns_response_time_ms: HTTPStatsByColoDNSResponseTimeMs = FieldInfo(alias="dnsResponseTimeMs")
Expand All @@ -194,6 +241,15 @@ class HTTPStatsByColo(BaseModel):
"""Count of unique devices that have run this test in the given time period"""


class TargetPolicy(BaseModel):
id: str

default: bool
"""Whether the policy is the default for the account"""

name: str


class DigitalExperienceMonitoringHTTPDetails(BaseModel):
host: Optional[str] = None
"""The url of the HTTP synthetic application test"""
Expand All @@ -212,3 +268,7 @@ class DigitalExperienceMonitoringHTTPDetails(BaseModel):

name: Optional[str] = None
"""The name of the HTTP synthetic application test"""

target_policies: Optional[List[TargetPolicy]] = None

targeted: Optional[bool] = None
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"TestHTTPResultsByColoResourceFetchTimeOverTime",
"TestHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod",
"TestHTTPResultsByColoResourceFetchTimeOverTimeValue",
"TestTargetPolicy",
"TestTracerouteResults",
"TestTracerouteResultsRoundTripTime",
"TestTracerouteResultsRoundTripTimeHistory",
Expand All @@ -46,6 +47,9 @@ class OverviewMetrics(BaseModel):
tests_total: int = FieldInfo(alias="testsTotal")
"""number of tests."""

avg_http_availability_pct: Optional[float] = FieldInfo(alias="avgHttpAvailabilityPct", default=None)
"""percentage availability for all HTTP test results in response"""

avg_traceroute_availability_pct: Optional[float] = FieldInfo(alias="avgTracerouteAvailabilityPct", default=None)
"""percentage availability for all traceroutes results in response"""

Expand Down Expand Up @@ -155,6 +159,16 @@ class TestHTTPResultsByColo(BaseModel):
resource_fetch_time: TestHTTPResultsByColoResourceFetchTime = FieldInfo(alias="resourceFetchTime")


class TestTargetPolicy(BaseModel):
__test__ = False
id: str

default: bool
"""Whether the policy is the default for the account"""

name: str


class TestTracerouteResultsRoundTripTimeHistoryTimePeriod(BaseModel):
__test__ = False
units: Literal["hours", "days", "testRuns"]
Expand Down Expand Up @@ -297,6 +311,10 @@ class Test(BaseModel):
method: Optional[str] = None
"""for HTTP, the method to use when running the test"""

target_policies: Optional[List[TestTargetPolicy]] = None

targeted: Optional[bool] = None

traceroute_results: Optional[TestTracerouteResults] = FieldInfo(alias="tracerouteResults", default=None)

traceroute_results_by_colo: Optional[List[TestTracerouteResultsByColo]] = FieldInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

__all__ = [
"DigitalExperienceMonitoringTracerouteDetails",
"TargetPolicy",
"TracerouteStats",
"TracerouteStatsAvailabilityPct",
"TracerouteStatsAvailabilityPctSlot",
Expand All @@ -30,6 +31,15 @@
]


class TargetPolicy(BaseModel):
id: str

default: bool
"""Whether the policy is the default for the account"""

name: str


class TracerouteStatsAvailabilityPctSlot(BaseModel):
timestamp: str

Expand Down Expand Up @@ -222,6 +232,10 @@ class DigitalExperienceMonitoringTracerouteDetails(BaseModel):
name: str
"""The name of the Traceroute synthetic application test"""

target_policies: Optional[List[TargetPolicy]] = None

targeted: Optional[bool] = None

traceroute_stats: Optional[TracerouteStats] = FieldInfo(alias="tracerouteStats", default=None)

traceroute_stats_by_colo: Optional[List[TracerouteStatsByColo]] = FieldInfo(
Expand Down

0 comments on commit ac53439

Please sign in to comment.