diff --git a/.stats.yml b/.stats.yml index 3336fc55499..cb1412e7ab3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1235 +configured_endpoints: 1288 diff --git a/README.md b/README.md index 2ea1ba530ac..8047c97241d 100644 --- a/README.md +++ b/README.md @@ -142,23 +142,6 @@ for account in first_page.result: # Remove `await` for non-async usage. ``` -## File Uploads - -Request parameters that correspond to file uploads can be passed as `bytes`, a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`. - -```python -from pathlib import Path -from cloudflare import Cloudflare - -client = Cloudflare() - -client.images.v1.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", -) -``` - -The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically. - ## Handling errors When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `cloudflare.APIConnectionError` is raised. diff --git a/api.md b/api.md index 0ec24a20e31..f55e7eea8ad 100644 --- a/api.md +++ b/api.md @@ -1688,6 +1688,32 @@ Methods: - client.dns.records.import\_(\*, zone_id, \*\*params) -> RecordImportResponse - client.dns.records.scan(\*, zone_id) -> RecordScanResponse +## Analytics + +### Reports + +Types: + +```python +from cloudflare.types.dns.analytics import DNSDNSAnalyticsAPIReport +``` + +Methods: + +- client.dns.analytics.reports.get(\*, zone_id, \*\*params) -> DNSDNSAnalyticsAPIReport + +#### Bytimes + +Types: + +```python +from cloudflare.types.dns.analytics.reports import DNSDNSAnalyticsAPIReportBytime +``` + +Methods: + +- client.dns.analytics.reports.bytimes.get(\*, zone_id, \*\*params) -> DNSDNSAnalyticsAPIReportBytime + ## Firewall Types: @@ -1704,6 +1730,20 @@ Methods: - client.dns.firewall.edit(dns_firewall_id, \*, account_id, \*\*params) -> DNSFirewallDNSFirewall - client.dns.firewall.get(dns_firewall_id, \*, account_id) -> DNSFirewallDNSFirewall +### Analytics + +#### Reports + +Methods: + +- client.dns.firewall.analytics.reports.get(dns_firewall_id, \*, account_id, \*\*params) -> DNSDNSAnalyticsAPIReport + +##### Bytimes + +Methods: + +- client.dns.firewall.analytics.reports.bytimes.get(dns_firewall_id, \*, account_id, \*\*params) -> DNSDNSAnalyticsAPIReportBytime + # DNSSEC Types: @@ -1976,9 +2016,36 @@ Methods: Types: ```python -from cloudflare.types import HealthchecksHealthchecks +from cloudflare.types import ( + HealthchecksHealthchecks, + HealthcheckListResponse, + HealthcheckDeleteResponse, +) +``` + +Methods: + +- client.healthchecks.create(\*, zone_id, \*\*params) -> HealthchecksHealthchecks +- client.healthchecks.update(healthcheck_id, \*, zone_id, \*\*params) -> HealthchecksHealthchecks +- client.healthchecks.list(\*, zone_id) -> Optional +- client.healthchecks.delete(healthcheck_id, \*, zone_id) -> HealthcheckDeleteResponse +- client.healthchecks.edit(healthcheck_id, \*, zone_id, \*\*params) -> HealthchecksHealthchecks +- client.healthchecks.get(healthcheck_id, \*, zone_id) -> HealthchecksHealthchecks + +## Previews + +Types: + +```python +from cloudflare.types.healthchecks import PreviewDeleteResponse ``` +Methods: + +- client.healthchecks.previews.create(\*, zone_id, \*\*params) -> HealthchecksHealthchecks +- client.healthchecks.previews.delete(healthcheck_id, \*, zone_id) -> PreviewDeleteResponse +- client.healthchecks.previews.get(healthcheck_id, \*, zone_id) -> HealthchecksHealthchecks + # KeylessCertificates Types: @@ -3689,6 +3756,184 @@ Methods: - client.intel.attack_surface_report.issues.severity(\*, account_id, \*\*params) -> IssueSeverityResponse - client.intel.attack_surface_report.issues.type(\*, account_id, \*\*params) -> IssueTypeResponse +# MagicTransit + +## CfInterconnects + +Types: + +```python +from cloudflare.types.magic_transit import ( + CfInterconnectUpdateResponse, + CfInterconnectListResponse, + CfInterconnectGetResponse, +) +``` + +Methods: + +- client.magic_transit.cf_interconnects.update(tunnel_identifier, \*, account_id, \*\*params) -> CfInterconnectUpdateResponse +- client.magic_transit.cf_interconnects.list(\*, account_id) -> CfInterconnectListResponse +- client.magic_transit.cf_interconnects.get(tunnel_identifier, \*, account_id) -> CfInterconnectGetResponse + +## GRETunnels + +Types: + +```python +from cloudflare.types.magic_transit import ( + GRETunnelCreateResponse, + GRETunnelUpdateResponse, + GRETunnelListResponse, + GRETunnelDeleteResponse, + GRETunnelGetResponse, +) +``` + +Methods: + +- client.magic_transit.gre_tunnels.create(\*, account_id, \*\*params) -> GRETunnelCreateResponse +- client.magic_transit.gre_tunnels.update(tunnel_identifier, \*, account_id, \*\*params) -> GRETunnelUpdateResponse +- client.magic_transit.gre_tunnels.list(\*, account_id) -> GRETunnelListResponse +- client.magic_transit.gre_tunnels.delete(tunnel_identifier, \*, account_id) -> GRETunnelDeleteResponse +- client.magic_transit.gre_tunnels.get(tunnel_identifier, \*, account_id) -> GRETunnelGetResponse + +## IPSECTunnels + +Types: + +```python +from cloudflare.types.magic_transit import ( + IPSECTunnelCreateResponse, + IPSECTunnelUpdateResponse, + IPSECTunnelListResponse, + IPSECTunnelDeleteResponse, + IPSECTunnelGetResponse, + IPSECTunnelPSKGenerateResponse, +) +``` + +Methods: + +- client.magic_transit.ipsec_tunnels.create(\*, account_id, \*\*params) -> IPSECTunnelCreateResponse +- client.magic_transit.ipsec_tunnels.update(tunnel_identifier, \*, account_id, \*\*params) -> IPSECTunnelUpdateResponse +- client.magic_transit.ipsec_tunnels.list(\*, account_id) -> IPSECTunnelListResponse +- client.magic_transit.ipsec_tunnels.delete(tunnel_identifier, \*, account_id) -> IPSECTunnelDeleteResponse +- client.magic_transit.ipsec_tunnels.get(tunnel_identifier, \*, account_id) -> IPSECTunnelGetResponse +- client.magic_transit.ipsec_tunnels.psk_generate(tunnel_identifier, \*, account_id) -> IPSECTunnelPSKGenerateResponse + +## Routes + +Types: + +```python +from cloudflare.types.magic_transit import ( + RouteCreateResponse, + RouteUpdateResponse, + RouteListResponse, + RouteDeleteResponse, + RouteEmptyResponse, + RouteGetResponse, +) +``` + +Methods: + +- client.magic_transit.routes.create(\*, account_id, \*\*params) -> RouteCreateResponse +- client.magic_transit.routes.update(route_identifier, \*, account_id, \*\*params) -> RouteUpdateResponse +- client.magic_transit.routes.list(\*, account_id) -> RouteListResponse +- client.magic_transit.routes.delete(route_identifier, \*, account_id) -> RouteDeleteResponse +- client.magic_transit.routes.empty(\*, account_id, \*\*params) -> RouteEmptyResponse +- client.magic_transit.routes.get(route_identifier, \*, account_id) -> RouteGetResponse + +## Sites + +Types: + +```python +from cloudflare.types.magic_transit import ( + SiteCreateResponse, + SiteUpdateResponse, + SiteListResponse, + SiteDeleteResponse, + SiteGetResponse, +) +``` + +Methods: + +- client.magic_transit.sites.create(\*, account_id, \*\*params) -> SiteCreateResponse +- client.magic_transit.sites.update(site_id, \*, account_id, \*\*params) -> SiteUpdateResponse +- client.magic_transit.sites.list(\*, account_id) -> SiteListResponse +- client.magic_transit.sites.delete(site_id, \*, account_id) -> SiteDeleteResponse +- client.magic_transit.sites.get(site_id, \*, account_id) -> SiteGetResponse + +### ACLs + +Types: + +```python +from cloudflare.types.magic_transit.sites import ( + ACLCreateResponse, + ACLUpdateResponse, + ACLListResponse, + ACLDeleteResponse, + ACLGetResponse, +) +``` + +Methods: + +- client.magic_transit.sites.acls.create(site_id, \*, account_id, \*\*params) -> ACLCreateResponse +- client.magic_transit.sites.acls.update(acl_identifier, \*, account_id, site_id, \*\*params) -> ACLUpdateResponse +- client.magic_transit.sites.acls.list(site_id, \*, account_id) -> ACLListResponse +- client.magic_transit.sites.acls.delete(acl_identifier, \*, account_id, site_id) -> ACLDeleteResponse +- client.magic_transit.sites.acls.get(acl_identifier, \*, account_id, site_id) -> ACLGetResponse + +### Lans + +Types: + +```python +from cloudflare.types.magic_transit.sites import ( + LanCreateResponse, + LanUpdateResponse, + LanListResponse, + LanDeleteResponse, + LanGetResponse, +) +``` + +Methods: + +- client.magic_transit.sites.lans.create(site_id, \*, account_id, \*\*params) -> LanCreateResponse +- client.magic_transit.sites.lans.update(lan_id, \*, account_id, site_id, \*\*params) -> LanUpdateResponse +- client.magic_transit.sites.lans.list(site_id, \*, account_id) -> LanListResponse +- client.magic_transit.sites.lans.delete(lan_id, \*, account_id, site_id) -> LanDeleteResponse +- client.magic_transit.sites.lans.get(lan_id, \*, account_id, site_id) -> LanGetResponse + +### Wans + +Types: + +```python +from cloudflare.types.magic_transit.sites import ( + WanCreateResponse, + WanUpdateResponse, + WanListResponse, + WanDeleteResponse, + WanGetResponse, +) +``` + +Methods: + +- client.magic_transit.sites.wans.create(site_id, \*, account_id, \*\*params) -> WanCreateResponse +- client.magic_transit.sites.wans.update(wan_id, \*, account_id, site_id, \*\*params) -> WanUpdateResponse +- client.magic_transit.sites.wans.list(site_id, \*, account_id) -> WanListResponse +- client.magic_transit.sites.wans.delete(wan_id, \*, account_id, site_id) -> WanDeleteResponse +- client.magic_transit.sites.wans.get(wan_id, \*, account_id, site_id) -> WanGetResponse + # MagicNetworkMonitoring ## Configs diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index a6e8a11427a..970437dd25b 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -71,6 +71,7 @@ class Cloudflare(SyncAPIClient): email_routing: resources.EmailRouting filters: resources.Filters firewall: resources.Firewall + healthchecks: resources.Healthchecks keyless_certificates: resources.KeylessCertificates logpush: resources.Logpush logs: resources.Logs @@ -96,6 +97,7 @@ class Cloudflare(SyncAPIClient): diagnostics: resources.Diagnostics images: resources.Images intel: resources.Intel + magic_transit: resources.MagicTransit magic_network_monitoring: resources.MagicNetworkMonitoring mtls_certificates: resources.MTLSCertificates pages: resources.Pages @@ -222,6 +224,7 @@ def __init__( self.email_routing = resources.EmailRouting(self) self.filters = resources.Filters(self) self.firewall = resources.Firewall(self) + self.healthchecks = resources.Healthchecks(self) self.keyless_certificates = resources.KeylessCertificates(self) self.logpush = resources.Logpush(self) self.logs = resources.Logs(self) @@ -247,6 +250,7 @@ def __init__( self.diagnostics = resources.Diagnostics(self) self.images = resources.Images(self) self.intel = resources.Intel(self) + self.magic_transit = resources.MagicTransit(self) self.magic_network_monitoring = resources.MagicNetworkMonitoring(self) self.mtls_certificates = resources.MTLSCertificates(self) self.pages = resources.Pages(self) @@ -478,6 +482,7 @@ class AsyncCloudflare(AsyncAPIClient): email_routing: resources.AsyncEmailRouting filters: resources.AsyncFilters firewall: resources.AsyncFirewall + healthchecks: resources.AsyncHealthchecks keyless_certificates: resources.AsyncKeylessCertificates logpush: resources.AsyncLogpush logs: resources.AsyncLogs @@ -503,6 +508,7 @@ class AsyncCloudflare(AsyncAPIClient): diagnostics: resources.AsyncDiagnostics images: resources.AsyncImages intel: resources.AsyncIntel + magic_transit: resources.AsyncMagicTransit magic_network_monitoring: resources.AsyncMagicNetworkMonitoring mtls_certificates: resources.AsyncMTLSCertificates pages: resources.AsyncPages @@ -629,6 +635,7 @@ def __init__( self.email_routing = resources.AsyncEmailRouting(self) self.filters = resources.AsyncFilters(self) self.firewall = resources.AsyncFirewall(self) + self.healthchecks = resources.AsyncHealthchecks(self) self.keyless_certificates = resources.AsyncKeylessCertificates(self) self.logpush = resources.AsyncLogpush(self) self.logs = resources.AsyncLogs(self) @@ -654,6 +661,7 @@ def __init__( self.diagnostics = resources.AsyncDiagnostics(self) self.images = resources.AsyncImages(self) self.intel = resources.AsyncIntel(self) + self.magic_transit = resources.AsyncMagicTransit(self) self.magic_network_monitoring = resources.AsyncMagicNetworkMonitoring(self) self.mtls_certificates = resources.AsyncMTLSCertificates(self) self.pages = resources.AsyncPages(self) @@ -886,6 +894,7 @@ def __init__(self, client: Cloudflare) -> None: self.email_routing = resources.EmailRoutingWithRawResponse(client.email_routing) self.filters = resources.FiltersWithRawResponse(client.filters) self.firewall = resources.FirewallWithRawResponse(client.firewall) + self.healthchecks = resources.HealthchecksWithRawResponse(client.healthchecks) self.keyless_certificates = resources.KeylessCertificatesWithRawResponse(client.keyless_certificates) self.logpush = resources.LogpushWithRawResponse(client.logpush) self.logs = resources.LogsWithRawResponse(client.logs) @@ -911,6 +920,7 @@ def __init__(self, client: Cloudflare) -> None: self.diagnostics = resources.DiagnosticsWithRawResponse(client.diagnostics) self.images = resources.ImagesWithRawResponse(client.images) self.intel = resources.IntelWithRawResponse(client.intel) + self.magic_transit = resources.MagicTransitWithRawResponse(client.magic_transit) self.magic_network_monitoring = resources.MagicNetworkMonitoringWithRawResponse(client.magic_network_monitoring) self.mtls_certificates = resources.MTLSCertificatesWithRawResponse(client.mtls_certificates) self.pages = resources.PagesWithRawResponse(client.pages) @@ -972,6 +982,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.email_routing = resources.AsyncEmailRoutingWithRawResponse(client.email_routing) self.filters = resources.AsyncFiltersWithRawResponse(client.filters) self.firewall = resources.AsyncFirewallWithRawResponse(client.firewall) + self.healthchecks = resources.AsyncHealthchecksWithRawResponse(client.healthchecks) self.keyless_certificates = resources.AsyncKeylessCertificatesWithRawResponse(client.keyless_certificates) self.logpush = resources.AsyncLogpushWithRawResponse(client.logpush) self.logs = resources.AsyncLogsWithRawResponse(client.logs) @@ -997,6 +1008,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.diagnostics = resources.AsyncDiagnosticsWithRawResponse(client.diagnostics) self.images = resources.AsyncImagesWithRawResponse(client.images) self.intel = resources.AsyncIntelWithRawResponse(client.intel) + self.magic_transit = resources.AsyncMagicTransitWithRawResponse(client.magic_transit) self.magic_network_monitoring = resources.AsyncMagicNetworkMonitoringWithRawResponse( client.magic_network_monitoring ) @@ -1060,6 +1072,7 @@ def __init__(self, client: Cloudflare) -> None: self.email_routing = resources.EmailRoutingWithStreamingResponse(client.email_routing) self.filters = resources.FiltersWithStreamingResponse(client.filters) self.firewall = resources.FirewallWithStreamingResponse(client.firewall) + self.healthchecks = resources.HealthchecksWithStreamingResponse(client.healthchecks) self.keyless_certificates = resources.KeylessCertificatesWithStreamingResponse(client.keyless_certificates) self.logpush = resources.LogpushWithStreamingResponse(client.logpush) self.logs = resources.LogsWithStreamingResponse(client.logs) @@ -1085,6 +1098,7 @@ def __init__(self, client: Cloudflare) -> None: self.diagnostics = resources.DiagnosticsWithStreamingResponse(client.diagnostics) self.images = resources.ImagesWithStreamingResponse(client.images) self.intel = resources.IntelWithStreamingResponse(client.intel) + self.magic_transit = resources.MagicTransitWithStreamingResponse(client.magic_transit) self.magic_network_monitoring = resources.MagicNetworkMonitoringWithStreamingResponse( client.magic_network_monitoring ) @@ -1150,6 +1164,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.email_routing = resources.AsyncEmailRoutingWithStreamingResponse(client.email_routing) self.filters = resources.AsyncFiltersWithStreamingResponse(client.filters) self.firewall = resources.AsyncFirewallWithStreamingResponse(client.firewall) + self.healthchecks = resources.AsyncHealthchecksWithStreamingResponse(client.healthchecks) self.keyless_certificates = resources.AsyncKeylessCertificatesWithStreamingResponse(client.keyless_certificates) self.logpush = resources.AsyncLogpushWithStreamingResponse(client.logpush) self.logs = resources.AsyncLogsWithStreamingResponse(client.logs) @@ -1177,6 +1192,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.diagnostics = resources.AsyncDiagnosticsWithStreamingResponse(client.diagnostics) self.images = resources.AsyncImagesWithStreamingResponse(client.images) self.intel = resources.AsyncIntelWithStreamingResponse(client.intel) + self.magic_transit = resources.AsyncMagicTransitWithStreamingResponse(client.magic_transit) self.magic_network_monitoring = resources.AsyncMagicNetworkMonitoringWithStreamingResponse( client.magic_network_monitoring ) diff --git a/src/cloudflare/_files.py b/src/cloudflare/_files.py index de98c29b284..0d2022ae79e 100644 --- a/src/cloudflare/_files.py +++ b/src/cloudflare/_files.py @@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None: if not is_file_content(obj): prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`" raise RuntimeError( - f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/cloudflare/cloudflare-python/tree/main#file-uploads" + f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead." ) from None diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index f6f88f731bf..2c1ab6cf2c3 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -400,6 +400,14 @@ URLScannerWithStreamingResponse, AsyncURLScannerWithStreamingResponse, ) +from .healthchecks import ( + Healthchecks, + AsyncHealthchecks, + HealthchecksWithRawResponse, + AsyncHealthchecksWithRawResponse, + HealthchecksWithStreamingResponse, + AsyncHealthchecksWithStreamingResponse, +) from .email_routing import ( EmailRouting, AsyncEmailRouting, @@ -408,6 +416,14 @@ EmailRoutingWithStreamingResponse, AsyncEmailRoutingWithStreamingResponse, ) +from .magic_transit import ( + MagicTransit, + AsyncMagicTransit, + MagicTransitWithRawResponse, + AsyncMagicTransitWithRawResponse, + MagicTransitWithStreamingResponse, + AsyncMagicTransitWithStreamingResponse, +) from .secondary_dns import ( SecondaryDNS, AsyncSecondaryDNS, @@ -770,6 +786,12 @@ "AsyncFirewallWithRawResponse", "FirewallWithStreamingResponse", "AsyncFirewallWithStreamingResponse", + "Healthchecks", + "AsyncHealthchecks", + "HealthchecksWithRawResponse", + "AsyncHealthchecksWithRawResponse", + "HealthchecksWithStreamingResponse", + "AsyncHealthchecksWithStreamingResponse", "KeylessCertificates", "AsyncKeylessCertificates", "KeylessCertificatesWithRawResponse", @@ -920,6 +942,12 @@ "AsyncIntelWithRawResponse", "IntelWithStreamingResponse", "AsyncIntelWithStreamingResponse", + "MagicTransit", + "AsyncMagicTransit", + "MagicTransitWithRawResponse", + "AsyncMagicTransitWithRawResponse", + "MagicTransitWithStreamingResponse", + "AsyncMagicTransitWithStreamingResponse", "MagicNetworkMonitoring", "AsyncMagicNetworkMonitoring", "MagicNetworkMonitoringWithRawResponse", diff --git a/src/cloudflare/resources/dns/__init__.py b/src/cloudflare/resources/dns/__init__.py index a7bcb514c50..bec5b418f44 100644 --- a/src/cloudflare/resources/dns/__init__.py +++ b/src/cloudflare/resources/dns/__init__.py @@ -24,6 +24,14 @@ FirewallWithStreamingResponse, AsyncFirewallWithStreamingResponse, ) +from .analytics import ( + Analytics, + AsyncAnalytics, + AnalyticsWithRawResponse, + AsyncAnalyticsWithRawResponse, + AnalyticsWithStreamingResponse, + AsyncAnalyticsWithStreamingResponse, +) __all__ = [ "Records", @@ -32,6 +40,12 @@ "AsyncRecordsWithRawResponse", "RecordsWithStreamingResponse", "AsyncRecordsWithStreamingResponse", + "Analytics", + "AsyncAnalytics", + "AnalyticsWithRawResponse", + "AsyncAnalyticsWithRawResponse", + "AnalyticsWithStreamingResponse", + "AsyncAnalyticsWithStreamingResponse", "Firewall", "AsyncFirewall", "FirewallWithRawResponse", diff --git a/src/cloudflare/resources/dns/analytics/__init__.py b/src/cloudflare/resources/dns/analytics/__init__.py new file mode 100644 index 00000000000..15d7a4bfd5f --- /dev/null +++ b/src/cloudflare/resources/dns/analytics/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .reports import ( + Reports, + AsyncReports, + ReportsWithRawResponse, + AsyncReportsWithRawResponse, + ReportsWithStreamingResponse, + AsyncReportsWithStreamingResponse, +) +from .analytics import ( + Analytics, + AsyncAnalytics, + AnalyticsWithRawResponse, + AsyncAnalyticsWithRawResponse, + AnalyticsWithStreamingResponse, + AsyncAnalyticsWithStreamingResponse, +) + +__all__ = [ + "Reports", + "AsyncReports", + "ReportsWithRawResponse", + "AsyncReportsWithRawResponse", + "ReportsWithStreamingResponse", + "AsyncReportsWithStreamingResponse", + "Analytics", + "AsyncAnalytics", + "AnalyticsWithRawResponse", + "AsyncAnalyticsWithRawResponse", + "AnalyticsWithStreamingResponse", + "AsyncAnalyticsWithStreamingResponse", +] diff --git a/src/cloudflare/resources/dns/analytics/analytics.py b/src/cloudflare/resources/dns/analytics/analytics.py new file mode 100644 index 00000000000..58181bd95e1 --- /dev/null +++ b/src/cloudflare/resources/dns/analytics/analytics.py @@ -0,0 +1,81 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .reports import ( + Reports, + AsyncReports, + ReportsWithRawResponse, + AsyncReportsWithRawResponse, + ReportsWithStreamingResponse, + AsyncReportsWithStreamingResponse, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from .reports.reports import Reports, AsyncReports + +__all__ = ["Analytics", "AsyncAnalytics"] + + +class Analytics(SyncAPIResource): + @cached_property + def reports(self) -> Reports: + return Reports(self._client) + + @cached_property + def with_raw_response(self) -> AnalyticsWithRawResponse: + return AnalyticsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AnalyticsWithStreamingResponse: + return AnalyticsWithStreamingResponse(self) + + +class AsyncAnalytics(AsyncAPIResource): + @cached_property + def reports(self) -> AsyncReports: + return AsyncReports(self._client) + + @cached_property + def with_raw_response(self) -> AsyncAnalyticsWithRawResponse: + return AsyncAnalyticsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAnalyticsWithStreamingResponse: + return AsyncAnalyticsWithStreamingResponse(self) + + +class AnalyticsWithRawResponse: + def __init__(self, analytics: Analytics) -> None: + self._analytics = analytics + + @cached_property + def reports(self) -> ReportsWithRawResponse: + return ReportsWithRawResponse(self._analytics.reports) + + +class AsyncAnalyticsWithRawResponse: + def __init__(self, analytics: AsyncAnalytics) -> None: + self._analytics = analytics + + @cached_property + def reports(self) -> AsyncReportsWithRawResponse: + return AsyncReportsWithRawResponse(self._analytics.reports) + + +class AnalyticsWithStreamingResponse: + def __init__(self, analytics: Analytics) -> None: + self._analytics = analytics + + @cached_property + def reports(self) -> ReportsWithStreamingResponse: + return ReportsWithStreamingResponse(self._analytics.reports) + + +class AsyncAnalyticsWithStreamingResponse: + def __init__(self, analytics: AsyncAnalytics) -> None: + self._analytics = analytics + + @cached_property + def reports(self) -> AsyncReportsWithStreamingResponse: + return AsyncReportsWithStreamingResponse(self._analytics.reports) diff --git a/src/cloudflare/resources/dns/analytics/reports/__init__.py b/src/cloudflare/resources/dns/analytics/reports/__init__.py new file mode 100644 index 00000000000..863e89438cf --- /dev/null +++ b/src/cloudflare/resources/dns/analytics/reports/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .bytimes import ( + Bytimes, + AsyncBytimes, + BytimesWithRawResponse, + AsyncBytimesWithRawResponse, + BytimesWithStreamingResponse, + AsyncBytimesWithStreamingResponse, +) +from .reports import ( + Reports, + AsyncReports, + ReportsWithRawResponse, + AsyncReportsWithRawResponse, + ReportsWithStreamingResponse, + AsyncReportsWithStreamingResponse, +) + +__all__ = [ + "Bytimes", + "AsyncBytimes", + "BytimesWithRawResponse", + "AsyncBytimesWithRawResponse", + "BytimesWithStreamingResponse", + "AsyncBytimesWithStreamingResponse", + "Reports", + "AsyncReports", + "ReportsWithRawResponse", + "AsyncReportsWithRawResponse", + "ReportsWithStreamingResponse", + "AsyncReportsWithStreamingResponse", +] diff --git a/src/cloudflare/resources/dns/analytics/reports/bytimes.py b/src/cloudflare/resources/dns/analytics/reports/bytimes.py new file mode 100644 index 00000000000..eb3865f2a64 --- /dev/null +++ b/src/cloudflare/resources/dns/analytics/reports/bytimes.py @@ -0,0 +1,250 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Union, cast +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import ( + make_request_options, +) +from .....types.dns.analytics.reports import DNSDNSAnalyticsAPIReportBytime, bytime_get_params + +__all__ = ["Bytimes", "AsyncBytimes"] + + +class Bytimes(SyncAPIResource): + @cached_property + def with_raw_response(self) -> BytimesWithRawResponse: + return BytimesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BytimesWithStreamingResponse: + return BytimesWithStreamingResponse(self) + + def get( + self, + *, + zone_id: str, + dimensions: str | NotGiven = NOT_GIVEN, + filters: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + metrics: str | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + sort: str | NotGiven = NOT_GIVEN, + time_delta: Literal["all", "auto", "year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"] + | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DNSDNSAnalyticsAPIReportBytime: + """ + Retrieves a list of aggregate metrics grouped by time interval. + + See + [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) + for detailed information about the available query parameters. + + Args: + zone_id: Identifier + + dimensions: A comma-separated list of dimensions to group results by. + + filters: Segmentation filter in 'attribute operator value' format. + + limit: Limit number of returned metrics. + + metrics: A comma-separated list of metrics to query. + + since: Start date and time of requesting data period in ISO 8601 format. + + sort: A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + + time_delta: Unit of time to group data by. + + until: End date and time of requesting data period in ISO 8601 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get( + f"/zones/{zone_id}/dns_analytics/report/bytime", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dimensions": dimensions, + "filters": filters, + "limit": limit, + "metrics": metrics, + "since": since, + "sort": sort, + "time_delta": time_delta, + "until": until, + }, + bytime_get_params.BytimeGetParams, + ), + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[DNSDNSAnalyticsAPIReportBytime], ResultWrapper[DNSDNSAnalyticsAPIReportBytime]), + ) + + +class AsyncBytimes(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncBytimesWithRawResponse: + return AsyncBytimesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBytimesWithStreamingResponse: + return AsyncBytimesWithStreamingResponse(self) + + async def get( + self, + *, + zone_id: str, + dimensions: str | NotGiven = NOT_GIVEN, + filters: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + metrics: str | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + sort: str | NotGiven = NOT_GIVEN, + time_delta: Literal["all", "auto", "year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"] + | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DNSDNSAnalyticsAPIReportBytime: + """ + Retrieves a list of aggregate metrics grouped by time interval. + + See + [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) + for detailed information about the available query parameters. + + Args: + zone_id: Identifier + + dimensions: A comma-separated list of dimensions to group results by. + + filters: Segmentation filter in 'attribute operator value' format. + + limit: Limit number of returned metrics. + + metrics: A comma-separated list of metrics to query. + + since: Start date and time of requesting data period in ISO 8601 format. + + sort: A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + + time_delta: Unit of time to group data by. + + until: End date and time of requesting data period in ISO 8601 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._get( + f"/zones/{zone_id}/dns_analytics/report/bytime", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "dimensions": dimensions, + "filters": filters, + "limit": limit, + "metrics": metrics, + "since": since, + "sort": sort, + "time_delta": time_delta, + "until": until, + }, + bytime_get_params.BytimeGetParams, + ), + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[DNSDNSAnalyticsAPIReportBytime], ResultWrapper[DNSDNSAnalyticsAPIReportBytime]), + ) + + +class BytimesWithRawResponse: + def __init__(self, bytimes: Bytimes) -> None: + self._bytimes = bytimes + + self.get = to_raw_response_wrapper( + bytimes.get, + ) + + +class AsyncBytimesWithRawResponse: + def __init__(self, bytimes: AsyncBytimes) -> None: + self._bytimes = bytimes + + self.get = async_to_raw_response_wrapper( + bytimes.get, + ) + + +class BytimesWithStreamingResponse: + def __init__(self, bytimes: Bytimes) -> None: + self._bytimes = bytimes + + self.get = to_streamed_response_wrapper( + bytimes.get, + ) + + +class AsyncBytimesWithStreamingResponse: + def __init__(self, bytimes: AsyncBytimes) -> None: + self._bytimes = bytimes + + self.get = async_to_streamed_response_wrapper( + bytimes.get, + ) diff --git a/src/cloudflare/resources/dns/analytics/reports/reports.py b/src/cloudflare/resources/dns/analytics/reports/reports.py new file mode 100644 index 00000000000..c3c6429a258 --- /dev/null +++ b/src/cloudflare/resources/dns/analytics/reports/reports.py @@ -0,0 +1,271 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Union, cast +from datetime import datetime + +import httpx + +from .bytimes import ( + Bytimes, + AsyncBytimes, + BytimesWithRawResponse, + AsyncBytimesWithRawResponse, + BytimesWithStreamingResponse, + AsyncBytimesWithStreamingResponse, +) +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import ( + make_request_options, +) +from .....types.dns.analytics import DNSDNSAnalyticsAPIReport, report_get_params + +__all__ = ["Reports", "AsyncReports"] + + +class Reports(SyncAPIResource): + @cached_property + def bytimes(self) -> Bytimes: + return Bytimes(self._client) + + @cached_property + def with_raw_response(self) -> ReportsWithRawResponse: + return ReportsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ReportsWithStreamingResponse: + return ReportsWithStreamingResponse(self) + + def get( + self, + *, + zone_id: str, + dimensions: str | NotGiven = NOT_GIVEN, + filters: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + metrics: str | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + sort: str | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DNSDNSAnalyticsAPIReport: + """ + Retrieves a list of summarised aggregate metrics over a given time period. + + See + [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) + for detailed information about the available query parameters. + + Args: + zone_id: Identifier + + dimensions: A comma-separated list of dimensions to group results by. + + filters: Segmentation filter in 'attribute operator value' format. + + limit: Limit number of returned metrics. + + metrics: A comma-separated list of metrics to query. + + since: Start date and time of requesting data period in ISO 8601 format. + + sort: A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + + until: End date and time of requesting data period in ISO 8601 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get( + f"/zones/{zone_id}/dns_analytics/report", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dimensions": dimensions, + "filters": filters, + "limit": limit, + "metrics": metrics, + "since": since, + "sort": sort, + "until": until, + }, + report_get_params.ReportGetParams, + ), + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[DNSDNSAnalyticsAPIReport], ResultWrapper[DNSDNSAnalyticsAPIReport]), + ) + + +class AsyncReports(AsyncAPIResource): + @cached_property + def bytimes(self) -> AsyncBytimes: + return AsyncBytimes(self._client) + + @cached_property + def with_raw_response(self) -> AsyncReportsWithRawResponse: + return AsyncReportsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncReportsWithStreamingResponse: + return AsyncReportsWithStreamingResponse(self) + + async def get( + self, + *, + zone_id: str, + dimensions: str | NotGiven = NOT_GIVEN, + filters: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + metrics: str | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + sort: str | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DNSDNSAnalyticsAPIReport: + """ + Retrieves a list of summarised aggregate metrics over a given time period. + + See + [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) + for detailed information about the available query parameters. + + Args: + zone_id: Identifier + + dimensions: A comma-separated list of dimensions to group results by. + + filters: Segmentation filter in 'attribute operator value' format. + + limit: Limit number of returned metrics. + + metrics: A comma-separated list of metrics to query. + + since: Start date and time of requesting data period in ISO 8601 format. + + sort: A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + + until: End date and time of requesting data period in ISO 8601 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._get( + f"/zones/{zone_id}/dns_analytics/report", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "dimensions": dimensions, + "filters": filters, + "limit": limit, + "metrics": metrics, + "since": since, + "sort": sort, + "until": until, + }, + report_get_params.ReportGetParams, + ), + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[DNSDNSAnalyticsAPIReport], ResultWrapper[DNSDNSAnalyticsAPIReport]), + ) + + +class ReportsWithRawResponse: + def __init__(self, reports: Reports) -> None: + self._reports = reports + + self.get = to_raw_response_wrapper( + reports.get, + ) + + @cached_property + def bytimes(self) -> BytimesWithRawResponse: + return BytimesWithRawResponse(self._reports.bytimes) + + +class AsyncReportsWithRawResponse: + def __init__(self, reports: AsyncReports) -> None: + self._reports = reports + + self.get = async_to_raw_response_wrapper( + reports.get, + ) + + @cached_property + def bytimes(self) -> AsyncBytimesWithRawResponse: + return AsyncBytimesWithRawResponse(self._reports.bytimes) + + +class ReportsWithStreamingResponse: + def __init__(self, reports: Reports) -> None: + self._reports = reports + + self.get = to_streamed_response_wrapper( + reports.get, + ) + + @cached_property + def bytimes(self) -> BytimesWithStreamingResponse: + return BytimesWithStreamingResponse(self._reports.bytimes) + + +class AsyncReportsWithStreamingResponse: + def __init__(self, reports: AsyncReports) -> None: + self._reports = reports + + self.get = async_to_streamed_response_wrapper( + reports.get, + ) + + @cached_property + def bytimes(self) -> AsyncBytimesWithStreamingResponse: + return AsyncBytimesWithStreamingResponse(self._reports.bytimes) diff --git a/src/cloudflare/resources/dns/dns.py b/src/cloudflare/resources/dns/dns.py index 65d86fb1f4b..9107057d3d0 100644 --- a/src/cloudflare/resources/dns/dns.py +++ b/src/cloudflare/resources/dns/dns.py @@ -19,8 +19,17 @@ AsyncFirewallWithStreamingResponse, ) from ..._compat import cached_property +from .analytics import ( + Analytics, + AsyncAnalytics, + AnalyticsWithRawResponse, + AsyncAnalyticsWithRawResponse, + AnalyticsWithStreamingResponse, + AsyncAnalyticsWithStreamingResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource from .firewall.firewall import Firewall, AsyncFirewall +from .analytics.analytics import Analytics, AsyncAnalytics __all__ = ["DNS", "AsyncDNS"] @@ -30,6 +39,10 @@ class DNS(SyncAPIResource): def records(self) -> Records: return Records(self._client) + @cached_property + def analytics(self) -> Analytics: + return Analytics(self._client) + @cached_property def firewall(self) -> Firewall: return Firewall(self._client) @@ -48,6 +61,10 @@ class AsyncDNS(AsyncAPIResource): def records(self) -> AsyncRecords: return AsyncRecords(self._client) + @cached_property + def analytics(self) -> AsyncAnalytics: + return AsyncAnalytics(self._client) + @cached_property def firewall(self) -> AsyncFirewall: return AsyncFirewall(self._client) @@ -69,6 +86,10 @@ def __init__(self, dns: DNS) -> None: def records(self) -> RecordsWithRawResponse: return RecordsWithRawResponse(self._dns.records) + @cached_property + def analytics(self) -> AnalyticsWithRawResponse: + return AnalyticsWithRawResponse(self._dns.analytics) + @cached_property def firewall(self) -> FirewallWithRawResponse: return FirewallWithRawResponse(self._dns.firewall) @@ -82,6 +103,10 @@ def __init__(self, dns: AsyncDNS) -> None: def records(self) -> AsyncRecordsWithRawResponse: return AsyncRecordsWithRawResponse(self._dns.records) + @cached_property + def analytics(self) -> AsyncAnalyticsWithRawResponse: + return AsyncAnalyticsWithRawResponse(self._dns.analytics) + @cached_property def firewall(self) -> AsyncFirewallWithRawResponse: return AsyncFirewallWithRawResponse(self._dns.firewall) @@ -95,6 +120,10 @@ def __init__(self, dns: DNS) -> None: def records(self) -> RecordsWithStreamingResponse: return RecordsWithStreamingResponse(self._dns.records) + @cached_property + def analytics(self) -> AnalyticsWithStreamingResponse: + return AnalyticsWithStreamingResponse(self._dns.analytics) + @cached_property def firewall(self) -> FirewallWithStreamingResponse: return FirewallWithStreamingResponse(self._dns.firewall) @@ -108,6 +137,10 @@ def __init__(self, dns: AsyncDNS) -> None: def records(self) -> AsyncRecordsWithStreamingResponse: return AsyncRecordsWithStreamingResponse(self._dns.records) + @cached_property + def analytics(self) -> AsyncAnalyticsWithStreamingResponse: + return AsyncAnalyticsWithStreamingResponse(self._dns.analytics) + @cached_property def firewall(self) -> AsyncFirewallWithStreamingResponse: return AsyncFirewallWithStreamingResponse(self._dns.firewall) diff --git a/src/cloudflare/resources/dns/firewall/__init__.py b/src/cloudflare/resources/dns/firewall/__init__.py index 5aae845c03f..f2d282ba943 100644 --- a/src/cloudflare/resources/dns/firewall/__init__.py +++ b/src/cloudflare/resources/dns/firewall/__init__.py @@ -8,8 +8,22 @@ FirewallWithStreamingResponse, AsyncFirewallWithStreamingResponse, ) +from .analytics import ( + Analytics, + AsyncAnalytics, + AnalyticsWithRawResponse, + AsyncAnalyticsWithRawResponse, + AnalyticsWithStreamingResponse, + AsyncAnalyticsWithStreamingResponse, +) __all__ = [ + "Analytics", + "AsyncAnalytics", + "AnalyticsWithRawResponse", + "AsyncAnalyticsWithRawResponse", + "AnalyticsWithStreamingResponse", + "AsyncAnalyticsWithStreamingResponse", "Firewall", "AsyncFirewall", "FirewallWithRawResponse", diff --git a/src/cloudflare/resources/dns/firewall/analytics/__init__.py b/src/cloudflare/resources/dns/firewall/analytics/__init__.py new file mode 100644 index 00000000000..15d7a4bfd5f --- /dev/null +++ b/src/cloudflare/resources/dns/firewall/analytics/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .reports import ( + Reports, + AsyncReports, + ReportsWithRawResponse, + AsyncReportsWithRawResponse, + ReportsWithStreamingResponse, + AsyncReportsWithStreamingResponse, +) +from .analytics import ( + Analytics, + AsyncAnalytics, + AnalyticsWithRawResponse, + AsyncAnalyticsWithRawResponse, + AnalyticsWithStreamingResponse, + AsyncAnalyticsWithStreamingResponse, +) + +__all__ = [ + "Reports", + "AsyncReports", + "ReportsWithRawResponse", + "AsyncReportsWithRawResponse", + "ReportsWithStreamingResponse", + "AsyncReportsWithStreamingResponse", + "Analytics", + "AsyncAnalytics", + "AnalyticsWithRawResponse", + "AsyncAnalyticsWithRawResponse", + "AnalyticsWithStreamingResponse", + "AsyncAnalyticsWithStreamingResponse", +] diff --git a/src/cloudflare/resources/dns/firewall/analytics/analytics.py b/src/cloudflare/resources/dns/firewall/analytics/analytics.py new file mode 100644 index 00000000000..4b98a9d710d --- /dev/null +++ b/src/cloudflare/resources/dns/firewall/analytics/analytics.py @@ -0,0 +1,81 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .reports import ( + Reports, + AsyncReports, + ReportsWithRawResponse, + AsyncReportsWithRawResponse, + ReportsWithStreamingResponse, + AsyncReportsWithStreamingResponse, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from .reports.reports import Reports, AsyncReports + +__all__ = ["Analytics", "AsyncAnalytics"] + + +class Analytics(SyncAPIResource): + @cached_property + def reports(self) -> Reports: + return Reports(self._client) + + @cached_property + def with_raw_response(self) -> AnalyticsWithRawResponse: + return AnalyticsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AnalyticsWithStreamingResponse: + return AnalyticsWithStreamingResponse(self) + + +class AsyncAnalytics(AsyncAPIResource): + @cached_property + def reports(self) -> AsyncReports: + return AsyncReports(self._client) + + @cached_property + def with_raw_response(self) -> AsyncAnalyticsWithRawResponse: + return AsyncAnalyticsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAnalyticsWithStreamingResponse: + return AsyncAnalyticsWithStreamingResponse(self) + + +class AnalyticsWithRawResponse: + def __init__(self, analytics: Analytics) -> None: + self._analytics = analytics + + @cached_property + def reports(self) -> ReportsWithRawResponse: + return ReportsWithRawResponse(self._analytics.reports) + + +class AsyncAnalyticsWithRawResponse: + def __init__(self, analytics: AsyncAnalytics) -> None: + self._analytics = analytics + + @cached_property + def reports(self) -> AsyncReportsWithRawResponse: + return AsyncReportsWithRawResponse(self._analytics.reports) + + +class AnalyticsWithStreamingResponse: + def __init__(self, analytics: Analytics) -> None: + self._analytics = analytics + + @cached_property + def reports(self) -> ReportsWithStreamingResponse: + return ReportsWithStreamingResponse(self._analytics.reports) + + +class AsyncAnalyticsWithStreamingResponse: + def __init__(self, analytics: AsyncAnalytics) -> None: + self._analytics = analytics + + @cached_property + def reports(self) -> AsyncReportsWithStreamingResponse: + return AsyncReportsWithStreamingResponse(self._analytics.reports) diff --git a/src/cloudflare/resources/dns/firewall/analytics/reports/__init__.py b/src/cloudflare/resources/dns/firewall/analytics/reports/__init__.py new file mode 100644 index 00000000000..863e89438cf --- /dev/null +++ b/src/cloudflare/resources/dns/firewall/analytics/reports/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .bytimes import ( + Bytimes, + AsyncBytimes, + BytimesWithRawResponse, + AsyncBytimesWithRawResponse, + BytimesWithStreamingResponse, + AsyncBytimesWithStreamingResponse, +) +from .reports import ( + Reports, + AsyncReports, + ReportsWithRawResponse, + AsyncReportsWithRawResponse, + ReportsWithStreamingResponse, + AsyncReportsWithStreamingResponse, +) + +__all__ = [ + "Bytimes", + "AsyncBytimes", + "BytimesWithRawResponse", + "AsyncBytimesWithRawResponse", + "BytimesWithStreamingResponse", + "AsyncBytimesWithStreamingResponse", + "Reports", + "AsyncReports", + "ReportsWithRawResponse", + "AsyncReportsWithRawResponse", + "ReportsWithStreamingResponse", + "AsyncReportsWithStreamingResponse", +] diff --git a/src/cloudflare/resources/dns/firewall/analytics/reports/bytimes.py b/src/cloudflare/resources/dns/firewall/analytics/reports/bytimes.py new file mode 100644 index 00000000000..49da0f978c8 --- /dev/null +++ b/src/cloudflare/resources/dns/firewall/analytics/reports/bytimes.py @@ -0,0 +1,261 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Union, cast +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( + maybe_transform, + async_maybe_transform, +) +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from ......_base_client import ( + make_request_options, +) +from ......types.dns.analytics.reports import DNSDNSAnalyticsAPIReportBytime +from ......types.dns.firewall.analytics.reports import bytime_get_params + +__all__ = ["Bytimes", "AsyncBytimes"] + + +class Bytimes(SyncAPIResource): + @cached_property + def with_raw_response(self) -> BytimesWithRawResponse: + return BytimesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BytimesWithStreamingResponse: + return BytimesWithStreamingResponse(self) + + def get( + self, + dns_firewall_id: str, + *, + account_id: str, + dimensions: str | NotGiven = NOT_GIVEN, + filters: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + metrics: str | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + sort: str | NotGiven = NOT_GIVEN, + time_delta: Literal["all", "auto", "year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"] + | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DNSDNSAnalyticsAPIReportBytime: + """ + Retrieves a list of aggregate metrics grouped by time interval. + + See + [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) + for detailed information about the available query parameters. + + Args: + account_id: Identifier + + dns_firewall_id: Identifier + + dimensions: A comma-separated list of dimensions to group results by. + + filters: Segmentation filter in 'attribute operator value' format. + + limit: Limit number of returned metrics. + + metrics: A comma-separated list of metrics to query. + + since: Start date and time of requesting data period in ISO 8601 format. + + sort: A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + + time_delta: Unit of time to group data by. + + until: End date and time of requesting data period in ISO 8601 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not dns_firewall_id: + raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") + return self._get( + f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report/bytime", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dimensions": dimensions, + "filters": filters, + "limit": limit, + "metrics": metrics, + "since": since, + "sort": sort, + "time_delta": time_delta, + "until": until, + }, + bytime_get_params.BytimeGetParams, + ), + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[DNSDNSAnalyticsAPIReportBytime], ResultWrapper[DNSDNSAnalyticsAPIReportBytime]), + ) + + +class AsyncBytimes(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncBytimesWithRawResponse: + return AsyncBytimesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBytimesWithStreamingResponse: + return AsyncBytimesWithStreamingResponse(self) + + async def get( + self, + dns_firewall_id: str, + *, + account_id: str, + dimensions: str | NotGiven = NOT_GIVEN, + filters: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + metrics: str | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + sort: str | NotGiven = NOT_GIVEN, + time_delta: Literal["all", "auto", "year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"] + | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DNSDNSAnalyticsAPIReportBytime: + """ + Retrieves a list of aggregate metrics grouped by time interval. + + See + [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) + for detailed information about the available query parameters. + + Args: + account_id: Identifier + + dns_firewall_id: Identifier + + dimensions: A comma-separated list of dimensions to group results by. + + filters: Segmentation filter in 'attribute operator value' format. + + limit: Limit number of returned metrics. + + metrics: A comma-separated list of metrics to query. + + since: Start date and time of requesting data period in ISO 8601 format. + + sort: A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + + time_delta: Unit of time to group data by. + + until: End date and time of requesting data period in ISO 8601 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not dns_firewall_id: + raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") + return await self._get( + f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report/bytime", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "dimensions": dimensions, + "filters": filters, + "limit": limit, + "metrics": metrics, + "since": since, + "sort": sort, + "time_delta": time_delta, + "until": until, + }, + bytime_get_params.BytimeGetParams, + ), + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[DNSDNSAnalyticsAPIReportBytime], ResultWrapper[DNSDNSAnalyticsAPIReportBytime]), + ) + + +class BytimesWithRawResponse: + def __init__(self, bytimes: Bytimes) -> None: + self._bytimes = bytimes + + self.get = to_raw_response_wrapper( + bytimes.get, + ) + + +class AsyncBytimesWithRawResponse: + def __init__(self, bytimes: AsyncBytimes) -> None: + self._bytimes = bytimes + + self.get = async_to_raw_response_wrapper( + bytimes.get, + ) + + +class BytimesWithStreamingResponse: + def __init__(self, bytimes: Bytimes) -> None: + self._bytimes = bytimes + + self.get = to_streamed_response_wrapper( + bytimes.get, + ) + + +class AsyncBytimesWithStreamingResponse: + def __init__(self, bytimes: AsyncBytimes) -> None: + self._bytimes = bytimes + + self.get = async_to_streamed_response_wrapper( + bytimes.get, + ) diff --git a/src/cloudflare/resources/dns/firewall/analytics/reports/reports.py b/src/cloudflare/resources/dns/firewall/analytics/reports/reports.py new file mode 100644 index 00000000000..91b41572e94 --- /dev/null +++ b/src/cloudflare/resources/dns/firewall/analytics/reports/reports.py @@ -0,0 +1,282 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Union, cast +from datetime import datetime + +import httpx + +from .bytimes import ( + Bytimes, + AsyncBytimes, + BytimesWithRawResponse, + AsyncBytimesWithRawResponse, + BytimesWithStreamingResponse, + AsyncBytimesWithStreamingResponse, +) +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( + maybe_transform, + async_maybe_transform, +) +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from ......_base_client import ( + make_request_options, +) +from ......types.dns.analytics import DNSDNSAnalyticsAPIReport +from ......types.dns.firewall.analytics import report_get_params + +__all__ = ["Reports", "AsyncReports"] + + +class Reports(SyncAPIResource): + @cached_property + def bytimes(self) -> Bytimes: + return Bytimes(self._client) + + @cached_property + def with_raw_response(self) -> ReportsWithRawResponse: + return ReportsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ReportsWithStreamingResponse: + return ReportsWithStreamingResponse(self) + + def get( + self, + dns_firewall_id: str, + *, + account_id: str, + dimensions: str | NotGiven = NOT_GIVEN, + filters: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + metrics: str | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + sort: str | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DNSDNSAnalyticsAPIReport: + """ + Retrieves a list of summarised aggregate metrics over a given time period. + + See + [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) + for detailed information about the available query parameters. + + Args: + account_id: Identifier + + dns_firewall_id: Identifier + + dimensions: A comma-separated list of dimensions to group results by. + + filters: Segmentation filter in 'attribute operator value' format. + + limit: Limit number of returned metrics. + + metrics: A comma-separated list of metrics to query. + + since: Start date and time of requesting data period in ISO 8601 format. + + sort: A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + + until: End date and time of requesting data period in ISO 8601 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not dns_firewall_id: + raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") + return self._get( + f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dimensions": dimensions, + "filters": filters, + "limit": limit, + "metrics": metrics, + "since": since, + "sort": sort, + "until": until, + }, + report_get_params.ReportGetParams, + ), + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[DNSDNSAnalyticsAPIReport], ResultWrapper[DNSDNSAnalyticsAPIReport]), + ) + + +class AsyncReports(AsyncAPIResource): + @cached_property + def bytimes(self) -> AsyncBytimes: + return AsyncBytimes(self._client) + + @cached_property + def with_raw_response(self) -> AsyncReportsWithRawResponse: + return AsyncReportsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncReportsWithStreamingResponse: + return AsyncReportsWithStreamingResponse(self) + + async def get( + self, + dns_firewall_id: str, + *, + account_id: str, + dimensions: str | NotGiven = NOT_GIVEN, + filters: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + metrics: str | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + sort: str | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DNSDNSAnalyticsAPIReport: + """ + Retrieves a list of summarised aggregate metrics over a given time period. + + See + [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) + for detailed information about the available query parameters. + + Args: + account_id: Identifier + + dns_firewall_id: Identifier + + dimensions: A comma-separated list of dimensions to group results by. + + filters: Segmentation filter in 'attribute operator value' format. + + limit: Limit number of returned metrics. + + metrics: A comma-separated list of metrics to query. + + since: Start date and time of requesting data period in ISO 8601 format. + + sort: A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + + until: End date and time of requesting data period in ISO 8601 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not dns_firewall_id: + raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") + return await self._get( + f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "dimensions": dimensions, + "filters": filters, + "limit": limit, + "metrics": metrics, + "since": since, + "sort": sort, + "until": until, + }, + report_get_params.ReportGetParams, + ), + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[DNSDNSAnalyticsAPIReport], ResultWrapper[DNSDNSAnalyticsAPIReport]), + ) + + +class ReportsWithRawResponse: + def __init__(self, reports: Reports) -> None: + self._reports = reports + + self.get = to_raw_response_wrapper( + reports.get, + ) + + @cached_property + def bytimes(self) -> BytimesWithRawResponse: + return BytimesWithRawResponse(self._reports.bytimes) + + +class AsyncReportsWithRawResponse: + def __init__(self, reports: AsyncReports) -> None: + self._reports = reports + + self.get = async_to_raw_response_wrapper( + reports.get, + ) + + @cached_property + def bytimes(self) -> AsyncBytimesWithRawResponse: + return AsyncBytimesWithRawResponse(self._reports.bytimes) + + +class ReportsWithStreamingResponse: + def __init__(self, reports: Reports) -> None: + self._reports = reports + + self.get = to_streamed_response_wrapper( + reports.get, + ) + + @cached_property + def bytimes(self) -> BytimesWithStreamingResponse: + return BytimesWithStreamingResponse(self._reports.bytimes) + + +class AsyncReportsWithStreamingResponse: + def __init__(self, reports: AsyncReports) -> None: + self._reports = reports + + self.get = async_to_streamed_response_wrapper( + reports.get, + ) + + @cached_property + def bytimes(self) -> AsyncBytimesWithStreamingResponse: + return AsyncBytimesWithStreamingResponse(self._reports.bytimes) diff --git a/src/cloudflare/resources/dns/firewall/firewall.py b/src/cloudflare/resources/dns/firewall/firewall.py index 0351532d9d5..4071da419ee 100644 --- a/src/cloudflare/resources/dns/firewall/firewall.py +++ b/src/cloudflare/resources/dns/firewall/firewall.py @@ -11,6 +11,14 @@ maybe_transform, async_maybe_transform, ) +from .analytics import ( + Analytics, + AsyncAnalytics, + AnalyticsWithRawResponse, + AsyncAnalyticsWithRawResponse, + AnalyticsWithStreamingResponse, + AsyncAnalyticsWithStreamingResponse, +) from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -32,11 +40,16 @@ AsyncPaginator, make_request_options, ) +from .analytics.analytics import Analytics, AsyncAnalytics __all__ = ["Firewall", "AsyncFirewall"] class Firewall(SyncAPIResource): + @cached_property + def analytics(self) -> Analytics: + return Analytics(self._client) + @cached_property def with_raw_response(self) -> FirewallWithRawResponse: return FirewallWithRawResponse(self) @@ -370,6 +383,10 @@ def get( class AsyncFirewall(AsyncAPIResource): + @cached_property + def analytics(self) -> AsyncAnalytics: + return AsyncAnalytics(self._client) + @cached_property def with_raw_response(self) -> AsyncFirewallWithRawResponse: return AsyncFirewallWithRawResponse(self) @@ -722,6 +739,10 @@ def __init__(self, firewall: Firewall) -> None: firewall.get, ) + @cached_property + def analytics(self) -> AnalyticsWithRawResponse: + return AnalyticsWithRawResponse(self._firewall.analytics) + class AsyncFirewallWithRawResponse: def __init__(self, firewall: AsyncFirewall) -> None: @@ -743,6 +764,10 @@ def __init__(self, firewall: AsyncFirewall) -> None: firewall.get, ) + @cached_property + def analytics(self) -> AsyncAnalyticsWithRawResponse: + return AsyncAnalyticsWithRawResponse(self._firewall.analytics) + class FirewallWithStreamingResponse: def __init__(self, firewall: Firewall) -> None: @@ -764,6 +789,10 @@ def __init__(self, firewall: Firewall) -> None: firewall.get, ) + @cached_property + def analytics(self) -> AnalyticsWithStreamingResponse: + return AnalyticsWithStreamingResponse(self._firewall.analytics) + class AsyncFirewallWithStreamingResponse: def __init__(self, firewall: AsyncFirewall) -> None: @@ -784,3 +813,7 @@ def __init__(self, firewall: AsyncFirewall) -> None: self.get = async_to_streamed_response_wrapper( firewall.get, ) + + @cached_property + def analytics(self) -> AsyncAnalyticsWithStreamingResponse: + return AsyncAnalyticsWithStreamingResponse(self._firewall.analytics) diff --git a/src/cloudflare/resources/healthchecks/__init__.py b/src/cloudflare/resources/healthchecks/__init__.py new file mode 100644 index 00000000000..3587bef8b68 --- /dev/null +++ b/src/cloudflare/resources/healthchecks/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .previews import ( + Previews, + AsyncPreviews, + PreviewsWithRawResponse, + AsyncPreviewsWithRawResponse, + PreviewsWithStreamingResponse, + AsyncPreviewsWithStreamingResponse, +) +from .healthchecks import ( + Healthchecks, + AsyncHealthchecks, + HealthchecksWithRawResponse, + AsyncHealthchecksWithRawResponse, + HealthchecksWithStreamingResponse, + AsyncHealthchecksWithStreamingResponse, +) + +__all__ = [ + "Previews", + "AsyncPreviews", + "PreviewsWithRawResponse", + "AsyncPreviewsWithRawResponse", + "PreviewsWithStreamingResponse", + "AsyncPreviewsWithStreamingResponse", + "Healthchecks", + "AsyncHealthchecks", + "HealthchecksWithRawResponse", + "AsyncHealthchecksWithRawResponse", + "HealthchecksWithStreamingResponse", + "AsyncHealthchecksWithStreamingResponse", +] diff --git a/src/cloudflare/resources/healthchecks/healthchecks.py b/src/cloudflare/resources/healthchecks/healthchecks.py new file mode 100644 index 00000000000..8c7b6640746 --- /dev/null +++ b/src/cloudflare/resources/healthchecks/healthchecks.py @@ -0,0 +1,1202 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Optional, cast +from typing_extensions import Literal + +import httpx + +from ...types import ( + HealthcheckListResponse, + HealthchecksHealthchecks, + HealthcheckDeleteResponse, + healthcheck_edit_params, + healthcheck_create_params, + healthcheck_update_params, +) +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from .previews import ( + Previews, + AsyncPreviews, + PreviewsWithRawResponse, + AsyncPreviewsWithRawResponse, + PreviewsWithStreamingResponse, + AsyncPreviewsWithStreamingResponse, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) + +__all__ = ["Healthchecks", "AsyncHealthchecks"] + + +class Healthchecks(SyncAPIResource): + @cached_property + def previews(self) -> Previews: + return Previews(self._client) + + @cached_property + def with_raw_response(self) -> HealthchecksWithRawResponse: + return HealthchecksWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> HealthchecksWithStreamingResponse: + return HealthchecksWithStreamingResponse(self) + + def create( + self, + *, + zone_id: str, + address: str, + name: str, + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + | NotGiven = NOT_GIVEN, + consecutive_fails: int | NotGiven = NOT_GIVEN, + consecutive_successes: int | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + http_config: Optional[healthcheck_create_params.HTTPConfig] | NotGiven = NOT_GIVEN, + interval: int | NotGiven = NOT_GIVEN, + retries: int | NotGiven = NOT_GIVEN, + suspended: bool | NotGiven = NOT_GIVEN, + tcp_config: Optional[healthcheck_create_params.TcpConfig] | NotGiven = NOT_GIVEN, + healthcheck_timeout: int | NotGiven = NOT_GIVEN, + type: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Create a new health check. + + Args: + zone_id: Identifier + + address: The hostname or IP address of the origin server to run health checks on. + + name: A short name to identify the health check. Only alphanumeric characters, hyphens + and underscores are allowed. + + check_regions: A list of regions from which to run health checks. Null means Cloudflare will + pick a default region. + + consecutive_fails: The number of consecutive fails required from a health check before changing the + health to unhealthy. + + consecutive_successes: The number of consecutive successes required from a health check before changing + the health to healthy. + + description: A human-readable description of the health check. + + http_config: Parameters specific to an HTTP or HTTPS health check. + + interval: The interval between each health check. Shorter intervals may give quicker + notifications if the origin status changes, but will increase load on the origin + as we check from multiple locations. + + retries: The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + + suspended: If suspended, no health checks are sent to the origin. + + tcp_config: Parameters specific to TCP health check. + + healthcheck_timeout: The timeout (in seconds) before marking the health check as failed. + + type: The protocol to use for the health check. Currently supported protocols are + 'HTTP', 'HTTPS' and 'TCP'. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._post( + f"/zones/{zone_id}/healthchecks", + body=maybe_transform( + { + "address": address, + "name": name, + "check_regions": check_regions, + "consecutive_fails": consecutive_fails, + "consecutive_successes": consecutive_successes, + "description": description, + "http_config": http_config, + "interval": interval, + "retries": retries, + "suspended": suspended, + "tcp_config": tcp_config, + "timeout": healthcheck_timeout, + "type": type, + }, + healthcheck_create_params.HealthcheckCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + def update( + self, + healthcheck_id: str, + *, + zone_id: str, + address: str, + name: str, + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + | NotGiven = NOT_GIVEN, + consecutive_fails: int | NotGiven = NOT_GIVEN, + consecutive_successes: int | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + http_config: Optional[healthcheck_update_params.HTTPConfig] | NotGiven = NOT_GIVEN, + interval: int | NotGiven = NOT_GIVEN, + retries: int | NotGiven = NOT_GIVEN, + suspended: bool | NotGiven = NOT_GIVEN, + tcp_config: Optional[healthcheck_update_params.TcpConfig] | NotGiven = NOT_GIVEN, + healthcheck_timeout: int | NotGiven = NOT_GIVEN, + type: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Update a configured health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + address: The hostname or IP address of the origin server to run health checks on. + + name: A short name to identify the health check. Only alphanumeric characters, hyphens + and underscores are allowed. + + check_regions: A list of regions from which to run health checks. Null means Cloudflare will + pick a default region. + + consecutive_fails: The number of consecutive fails required from a health check before changing the + health to unhealthy. + + consecutive_successes: The number of consecutive successes required from a health check before changing + the health to healthy. + + description: A human-readable description of the health check. + + http_config: Parameters specific to an HTTP or HTTPS health check. + + interval: The interval between each health check. Shorter intervals may give quicker + notifications if the origin status changes, but will increase load on the origin + as we check from multiple locations. + + retries: The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + + suspended: If suspended, no health checks are sent to the origin. + + tcp_config: Parameters specific to TCP health check. + + healthcheck_timeout: The timeout (in seconds) before marking the health check as failed. + + type: The protocol to use for the health check. Currently supported protocols are + 'HTTP', 'HTTPS' and 'TCP'. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return self._put( + f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + body=maybe_transform( + { + "address": address, + "name": name, + "check_regions": check_regions, + "consecutive_fails": consecutive_fails, + "consecutive_successes": consecutive_successes, + "description": description, + "http_config": http_config, + "interval": interval, + "retries": retries, + "suspended": suspended, + "tcp_config": tcp_config, + "timeout": healthcheck_timeout, + "type": type, + }, + healthcheck_update_params.HealthcheckUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + def list( + self, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[HealthcheckListResponse]: + """ + List configured health checks. + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get( + f"/zones/{zone_id}/healthchecks", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[Optional[HealthcheckListResponse]], ResultWrapper[HealthcheckListResponse]), + ) + + def delete( + self, + healthcheck_id: str, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthcheckDeleteResponse: + """ + Delete a health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return self._delete( + f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthcheckDeleteResponse], ResultWrapper[HealthcheckDeleteResponse]), + ) + + def edit( + self, + healthcheck_id: str, + *, + zone_id: str, + address: str, + name: str, + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + | NotGiven = NOT_GIVEN, + consecutive_fails: int | NotGiven = NOT_GIVEN, + consecutive_successes: int | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + http_config: Optional[healthcheck_edit_params.HTTPConfig] | NotGiven = NOT_GIVEN, + interval: int | NotGiven = NOT_GIVEN, + retries: int | NotGiven = NOT_GIVEN, + suspended: bool | NotGiven = NOT_GIVEN, + tcp_config: Optional[healthcheck_edit_params.TcpConfig] | NotGiven = NOT_GIVEN, + healthcheck_timeout: int | NotGiven = NOT_GIVEN, + type: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Patch a configured health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + address: The hostname or IP address of the origin server to run health checks on. + + name: A short name to identify the health check. Only alphanumeric characters, hyphens + and underscores are allowed. + + check_regions: A list of regions from which to run health checks. Null means Cloudflare will + pick a default region. + + consecutive_fails: The number of consecutive fails required from a health check before changing the + health to unhealthy. + + consecutive_successes: The number of consecutive successes required from a health check before changing + the health to healthy. + + description: A human-readable description of the health check. + + http_config: Parameters specific to an HTTP or HTTPS health check. + + interval: The interval between each health check. Shorter intervals may give quicker + notifications if the origin status changes, but will increase load on the origin + as we check from multiple locations. + + retries: The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + + suspended: If suspended, no health checks are sent to the origin. + + tcp_config: Parameters specific to TCP health check. + + healthcheck_timeout: The timeout (in seconds) before marking the health check as failed. + + type: The protocol to use for the health check. Currently supported protocols are + 'HTTP', 'HTTPS' and 'TCP'. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return self._patch( + f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + body=maybe_transform( + { + "address": address, + "name": name, + "check_regions": check_regions, + "consecutive_fails": consecutive_fails, + "consecutive_successes": consecutive_successes, + "description": description, + "http_config": http_config, + "interval": interval, + "retries": retries, + "suspended": suspended, + "tcp_config": tcp_config, + "timeout": healthcheck_timeout, + "type": type, + }, + healthcheck_edit_params.HealthcheckEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + def get( + self, + healthcheck_id: str, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Fetch a single configured health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return self._get( + f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + +class AsyncHealthchecks(AsyncAPIResource): + @cached_property + def previews(self) -> AsyncPreviews: + return AsyncPreviews(self._client) + + @cached_property + def with_raw_response(self) -> AsyncHealthchecksWithRawResponse: + return AsyncHealthchecksWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncHealthchecksWithStreamingResponse: + return AsyncHealthchecksWithStreamingResponse(self) + + async def create( + self, + *, + zone_id: str, + address: str, + name: str, + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + | NotGiven = NOT_GIVEN, + consecutive_fails: int | NotGiven = NOT_GIVEN, + consecutive_successes: int | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + http_config: Optional[healthcheck_create_params.HTTPConfig] | NotGiven = NOT_GIVEN, + interval: int | NotGiven = NOT_GIVEN, + retries: int | NotGiven = NOT_GIVEN, + suspended: bool | NotGiven = NOT_GIVEN, + tcp_config: Optional[healthcheck_create_params.TcpConfig] | NotGiven = NOT_GIVEN, + healthcheck_timeout: int | NotGiven = NOT_GIVEN, + type: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Create a new health check. + + Args: + zone_id: Identifier + + address: The hostname or IP address of the origin server to run health checks on. + + name: A short name to identify the health check. Only alphanumeric characters, hyphens + and underscores are allowed. + + check_regions: A list of regions from which to run health checks. Null means Cloudflare will + pick a default region. + + consecutive_fails: The number of consecutive fails required from a health check before changing the + health to unhealthy. + + consecutive_successes: The number of consecutive successes required from a health check before changing + the health to healthy. + + description: A human-readable description of the health check. + + http_config: Parameters specific to an HTTP or HTTPS health check. + + interval: The interval between each health check. Shorter intervals may give quicker + notifications if the origin status changes, but will increase load on the origin + as we check from multiple locations. + + retries: The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + + suspended: If suspended, no health checks are sent to the origin. + + tcp_config: Parameters specific to TCP health check. + + healthcheck_timeout: The timeout (in seconds) before marking the health check as failed. + + type: The protocol to use for the health check. Currently supported protocols are + 'HTTP', 'HTTPS' and 'TCP'. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._post( + f"/zones/{zone_id}/healthchecks", + body=await async_maybe_transform( + { + "address": address, + "name": name, + "check_regions": check_regions, + "consecutive_fails": consecutive_fails, + "consecutive_successes": consecutive_successes, + "description": description, + "http_config": http_config, + "interval": interval, + "retries": retries, + "suspended": suspended, + "tcp_config": tcp_config, + "timeout": healthcheck_timeout, + "type": type, + }, + healthcheck_create_params.HealthcheckCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + async def update( + self, + healthcheck_id: str, + *, + zone_id: str, + address: str, + name: str, + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + | NotGiven = NOT_GIVEN, + consecutive_fails: int | NotGiven = NOT_GIVEN, + consecutive_successes: int | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + http_config: Optional[healthcheck_update_params.HTTPConfig] | NotGiven = NOT_GIVEN, + interval: int | NotGiven = NOT_GIVEN, + retries: int | NotGiven = NOT_GIVEN, + suspended: bool | NotGiven = NOT_GIVEN, + tcp_config: Optional[healthcheck_update_params.TcpConfig] | NotGiven = NOT_GIVEN, + healthcheck_timeout: int | NotGiven = NOT_GIVEN, + type: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Update a configured health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + address: The hostname or IP address of the origin server to run health checks on. + + name: A short name to identify the health check. Only alphanumeric characters, hyphens + and underscores are allowed. + + check_regions: A list of regions from which to run health checks. Null means Cloudflare will + pick a default region. + + consecutive_fails: The number of consecutive fails required from a health check before changing the + health to unhealthy. + + consecutive_successes: The number of consecutive successes required from a health check before changing + the health to healthy. + + description: A human-readable description of the health check. + + http_config: Parameters specific to an HTTP or HTTPS health check. + + interval: The interval between each health check. Shorter intervals may give quicker + notifications if the origin status changes, but will increase load on the origin + as we check from multiple locations. + + retries: The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + + suspended: If suspended, no health checks are sent to the origin. + + tcp_config: Parameters specific to TCP health check. + + healthcheck_timeout: The timeout (in seconds) before marking the health check as failed. + + type: The protocol to use for the health check. Currently supported protocols are + 'HTTP', 'HTTPS' and 'TCP'. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return await self._put( + f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + body=await async_maybe_transform( + { + "address": address, + "name": name, + "check_regions": check_regions, + "consecutive_fails": consecutive_fails, + "consecutive_successes": consecutive_successes, + "description": description, + "http_config": http_config, + "interval": interval, + "retries": retries, + "suspended": suspended, + "tcp_config": tcp_config, + "timeout": healthcheck_timeout, + "type": type, + }, + healthcheck_update_params.HealthcheckUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + async def list( + self, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[HealthcheckListResponse]: + """ + List configured health checks. + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._get( + f"/zones/{zone_id}/healthchecks", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[Optional[HealthcheckListResponse]], ResultWrapper[HealthcheckListResponse]), + ) + + async def delete( + self, + healthcheck_id: str, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthcheckDeleteResponse: + """ + Delete a health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return await self._delete( + f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthcheckDeleteResponse], ResultWrapper[HealthcheckDeleteResponse]), + ) + + async def edit( + self, + healthcheck_id: str, + *, + zone_id: str, + address: str, + name: str, + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + | NotGiven = NOT_GIVEN, + consecutive_fails: int | NotGiven = NOT_GIVEN, + consecutive_successes: int | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + http_config: Optional[healthcheck_edit_params.HTTPConfig] | NotGiven = NOT_GIVEN, + interval: int | NotGiven = NOT_GIVEN, + retries: int | NotGiven = NOT_GIVEN, + suspended: bool | NotGiven = NOT_GIVEN, + tcp_config: Optional[healthcheck_edit_params.TcpConfig] | NotGiven = NOT_GIVEN, + healthcheck_timeout: int | NotGiven = NOT_GIVEN, + type: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Patch a configured health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + address: The hostname or IP address of the origin server to run health checks on. + + name: A short name to identify the health check. Only alphanumeric characters, hyphens + and underscores are allowed. + + check_regions: A list of regions from which to run health checks. Null means Cloudflare will + pick a default region. + + consecutive_fails: The number of consecutive fails required from a health check before changing the + health to unhealthy. + + consecutive_successes: The number of consecutive successes required from a health check before changing + the health to healthy. + + description: A human-readable description of the health check. + + http_config: Parameters specific to an HTTP or HTTPS health check. + + interval: The interval between each health check. Shorter intervals may give quicker + notifications if the origin status changes, but will increase load on the origin + as we check from multiple locations. + + retries: The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + + suspended: If suspended, no health checks are sent to the origin. + + tcp_config: Parameters specific to TCP health check. + + healthcheck_timeout: The timeout (in seconds) before marking the health check as failed. + + type: The protocol to use for the health check. Currently supported protocols are + 'HTTP', 'HTTPS' and 'TCP'. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return await self._patch( + f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + body=await async_maybe_transform( + { + "address": address, + "name": name, + "check_regions": check_regions, + "consecutive_fails": consecutive_fails, + "consecutive_successes": consecutive_successes, + "description": description, + "http_config": http_config, + "interval": interval, + "retries": retries, + "suspended": suspended, + "tcp_config": tcp_config, + "timeout": healthcheck_timeout, + "type": type, + }, + healthcheck_edit_params.HealthcheckEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + async def get( + self, + healthcheck_id: str, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Fetch a single configured health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return await self._get( + f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + +class HealthchecksWithRawResponse: + def __init__(self, healthchecks: Healthchecks) -> None: + self._healthchecks = healthchecks + + self.create = to_raw_response_wrapper( + healthchecks.create, + ) + self.update = to_raw_response_wrapper( + healthchecks.update, + ) + self.list = to_raw_response_wrapper( + healthchecks.list, + ) + self.delete = to_raw_response_wrapper( + healthchecks.delete, + ) + self.edit = to_raw_response_wrapper( + healthchecks.edit, + ) + self.get = to_raw_response_wrapper( + healthchecks.get, + ) + + @cached_property + def previews(self) -> PreviewsWithRawResponse: + return PreviewsWithRawResponse(self._healthchecks.previews) + + +class AsyncHealthchecksWithRawResponse: + def __init__(self, healthchecks: AsyncHealthchecks) -> None: + self._healthchecks = healthchecks + + self.create = async_to_raw_response_wrapper( + healthchecks.create, + ) + self.update = async_to_raw_response_wrapper( + healthchecks.update, + ) + self.list = async_to_raw_response_wrapper( + healthchecks.list, + ) + self.delete = async_to_raw_response_wrapper( + healthchecks.delete, + ) + self.edit = async_to_raw_response_wrapper( + healthchecks.edit, + ) + self.get = async_to_raw_response_wrapper( + healthchecks.get, + ) + + @cached_property + def previews(self) -> AsyncPreviewsWithRawResponse: + return AsyncPreviewsWithRawResponse(self._healthchecks.previews) + + +class HealthchecksWithStreamingResponse: + def __init__(self, healthchecks: Healthchecks) -> None: + self._healthchecks = healthchecks + + self.create = to_streamed_response_wrapper( + healthchecks.create, + ) + self.update = to_streamed_response_wrapper( + healthchecks.update, + ) + self.list = to_streamed_response_wrapper( + healthchecks.list, + ) + self.delete = to_streamed_response_wrapper( + healthchecks.delete, + ) + self.edit = to_streamed_response_wrapper( + healthchecks.edit, + ) + self.get = to_streamed_response_wrapper( + healthchecks.get, + ) + + @cached_property + def previews(self) -> PreviewsWithStreamingResponse: + return PreviewsWithStreamingResponse(self._healthchecks.previews) + + +class AsyncHealthchecksWithStreamingResponse: + def __init__(self, healthchecks: AsyncHealthchecks) -> None: + self._healthchecks = healthchecks + + self.create = async_to_streamed_response_wrapper( + healthchecks.create, + ) + self.update = async_to_streamed_response_wrapper( + healthchecks.update, + ) + self.list = async_to_streamed_response_wrapper( + healthchecks.list, + ) + self.delete = async_to_streamed_response_wrapper( + healthchecks.delete, + ) + self.edit = async_to_streamed_response_wrapper( + healthchecks.edit, + ) + self.get = async_to_streamed_response_wrapper( + healthchecks.get, + ) + + @cached_property + def previews(self) -> AsyncPreviewsWithStreamingResponse: + return AsyncPreviewsWithStreamingResponse(self._healthchecks.previews) diff --git a/src/cloudflare/resources/healthchecks/previews.py b/src/cloudflare/resources/healthchecks/previews.py new file mode 100644 index 00000000000..a7350c837ec --- /dev/null +++ b/src/cloudflare/resources/healthchecks/previews.py @@ -0,0 +1,534 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Optional, cast +from typing_extensions import Literal + +import httpx + +from ...types import HealthchecksHealthchecks +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) +from ...types.healthchecks import PreviewDeleteResponse, preview_create_params + +__all__ = ["Previews", "AsyncPreviews"] + + +class Previews(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PreviewsWithRawResponse: + return PreviewsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PreviewsWithStreamingResponse: + return PreviewsWithStreamingResponse(self) + + def create( + self, + *, + zone_id: str, + address: str, + name: str, + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + | NotGiven = NOT_GIVEN, + consecutive_fails: int | NotGiven = NOT_GIVEN, + consecutive_successes: int | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + http_config: Optional[preview_create_params.HTTPConfig] | NotGiven = NOT_GIVEN, + interval: int | NotGiven = NOT_GIVEN, + retries: int | NotGiven = NOT_GIVEN, + suspended: bool | NotGiven = NOT_GIVEN, + tcp_config: Optional[preview_create_params.TcpConfig] | NotGiven = NOT_GIVEN, + healthcheck_timeout: int | NotGiven = NOT_GIVEN, + type: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Create a new preview health check. + + Args: + zone_id: Identifier + + address: The hostname or IP address of the origin server to run health checks on. + + name: A short name to identify the health check. Only alphanumeric characters, hyphens + and underscores are allowed. + + check_regions: A list of regions from which to run health checks. Null means Cloudflare will + pick a default region. + + consecutive_fails: The number of consecutive fails required from a health check before changing the + health to unhealthy. + + consecutive_successes: The number of consecutive successes required from a health check before changing + the health to healthy. + + description: A human-readable description of the health check. + + http_config: Parameters specific to an HTTP or HTTPS health check. + + interval: The interval between each health check. Shorter intervals may give quicker + notifications if the origin status changes, but will increase load on the origin + as we check from multiple locations. + + retries: The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + + suspended: If suspended, no health checks are sent to the origin. + + tcp_config: Parameters specific to TCP health check. + + healthcheck_timeout: The timeout (in seconds) before marking the health check as failed. + + type: The protocol to use for the health check. Currently supported protocols are + 'HTTP', 'HTTPS' and 'TCP'. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._post( + f"/zones/{zone_id}/healthchecks/preview", + body=maybe_transform( + { + "address": address, + "name": name, + "check_regions": check_regions, + "consecutive_fails": consecutive_fails, + "consecutive_successes": consecutive_successes, + "description": description, + "http_config": http_config, + "interval": interval, + "retries": retries, + "suspended": suspended, + "tcp_config": tcp_config, + "timeout": healthcheck_timeout, + "type": type, + }, + preview_create_params.PreviewCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + def delete( + self, + healthcheck_id: str, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> PreviewDeleteResponse: + """ + Delete a health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return self._delete( + f"/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[PreviewDeleteResponse], ResultWrapper[PreviewDeleteResponse]), + ) + + def get( + self, + healthcheck_id: str, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Fetch a single configured health check preview. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return self._get( + f"/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + +class AsyncPreviews(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPreviewsWithRawResponse: + return AsyncPreviewsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPreviewsWithStreamingResponse: + return AsyncPreviewsWithStreamingResponse(self) + + async def create( + self, + *, + zone_id: str, + address: str, + name: str, + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + | NotGiven = NOT_GIVEN, + consecutive_fails: int | NotGiven = NOT_GIVEN, + consecutive_successes: int | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + http_config: Optional[preview_create_params.HTTPConfig] | NotGiven = NOT_GIVEN, + interval: int | NotGiven = NOT_GIVEN, + retries: int | NotGiven = NOT_GIVEN, + suspended: bool | NotGiven = NOT_GIVEN, + tcp_config: Optional[preview_create_params.TcpConfig] | NotGiven = NOT_GIVEN, + healthcheck_timeout: int | NotGiven = NOT_GIVEN, + type: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Create a new preview health check. + + Args: + zone_id: Identifier + + address: The hostname or IP address of the origin server to run health checks on. + + name: A short name to identify the health check. Only alphanumeric characters, hyphens + and underscores are allowed. + + check_regions: A list of regions from which to run health checks. Null means Cloudflare will + pick a default region. + + consecutive_fails: The number of consecutive fails required from a health check before changing the + health to unhealthy. + + consecutive_successes: The number of consecutive successes required from a health check before changing + the health to healthy. + + description: A human-readable description of the health check. + + http_config: Parameters specific to an HTTP or HTTPS health check. + + interval: The interval between each health check. Shorter intervals may give quicker + notifications if the origin status changes, but will increase load on the origin + as we check from multiple locations. + + retries: The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + + suspended: If suspended, no health checks are sent to the origin. + + tcp_config: Parameters specific to TCP health check. + + healthcheck_timeout: The timeout (in seconds) before marking the health check as failed. + + type: The protocol to use for the health check. Currently supported protocols are + 'HTTP', 'HTTPS' and 'TCP'. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._post( + f"/zones/{zone_id}/healthchecks/preview", + body=await async_maybe_transform( + { + "address": address, + "name": name, + "check_regions": check_regions, + "consecutive_fails": consecutive_fails, + "consecutive_successes": consecutive_successes, + "description": description, + "http_config": http_config, + "interval": interval, + "retries": retries, + "suspended": suspended, + "tcp_config": tcp_config, + "timeout": healthcheck_timeout, + "type": type, + }, + preview_create_params.PreviewCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + async def delete( + self, + healthcheck_id: str, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> PreviewDeleteResponse: + """ + Delete a health check. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return await self._delete( + f"/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[PreviewDeleteResponse], ResultWrapper[PreviewDeleteResponse]), + ) + + async def get( + self, + healthcheck_id: str, + *, + zone_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> HealthchecksHealthchecks: + """ + Fetch a single configured health check preview. + + Args: + zone_id: Identifier + + healthcheck_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not healthcheck_id: + raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") + return await self._get( + f"/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[HealthchecksHealthchecks], ResultWrapper[HealthchecksHealthchecks]), + ) + + +class PreviewsWithRawResponse: + def __init__(self, previews: Previews) -> None: + self._previews = previews + + self.create = to_raw_response_wrapper( + previews.create, + ) + self.delete = to_raw_response_wrapper( + previews.delete, + ) + self.get = to_raw_response_wrapper( + previews.get, + ) + + +class AsyncPreviewsWithRawResponse: + def __init__(self, previews: AsyncPreviews) -> None: + self._previews = previews + + self.create = async_to_raw_response_wrapper( + previews.create, + ) + self.delete = async_to_raw_response_wrapper( + previews.delete, + ) + self.get = async_to_raw_response_wrapper( + previews.get, + ) + + +class PreviewsWithStreamingResponse: + def __init__(self, previews: Previews) -> None: + self._previews = previews + + self.create = to_streamed_response_wrapper( + previews.create, + ) + self.delete = to_streamed_response_wrapper( + previews.delete, + ) + self.get = to_streamed_response_wrapper( + previews.get, + ) + + +class AsyncPreviewsWithStreamingResponse: + def __init__(self, previews: AsyncPreviews) -> None: + self._previews = previews + + self.create = async_to_streamed_response_wrapper( + previews.create, + ) + self.delete = async_to_streamed_response_wrapper( + previews.delete, + ) + self.get = async_to_streamed_response_wrapper( + previews.get, + ) diff --git a/src/cloudflare/resources/magic_transit/__init__.py b/src/cloudflare/resources/magic_transit/__init__.py new file mode 100644 index 00000000000..e554d5d7620 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/__init__.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .sites import ( + Sites, + AsyncSites, + SitesWithRawResponse, + AsyncSitesWithRawResponse, + SitesWithStreamingResponse, + AsyncSitesWithStreamingResponse, +) +from .routes import ( + Routes, + AsyncRoutes, + RoutesWithRawResponse, + AsyncRoutesWithRawResponse, + RoutesWithStreamingResponse, + AsyncRoutesWithStreamingResponse, +) +from .gre_tunnels import ( + GRETunnels, + AsyncGRETunnels, + GRETunnelsWithRawResponse, + AsyncGRETunnelsWithRawResponse, + GRETunnelsWithStreamingResponse, + AsyncGRETunnelsWithStreamingResponse, +) +from .ipsec_tunnels import ( + IPSECTunnels, + AsyncIPSECTunnels, + IPSECTunnelsWithRawResponse, + AsyncIPSECTunnelsWithRawResponse, + IPSECTunnelsWithStreamingResponse, + AsyncIPSECTunnelsWithStreamingResponse, +) +from .magic_transit import ( + MagicTransit, + AsyncMagicTransit, + MagicTransitWithRawResponse, + AsyncMagicTransitWithRawResponse, + MagicTransitWithStreamingResponse, + AsyncMagicTransitWithStreamingResponse, +) +from .cf_interconnects import ( + CfInterconnects, + AsyncCfInterconnects, + CfInterconnectsWithRawResponse, + AsyncCfInterconnectsWithRawResponse, + CfInterconnectsWithStreamingResponse, + AsyncCfInterconnectsWithStreamingResponse, +) + +__all__ = [ + "CfInterconnects", + "AsyncCfInterconnects", + "CfInterconnectsWithRawResponse", + "AsyncCfInterconnectsWithRawResponse", + "CfInterconnectsWithStreamingResponse", + "AsyncCfInterconnectsWithStreamingResponse", + "GRETunnels", + "AsyncGRETunnels", + "GRETunnelsWithRawResponse", + "AsyncGRETunnelsWithRawResponse", + "GRETunnelsWithStreamingResponse", + "AsyncGRETunnelsWithStreamingResponse", + "IPSECTunnels", + "AsyncIPSECTunnels", + "IPSECTunnelsWithRawResponse", + "AsyncIPSECTunnelsWithRawResponse", + "IPSECTunnelsWithStreamingResponse", + "AsyncIPSECTunnelsWithStreamingResponse", + "Routes", + "AsyncRoutes", + "RoutesWithRawResponse", + "AsyncRoutesWithRawResponse", + "RoutesWithStreamingResponse", + "AsyncRoutesWithStreamingResponse", + "Sites", + "AsyncSites", + "SitesWithRawResponse", + "AsyncSitesWithRawResponse", + "SitesWithStreamingResponse", + "AsyncSitesWithStreamingResponse", + "MagicTransit", + "AsyncMagicTransit", + "MagicTransitWithRawResponse", + "AsyncMagicTransitWithRawResponse", + "MagicTransitWithStreamingResponse", + "AsyncMagicTransitWithStreamingResponse", +] diff --git a/src/cloudflare/resources/magic_transit/cf_interconnects.py b/src/cloudflare/resources/magic_transit/cf_interconnects.py new file mode 100644 index 00000000000..baeb9340daf --- /dev/null +++ b/src/cloudflare/resources/magic_transit/cf_interconnects.py @@ -0,0 +1,425 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) +from ...types.magic_transit import ( + CfInterconnectGetResponse, + CfInterconnectListResponse, + CfInterconnectUpdateResponse, + cf_interconnect_update_params, +) + +__all__ = ["CfInterconnects", "AsyncCfInterconnects"] + + +class CfInterconnects(SyncAPIResource): + @cached_property + def with_raw_response(self) -> CfInterconnectsWithRawResponse: + return CfInterconnectsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CfInterconnectsWithStreamingResponse: + return CfInterconnectsWithStreamingResponse(self) + + def update( + self, + tunnel_identifier: str, + *, + account_id: str, + description: str | NotGiven = NOT_GIVEN, + gre: cf_interconnect_update_params.GRE | NotGiven = NOT_GIVEN, + health_check: cf_interconnect_update_params.HealthCheck | NotGiven = NOT_GIVEN, + interface_address: str | NotGiven = NOT_GIVEN, + mtu: int | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CfInterconnectUpdateResponse: + """Updates a specific interconnect associated with an account. + + Use + `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + description: An optional description of the interconnect. + + gre: The configuration specific to GRE interconnects. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + mtu: The Maximum Transmission Unit (MTU) in bytes for the interconnect. The minimum + value is 576. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._put( + f"/accounts/{account_id}/magic/cf_interconnects/{tunnel_identifier}", + body=maybe_transform( + { + "description": description, + "gre": gre, + "health_check": health_check, + "interface_address": interface_address, + "mtu": mtu, + }, + cf_interconnect_update_params.CfInterconnectUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[CfInterconnectUpdateResponse], ResultWrapper[CfInterconnectUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CfInterconnectListResponse: + """ + Lists interconnects associated with an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/magic/cf_interconnects", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[CfInterconnectListResponse], ResultWrapper[CfInterconnectListResponse]), + ) + + def get( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CfInterconnectGetResponse: + """ + Lists details for a specific interconnect. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._get( + f"/accounts/{account_id}/magic/cf_interconnects/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[CfInterconnectGetResponse], ResultWrapper[CfInterconnectGetResponse]), + ) + + +class AsyncCfInterconnects(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncCfInterconnectsWithRawResponse: + return AsyncCfInterconnectsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCfInterconnectsWithStreamingResponse: + return AsyncCfInterconnectsWithStreamingResponse(self) + + async def update( + self, + tunnel_identifier: str, + *, + account_id: str, + description: str | NotGiven = NOT_GIVEN, + gre: cf_interconnect_update_params.GRE | NotGiven = NOT_GIVEN, + health_check: cf_interconnect_update_params.HealthCheck | NotGiven = NOT_GIVEN, + interface_address: str | NotGiven = NOT_GIVEN, + mtu: int | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CfInterconnectUpdateResponse: + """Updates a specific interconnect associated with an account. + + Use + `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + description: An optional description of the interconnect. + + gre: The configuration specific to GRE interconnects. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + mtu: The Maximum Transmission Unit (MTU) in bytes for the interconnect. The minimum + value is 576. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._put( + f"/accounts/{account_id}/magic/cf_interconnects/{tunnel_identifier}", + body=await async_maybe_transform( + { + "description": description, + "gre": gre, + "health_check": health_check, + "interface_address": interface_address, + "mtu": mtu, + }, + cf_interconnect_update_params.CfInterconnectUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[CfInterconnectUpdateResponse], ResultWrapper[CfInterconnectUpdateResponse]), + ) + + async def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CfInterconnectListResponse: + """ + Lists interconnects associated with an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/cf_interconnects", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[CfInterconnectListResponse], ResultWrapper[CfInterconnectListResponse]), + ) + + async def get( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> CfInterconnectGetResponse: + """ + Lists details for a specific interconnect. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._get( + f"/accounts/{account_id}/magic/cf_interconnects/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[CfInterconnectGetResponse], ResultWrapper[CfInterconnectGetResponse]), + ) + + +class CfInterconnectsWithRawResponse: + def __init__(self, cf_interconnects: CfInterconnects) -> None: + self._cf_interconnects = cf_interconnects + + self.update = to_raw_response_wrapper( + cf_interconnects.update, + ) + self.list = to_raw_response_wrapper( + cf_interconnects.list, + ) + self.get = to_raw_response_wrapper( + cf_interconnects.get, + ) + + +class AsyncCfInterconnectsWithRawResponse: + def __init__(self, cf_interconnects: AsyncCfInterconnects) -> None: + self._cf_interconnects = cf_interconnects + + self.update = async_to_raw_response_wrapper( + cf_interconnects.update, + ) + self.list = async_to_raw_response_wrapper( + cf_interconnects.list, + ) + self.get = async_to_raw_response_wrapper( + cf_interconnects.get, + ) + + +class CfInterconnectsWithStreamingResponse: + def __init__(self, cf_interconnects: CfInterconnects) -> None: + self._cf_interconnects = cf_interconnects + + self.update = to_streamed_response_wrapper( + cf_interconnects.update, + ) + self.list = to_streamed_response_wrapper( + cf_interconnects.list, + ) + self.get = to_streamed_response_wrapper( + cf_interconnects.get, + ) + + +class AsyncCfInterconnectsWithStreamingResponse: + def __init__(self, cf_interconnects: AsyncCfInterconnects) -> None: + self._cf_interconnects = cf_interconnects + + self.update = async_to_streamed_response_wrapper( + cf_interconnects.update, + ) + self.list = async_to_streamed_response_wrapper( + cf_interconnects.list, + ) + self.get = async_to_streamed_response_wrapper( + cf_interconnects.get, + ) diff --git a/src/cloudflare/resources/magic_transit/gre_tunnels.py b/src/cloudflare/resources/magic_transit/gre_tunnels.py new file mode 100644 index 00000000000..178f4b622ff --- /dev/null +++ b/src/cloudflare/resources/magic_transit/gre_tunnels.py @@ -0,0 +1,654 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) +from ...types.magic_transit import ( + GRETunnelGetResponse, + GRETunnelListResponse, + GRETunnelCreateResponse, + GRETunnelDeleteResponse, + GRETunnelUpdateResponse, + gre_tunnel_create_params, + gre_tunnel_update_params, +) + +__all__ = ["GRETunnels", "AsyncGRETunnels"] + + +class GRETunnels(SyncAPIResource): + @cached_property + def with_raw_response(self) -> GRETunnelsWithRawResponse: + return GRETunnelsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> GRETunnelsWithStreamingResponse: + return GRETunnelsWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + body: object, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelCreateResponse: + """Creates new GRE tunnels. + + Use `?validate_only=true` as an optional query + parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/magic/gre_tunnels", + body=maybe_transform(body, gre_tunnel_create_params.GRETunnelCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelCreateResponse], ResultWrapper[GRETunnelCreateResponse]), + ) + + def update( + self, + tunnel_identifier: str, + *, + account_id: str, + cloudflare_gre_endpoint: str, + customer_gre_endpoint: str, + interface_address: str, + name: str, + description: str | NotGiven = NOT_GIVEN, + health_check: gre_tunnel_update_params.HealthCheck | NotGiven = NOT_GIVEN, + mtu: int | NotGiven = NOT_GIVEN, + ttl: int | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelUpdateResponse: + """Updates a specific GRE tunnel. + + Use `?validate_only=true` as an optional query + parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + cloudflare_gre_endpoint: The IP address assigned to the Cloudflare side of the GRE tunnel. + + customer_gre_endpoint: The IP address assigned to the customer side of the GRE tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the tunnel. The name cannot contain spaces or special characters, + must be 15 characters or less, and cannot share a name with another GRE tunnel. + + description: An optional description of the GRE tunnel. + + mtu: Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value + is 576. + + ttl: Time To Live (TTL) in number of hops of the GRE tunnel. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._put( + f"/accounts/{account_id}/magic/gre_tunnels/{tunnel_identifier}", + body=maybe_transform( + { + "cloudflare_gre_endpoint": cloudflare_gre_endpoint, + "customer_gre_endpoint": customer_gre_endpoint, + "interface_address": interface_address, + "name": name, + "description": description, + "health_check": health_check, + "mtu": mtu, + "ttl": ttl, + }, + gre_tunnel_update_params.GRETunnelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelUpdateResponse], ResultWrapper[GRETunnelUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelListResponse: + """ + Lists GRE tunnels associated with an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/magic/gre_tunnels", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelListResponse], ResultWrapper[GRETunnelListResponse]), + ) + + def delete( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelDeleteResponse: + """Disables and removes a specific static GRE tunnel. + + Use `?validate_only=true` as + an optional query parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._delete( + f"/accounts/{account_id}/magic/gre_tunnels/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelDeleteResponse], ResultWrapper[GRETunnelDeleteResponse]), + ) + + def get( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelGetResponse: + """ + Lists informtion for a specific GRE tunnel. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._get( + f"/accounts/{account_id}/magic/gre_tunnels/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelGetResponse], ResultWrapper[GRETunnelGetResponse]), + ) + + +class AsyncGRETunnels(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncGRETunnelsWithRawResponse: + return AsyncGRETunnelsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncGRETunnelsWithStreamingResponse: + return AsyncGRETunnelsWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + body: object, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelCreateResponse: + """Creates new GRE tunnels. + + Use `?validate_only=true` as an optional query + parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/gre_tunnels", + body=await async_maybe_transform(body, gre_tunnel_create_params.GRETunnelCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelCreateResponse], ResultWrapper[GRETunnelCreateResponse]), + ) + + async def update( + self, + tunnel_identifier: str, + *, + account_id: str, + cloudflare_gre_endpoint: str, + customer_gre_endpoint: str, + interface_address: str, + name: str, + description: str | NotGiven = NOT_GIVEN, + health_check: gre_tunnel_update_params.HealthCheck | NotGiven = NOT_GIVEN, + mtu: int | NotGiven = NOT_GIVEN, + ttl: int | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelUpdateResponse: + """Updates a specific GRE tunnel. + + Use `?validate_only=true` as an optional query + parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + cloudflare_gre_endpoint: The IP address assigned to the Cloudflare side of the GRE tunnel. + + customer_gre_endpoint: The IP address assigned to the customer side of the GRE tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the tunnel. The name cannot contain spaces or special characters, + must be 15 characters or less, and cannot share a name with another GRE tunnel. + + description: An optional description of the GRE tunnel. + + mtu: Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value + is 576. + + ttl: Time To Live (TTL) in number of hops of the GRE tunnel. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._put( + f"/accounts/{account_id}/magic/gre_tunnels/{tunnel_identifier}", + body=await async_maybe_transform( + { + "cloudflare_gre_endpoint": cloudflare_gre_endpoint, + "customer_gre_endpoint": customer_gre_endpoint, + "interface_address": interface_address, + "name": name, + "description": description, + "health_check": health_check, + "mtu": mtu, + "ttl": ttl, + }, + gre_tunnel_update_params.GRETunnelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelUpdateResponse], ResultWrapper[GRETunnelUpdateResponse]), + ) + + async def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelListResponse: + """ + Lists GRE tunnels associated with an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/gre_tunnels", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelListResponse], ResultWrapper[GRETunnelListResponse]), + ) + + async def delete( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelDeleteResponse: + """Disables and removes a specific static GRE tunnel. + + Use `?validate_only=true` as + an optional query parameter to only run validation without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._delete( + f"/accounts/{account_id}/magic/gre_tunnels/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelDeleteResponse], ResultWrapper[GRETunnelDeleteResponse]), + ) + + async def get( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> GRETunnelGetResponse: + """ + Lists informtion for a specific GRE tunnel. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._get( + f"/accounts/{account_id}/magic/gre_tunnels/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[GRETunnelGetResponse], ResultWrapper[GRETunnelGetResponse]), + ) + + +class GRETunnelsWithRawResponse: + def __init__(self, gre_tunnels: GRETunnels) -> None: + self._gre_tunnels = gre_tunnels + + self.create = to_raw_response_wrapper( + gre_tunnels.create, + ) + self.update = to_raw_response_wrapper( + gre_tunnels.update, + ) + self.list = to_raw_response_wrapper( + gre_tunnels.list, + ) + self.delete = to_raw_response_wrapper( + gre_tunnels.delete, + ) + self.get = to_raw_response_wrapper( + gre_tunnels.get, + ) + + +class AsyncGRETunnelsWithRawResponse: + def __init__(self, gre_tunnels: AsyncGRETunnels) -> None: + self._gre_tunnels = gre_tunnels + + self.create = async_to_raw_response_wrapper( + gre_tunnels.create, + ) + self.update = async_to_raw_response_wrapper( + gre_tunnels.update, + ) + self.list = async_to_raw_response_wrapper( + gre_tunnels.list, + ) + self.delete = async_to_raw_response_wrapper( + gre_tunnels.delete, + ) + self.get = async_to_raw_response_wrapper( + gre_tunnels.get, + ) + + +class GRETunnelsWithStreamingResponse: + def __init__(self, gre_tunnels: GRETunnels) -> None: + self._gre_tunnels = gre_tunnels + + self.create = to_streamed_response_wrapper( + gre_tunnels.create, + ) + self.update = to_streamed_response_wrapper( + gre_tunnels.update, + ) + self.list = to_streamed_response_wrapper( + gre_tunnels.list, + ) + self.delete = to_streamed_response_wrapper( + gre_tunnels.delete, + ) + self.get = to_streamed_response_wrapper( + gre_tunnels.get, + ) + + +class AsyncGRETunnelsWithStreamingResponse: + def __init__(self, gre_tunnels: AsyncGRETunnels) -> None: + self._gre_tunnels = gre_tunnels + + self.create = async_to_streamed_response_wrapper( + gre_tunnels.create, + ) + self.update = async_to_streamed_response_wrapper( + gre_tunnels.update, + ) + self.list = async_to_streamed_response_wrapper( + gre_tunnels.list, + ) + self.delete = async_to_streamed_response_wrapper( + gre_tunnels.delete, + ) + self.get = async_to_streamed_response_wrapper( + gre_tunnels.get, + ) diff --git a/src/cloudflare/resources/magic_transit/ipsec_tunnels.py b/src/cloudflare/resources/magic_transit/ipsec_tunnels.py new file mode 100644 index 00000000000..55067d5e807 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/ipsec_tunnels.py @@ -0,0 +1,837 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) +from ...types.magic_transit import ( + IPSECTunnelGetResponse, + IPSECTunnelListResponse, + IPSECTunnelCreateResponse, + IPSECTunnelDeleteResponse, + IPSECTunnelUpdateResponse, + IPSECTunnelPSKGenerateResponse, + ipsec_tunnel_create_params, + ipsec_tunnel_update_params, +) + +__all__ = ["IPSECTunnels", "AsyncIPSECTunnels"] + + +class IPSECTunnels(SyncAPIResource): + @cached_property + def with_raw_response(self) -> IPSECTunnelsWithRawResponse: + return IPSECTunnelsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IPSECTunnelsWithStreamingResponse: + return IPSECTunnelsWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + cloudflare_endpoint: str, + interface_address: str, + name: str, + customer_endpoint: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + health_check: ipsec_tunnel_create_params.HealthCheck | NotGiven = NOT_GIVEN, + psk: str | NotGiven = NOT_GIVEN, + replay_protection: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelCreateResponse: + """Creates new IPsec tunnels associated with an account. + + Use `?validate_only=true` + as an optional query parameter to only run validation without persisting + changes. + + Args: + account_id: Identifier + + cloudflare_endpoint: The IP address assigned to the Cloudflare side of the IPsec tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the IPsec tunnel. The name cannot share a name with other tunnels. + + customer_endpoint: The IP address assigned to the customer side of the IPsec tunnel. + + description: An optional description forthe IPsec tunnel. + + psk: A randomly generated or provided string for use in the IPsec tunnel. + + replay_protection: If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/magic/ipsec_tunnels", + body=maybe_transform( + { + "cloudflare_endpoint": cloudflare_endpoint, + "interface_address": interface_address, + "name": name, + "customer_endpoint": customer_endpoint, + "description": description, + "health_check": health_check, + "psk": psk, + "replay_protection": replay_protection, + }, + ipsec_tunnel_create_params.IPSECTunnelCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelCreateResponse], ResultWrapper[IPSECTunnelCreateResponse]), + ) + + def update( + self, + tunnel_identifier: str, + *, + account_id: str, + cloudflare_endpoint: str, + interface_address: str, + name: str, + customer_endpoint: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + health_check: ipsec_tunnel_update_params.HealthCheck | NotGiven = NOT_GIVEN, + psk: str | NotGiven = NOT_GIVEN, + replay_protection: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelUpdateResponse: + """Updates a specific IPsec tunnel associated with an account. + + Use + `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + cloudflare_endpoint: The IP address assigned to the Cloudflare side of the IPsec tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the IPsec tunnel. The name cannot share a name with other tunnels. + + customer_endpoint: The IP address assigned to the customer side of the IPsec tunnel. + + description: An optional description forthe IPsec tunnel. + + psk: A randomly generated or provided string for use in the IPsec tunnel. + + replay_protection: If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._put( + f"/accounts/{account_id}/magic/ipsec_tunnels/{tunnel_identifier}", + body=maybe_transform( + { + "cloudflare_endpoint": cloudflare_endpoint, + "interface_address": interface_address, + "name": name, + "customer_endpoint": customer_endpoint, + "description": description, + "health_check": health_check, + "psk": psk, + "replay_protection": replay_protection, + }, + ipsec_tunnel_update_params.IPSECTunnelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelUpdateResponse], ResultWrapper[IPSECTunnelUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelListResponse: + """ + Lists IPsec tunnels associated with an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/magic/ipsec_tunnels", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelListResponse], ResultWrapper[IPSECTunnelListResponse]), + ) + + def delete( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelDeleteResponse: + """ + Disables and removes a specific static IPsec Tunnel associated with an account. + Use `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._delete( + f"/accounts/{account_id}/magic/ipsec_tunnels/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelDeleteResponse], ResultWrapper[IPSECTunnelDeleteResponse]), + ) + + def get( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelGetResponse: + """ + Lists details for a specific IPsec tunnel. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._get( + f"/accounts/{account_id}/magic/ipsec_tunnels/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelGetResponse], ResultWrapper[IPSECTunnelGetResponse]), + ) + + def psk_generate( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelPSKGenerateResponse: + """ + Generates a Pre Shared Key for a specific IPsec tunnel used in the IKE session. + Use `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. After a PSK is generated, the PSK is immediately + persisted to Cloudflare's edge and cannot be retrieved later. Note the PSK in a + safe place. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return self._post( + f"/accounts/{account_id}/magic/ipsec_tunnels/{tunnel_identifier}/psk_generate", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelPSKGenerateResponse], ResultWrapper[IPSECTunnelPSKGenerateResponse]), + ) + + +class AsyncIPSECTunnels(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIPSECTunnelsWithRawResponse: + return AsyncIPSECTunnelsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIPSECTunnelsWithStreamingResponse: + return AsyncIPSECTunnelsWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + cloudflare_endpoint: str, + interface_address: str, + name: str, + customer_endpoint: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + health_check: ipsec_tunnel_create_params.HealthCheck | NotGiven = NOT_GIVEN, + psk: str | NotGiven = NOT_GIVEN, + replay_protection: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelCreateResponse: + """Creates new IPsec tunnels associated with an account. + + Use `?validate_only=true` + as an optional query parameter to only run validation without persisting + changes. + + Args: + account_id: Identifier + + cloudflare_endpoint: The IP address assigned to the Cloudflare side of the IPsec tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the IPsec tunnel. The name cannot share a name with other tunnels. + + customer_endpoint: The IP address assigned to the customer side of the IPsec tunnel. + + description: An optional description forthe IPsec tunnel. + + psk: A randomly generated or provided string for use in the IPsec tunnel. + + replay_protection: If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/ipsec_tunnels", + body=await async_maybe_transform( + { + "cloudflare_endpoint": cloudflare_endpoint, + "interface_address": interface_address, + "name": name, + "customer_endpoint": customer_endpoint, + "description": description, + "health_check": health_check, + "psk": psk, + "replay_protection": replay_protection, + }, + ipsec_tunnel_create_params.IPSECTunnelCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelCreateResponse], ResultWrapper[IPSECTunnelCreateResponse]), + ) + + async def update( + self, + tunnel_identifier: str, + *, + account_id: str, + cloudflare_endpoint: str, + interface_address: str, + name: str, + customer_endpoint: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + health_check: ipsec_tunnel_update_params.HealthCheck | NotGiven = NOT_GIVEN, + psk: str | NotGiven = NOT_GIVEN, + replay_protection: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelUpdateResponse: + """Updates a specific IPsec tunnel associated with an account. + + Use + `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + cloudflare_endpoint: The IP address assigned to the Cloudflare side of the IPsec tunnel. + + interface_address: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + + name: The name of the IPsec tunnel. The name cannot share a name with other tunnels. + + customer_endpoint: The IP address assigned to the customer side of the IPsec tunnel. + + description: An optional description forthe IPsec tunnel. + + psk: A randomly generated or provided string for use in the IPsec tunnel. + + replay_protection: If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._put( + f"/accounts/{account_id}/magic/ipsec_tunnels/{tunnel_identifier}", + body=await async_maybe_transform( + { + "cloudflare_endpoint": cloudflare_endpoint, + "interface_address": interface_address, + "name": name, + "customer_endpoint": customer_endpoint, + "description": description, + "health_check": health_check, + "psk": psk, + "replay_protection": replay_protection, + }, + ipsec_tunnel_update_params.IPSECTunnelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelUpdateResponse], ResultWrapper[IPSECTunnelUpdateResponse]), + ) + + async def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelListResponse: + """ + Lists IPsec tunnels associated with an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/ipsec_tunnels", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelListResponse], ResultWrapper[IPSECTunnelListResponse]), + ) + + async def delete( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelDeleteResponse: + """ + Disables and removes a specific static IPsec Tunnel associated with an account. + Use `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._delete( + f"/accounts/{account_id}/magic/ipsec_tunnels/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelDeleteResponse], ResultWrapper[IPSECTunnelDeleteResponse]), + ) + + async def get( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelGetResponse: + """ + Lists details for a specific IPsec tunnel. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._get( + f"/accounts/{account_id}/magic/ipsec_tunnels/{tunnel_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelGetResponse], ResultWrapper[IPSECTunnelGetResponse]), + ) + + async def psk_generate( + self, + tunnel_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> IPSECTunnelPSKGenerateResponse: + """ + Generates a Pre Shared Key for a specific IPsec tunnel used in the IKE session. + Use `?validate_only=true` as an optional query parameter to only run validation + without persisting changes. After a PSK is generated, the PSK is immediately + persisted to Cloudflare's edge and cannot be retrieved later. Note the PSK in a + safe place. + + Args: + account_id: Identifier + + tunnel_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not tunnel_identifier: + raise ValueError(f"Expected a non-empty value for `tunnel_identifier` but received {tunnel_identifier!r}") + return await self._post( + f"/accounts/{account_id}/magic/ipsec_tunnels/{tunnel_identifier}/psk_generate", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[IPSECTunnelPSKGenerateResponse], ResultWrapper[IPSECTunnelPSKGenerateResponse]), + ) + + +class IPSECTunnelsWithRawResponse: + def __init__(self, ipsec_tunnels: IPSECTunnels) -> None: + self._ipsec_tunnels = ipsec_tunnels + + self.create = to_raw_response_wrapper( + ipsec_tunnels.create, + ) + self.update = to_raw_response_wrapper( + ipsec_tunnels.update, + ) + self.list = to_raw_response_wrapper( + ipsec_tunnels.list, + ) + self.delete = to_raw_response_wrapper( + ipsec_tunnels.delete, + ) + self.get = to_raw_response_wrapper( + ipsec_tunnels.get, + ) + self.psk_generate = to_raw_response_wrapper( + ipsec_tunnels.psk_generate, + ) + + +class AsyncIPSECTunnelsWithRawResponse: + def __init__(self, ipsec_tunnels: AsyncIPSECTunnels) -> None: + self._ipsec_tunnels = ipsec_tunnels + + self.create = async_to_raw_response_wrapper( + ipsec_tunnels.create, + ) + self.update = async_to_raw_response_wrapper( + ipsec_tunnels.update, + ) + self.list = async_to_raw_response_wrapper( + ipsec_tunnels.list, + ) + self.delete = async_to_raw_response_wrapper( + ipsec_tunnels.delete, + ) + self.get = async_to_raw_response_wrapper( + ipsec_tunnels.get, + ) + self.psk_generate = async_to_raw_response_wrapper( + ipsec_tunnels.psk_generate, + ) + + +class IPSECTunnelsWithStreamingResponse: + def __init__(self, ipsec_tunnels: IPSECTunnels) -> None: + self._ipsec_tunnels = ipsec_tunnels + + self.create = to_streamed_response_wrapper( + ipsec_tunnels.create, + ) + self.update = to_streamed_response_wrapper( + ipsec_tunnels.update, + ) + self.list = to_streamed_response_wrapper( + ipsec_tunnels.list, + ) + self.delete = to_streamed_response_wrapper( + ipsec_tunnels.delete, + ) + self.get = to_streamed_response_wrapper( + ipsec_tunnels.get, + ) + self.psk_generate = to_streamed_response_wrapper( + ipsec_tunnels.psk_generate, + ) + + +class AsyncIPSECTunnelsWithStreamingResponse: + def __init__(self, ipsec_tunnels: AsyncIPSECTunnels) -> None: + self._ipsec_tunnels = ipsec_tunnels + + self.create = async_to_streamed_response_wrapper( + ipsec_tunnels.create, + ) + self.update = async_to_streamed_response_wrapper( + ipsec_tunnels.update, + ) + self.list = async_to_streamed_response_wrapper( + ipsec_tunnels.list, + ) + self.delete = async_to_streamed_response_wrapper( + ipsec_tunnels.delete, + ) + self.get = async_to_streamed_response_wrapper( + ipsec_tunnels.get, + ) + self.psk_generate = async_to_streamed_response_wrapper( + ipsec_tunnels.psk_generate, + ) diff --git a/src/cloudflare/resources/magic_transit/magic_transit.py b/src/cloudflare/resources/magic_transit/magic_transit.py new file mode 100644 index 00000000000..5c6ad22503a --- /dev/null +++ b/src/cloudflare/resources/magic_transit/magic_transit.py @@ -0,0 +1,209 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .sites import ( + Sites, + AsyncSites, + SitesWithRawResponse, + AsyncSitesWithRawResponse, + SitesWithStreamingResponse, + AsyncSitesWithStreamingResponse, +) +from .routes import ( + Routes, + AsyncRoutes, + RoutesWithRawResponse, + AsyncRoutesWithRawResponse, + RoutesWithStreamingResponse, + AsyncRoutesWithStreamingResponse, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from .gre_tunnels import ( + GRETunnels, + AsyncGRETunnels, + GRETunnelsWithRawResponse, + AsyncGRETunnelsWithRawResponse, + GRETunnelsWithStreamingResponse, + AsyncGRETunnelsWithStreamingResponse, +) +from .sites.sites import Sites, AsyncSites +from .ipsec_tunnels import ( + IPSECTunnels, + AsyncIPSECTunnels, + IPSECTunnelsWithRawResponse, + AsyncIPSECTunnelsWithRawResponse, + IPSECTunnelsWithStreamingResponse, + AsyncIPSECTunnelsWithStreamingResponse, +) +from .cf_interconnects import ( + CfInterconnects, + AsyncCfInterconnects, + CfInterconnectsWithRawResponse, + AsyncCfInterconnectsWithRawResponse, + CfInterconnectsWithStreamingResponse, + AsyncCfInterconnectsWithStreamingResponse, +) + +__all__ = ["MagicTransit", "AsyncMagicTransit"] + + +class MagicTransit(SyncAPIResource): + @cached_property + def cf_interconnects(self) -> CfInterconnects: + return CfInterconnects(self._client) + + @cached_property + def gre_tunnels(self) -> GRETunnels: + return GRETunnels(self._client) + + @cached_property + def ipsec_tunnels(self) -> IPSECTunnels: + return IPSECTunnels(self._client) + + @cached_property + def routes(self) -> Routes: + return Routes(self._client) + + @cached_property + def sites(self) -> Sites: + return Sites(self._client) + + @cached_property + def with_raw_response(self) -> MagicTransitWithRawResponse: + return MagicTransitWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MagicTransitWithStreamingResponse: + return MagicTransitWithStreamingResponse(self) + + +class AsyncMagicTransit(AsyncAPIResource): + @cached_property + def cf_interconnects(self) -> AsyncCfInterconnects: + return AsyncCfInterconnects(self._client) + + @cached_property + def gre_tunnels(self) -> AsyncGRETunnels: + return AsyncGRETunnels(self._client) + + @cached_property + def ipsec_tunnels(self) -> AsyncIPSECTunnels: + return AsyncIPSECTunnels(self._client) + + @cached_property + def routes(self) -> AsyncRoutes: + return AsyncRoutes(self._client) + + @cached_property + def sites(self) -> AsyncSites: + return AsyncSites(self._client) + + @cached_property + def with_raw_response(self) -> AsyncMagicTransitWithRawResponse: + return AsyncMagicTransitWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMagicTransitWithStreamingResponse: + return AsyncMagicTransitWithStreamingResponse(self) + + +class MagicTransitWithRawResponse: + def __init__(self, magic_transit: MagicTransit) -> None: + self._magic_transit = magic_transit + + @cached_property + def cf_interconnects(self) -> CfInterconnectsWithRawResponse: + return CfInterconnectsWithRawResponse(self._magic_transit.cf_interconnects) + + @cached_property + def gre_tunnels(self) -> GRETunnelsWithRawResponse: + return GRETunnelsWithRawResponse(self._magic_transit.gre_tunnels) + + @cached_property + def ipsec_tunnels(self) -> IPSECTunnelsWithRawResponse: + return IPSECTunnelsWithRawResponse(self._magic_transit.ipsec_tunnels) + + @cached_property + def routes(self) -> RoutesWithRawResponse: + return RoutesWithRawResponse(self._magic_transit.routes) + + @cached_property + def sites(self) -> SitesWithRawResponse: + return SitesWithRawResponse(self._magic_transit.sites) + + +class AsyncMagicTransitWithRawResponse: + def __init__(self, magic_transit: AsyncMagicTransit) -> None: + self._magic_transit = magic_transit + + @cached_property + def cf_interconnects(self) -> AsyncCfInterconnectsWithRawResponse: + return AsyncCfInterconnectsWithRawResponse(self._magic_transit.cf_interconnects) + + @cached_property + def gre_tunnels(self) -> AsyncGRETunnelsWithRawResponse: + return AsyncGRETunnelsWithRawResponse(self._magic_transit.gre_tunnels) + + @cached_property + def ipsec_tunnels(self) -> AsyncIPSECTunnelsWithRawResponse: + return AsyncIPSECTunnelsWithRawResponse(self._magic_transit.ipsec_tunnels) + + @cached_property + def routes(self) -> AsyncRoutesWithRawResponse: + return AsyncRoutesWithRawResponse(self._magic_transit.routes) + + @cached_property + def sites(self) -> AsyncSitesWithRawResponse: + return AsyncSitesWithRawResponse(self._magic_transit.sites) + + +class MagicTransitWithStreamingResponse: + def __init__(self, magic_transit: MagicTransit) -> None: + self._magic_transit = magic_transit + + @cached_property + def cf_interconnects(self) -> CfInterconnectsWithStreamingResponse: + return CfInterconnectsWithStreamingResponse(self._magic_transit.cf_interconnects) + + @cached_property + def gre_tunnels(self) -> GRETunnelsWithStreamingResponse: + return GRETunnelsWithStreamingResponse(self._magic_transit.gre_tunnels) + + @cached_property + def ipsec_tunnels(self) -> IPSECTunnelsWithStreamingResponse: + return IPSECTunnelsWithStreamingResponse(self._magic_transit.ipsec_tunnels) + + @cached_property + def routes(self) -> RoutesWithStreamingResponse: + return RoutesWithStreamingResponse(self._magic_transit.routes) + + @cached_property + def sites(self) -> SitesWithStreamingResponse: + return SitesWithStreamingResponse(self._magic_transit.sites) + + +class AsyncMagicTransitWithStreamingResponse: + def __init__(self, magic_transit: AsyncMagicTransit) -> None: + self._magic_transit = magic_transit + + @cached_property + def cf_interconnects(self) -> AsyncCfInterconnectsWithStreamingResponse: + return AsyncCfInterconnectsWithStreamingResponse(self._magic_transit.cf_interconnects) + + @cached_property + def gre_tunnels(self) -> AsyncGRETunnelsWithStreamingResponse: + return AsyncGRETunnelsWithStreamingResponse(self._magic_transit.gre_tunnels) + + @cached_property + def ipsec_tunnels(self) -> AsyncIPSECTunnelsWithStreamingResponse: + return AsyncIPSECTunnelsWithStreamingResponse(self._magic_transit.ipsec_tunnels) + + @cached_property + def routes(self) -> AsyncRoutesWithStreamingResponse: + return AsyncRoutesWithStreamingResponse(self._magic_transit.routes) + + @cached_property + def sites(self) -> AsyncSitesWithStreamingResponse: + return AsyncSitesWithStreamingResponse(self._magic_transit.sites) diff --git a/src/cloudflare/resources/magic_transit/routes.py b/src/cloudflare/resources/magic_transit/routes.py new file mode 100644 index 00000000000..1572a6623fa --- /dev/null +++ b/src/cloudflare/resources/magic_transit/routes.py @@ -0,0 +1,726 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, cast + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) +from ...types.magic_transit import ( + RouteGetResponse, + RouteListResponse, + RouteEmptyResponse, + RouteCreateResponse, + RouteDeleteResponse, + RouteUpdateResponse, + route_empty_params, + route_create_params, + route_update_params, +) + +__all__ = ["Routes", "AsyncRoutes"] + + +class Routes(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RoutesWithRawResponse: + return RoutesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RoutesWithStreamingResponse: + return RoutesWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + body: object, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteCreateResponse: + """Creates a new Magic static route. + + Use `?validate_only=true` as an optional query + parameter to run validation only without persisting changes. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/magic/routes", + body=maybe_transform(body, route_create_params.RouteCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteCreateResponse], ResultWrapper[RouteCreateResponse]), + ) + + def update( + self, + route_identifier: str, + *, + account_id: str, + nexthop: str, + prefix: str, + priority: int, + description: str | NotGiven = NOT_GIVEN, + scope: route_update_params.Scope | NotGiven = NOT_GIVEN, + weight: int | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteUpdateResponse: + """Update a specific Magic static route. + + Use `?validate_only=true` as an optional + query parameter to run validation only without persisting changes. + + Args: + account_id: Identifier + + route_identifier: Identifier + + nexthop: The next-hop IP Address for the static route. + + prefix: IP Prefix in Classless Inter-Domain Routing format. + + priority: Priority of the static route. + + description: An optional human provided description of the static route. + + scope: Used only for ECMP routes. + + weight: Optional weight of the ECMP scope - if provided. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_identifier: + raise ValueError(f"Expected a non-empty value for `route_identifier` but received {route_identifier!r}") + return self._put( + f"/accounts/{account_id}/magic/routes/{route_identifier}", + body=maybe_transform( + { + "nexthop": nexthop, + "prefix": prefix, + "priority": priority, + "description": description, + "scope": scope, + "weight": weight, + }, + route_update_params.RouteUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteUpdateResponse], ResultWrapper[RouteUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteListResponse: + """ + List all Magic static routes. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/magic/routes", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteListResponse], ResultWrapper[RouteListResponse]), + ) + + def delete( + self, + route_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteDeleteResponse: + """ + Disable and remove a specific Magic static route. + + Args: + account_id: Identifier + + route_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_identifier: + raise ValueError(f"Expected a non-empty value for `route_identifier` but received {route_identifier!r}") + return self._delete( + f"/accounts/{account_id}/magic/routes/{route_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteDeleteResponse], ResultWrapper[RouteDeleteResponse]), + ) + + def empty( + self, + *, + account_id: str, + routes: Iterable[route_empty_params.Route], + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteEmptyResponse: + """ + Delete multiple Magic static routes. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/routes", + body=maybe_transform({"routes": routes}, route_empty_params.RouteEmptyParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteEmptyResponse], ResultWrapper[RouteEmptyResponse]), + ) + + def get( + self, + route_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteGetResponse: + """ + Get a specific Magic static route. + + Args: + account_id: Identifier + + route_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_identifier: + raise ValueError(f"Expected a non-empty value for `route_identifier` but received {route_identifier!r}") + return self._get( + f"/accounts/{account_id}/magic/routes/{route_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteGetResponse], ResultWrapper[RouteGetResponse]), + ) + + +class AsyncRoutes(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRoutesWithRawResponse: + return AsyncRoutesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRoutesWithStreamingResponse: + return AsyncRoutesWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + body: object, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteCreateResponse: + """Creates a new Magic static route. + + Use `?validate_only=true` as an optional query + parameter to run validation only without persisting changes. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/routes", + body=await async_maybe_transform(body, route_create_params.RouteCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteCreateResponse], ResultWrapper[RouteCreateResponse]), + ) + + async def update( + self, + route_identifier: str, + *, + account_id: str, + nexthop: str, + prefix: str, + priority: int, + description: str | NotGiven = NOT_GIVEN, + scope: route_update_params.Scope | NotGiven = NOT_GIVEN, + weight: int | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteUpdateResponse: + """Update a specific Magic static route. + + Use `?validate_only=true` as an optional + query parameter to run validation only without persisting changes. + + Args: + account_id: Identifier + + route_identifier: Identifier + + nexthop: The next-hop IP Address for the static route. + + prefix: IP Prefix in Classless Inter-Domain Routing format. + + priority: Priority of the static route. + + description: An optional human provided description of the static route. + + scope: Used only for ECMP routes. + + weight: Optional weight of the ECMP scope - if provided. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_identifier: + raise ValueError(f"Expected a non-empty value for `route_identifier` but received {route_identifier!r}") + return await self._put( + f"/accounts/{account_id}/magic/routes/{route_identifier}", + body=await async_maybe_transform( + { + "nexthop": nexthop, + "prefix": prefix, + "priority": priority, + "description": description, + "scope": scope, + "weight": weight, + }, + route_update_params.RouteUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteUpdateResponse], ResultWrapper[RouteUpdateResponse]), + ) + + async def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteListResponse: + """ + List all Magic static routes. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/routes", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteListResponse], ResultWrapper[RouteListResponse]), + ) + + async def delete( + self, + route_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteDeleteResponse: + """ + Disable and remove a specific Magic static route. + + Args: + account_id: Identifier + + route_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_identifier: + raise ValueError(f"Expected a non-empty value for `route_identifier` but received {route_identifier!r}") + return await self._delete( + f"/accounts/{account_id}/magic/routes/{route_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteDeleteResponse], ResultWrapper[RouteDeleteResponse]), + ) + + async def empty( + self, + *, + account_id: str, + routes: Iterable[route_empty_params.Route], + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteEmptyResponse: + """ + Delete multiple Magic static routes. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/routes", + body=await async_maybe_transform({"routes": routes}, route_empty_params.RouteEmptyParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteEmptyResponse], ResultWrapper[RouteEmptyResponse]), + ) + + async def get( + self, + route_identifier: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RouteGetResponse: + """ + Get a specific Magic static route. + + Args: + account_id: Identifier + + route_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not route_identifier: + raise ValueError(f"Expected a non-empty value for `route_identifier` but received {route_identifier!r}") + return await self._get( + f"/accounts/{account_id}/magic/routes/{route_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RouteGetResponse], ResultWrapper[RouteGetResponse]), + ) + + +class RoutesWithRawResponse: + def __init__(self, routes: Routes) -> None: + self._routes = routes + + self.create = to_raw_response_wrapper( + routes.create, + ) + self.update = to_raw_response_wrapper( + routes.update, + ) + self.list = to_raw_response_wrapper( + routes.list, + ) + self.delete = to_raw_response_wrapper( + routes.delete, + ) + self.empty = to_raw_response_wrapper( + routes.empty, + ) + self.get = to_raw_response_wrapper( + routes.get, + ) + + +class AsyncRoutesWithRawResponse: + def __init__(self, routes: AsyncRoutes) -> None: + self._routes = routes + + self.create = async_to_raw_response_wrapper( + routes.create, + ) + self.update = async_to_raw_response_wrapper( + routes.update, + ) + self.list = async_to_raw_response_wrapper( + routes.list, + ) + self.delete = async_to_raw_response_wrapper( + routes.delete, + ) + self.empty = async_to_raw_response_wrapper( + routes.empty, + ) + self.get = async_to_raw_response_wrapper( + routes.get, + ) + + +class RoutesWithStreamingResponse: + def __init__(self, routes: Routes) -> None: + self._routes = routes + + self.create = to_streamed_response_wrapper( + routes.create, + ) + self.update = to_streamed_response_wrapper( + routes.update, + ) + self.list = to_streamed_response_wrapper( + routes.list, + ) + self.delete = to_streamed_response_wrapper( + routes.delete, + ) + self.empty = to_streamed_response_wrapper( + routes.empty, + ) + self.get = to_streamed_response_wrapper( + routes.get, + ) + + +class AsyncRoutesWithStreamingResponse: + def __init__(self, routes: AsyncRoutes) -> None: + self._routes = routes + + self.create = async_to_streamed_response_wrapper( + routes.create, + ) + self.update = async_to_streamed_response_wrapper( + routes.update, + ) + self.list = async_to_streamed_response_wrapper( + routes.list, + ) + self.delete = async_to_streamed_response_wrapper( + routes.delete, + ) + self.empty = async_to_streamed_response_wrapper( + routes.empty, + ) + self.get = async_to_streamed_response_wrapper( + routes.get, + ) diff --git a/src/cloudflare/resources/magic_transit/sites/__init__.py b/src/cloudflare/resources/magic_transit/sites/__init__.py new file mode 100644 index 00000000000..6f7321db90f --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/__init__.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .acls import ( + ACLs, + AsyncACLs, + ACLsWithRawResponse, + AsyncACLsWithRawResponse, + ACLsWithStreamingResponse, + AsyncACLsWithStreamingResponse, +) +from .lans import ( + Lans, + AsyncLans, + LansWithRawResponse, + AsyncLansWithRawResponse, + LansWithStreamingResponse, + AsyncLansWithStreamingResponse, +) +from .wans import ( + Wans, + AsyncWans, + WansWithRawResponse, + AsyncWansWithRawResponse, + WansWithStreamingResponse, + AsyncWansWithStreamingResponse, +) +from .sites import ( + Sites, + AsyncSites, + SitesWithRawResponse, + AsyncSitesWithRawResponse, + SitesWithStreamingResponse, + AsyncSitesWithStreamingResponse, +) + +__all__ = [ + "ACLs", + "AsyncACLs", + "ACLsWithRawResponse", + "AsyncACLsWithRawResponse", + "ACLsWithStreamingResponse", + "AsyncACLsWithStreamingResponse", + "Lans", + "AsyncLans", + "LansWithRawResponse", + "AsyncLansWithRawResponse", + "LansWithStreamingResponse", + "AsyncLansWithStreamingResponse", + "Wans", + "AsyncWans", + "WansWithRawResponse", + "AsyncWansWithRawResponse", + "WansWithStreamingResponse", + "AsyncWansWithStreamingResponse", + "Sites", + "AsyncSites", + "SitesWithRawResponse", + "AsyncSitesWithRawResponse", + "SitesWithStreamingResponse", + "AsyncSitesWithStreamingResponse", +] diff --git a/src/cloudflare/resources/magic_transit/sites/acls.py b/src/cloudflare/resources/magic_transit/sites/acls.py new file mode 100644 index 00000000000..6d9f85883c8 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/acls.py @@ -0,0 +1,618 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import ( + make_request_options, +) +from ....types.magic_transit.sites import ( + ACLGetResponse, + ACLListResponse, + ACLCreateResponse, + ACLDeleteResponse, + ACLUpdateResponse, + acl_create_params, + acl_update_params, +) + +__all__ = ["ACLs", "AsyncACLs"] + + +class ACLs(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ACLsWithRawResponse: + return ACLsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ACLsWithStreamingResponse: + return ACLsWithStreamingResponse(self) + + def create( + self, + site_id: str, + *, + account_id: str, + acl: acl_create_params.ACL | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLCreateResponse: + """ + Creates a new Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/acls", + body=maybe_transform({"acl": acl}, acl_create_params.ACLCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLCreateResponse], ResultWrapper[ACLCreateResponse]), + ) + + def update( + self, + acl_identifier: str, + *, + account_id: str, + site_id: str, + acl: acl_update_params.ACL | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLUpdateResponse: + """ + Update a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_identifier: + raise ValueError(f"Expected a non-empty value for `acl_identifier` but received {acl_identifier!r}") + return self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier}", + body=maybe_transform({"acl": acl}, acl_update_params.ACLUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLUpdateResponse], ResultWrapper[ACLUpdateResponse]), + ) + + def list( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLListResponse: + """ + Lists Site ACLs associated with an account. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/acls", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLListResponse], ResultWrapper[ACLListResponse]), + ) + + def delete( + self, + acl_identifier: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLDeleteResponse: + """ + Remove a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_identifier: + raise ValueError(f"Expected a non-empty value for `acl_identifier` but received {acl_identifier!r}") + return self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLDeleteResponse], ResultWrapper[ACLDeleteResponse]), + ) + + def get( + self, + acl_identifier: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLGetResponse: + """ + Get a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_identifier: + raise ValueError(f"Expected a non-empty value for `acl_identifier` but received {acl_identifier!r}") + return self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLGetResponse], ResultWrapper[ACLGetResponse]), + ) + + +class AsyncACLs(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncACLsWithRawResponse: + return AsyncACLsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncACLsWithStreamingResponse: + return AsyncACLsWithStreamingResponse(self) + + async def create( + self, + site_id: str, + *, + account_id: str, + acl: acl_create_params.ACL | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLCreateResponse: + """ + Creates a new Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/acls", + body=await async_maybe_transform({"acl": acl}, acl_create_params.ACLCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLCreateResponse], ResultWrapper[ACLCreateResponse]), + ) + + async def update( + self, + acl_identifier: str, + *, + account_id: str, + site_id: str, + acl: acl_update_params.ACL | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLUpdateResponse: + """ + Update a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_identifier: + raise ValueError(f"Expected a non-empty value for `acl_identifier` but received {acl_identifier!r}") + return await self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier}", + body=await async_maybe_transform({"acl": acl}, acl_update_params.ACLUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLUpdateResponse], ResultWrapper[ACLUpdateResponse]), + ) + + async def list( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLListResponse: + """ + Lists Site ACLs associated with an account. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/acls", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLListResponse], ResultWrapper[ACLListResponse]), + ) + + async def delete( + self, + acl_identifier: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLDeleteResponse: + """ + Remove a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_identifier: + raise ValueError(f"Expected a non-empty value for `acl_identifier` but received {acl_identifier!r}") + return await self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLDeleteResponse], ResultWrapper[ACLDeleteResponse]), + ) + + async def get( + self, + acl_identifier: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ACLGetResponse: + """ + Get a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_identifier: + raise ValueError(f"Expected a non-empty value for `acl_identifier` but received {acl_identifier!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[ACLGetResponse], ResultWrapper[ACLGetResponse]), + ) + + +class ACLsWithRawResponse: + def __init__(self, acls: ACLs) -> None: + self._acls = acls + + self.create = to_raw_response_wrapper( + acls.create, + ) + self.update = to_raw_response_wrapper( + acls.update, + ) + self.list = to_raw_response_wrapper( + acls.list, + ) + self.delete = to_raw_response_wrapper( + acls.delete, + ) + self.get = to_raw_response_wrapper( + acls.get, + ) + + +class AsyncACLsWithRawResponse: + def __init__(self, acls: AsyncACLs) -> None: + self._acls = acls + + self.create = async_to_raw_response_wrapper( + acls.create, + ) + self.update = async_to_raw_response_wrapper( + acls.update, + ) + self.list = async_to_raw_response_wrapper( + acls.list, + ) + self.delete = async_to_raw_response_wrapper( + acls.delete, + ) + self.get = async_to_raw_response_wrapper( + acls.get, + ) + + +class ACLsWithStreamingResponse: + def __init__(self, acls: ACLs) -> None: + self._acls = acls + + self.create = to_streamed_response_wrapper( + acls.create, + ) + self.update = to_streamed_response_wrapper( + acls.update, + ) + self.list = to_streamed_response_wrapper( + acls.list, + ) + self.delete = to_streamed_response_wrapper( + acls.delete, + ) + self.get = to_streamed_response_wrapper( + acls.get, + ) + + +class AsyncACLsWithStreamingResponse: + def __init__(self, acls: AsyncACLs) -> None: + self._acls = acls + + self.create = async_to_streamed_response_wrapper( + acls.create, + ) + self.update = async_to_streamed_response_wrapper( + acls.update, + ) + self.list = async_to_streamed_response_wrapper( + acls.list, + ) + self.delete = async_to_streamed_response_wrapper( + acls.delete, + ) + self.get = async_to_streamed_response_wrapper( + acls.get, + ) diff --git a/src/cloudflare/resources/magic_transit/sites/lans.py b/src/cloudflare/resources/magic_transit/sites/lans.py new file mode 100644 index 00000000000..d4e8334ed9c --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/lans.py @@ -0,0 +1,622 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import ( + make_request_options, +) +from ....types.magic_transit.sites import ( + LanGetResponse, + LanListResponse, + LanCreateResponse, + LanDeleteResponse, + LanUpdateResponse, + lan_create_params, + lan_update_params, +) + +__all__ = ["Lans", "AsyncLans"] + + +class Lans(SyncAPIResource): + @cached_property + def with_raw_response(self) -> LansWithRawResponse: + return LansWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LansWithStreamingResponse: + return LansWithStreamingResponse(self) + + def create( + self, + site_id: str, + *, + account_id: str, + lan: lan_create_params.Lan | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanCreateResponse: + """Creates a new LAN. + + If the site is in high availability mode, static_addressing + is required along with secondary and virtual address. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/lans", + body=maybe_transform({"lan": lan}, lan_create_params.LanCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanCreateResponse], ResultWrapper[LanCreateResponse]), + ) + + def update( + self, + lan_id: str, + *, + account_id: str, + site_id: str, + lan: lan_update_params.Lan | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanUpdateResponse: + """ + Update a specific LAN. + + Args: + account_id: Identifier + + site_id: Identifier + + lan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not lan_id: + raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") + return self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + body=maybe_transform({"lan": lan}, lan_update_params.LanUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanUpdateResponse], ResultWrapper[LanUpdateResponse]), + ) + + def list( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanListResponse: + """ + Lists LANs associated with an account and site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/lans", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanListResponse], ResultWrapper[LanListResponse]), + ) + + def delete( + self, + lan_id: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanDeleteResponse: + """ + Remove a specific LAN. + + Args: + account_id: Identifier + + site_id: Identifier + + lan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not lan_id: + raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanDeleteResponse], ResultWrapper[LanDeleteResponse]), + ) + + def get( + self, + lan_id: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanGetResponse: + """ + Get a specific LAN. + + Args: + account_id: Identifier + + site_id: Identifier + + lan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not lan_id: + raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") + return self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanGetResponse], ResultWrapper[LanGetResponse]), + ) + + +class AsyncLans(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncLansWithRawResponse: + return AsyncLansWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLansWithStreamingResponse: + return AsyncLansWithStreamingResponse(self) + + async def create( + self, + site_id: str, + *, + account_id: str, + lan: lan_create_params.Lan | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanCreateResponse: + """Creates a new LAN. + + If the site is in high availability mode, static_addressing + is required along with secondary and virtual address. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/lans", + body=await async_maybe_transform({"lan": lan}, lan_create_params.LanCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanCreateResponse], ResultWrapper[LanCreateResponse]), + ) + + async def update( + self, + lan_id: str, + *, + account_id: str, + site_id: str, + lan: lan_update_params.Lan | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanUpdateResponse: + """ + Update a specific LAN. + + Args: + account_id: Identifier + + site_id: Identifier + + lan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not lan_id: + raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + body=await async_maybe_transform({"lan": lan}, lan_update_params.LanUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanUpdateResponse], ResultWrapper[LanUpdateResponse]), + ) + + async def list( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanListResponse: + """ + Lists LANs associated with an account and site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/lans", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanListResponse], ResultWrapper[LanListResponse]), + ) + + async def delete( + self, + lan_id: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanDeleteResponse: + """ + Remove a specific LAN. + + Args: + account_id: Identifier + + site_id: Identifier + + lan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not lan_id: + raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanDeleteResponse], ResultWrapper[LanDeleteResponse]), + ) + + async def get( + self, + lan_id: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LanGetResponse: + """ + Get a specific LAN. + + Args: + account_id: Identifier + + site_id: Identifier + + lan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not lan_id: + raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[LanGetResponse], ResultWrapper[LanGetResponse]), + ) + + +class LansWithRawResponse: + def __init__(self, lans: Lans) -> None: + self._lans = lans + + self.create = to_raw_response_wrapper( + lans.create, + ) + self.update = to_raw_response_wrapper( + lans.update, + ) + self.list = to_raw_response_wrapper( + lans.list, + ) + self.delete = to_raw_response_wrapper( + lans.delete, + ) + self.get = to_raw_response_wrapper( + lans.get, + ) + + +class AsyncLansWithRawResponse: + def __init__(self, lans: AsyncLans) -> None: + self._lans = lans + + self.create = async_to_raw_response_wrapper( + lans.create, + ) + self.update = async_to_raw_response_wrapper( + lans.update, + ) + self.list = async_to_raw_response_wrapper( + lans.list, + ) + self.delete = async_to_raw_response_wrapper( + lans.delete, + ) + self.get = async_to_raw_response_wrapper( + lans.get, + ) + + +class LansWithStreamingResponse: + def __init__(self, lans: Lans) -> None: + self._lans = lans + + self.create = to_streamed_response_wrapper( + lans.create, + ) + self.update = to_streamed_response_wrapper( + lans.update, + ) + self.list = to_streamed_response_wrapper( + lans.list, + ) + self.delete = to_streamed_response_wrapper( + lans.delete, + ) + self.get = to_streamed_response_wrapper( + lans.get, + ) + + +class AsyncLansWithStreamingResponse: + def __init__(self, lans: AsyncLans) -> None: + self._lans = lans + + self.create = async_to_streamed_response_wrapper( + lans.create, + ) + self.update = async_to_streamed_response_wrapper( + lans.update, + ) + self.list = async_to_streamed_response_wrapper( + lans.list, + ) + self.delete = async_to_streamed_response_wrapper( + lans.delete, + ) + self.get = async_to_streamed_response_wrapper( + lans.get, + ) diff --git a/src/cloudflare/resources/magic_transit/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites.py new file mode 100644 index 00000000000..b0c7ccef6a3 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/sites.py @@ -0,0 +1,670 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from .acls import ( + ACLs, + AsyncACLs, + ACLsWithRawResponse, + AsyncACLsWithRawResponse, + ACLsWithStreamingResponse, + AsyncACLsWithStreamingResponse, +) +from .lans import ( + Lans, + AsyncLans, + LansWithRawResponse, + AsyncLansWithRawResponse, + LansWithStreamingResponse, + AsyncLansWithStreamingResponse, +) +from .wans import ( + Wans, + AsyncWans, + WansWithRawResponse, + AsyncWansWithRawResponse, + WansWithStreamingResponse, + AsyncWansWithStreamingResponse, +) +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import ( + make_request_options, +) +from ....types.magic_transit import ( + SiteGetResponse, + SiteListResponse, + SiteCreateResponse, + SiteDeleteResponse, + SiteUpdateResponse, + site_create_params, + site_update_params, +) + +__all__ = ["Sites", "AsyncSites"] + + +class Sites(SyncAPIResource): + @cached_property + def acls(self) -> ACLs: + return ACLs(self._client) + + @cached_property + def lans(self) -> Lans: + return Lans(self._client) + + @cached_property + def wans(self) -> Wans: + return Wans(self._client) + + @cached_property + def with_raw_response(self) -> SitesWithRawResponse: + return SitesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SitesWithStreamingResponse: + return SitesWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + site: site_create_params.Site | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteCreateResponse: + """ + Creates a new Site + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/magic/sites", + body=maybe_transform({"site": site}, site_create_params.SiteCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteCreateResponse], ResultWrapper[SiteCreateResponse]), + ) + + def update( + self, + site_id: str, + *, + account_id: str, + site: site_update_params.Site | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteUpdateResponse: + """ + Update a specific Site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._put( + f"/accounts/{account_id}/magic/sites/{site_id}", + body=maybe_transform({"site": site}, site_update_params.SiteUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteUpdateResponse], ResultWrapper[SiteUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteListResponse: + """Lists Sites associated with an account. + + Use connector_identifier query param to + return sites where connector_identifier matches either site.ConnectorID or + site.SecondaryConnectorID. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/magic/sites", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteListResponse], ResultWrapper[SiteListResponse]), + ) + + def delete( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteDeleteResponse: + """ + Remove a specific Site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteDeleteResponse], ResultWrapper[SiteDeleteResponse]), + ) + + def get( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteGetResponse: + """ + Get a specific Site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._get( + f"/accounts/{account_id}/magic/sites/{site_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteGetResponse], ResultWrapper[SiteGetResponse]), + ) + + +class AsyncSites(AsyncAPIResource): + @cached_property + def acls(self) -> AsyncACLs: + return AsyncACLs(self._client) + + @cached_property + def lans(self) -> AsyncLans: + return AsyncLans(self._client) + + @cached_property + def wans(self) -> AsyncWans: + return AsyncWans(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSitesWithRawResponse: + return AsyncSitesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSitesWithStreamingResponse: + return AsyncSitesWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + site: site_create_params.Site | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteCreateResponse: + """ + Creates a new Site + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/sites", + body=await async_maybe_transform({"site": site}, site_create_params.SiteCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteCreateResponse], ResultWrapper[SiteCreateResponse]), + ) + + async def update( + self, + site_id: str, + *, + account_id: str, + site: site_update_params.Site | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteUpdateResponse: + """ + Update a specific Site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/sites/{site_id}", + body=await async_maybe_transform({"site": site}, site_update_params.SiteUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteUpdateResponse], ResultWrapper[SiteUpdateResponse]), + ) + + async def list( + self, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteListResponse: + """Lists Sites associated with an account. + + Use connector_identifier query param to + return sites where connector_identifier matches either site.ConnectorID or + site.SecondaryConnectorID. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteListResponse], ResultWrapper[SiteListResponse]), + ) + + async def delete( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteDeleteResponse: + """ + Remove a specific Site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteDeleteResponse], ResultWrapper[SiteDeleteResponse]), + ) + + async def get( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SiteGetResponse: + """ + Get a specific Site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites/{site_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[SiteGetResponse], ResultWrapper[SiteGetResponse]), + ) + + +class SitesWithRawResponse: + def __init__(self, sites: Sites) -> None: + self._sites = sites + + self.create = to_raw_response_wrapper( + sites.create, + ) + self.update = to_raw_response_wrapper( + sites.update, + ) + self.list = to_raw_response_wrapper( + sites.list, + ) + self.delete = to_raw_response_wrapper( + sites.delete, + ) + self.get = to_raw_response_wrapper( + sites.get, + ) + + @cached_property + def acls(self) -> ACLsWithRawResponse: + return ACLsWithRawResponse(self._sites.acls) + + @cached_property + def lans(self) -> LansWithRawResponse: + return LansWithRawResponse(self._sites.lans) + + @cached_property + def wans(self) -> WansWithRawResponse: + return WansWithRawResponse(self._sites.wans) + + +class AsyncSitesWithRawResponse: + def __init__(self, sites: AsyncSites) -> None: + self._sites = sites + + self.create = async_to_raw_response_wrapper( + sites.create, + ) + self.update = async_to_raw_response_wrapper( + sites.update, + ) + self.list = async_to_raw_response_wrapper( + sites.list, + ) + self.delete = async_to_raw_response_wrapper( + sites.delete, + ) + self.get = async_to_raw_response_wrapper( + sites.get, + ) + + @cached_property + def acls(self) -> AsyncACLsWithRawResponse: + return AsyncACLsWithRawResponse(self._sites.acls) + + @cached_property + def lans(self) -> AsyncLansWithRawResponse: + return AsyncLansWithRawResponse(self._sites.lans) + + @cached_property + def wans(self) -> AsyncWansWithRawResponse: + return AsyncWansWithRawResponse(self._sites.wans) + + +class SitesWithStreamingResponse: + def __init__(self, sites: Sites) -> None: + self._sites = sites + + self.create = to_streamed_response_wrapper( + sites.create, + ) + self.update = to_streamed_response_wrapper( + sites.update, + ) + self.list = to_streamed_response_wrapper( + sites.list, + ) + self.delete = to_streamed_response_wrapper( + sites.delete, + ) + self.get = to_streamed_response_wrapper( + sites.get, + ) + + @cached_property + def acls(self) -> ACLsWithStreamingResponse: + return ACLsWithStreamingResponse(self._sites.acls) + + @cached_property + def lans(self) -> LansWithStreamingResponse: + return LansWithStreamingResponse(self._sites.lans) + + @cached_property + def wans(self) -> WansWithStreamingResponse: + return WansWithStreamingResponse(self._sites.wans) + + +class AsyncSitesWithStreamingResponse: + def __init__(self, sites: AsyncSites) -> None: + self._sites = sites + + self.create = async_to_streamed_response_wrapper( + sites.create, + ) + self.update = async_to_streamed_response_wrapper( + sites.update, + ) + self.list = async_to_streamed_response_wrapper( + sites.list, + ) + self.delete = async_to_streamed_response_wrapper( + sites.delete, + ) + self.get = async_to_streamed_response_wrapper( + sites.get, + ) + + @cached_property + def acls(self) -> AsyncACLsWithStreamingResponse: + return AsyncACLsWithStreamingResponse(self._sites.acls) + + @cached_property + def lans(self) -> AsyncLansWithStreamingResponse: + return AsyncLansWithStreamingResponse(self._sites.lans) + + @cached_property + def wans(self) -> AsyncWansWithStreamingResponse: + return AsyncWansWithStreamingResponse(self._sites.wans) diff --git a/src/cloudflare/resources/magic_transit/sites/wans.py b/src/cloudflare/resources/magic_transit/sites/wans.py new file mode 100644 index 00000000000..f79dcfa6a72 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/wans.py @@ -0,0 +1,618 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import ( + make_request_options, +) +from ....types.magic_transit.sites import ( + WanGetResponse, + WanListResponse, + WanCreateResponse, + WanDeleteResponse, + WanUpdateResponse, + wan_create_params, + wan_update_params, +) + +__all__ = ["Wans", "AsyncWans"] + + +class Wans(SyncAPIResource): + @cached_property + def with_raw_response(self) -> WansWithRawResponse: + return WansWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> WansWithStreamingResponse: + return WansWithStreamingResponse(self) + + def create( + self, + site_id: str, + *, + account_id: str, + wan: wan_create_params.Wan | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanCreateResponse: + """ + Creates a new WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/wans", + body=maybe_transform({"wan": wan}, wan_create_params.WanCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanCreateResponse], ResultWrapper[WanCreateResponse]), + ) + + def update( + self, + wan_id: str, + *, + account_id: str, + site_id: str, + wan: wan_update_params.Wan | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanUpdateResponse: + """ + Update a specific WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + wan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not wan_id: + raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") + return self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + body=maybe_transform({"wan": wan}, wan_update_params.WanUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanUpdateResponse], ResultWrapper[WanUpdateResponse]), + ) + + def list( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanListResponse: + """ + Lists WANs associated with an account and site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/wans", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanListResponse], ResultWrapper[WanListResponse]), + ) + + def delete( + self, + wan_id: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanDeleteResponse: + """ + Remove a specific WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + wan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not wan_id: + raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanDeleteResponse], ResultWrapper[WanDeleteResponse]), + ) + + def get( + self, + wan_id: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanGetResponse: + """ + Get a specific WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + wan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not wan_id: + raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") + return self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanGetResponse], ResultWrapper[WanGetResponse]), + ) + + +class AsyncWans(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncWansWithRawResponse: + return AsyncWansWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncWansWithStreamingResponse: + return AsyncWansWithStreamingResponse(self) + + async def create( + self, + site_id: str, + *, + account_id: str, + wan: wan_create_params.Wan | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanCreateResponse: + """ + Creates a new WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/wans", + body=await async_maybe_transform({"wan": wan}, wan_create_params.WanCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanCreateResponse], ResultWrapper[WanCreateResponse]), + ) + + async def update( + self, + wan_id: str, + *, + account_id: str, + site_id: str, + wan: wan_update_params.Wan | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanUpdateResponse: + """ + Update a specific WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + wan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not wan_id: + raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + body=await async_maybe_transform({"wan": wan}, wan_update_params.WanUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanUpdateResponse], ResultWrapper[WanUpdateResponse]), + ) + + async def list( + self, + site_id: str, + *, + account_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanListResponse: + """ + Lists WANs associated with an account and site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/wans", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanListResponse], ResultWrapper[WanListResponse]), + ) + + async def delete( + self, + wan_id: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanDeleteResponse: + """ + Remove a specific WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + wan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not wan_id: + raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanDeleteResponse], ResultWrapper[WanDeleteResponse]), + ) + + async def get( + self, + wan_id: str, + *, + account_id: str, + site_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> WanGetResponse: + """ + Get a specific WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + wan_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not wan_id: + raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[WanGetResponse], ResultWrapper[WanGetResponse]), + ) + + +class WansWithRawResponse: + def __init__(self, wans: Wans) -> None: + self._wans = wans + + self.create = to_raw_response_wrapper( + wans.create, + ) + self.update = to_raw_response_wrapper( + wans.update, + ) + self.list = to_raw_response_wrapper( + wans.list, + ) + self.delete = to_raw_response_wrapper( + wans.delete, + ) + self.get = to_raw_response_wrapper( + wans.get, + ) + + +class AsyncWansWithRawResponse: + def __init__(self, wans: AsyncWans) -> None: + self._wans = wans + + self.create = async_to_raw_response_wrapper( + wans.create, + ) + self.update = async_to_raw_response_wrapper( + wans.update, + ) + self.list = async_to_raw_response_wrapper( + wans.list, + ) + self.delete = async_to_raw_response_wrapper( + wans.delete, + ) + self.get = async_to_raw_response_wrapper( + wans.get, + ) + + +class WansWithStreamingResponse: + def __init__(self, wans: Wans) -> None: + self._wans = wans + + self.create = to_streamed_response_wrapper( + wans.create, + ) + self.update = to_streamed_response_wrapper( + wans.update, + ) + self.list = to_streamed_response_wrapper( + wans.list, + ) + self.delete = to_streamed_response_wrapper( + wans.delete, + ) + self.get = to_streamed_response_wrapper( + wans.get, + ) + + +class AsyncWansWithStreamingResponse: + def __init__(self, wans: AsyncWans) -> None: + self._wans = wans + + self.create = async_to_streamed_response_wrapper( + wans.create, + ) + self.update = async_to_streamed_response_wrapper( + wans.update, + ) + self.list = async_to_streamed_response_wrapper( + wans.list, + ) + self.delete = async_to_streamed_response_wrapper( + wans.delete, + ) + self.get = async_to_streamed_response_wrapper( + wans.get, + ) diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index ec5b173cc33..e835374b94d 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -76,6 +76,7 @@ from .rate_limit_list_params import RateLimitListParams as RateLimitListParams from .account_update_response import AccountUpdateResponse as AccountUpdateResponse from .audit_log_list_response import AuditLogListResponse as AuditLogListResponse +from .healthcheck_edit_params import HealthcheckEditParams as HealthcheckEditParams from .intel_phishing_url_info import IntelPhishingURLInfo as IntelPhishingURLInfo from .membership_get_response import MembershipGetResponse as MembershipGetResponse from .rate_limit_get_response import RateLimitGetResponse as RateLimitGetResponse @@ -91,6 +92,10 @@ from .rate_limit_list_response import RateLimitListResponse as RateLimitListResponse from .speed_trends_list_params import SpeedTrendsListParams as SpeedTrendsListParams from .waiting_room_edit_params import WaitingRoomEditParams as WaitingRoomEditParams +from .healthcheck_create_params import HealthcheckCreateParams as HealthcheckCreateParams +from .healthcheck_list_response import HealthcheckListResponse as HealthcheckListResponse +from .healthcheck_update_params import HealthcheckUpdateParams as HealthcheckUpdateParams +from .healthchecks_healthchecks import HealthchecksHealthchecks as HealthchecksHealthchecks from .intel_phishing_url_submit import IntelPhishingURLSubmit as IntelPhishingURLSubmit from .load_balancer_edit_params import LoadBalancerEditParams as LoadBalancerEditParams from .page_shield_update_params import PageShieldUpdateParams as PageShieldUpdateParams @@ -115,6 +120,7 @@ from .bot_management_get_response import BotManagementGetResponse as BotManagementGetResponse from .custom_hostname_edit_params import CustomHostnameEditParams as CustomHostnameEditParams from .custom_hostname_list_params import CustomHostnameListParams as CustomHostnameListParams +from .healthcheck_delete_response import HealthcheckDeleteResponse as HealthcheckDeleteResponse from .load_balancer_create_params import LoadBalancerCreateParams as LoadBalancerCreateParams from .load_balancer_list_response import LoadBalancerListResponse as LoadBalancerListResponse from .load_balancer_update_params import LoadBalancerUpdateParams as LoadBalancerUpdateParams diff --git a/src/cloudflare/types/dns/analytics/__init__.py b/src/cloudflare/types/dns/analytics/__init__.py index f8ee8b14b1c..a8e1c2d94e4 100644 --- a/src/cloudflare/types/dns/analytics/__init__.py +++ b/src/cloudflare/types/dns/analytics/__init__.py @@ -1,3 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .report_get_params import ReportGetParams as ReportGetParams +from .dns_dns_analytics_api_report import DNSDNSAnalyticsAPIReport as DNSDNSAnalyticsAPIReport diff --git a/src/cloudflare/types/dns/analytics/dns_dns_analytics_api_report.py b/src/cloudflare/types/dns/analytics/dns_dns_analytics_api_report.py new file mode 100644 index 00000000000..17e9ca38361 --- /dev/null +++ b/src/cloudflare/types/dns/analytics/dns_dns_analytics_api_report.py @@ -0,0 +1,79 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["DNSDNSAnalyticsAPIReport", "Data", "Query"] + + +class Data(BaseModel): + dimensions: List[str] + """ + Array of dimension values, representing the combination of dimension values + corresponding to this row. + """ + + metrics: List[float] + """Array with one item per requested metric. Each item is a single value.""" + + +class Query(BaseModel): + dimensions: List[str] + """Array of dimension names.""" + + limit: int + """Limit number of returned metrics.""" + + metrics: List[str] + """Array of metric names.""" + + since: datetime + """Start date and time of requesting data period in ISO 8601 format.""" + + until: datetime + """End date and time of requesting data period in ISO 8601 format.""" + + filters: Optional[str] = None + """Segmentation filter in 'attribute operator value' format.""" + + sort: Optional[List[str]] = None + """ + Array of dimensions to sort by, where each dimension may be prefixed by - + (descending) or + (ascending). + """ + + +class DNSDNSAnalyticsAPIReport(BaseModel): + data: List[Data] + """Array with one row per combination of dimension values.""" + + data_lag: float + """ + Number of seconds between current time and last processed event, in another + words how many seconds of data could be missing. + """ + + max: object + """Maximum results for each metric (object mapping metric names to values). + + Currently always an empty object. + """ + + min: object + """Minimum results for each metric (object mapping metric names to values). + + Currently always an empty object. + """ + + query: Query + + rows: float + """Total number of rows in the result.""" + + totals: object + """ + Total results for metrics across all data (object mapping metric names to + values). + """ diff --git a/src/cloudflare/types/dns/analytics/report_get_params.py b/src/cloudflare/types/dns/analytics/report_get_params.py new file mode 100644 index 00000000000..12caad200d7 --- /dev/null +++ b/src/cloudflare/types/dns/analytics/report_get_params.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["ReportGetParams"] + + +class ReportGetParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + dimensions: str + """A comma-separated list of dimensions to group results by.""" + + filters: str + """Segmentation filter in 'attribute operator value' format.""" + + limit: int + """Limit number of returned metrics.""" + + metrics: str + """A comma-separated list of metrics to query.""" + + since: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """Start date and time of requesting data period in ISO 8601 format.""" + + sort: str + """ + A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + """ + + until: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """End date and time of requesting data period in ISO 8601 format.""" diff --git a/src/cloudflare/types/dns/analytics/reports/__init__.py b/src/cloudflare/types/dns/analytics/reports/__init__.py index f8ee8b14b1c..8d0bea62f39 100644 --- a/src/cloudflare/types/dns/analytics/reports/__init__.py +++ b/src/cloudflare/types/dns/analytics/reports/__init__.py @@ -1,3 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .bytime_get_params import BytimeGetParams as BytimeGetParams +from .dns_dns_analytics_api_report_bytime import DNSDNSAnalyticsAPIReportBytime as DNSDNSAnalyticsAPIReportBytime diff --git a/src/cloudflare/types/dns/analytics/reports/bytime_get_params.py b/src/cloudflare/types/dns/analytics/reports/bytime_get_params.py new file mode 100644 index 00000000000..12ef8217a02 --- /dev/null +++ b/src/cloudflare/types/dns/analytics/reports/bytime_get_params.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ....._utils import PropertyInfo + +__all__ = ["BytimeGetParams"] + + +class BytimeGetParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + dimensions: str + """A comma-separated list of dimensions to group results by.""" + + filters: str + """Segmentation filter in 'attribute operator value' format.""" + + limit: int + """Limit number of returned metrics.""" + + metrics: str + """A comma-separated list of metrics to query.""" + + since: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """Start date and time of requesting data period in ISO 8601 format.""" + + sort: str + """ + A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + """ + + time_delta: Literal["all", "auto", "year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"] + """Unit of time to group data by.""" + + until: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """End date and time of requesting data period in ISO 8601 format.""" diff --git a/src/cloudflare/types/dns/analytics/reports/dns_dns_analytics_api_report_bytime.py b/src/cloudflare/types/dns/analytics/reports/dns_dns_analytics_api_report_bytime.py new file mode 100644 index 00000000000..003873123d1 --- /dev/null +++ b/src/cloudflare/types/dns/analytics/reports/dns_dns_analytics_api_report_bytime.py @@ -0,0 +1,93 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["DNSDNSAnalyticsAPIReportBytime", "Data", "Query"] + + +class Data(BaseModel): + dimensions: List[str] + """ + Array of dimension values, representing the combination of dimension values + corresponding to this row. + """ + + metrics: List[List[object]] + """Array with one item per requested metric. + + Each item is an array of values, broken down by time interval. + """ + + +class Query(BaseModel): + dimensions: List[str] + """Array of dimension names.""" + + limit: int + """Limit number of returned metrics.""" + + metrics: List[str] + """Array of metric names.""" + + since: datetime + """Start date and time of requesting data period in ISO 8601 format.""" + + time_delta: Literal["all", "auto", "year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"] + """Unit of time to group data by.""" + + until: datetime + """End date and time of requesting data period in ISO 8601 format.""" + + filters: Optional[str] = None + """Segmentation filter in 'attribute operator value' format.""" + + sort: Optional[List[str]] = None + """ + Array of dimensions to sort by, where each dimension may be prefixed by - + (descending) or + (ascending). + """ + + +class DNSDNSAnalyticsAPIReportBytime(BaseModel): + data: List[Data] + """Array with one row per combination of dimension values.""" + + data_lag: float + """ + Number of seconds between current time and last processed event, in another + words how many seconds of data could be missing. + """ + + max: object + """Maximum results for each metric (object mapping metric names to values). + + Currently always an empty object. + """ + + min: object + """Minimum results for each metric (object mapping metric names to values). + + Currently always an empty object. + """ + + query: Query + + rows: float + """Total number of rows in the result.""" + + time_intervals: List[List[datetime]] + """Array of time intervals in the response data. + + Each interval is represented as an array containing two values: the start time, + and the end time. + """ + + totals: object + """ + Total results for metrics across all data (object mapping metric names to + values). + """ diff --git a/src/cloudflare/types/dns/firewall/analytics/__init__.py b/src/cloudflare/types/dns/firewall/analytics/__init__.py index f8ee8b14b1c..5702c7a172a 100644 --- a/src/cloudflare/types/dns/firewall/analytics/__init__.py +++ b/src/cloudflare/types/dns/firewall/analytics/__init__.py @@ -1,3 +1,5 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .report_get_params import ReportGetParams as ReportGetParams diff --git a/src/cloudflare/types/dns/firewall/analytics/report_get_params.py b/src/cloudflare/types/dns/firewall/analytics/report_get_params.py new file mode 100644 index 00000000000..5697245f32d --- /dev/null +++ b/src/cloudflare/types/dns/firewall/analytics/report_get_params.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict + +from ....._utils import PropertyInfo + +__all__ = ["ReportGetParams"] + + +class ReportGetParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + dimensions: str + """A comma-separated list of dimensions to group results by.""" + + filters: str + """Segmentation filter in 'attribute operator value' format.""" + + limit: int + """Limit number of returned metrics.""" + + metrics: str + """A comma-separated list of metrics to query.""" + + since: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """Start date and time of requesting data period in ISO 8601 format.""" + + sort: str + """ + A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + """ + + until: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """End date and time of requesting data period in ISO 8601 format.""" diff --git a/src/cloudflare/types/dns/firewall/analytics/reports/__init__.py b/src/cloudflare/types/dns/firewall/analytics/reports/__init__.py index f8ee8b14b1c..e88c3f32e1f 100644 --- a/src/cloudflare/types/dns/firewall/analytics/reports/__init__.py +++ b/src/cloudflare/types/dns/firewall/analytics/reports/__init__.py @@ -1,3 +1,5 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .bytime_get_params import BytimeGetParams as BytimeGetParams diff --git a/src/cloudflare/types/dns/firewall/analytics/reports/bytime_get_params.py b/src/cloudflare/types/dns/firewall/analytics/reports/bytime_get_params.py new file mode 100644 index 00000000000..91d85b4a63a --- /dev/null +++ b/src/cloudflare/types/dns/firewall/analytics/reports/bytime_get_params.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ......_utils import PropertyInfo + +__all__ = ["BytimeGetParams"] + + +class BytimeGetParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + dimensions: str + """A comma-separated list of dimensions to group results by.""" + + filters: str + """Segmentation filter in 'attribute operator value' format.""" + + limit: int + """Limit number of returned metrics.""" + + metrics: str + """A comma-separated list of metrics to query.""" + + since: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """Start date and time of requesting data period in ISO 8601 format.""" + + sort: str + """ + A comma-separated list of dimensions to sort by, where each dimension may be + prefixed by - (descending) or + (ascending). + """ + + time_delta: Literal["all", "auto", "year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"] + """Unit of time to group data by.""" + + until: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """End date and time of requesting data period in ISO 8601 format.""" diff --git a/src/cloudflare/types/healthcheck_create_params.py b/src/cloudflare/types/healthcheck_create_params.py new file mode 100644 index 00000000000..1c96c204d9f --- /dev/null +++ b/src/cloudflare/types/healthcheck_create_params.py @@ -0,0 +1,143 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["HealthcheckCreateParams", "HTTPConfig", "TcpConfig"] + + +class HealthcheckCreateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + address: Required[str] + """The hostname or IP address of the origin server to run health checks on.""" + + name: Required[str] + """A short name to identify the health check. + + Only alphanumeric characters, hyphens and underscores are allowed. + """ + + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + """A list of regions from which to run health checks. + + Null means Cloudflare will pick a default region. + """ + + consecutive_fails: int + """ + The number of consecutive fails required from a health check before changing the + health to unhealthy. + """ + + consecutive_successes: int + """ + The number of consecutive successes required from a health check before changing + the health to healthy. + """ + + description: str + """A human-readable description of the health check.""" + + http_config: Optional[HTTPConfig] + """Parameters specific to an HTTP or HTTPS health check.""" + + interval: int + """The interval between each health check. + + Shorter intervals may give quicker notifications if the origin status changes, + but will increase load on the origin as we check from multiple locations. + """ + + retries: int + """ + The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + """ + + suspended: bool + """If suspended, no health checks are sent to the origin.""" + + tcp_config: Optional[TcpConfig] + """Parameters specific to TCP health check.""" + + healthcheck_timeout: Annotated[int, PropertyInfo(alias="timeout")] + """The timeout (in seconds) before marking the health check as failed.""" + + type: str + """The protocol to use for the health check. + + Currently supported protocols are 'HTTP', 'HTTPS' and 'TCP'. + """ + + +class HTTPConfig(TypedDict, total=False): + allow_insecure: bool + """Do not validate the certificate when the health check uses HTTPS.""" + + expected_body: str + """A case-insensitive sub-string to look for in the response body. + + If this string is not found, the origin will be marked as unhealthy. + """ + + expected_codes: Optional[List[str]] + """The expected HTTP response codes (e.g. + + "200") or code ranges (e.g. "2xx" for all codes starting with 2) of the health + check. + """ + + follow_redirects: bool + """Follow redirects if the origin returns a 3xx status code.""" + + header: Optional[object] + """The HTTP request headers to send in the health check. + + It is recommended you set a Host header by default. The User-Agent header cannot + be overridden. + """ + + method: Literal["GET", "HEAD"] + """The HTTP method to use for the health check.""" + + path: str + """The endpoint path to health check against.""" + + port: int + """Port number to connect to for the health check. + + Defaults to 80 if type is HTTP or 443 if type is HTTPS. + """ + + +class TcpConfig(TypedDict, total=False): + method: Literal["connection_established"] + """The TCP connection method to use for the health check.""" + + port: int + """Port number to connect to for the health check. Defaults to 80.""" diff --git a/src/cloudflare/types/healthcheck_delete_response.py b/src/cloudflare/types/healthcheck_delete_response.py new file mode 100644 index 00000000000..6bbe40c8819 --- /dev/null +++ b/src/cloudflare/types/healthcheck_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from .._models import BaseModel + +__all__ = ["HealthcheckDeleteResponse"] + + +class HealthcheckDeleteResponse(BaseModel): + id: Optional[str] = None + """Identifier""" diff --git a/src/cloudflare/types/healthcheck_edit_params.py b/src/cloudflare/types/healthcheck_edit_params.py new file mode 100644 index 00000000000..f633b951f2b --- /dev/null +++ b/src/cloudflare/types/healthcheck_edit_params.py @@ -0,0 +1,143 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["HealthcheckEditParams", "HTTPConfig", "TcpConfig"] + + +class HealthcheckEditParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + address: Required[str] + """The hostname or IP address of the origin server to run health checks on.""" + + name: Required[str] + """A short name to identify the health check. + + Only alphanumeric characters, hyphens and underscores are allowed. + """ + + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + """A list of regions from which to run health checks. + + Null means Cloudflare will pick a default region. + """ + + consecutive_fails: int + """ + The number of consecutive fails required from a health check before changing the + health to unhealthy. + """ + + consecutive_successes: int + """ + The number of consecutive successes required from a health check before changing + the health to healthy. + """ + + description: str + """A human-readable description of the health check.""" + + http_config: Optional[HTTPConfig] + """Parameters specific to an HTTP or HTTPS health check.""" + + interval: int + """The interval between each health check. + + Shorter intervals may give quicker notifications if the origin status changes, + but will increase load on the origin as we check from multiple locations. + """ + + retries: int + """ + The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + """ + + suspended: bool + """If suspended, no health checks are sent to the origin.""" + + tcp_config: Optional[TcpConfig] + """Parameters specific to TCP health check.""" + + healthcheck_timeout: Annotated[int, PropertyInfo(alias="timeout")] + """The timeout (in seconds) before marking the health check as failed.""" + + type: str + """The protocol to use for the health check. + + Currently supported protocols are 'HTTP', 'HTTPS' and 'TCP'. + """ + + +class HTTPConfig(TypedDict, total=False): + allow_insecure: bool + """Do not validate the certificate when the health check uses HTTPS.""" + + expected_body: str + """A case-insensitive sub-string to look for in the response body. + + If this string is not found, the origin will be marked as unhealthy. + """ + + expected_codes: Optional[List[str]] + """The expected HTTP response codes (e.g. + + "200") or code ranges (e.g. "2xx" for all codes starting with 2) of the health + check. + """ + + follow_redirects: bool + """Follow redirects if the origin returns a 3xx status code.""" + + header: Optional[object] + """The HTTP request headers to send in the health check. + + It is recommended you set a Host header by default. The User-Agent header cannot + be overridden. + """ + + method: Literal["GET", "HEAD"] + """The HTTP method to use for the health check.""" + + path: str + """The endpoint path to health check against.""" + + port: int + """Port number to connect to for the health check. + + Defaults to 80 if type is HTTP or 443 if type is HTTPS. + """ + + +class TcpConfig(TypedDict, total=False): + method: Literal["connection_established"] + """The TCP connection method to use for the health check.""" + + port: int + """Port number to connect to for the health check. Defaults to 80.""" diff --git a/src/cloudflare/types/healthcheck_list_response.py b/src/cloudflare/types/healthcheck_list_response.py new file mode 100644 index 00000000000..d2bd7b377c0 --- /dev/null +++ b/src/cloudflare/types/healthcheck_list_response.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .healthchecks_healthchecks import HealthchecksHealthchecks + +__all__ = ["HealthcheckListResponse"] + +HealthcheckListResponse = List[HealthchecksHealthchecks] diff --git a/src/cloudflare/types/healthcheck_update_params.py b/src/cloudflare/types/healthcheck_update_params.py new file mode 100644 index 00000000000..e0f6b276d0a --- /dev/null +++ b/src/cloudflare/types/healthcheck_update_params.py @@ -0,0 +1,143 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["HealthcheckUpdateParams", "HTTPConfig", "TcpConfig"] + + +class HealthcheckUpdateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + address: Required[str] + """The hostname or IP address of the origin server to run health checks on.""" + + name: Required[str] + """A short name to identify the health check. + + Only alphanumeric characters, hyphens and underscores are allowed. + """ + + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + """A list of regions from which to run health checks. + + Null means Cloudflare will pick a default region. + """ + + consecutive_fails: int + """ + The number of consecutive fails required from a health check before changing the + health to unhealthy. + """ + + consecutive_successes: int + """ + The number of consecutive successes required from a health check before changing + the health to healthy. + """ + + description: str + """A human-readable description of the health check.""" + + http_config: Optional[HTTPConfig] + """Parameters specific to an HTTP or HTTPS health check.""" + + interval: int + """The interval between each health check. + + Shorter intervals may give quicker notifications if the origin status changes, + but will increase load on the origin as we check from multiple locations. + """ + + retries: int + """ + The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + """ + + suspended: bool + """If suspended, no health checks are sent to the origin.""" + + tcp_config: Optional[TcpConfig] + """Parameters specific to TCP health check.""" + + healthcheck_timeout: Annotated[int, PropertyInfo(alias="timeout")] + """The timeout (in seconds) before marking the health check as failed.""" + + type: str + """The protocol to use for the health check. + + Currently supported protocols are 'HTTP', 'HTTPS' and 'TCP'. + """ + + +class HTTPConfig(TypedDict, total=False): + allow_insecure: bool + """Do not validate the certificate when the health check uses HTTPS.""" + + expected_body: str + """A case-insensitive sub-string to look for in the response body. + + If this string is not found, the origin will be marked as unhealthy. + """ + + expected_codes: Optional[List[str]] + """The expected HTTP response codes (e.g. + + "200") or code ranges (e.g. "2xx" for all codes starting with 2) of the health + check. + """ + + follow_redirects: bool + """Follow redirects if the origin returns a 3xx status code.""" + + header: Optional[object] + """The HTTP request headers to send in the health check. + + It is recommended you set a Host header by default. The User-Agent header cannot + be overridden. + """ + + method: Literal["GET", "HEAD"] + """The HTTP method to use for the health check.""" + + path: str + """The endpoint path to health check against.""" + + port: int + """Port number to connect to for the health check. + + Defaults to 80 if type is HTTP or 443 if type is HTTPS. + """ + + +class TcpConfig(TypedDict, total=False): + method: Literal["connection_established"] + """The TCP connection method to use for the health check.""" + + port: int + """Port number to connect to for the health check. Defaults to 80.""" diff --git a/src/cloudflare/types/healthchecks/__init__.py b/src/cloudflare/types/healthchecks/__init__.py index f8ee8b14b1c..176d1de0dd3 100644 --- a/src/cloudflare/types/healthchecks/__init__.py +++ b/src/cloudflare/types/healthchecks/__init__.py @@ -1,3 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .preview_create_params import PreviewCreateParams as PreviewCreateParams +from .preview_delete_response import PreviewDeleteResponse as PreviewDeleteResponse diff --git a/src/cloudflare/types/healthchecks/preview_create_params.py b/src/cloudflare/types/healthchecks/preview_create_params.py new file mode 100644 index 00000000000..a37fce3f2a0 --- /dev/null +++ b/src/cloudflare/types/healthchecks/preview_create_params.py @@ -0,0 +1,143 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["PreviewCreateParams", "HTTPConfig", "TcpConfig"] + + +class PreviewCreateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + address: Required[str] + """The hostname or IP address of the origin server to run health checks on.""" + + name: Required[str] + """A short name to identify the health check. + + Only alphanumeric characters, hyphens and underscores are allowed. + """ + + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] + """A list of regions from which to run health checks. + + Null means Cloudflare will pick a default region. + """ + + consecutive_fails: int + """ + The number of consecutive fails required from a health check before changing the + health to unhealthy. + """ + + consecutive_successes: int + """ + The number of consecutive successes required from a health check before changing + the health to healthy. + """ + + description: str + """A human-readable description of the health check.""" + + http_config: Optional[HTTPConfig] + """Parameters specific to an HTTP or HTTPS health check.""" + + interval: int + """The interval between each health check. + + Shorter intervals may give quicker notifications if the origin status changes, + but will increase load on the origin as we check from multiple locations. + """ + + retries: int + """ + The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + """ + + suspended: bool + """If suspended, no health checks are sent to the origin.""" + + tcp_config: Optional[TcpConfig] + """Parameters specific to TCP health check.""" + + healthcheck_timeout: Annotated[int, PropertyInfo(alias="timeout")] + """The timeout (in seconds) before marking the health check as failed.""" + + type: str + """The protocol to use for the health check. + + Currently supported protocols are 'HTTP', 'HTTPS' and 'TCP'. + """ + + +class HTTPConfig(TypedDict, total=False): + allow_insecure: bool + """Do not validate the certificate when the health check uses HTTPS.""" + + expected_body: str + """A case-insensitive sub-string to look for in the response body. + + If this string is not found, the origin will be marked as unhealthy. + """ + + expected_codes: Optional[List[str]] + """The expected HTTP response codes (e.g. + + "200") or code ranges (e.g. "2xx" for all codes starting with 2) of the health + check. + """ + + follow_redirects: bool + """Follow redirects if the origin returns a 3xx status code.""" + + header: Optional[object] + """The HTTP request headers to send in the health check. + + It is recommended you set a Host header by default. The User-Agent header cannot + be overridden. + """ + + method: Literal["GET", "HEAD"] + """The HTTP method to use for the health check.""" + + path: str + """The endpoint path to health check against.""" + + port: int + """Port number to connect to for the health check. + + Defaults to 80 if type is HTTP or 443 if type is HTTPS. + """ + + +class TcpConfig(TypedDict, total=False): + method: Literal["connection_established"] + """The TCP connection method to use for the health check.""" + + port: int + """Port number to connect to for the health check. Defaults to 80.""" diff --git a/src/cloudflare/types/healthchecks/preview_delete_response.py b/src/cloudflare/types/healthchecks/preview_delete_response.py new file mode 100644 index 00000000000..6aad74a6a3e --- /dev/null +++ b/src/cloudflare/types/healthchecks/preview_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["PreviewDeleteResponse"] + + +class PreviewDeleteResponse(BaseModel): + id: Optional[str] = None + """Identifier""" diff --git a/src/cloudflare/types/healthchecks_healthchecks.py b/src/cloudflare/types/healthchecks_healthchecks.py new file mode 100644 index 00000000000..e7b80ce0dfd --- /dev/null +++ b/src/cloudflare/types/healthchecks_healthchecks.py @@ -0,0 +1,152 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["HealthchecksHealthchecks", "HTTPConfig", "TcpConfig"] + + +class HTTPConfig(BaseModel): + allow_insecure: Optional[bool] = None + """Do not validate the certificate when the health check uses HTTPS.""" + + expected_body: Optional[str] = None + """A case-insensitive sub-string to look for in the response body. + + If this string is not found, the origin will be marked as unhealthy. + """ + + expected_codes: Optional[List[str]] = None + """The expected HTTP response codes (e.g. + + "200") or code ranges (e.g. "2xx" for all codes starting with 2) of the health + check. + """ + + follow_redirects: Optional[bool] = None + """Follow redirects if the origin returns a 3xx status code.""" + + header: Optional[object] = None + """The HTTP request headers to send in the health check. + + It is recommended you set a Host header by default. The User-Agent header cannot + be overridden. + """ + + method: Optional[Literal["GET", "HEAD"]] = None + """The HTTP method to use for the health check.""" + + path: Optional[str] = None + """The endpoint path to health check against.""" + + port: Optional[int] = None + """Port number to connect to for the health check. + + Defaults to 80 if type is HTTP or 443 if type is HTTPS. + """ + + +class TcpConfig(BaseModel): + method: Optional[Literal["connection_established"]] = None + """The TCP connection method to use for the health check.""" + + port: Optional[int] = None + """Port number to connect to for the health check. Defaults to 80.""" + + +class HealthchecksHealthchecks(BaseModel): + id: Optional[str] = None + """Identifier""" + + address: Optional[str] = None + """The hostname or IP address of the origin server to run health checks on.""" + + check_regions: Optional[ + List[ + Literal[ + "WNAM", + "ENAM", + "WEU", + "EEU", + "NSAM", + "SSAM", + "OC", + "ME", + "NAF", + "SAF", + "IN", + "SEAS", + "NEAS", + "ALL_REGIONS", + ] + ] + ] = None + """A list of regions from which to run health checks. + + Null means Cloudflare will pick a default region. + """ + + consecutive_fails: Optional[int] = None + """ + The number of consecutive fails required from a health check before changing the + health to unhealthy. + """ + + consecutive_successes: Optional[int] = None + """ + The number of consecutive successes required from a health check before changing + the health to healthy. + """ + + created_on: Optional[datetime] = None + + description: Optional[str] = None + """A human-readable description of the health check.""" + + failure_reason: Optional[str] = None + """The current failure reason if status is unhealthy.""" + + http_config: Optional[HTTPConfig] = None + """Parameters specific to an HTTP or HTTPS health check.""" + + interval: Optional[int] = None + """The interval between each health check. + + Shorter intervals may give quicker notifications if the origin status changes, + but will increase load on the origin as we check from multiple locations. + """ + + modified_on: Optional[datetime] = None + + name: Optional[str] = None + """A short name to identify the health check. + + Only alphanumeric characters, hyphens and underscores are allowed. + """ + + retries: Optional[int] = None + """ + The number of retries to attempt in case of a timeout before marking the origin + as unhealthy. Retries are attempted immediately. + """ + + status: Optional[Literal["unknown", "healthy", "unhealthy", "suspended"]] = None + """The current status of the origin server according to the health check.""" + + suspended: Optional[bool] = None + """If suspended, no health checks are sent to the origin.""" + + tcp_config: Optional[TcpConfig] = None + """Parameters specific to TCP health check.""" + + timeout: Optional[int] = None + """The timeout (in seconds) before marking the health check as failed.""" + + type: Optional[str] = None + """The protocol to use for the health check. + + Currently supported protocols are 'HTTP', 'HTTPS' and 'TCP'. + """ diff --git a/src/cloudflare/types/magic_transit/__init__.py b/src/cloudflare/types/magic_transit/__init__.py index f8ee8b14b1c..4cef5611947 100644 --- a/src/cloudflare/types/magic_transit/__init__.py +++ b/src/cloudflare/types/magic_transit/__init__.py @@ -1,3 +1,39 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .site_get_response import SiteGetResponse as SiteGetResponse +from .route_empty_params import RouteEmptyParams as RouteEmptyParams +from .route_get_response import RouteGetResponse as RouteGetResponse +from .site_create_params import SiteCreateParams as SiteCreateParams +from .site_list_response import SiteListResponse as SiteListResponse +from .site_update_params import SiteUpdateParams as SiteUpdateParams +from .route_create_params import RouteCreateParams as RouteCreateParams +from .route_list_response import RouteListResponse as RouteListResponse +from .route_update_params import RouteUpdateParams as RouteUpdateParams +from .route_empty_response import RouteEmptyResponse as RouteEmptyResponse +from .site_create_response import SiteCreateResponse as SiteCreateResponse +from .site_delete_response import SiteDeleteResponse as SiteDeleteResponse +from .site_update_response import SiteUpdateResponse as SiteUpdateResponse +from .route_create_response import RouteCreateResponse as RouteCreateResponse +from .route_delete_response import RouteDeleteResponse as RouteDeleteResponse +from .route_update_response import RouteUpdateResponse as RouteUpdateResponse +from .gre_tunnel_get_response import GRETunnelGetResponse as GRETunnelGetResponse +from .gre_tunnel_create_params import GRETunnelCreateParams as GRETunnelCreateParams +from .gre_tunnel_list_response import GRETunnelListResponse as GRETunnelListResponse +from .gre_tunnel_update_params import GRETunnelUpdateParams as GRETunnelUpdateParams +from .ipsec_tunnel_get_response import IPSECTunnelGetResponse as IPSECTunnelGetResponse +from .gre_tunnel_create_response import GRETunnelCreateResponse as GRETunnelCreateResponse +from .gre_tunnel_delete_response import GRETunnelDeleteResponse as GRETunnelDeleteResponse +from .gre_tunnel_update_response import GRETunnelUpdateResponse as GRETunnelUpdateResponse +from .ipsec_tunnel_create_params import IPSECTunnelCreateParams as IPSECTunnelCreateParams +from .ipsec_tunnel_list_response import IPSECTunnelListResponse as IPSECTunnelListResponse +from .ipsec_tunnel_update_params import IPSECTunnelUpdateParams as IPSECTunnelUpdateParams +from .cf_interconnect_get_response import CfInterconnectGetResponse as CfInterconnectGetResponse +from .ipsec_tunnel_create_response import IPSECTunnelCreateResponse as IPSECTunnelCreateResponse +from .ipsec_tunnel_delete_response import IPSECTunnelDeleteResponse as IPSECTunnelDeleteResponse +from .ipsec_tunnel_update_response import IPSECTunnelUpdateResponse as IPSECTunnelUpdateResponse +from .cf_interconnect_list_response import CfInterconnectListResponse as CfInterconnectListResponse +from .cf_interconnect_update_params import CfInterconnectUpdateParams as CfInterconnectUpdateParams +from .cf_interconnect_update_response import CfInterconnectUpdateResponse as CfInterconnectUpdateResponse +from .ipsec_tunnel_psk_generate_response import IPSECTunnelPSKGenerateResponse as IPSECTunnelPSKGenerateResponse diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_get_response.py b/src/cloudflare/types/magic_transit/cf_interconnect_get_response.py new file mode 100644 index 00000000000..1693571a82a --- /dev/null +++ b/src/cloudflare/types/magic_transit/cf_interconnect_get_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["CfInterconnectGetResponse"] + + +class CfInterconnectGetResponse(BaseModel): + interconnect: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_list_response.py b/src/cloudflare/types/magic_transit/cf_interconnect_list_response.py new file mode 100644 index 00000000000..4fe4b3e4947 --- /dev/null +++ b/src/cloudflare/types/magic_transit/cf_interconnect_list_response.py @@ -0,0 +1,78 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["CfInterconnectListResponse", "Interconnect", "InterconnectGRE", "InterconnectHealthCheck"] + + +class InterconnectGRE(BaseModel): + cloudflare_endpoint: Optional[str] = None + """ + The IP address assigned to the Cloudflare side of the GRE tunnel created as part + of the Interconnect. + """ + + +class InterconnectHealthCheck(BaseModel): + enabled: Optional[bool] = None + """Determines whether to run healthchecks for a tunnel.""" + + rate: Optional[Literal["low", "mid", "high"]] = None + """How frequent the health check is run. The default value is `mid`.""" + + target: Optional[str] = None + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. + """ + + type: Optional[Literal["reply", "request"]] = None + """The type of healthcheck to run, reply or request. The default value is `reply`.""" + + +class Interconnect(BaseModel): + id: Optional[str] = None + """Tunnel identifier tag.""" + + colo_name: Optional[str] = None + """The name of the interconnect. The name cannot share a name with other tunnels.""" + + created_on: Optional[datetime] = None + """The date and time the tunnel was created.""" + + description: Optional[str] = None + """An optional description of the interconnect.""" + + gre: Optional[InterconnectGRE] = None + """The configuration specific to GRE interconnects.""" + + health_check: Optional[InterconnectHealthCheck] = None + + interface_address: Optional[str] = None + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + modified_on: Optional[datetime] = None + """The date and time the tunnel was last modified.""" + + mtu: Optional[int] = None + """The Maximum Transmission Unit (MTU) in bytes for the interconnect. + + The minimum value is 576. + """ + + name: Optional[str] = None + """The name of the interconnect. The name cannot share a name with other tunnels.""" + + +class CfInterconnectListResponse(BaseModel): + interconnects: Optional[List[Interconnect]] = None diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py b/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py new file mode 100644 index 00000000000..647a50b30ab --- /dev/null +++ b/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py @@ -0,0 +1,60 @@ +# 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__ = ["CfInterconnectUpdateParams", "GRE", "HealthCheck"] + + +class CfInterconnectUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + description: str + """An optional description of the interconnect.""" + + gre: GRE + """The configuration specific to GRE interconnects.""" + + health_check: HealthCheck + + interface_address: str + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + mtu: int + """The Maximum Transmission Unit (MTU) in bytes for the interconnect. + + The minimum value is 576. + """ + + +class GRE(TypedDict, total=False): + cloudflare_endpoint: str + """ + The IP address assigned to the Cloudflare side of the GRE tunnel created as part + of the Interconnect. + """ + + +class HealthCheck(TypedDict, total=False): + enabled: bool + """Determines whether to run healthchecks for a tunnel.""" + + rate: Literal["low", "mid", "high"] + """How frequent the health check is run. The default value is `mid`.""" + + target: str + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. + """ + + type: Literal["reply", "request"] + """The type of healthcheck to run, reply or request. The default value is `reply`.""" diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_update_response.py b/src/cloudflare/types/magic_transit/cf_interconnect_update_response.py new file mode 100644 index 00000000000..e21d22dbd40 --- /dev/null +++ b/src/cloudflare/types/magic_transit/cf_interconnect_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["CfInterconnectUpdateResponse"] + + +class CfInterconnectUpdateResponse(BaseModel): + modified: Optional[bool] = None + + modified_interconnect: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_create_params.py b/src/cloudflare/types/magic_transit/gre_tunnel_create_params.py new file mode 100644 index 00000000000..3e2fa625ec0 --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_create_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["GRETunnelCreateParams"] + + +class GRETunnelCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_create_response.py b/src/cloudflare/types/magic_transit/gre_tunnel_create_response.py new file mode 100644 index 00000000000..c6cb68e2b20 --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_create_response.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["GRETunnelCreateResponse", "GRETunnel", "GRETunnelHealthCheck"] + + +class GRETunnelHealthCheck(BaseModel): + direction: Optional[Literal["unidirectional", "bidirectional"]] = None + """The direction of the flow of the healthcheck. + + Either unidirectional, where the probe comes to you via the tunnel and the + result comes back to Cloudflare via the open Internet, or bidirectional where + both the probe and result come and go via the tunnel. Note in the case of + bidirecitonal healthchecks, the target field in health_check is ignored as the + interface_address is used to send traffic into the tunnel. + """ + + enabled: Optional[bool] = None + """Determines whether to run healthchecks for a tunnel.""" + + rate: Optional[Literal["low", "mid", "high"]] = None + """How frequent the health check is run. The default value is `mid`.""" + + target: Optional[str] = None + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. This field is ignored for bidirectional + healthchecks as the interface_address (not assigned to the Cloudflare side of + the tunnel) is used as the target. + """ + + type: Optional[Literal["reply", "request"]] = None + """The type of healthcheck to run, reply or request. The default value is `reply`.""" + + +class GRETunnel(BaseModel): + cloudflare_gre_endpoint: str + """The IP address assigned to the Cloudflare side of the GRE tunnel.""" + + customer_gre_endpoint: str + """The IP address assigned to the customer side of the GRE tunnel.""" + + interface_address: str + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: str + """The name of the tunnel. + + The name cannot contain spaces or special characters, must be 15 characters or + less, and cannot share a name with another GRE tunnel. + """ + + id: Optional[str] = None + """Tunnel identifier tag.""" + + created_on: Optional[datetime] = None + """The date and time the tunnel was created.""" + + description: Optional[str] = None + """An optional description of the GRE tunnel.""" + + health_check: Optional[GRETunnelHealthCheck] = None + + modified_on: Optional[datetime] = None + """The date and time the tunnel was last modified.""" + + mtu: Optional[int] = None + """Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. + + The minimum value is 576. + """ + + ttl: Optional[int] = None + """Time To Live (TTL) in number of hops of the GRE tunnel.""" + + +class GRETunnelCreateResponse(BaseModel): + gre_tunnels: Optional[List[GRETunnel]] = None diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_delete_response.py b/src/cloudflare/types/magic_transit/gre_tunnel_delete_response.py new file mode 100644 index 00000000000..5165f2dcc3b --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_delete_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["GRETunnelDeleteResponse"] + + +class GRETunnelDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_gre_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_get_response.py b/src/cloudflare/types/magic_transit/gre_tunnel_get_response.py new file mode 100644 index 00000000000..141c70992f1 --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_get_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["GRETunnelGetResponse"] + + +class GRETunnelGetResponse(BaseModel): + gre_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_list_response.py b/src/cloudflare/types/magic_transit/gre_tunnel_list_response.py new file mode 100644 index 00000000000..017d9f3608d --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_list_response.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["GRETunnelListResponse", "GRETunnel", "GRETunnelHealthCheck"] + + +class GRETunnelHealthCheck(BaseModel): + direction: Optional[Literal["unidirectional", "bidirectional"]] = None + """The direction of the flow of the healthcheck. + + Either unidirectional, where the probe comes to you via the tunnel and the + result comes back to Cloudflare via the open Internet, or bidirectional where + both the probe and result come and go via the tunnel. Note in the case of + bidirecitonal healthchecks, the target field in health_check is ignored as the + interface_address is used to send traffic into the tunnel. + """ + + enabled: Optional[bool] = None + """Determines whether to run healthchecks for a tunnel.""" + + rate: Optional[Literal["low", "mid", "high"]] = None + """How frequent the health check is run. The default value is `mid`.""" + + target: Optional[str] = None + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. This field is ignored for bidirectional + healthchecks as the interface_address (not assigned to the Cloudflare side of + the tunnel) is used as the target. + """ + + type: Optional[Literal["reply", "request"]] = None + """The type of healthcheck to run, reply or request. The default value is `reply`.""" + + +class GRETunnel(BaseModel): + cloudflare_gre_endpoint: str + """The IP address assigned to the Cloudflare side of the GRE tunnel.""" + + customer_gre_endpoint: str + """The IP address assigned to the customer side of the GRE tunnel.""" + + interface_address: str + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: str + """The name of the tunnel. + + The name cannot contain spaces or special characters, must be 15 characters or + less, and cannot share a name with another GRE tunnel. + """ + + id: Optional[str] = None + """Tunnel identifier tag.""" + + created_on: Optional[datetime] = None + """The date and time the tunnel was created.""" + + description: Optional[str] = None + """An optional description of the GRE tunnel.""" + + health_check: Optional[GRETunnelHealthCheck] = None + + modified_on: Optional[datetime] = None + """The date and time the tunnel was last modified.""" + + mtu: Optional[int] = None + """Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. + + The minimum value is 576. + """ + + ttl: Optional[int] = None + """Time To Live (TTL) in number of hops of the GRE tunnel.""" + + +class GRETunnelListResponse(BaseModel): + gre_tunnels: Optional[List[GRETunnel]] = None diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py b/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py new file mode 100644 index 00000000000..d47de7a4dd0 --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py @@ -0,0 +1,77 @@ +# 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__ = ["GRETunnelUpdateParams", "HealthCheck"] + + +class GRETunnelUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + cloudflare_gre_endpoint: Required[str] + """The IP address assigned to the Cloudflare side of the GRE tunnel.""" + + customer_gre_endpoint: Required[str] + """The IP address assigned to the customer side of the GRE tunnel.""" + + interface_address: Required[str] + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: Required[str] + """The name of the tunnel. + + The name cannot contain spaces or special characters, must be 15 characters or + less, and cannot share a name with another GRE tunnel. + """ + + description: str + """An optional description of the GRE tunnel.""" + + health_check: HealthCheck + + mtu: int + """Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. + + The minimum value is 576. + """ + + ttl: int + """Time To Live (TTL) in number of hops of the GRE tunnel.""" + + +class HealthCheck(TypedDict, total=False): + direction: Literal["unidirectional", "bidirectional"] + """The direction of the flow of the healthcheck. + + Either unidirectional, where the probe comes to you via the tunnel and the + result comes back to Cloudflare via the open Internet, or bidirectional where + both the probe and result come and go via the tunnel. Note in the case of + bidirecitonal healthchecks, the target field in health_check is ignored as the + interface_address is used to send traffic into the tunnel. + """ + + enabled: bool + """Determines whether to run healthchecks for a tunnel.""" + + rate: Literal["low", "mid", "high"] + """How frequent the health check is run. The default value is `mid`.""" + + target: str + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. This field is ignored for bidirectional + healthchecks as the interface_address (not assigned to the Cloudflare side of + the tunnel) is used as the target. + """ + + type: Literal["reply", "request"] + """The type of healthcheck to run, reply or request. The default value is `reply`.""" diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_update_response.py b/src/cloudflare/types/magic_transit/gre_tunnel_update_response.py new file mode 100644 index 00000000000..c84ba582d7e --- /dev/null +++ b/src/cloudflare/types/magic_transit/gre_tunnel_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["GRETunnelUpdateResponse"] + + +class GRETunnelUpdateResponse(BaseModel): + modified: Optional[bool] = None + + modified_gre_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_create_params.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_create_params.py new file mode 100644 index 00000000000..38abef0649d --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_create_params.py @@ -0,0 +1,73 @@ +# 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__ = ["IPSECTunnelCreateParams", "HealthCheck"] + + +class IPSECTunnelCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + cloudflare_endpoint: Required[str] + """The IP address assigned to the Cloudflare side of the IPsec tunnel.""" + + interface_address: Required[str] + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: Required[str] + """The name of the IPsec tunnel. The name cannot share a name with other tunnels.""" + + customer_endpoint: str + """The IP address assigned to the customer side of the IPsec tunnel.""" + + description: str + """An optional description forthe IPsec tunnel.""" + + health_check: HealthCheck + + psk: str + """A randomly generated or provided string for use in the IPsec tunnel.""" + + replay_protection: bool + """ + If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + """ + + +class HealthCheck(TypedDict, total=False): + direction: Literal["unidirectional", "bidirectional"] + """The direction of the flow of the healthcheck. + + Either unidirectional, where the probe comes to you via the tunnel and the + result comes back to Cloudflare via the open Internet, or bidirectional where + both the probe and result come and go via the tunnel. Note in the case of + bidirecitonal healthchecks, the target field in health_check is ignored as the + interface_address is used to send traffic into the tunnel. + """ + + enabled: bool + """Determines whether to run healthchecks for a tunnel.""" + + rate: Literal["low", "mid", "high"] + """How frequent the health check is run. The default value is `mid`.""" + + target: str + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. This field is ignored for bidirectional + healthchecks as the interface_address (not assigned to the Cloudflare side of + the tunnel) is used as the target. + """ + + type: Literal["reply", "request"] + """The type of healthcheck to run, reply or request. The default value is `reply`.""" diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_create_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_create_response.py new file mode 100644 index 00000000000..19870c524ab --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_create_response.py @@ -0,0 +1,84 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelCreateResponse", "IPSECTunnel", "IPSECTunnelPSKMetadata", "IPSECTunnelTunnelHealthCheck"] + + +class IPSECTunnelPSKMetadata(BaseModel): + last_generated_on: Optional[datetime] = None + """The date and time the tunnel was last modified.""" + + +class IPSECTunnelTunnelHealthCheck(BaseModel): + enabled: Optional[bool] = None + """Determines whether to run healthchecks for a tunnel.""" + + rate: Optional[Literal["low", "mid", "high"]] = None + """How frequent the health check is run. The default value is `mid`.""" + + target: Optional[str] = None + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. + """ + + type: Optional[Literal["reply", "request"]] = None + """The type of healthcheck to run, reply or request. The default value is `reply`.""" + + +class IPSECTunnel(BaseModel): + cloudflare_endpoint: str + """The IP address assigned to the Cloudflare side of the IPsec tunnel.""" + + interface_address: str + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: str + """The name of the IPsec tunnel. The name cannot share a name with other tunnels.""" + + id: Optional[str] = None + """Tunnel identifier tag.""" + + allow_null_cipher: Optional[bool] = None + """ + When `true`, the tunnel can use a null-cipher (`ENCR_NULL`) in the ESP tunnel + (Phase 2). + """ + + created_on: Optional[datetime] = None + """The date and time the tunnel was created.""" + + customer_endpoint: Optional[str] = None + """The IP address assigned to the customer side of the IPsec tunnel.""" + + description: Optional[str] = None + """An optional description forthe IPsec tunnel.""" + + modified_on: Optional[datetime] = None + """The date and time the tunnel was last modified.""" + + psk_metadata: Optional[IPSECTunnelPSKMetadata] = None + """The PSK metadata that includes when the PSK was generated.""" + + replay_protection: Optional[bool] = None + """ + If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + """ + + tunnel_health_check: Optional[IPSECTunnelTunnelHealthCheck] = None + + +class IPSECTunnelCreateResponse(BaseModel): + ipsec_tunnels: Optional[List[IPSECTunnel]] = None diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_delete_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_delete_response.py new file mode 100644 index 00000000000..b39ba183f72 --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_delete_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelDeleteResponse"] + + +class IPSECTunnelDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_ipsec_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_get_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_get_response.py new file mode 100644 index 00000000000..816098c9ead --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_get_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelGetResponse"] + + +class IPSECTunnelGetResponse(BaseModel): + ipsec_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_list_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_list_response.py new file mode 100644 index 00000000000..93f47391a93 --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_list_response.py @@ -0,0 +1,84 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelListResponse", "IPSECTunnel", "IPSECTunnelPSKMetadata", "IPSECTunnelTunnelHealthCheck"] + + +class IPSECTunnelPSKMetadata(BaseModel): + last_generated_on: Optional[datetime] = None + """The date and time the tunnel was last modified.""" + + +class IPSECTunnelTunnelHealthCheck(BaseModel): + enabled: Optional[bool] = None + """Determines whether to run healthchecks for a tunnel.""" + + rate: Optional[Literal["low", "mid", "high"]] = None + """How frequent the health check is run. The default value is `mid`.""" + + target: Optional[str] = None + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. + """ + + type: Optional[Literal["reply", "request"]] = None + """The type of healthcheck to run, reply or request. The default value is `reply`.""" + + +class IPSECTunnel(BaseModel): + cloudflare_endpoint: str + """The IP address assigned to the Cloudflare side of the IPsec tunnel.""" + + interface_address: str + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: str + """The name of the IPsec tunnel. The name cannot share a name with other tunnels.""" + + id: Optional[str] = None + """Tunnel identifier tag.""" + + allow_null_cipher: Optional[bool] = None + """ + When `true`, the tunnel can use a null-cipher (`ENCR_NULL`) in the ESP tunnel + (Phase 2). + """ + + created_on: Optional[datetime] = None + """The date and time the tunnel was created.""" + + customer_endpoint: Optional[str] = None + """The IP address assigned to the customer side of the IPsec tunnel.""" + + description: Optional[str] = None + """An optional description forthe IPsec tunnel.""" + + modified_on: Optional[datetime] = None + """The date and time the tunnel was last modified.""" + + psk_metadata: Optional[IPSECTunnelPSKMetadata] = None + """The PSK metadata that includes when the PSK was generated.""" + + replay_protection: Optional[bool] = None + """ + If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + """ + + tunnel_health_check: Optional[IPSECTunnelTunnelHealthCheck] = None + + +class IPSECTunnelListResponse(BaseModel): + ipsec_tunnels: Optional[List[IPSECTunnel]] = None diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_response.py new file mode 100644 index 00000000000..260b879fecc --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelPSKGenerateResponse", "PSKMetadata"] + + +class PSKMetadata(BaseModel): + last_generated_on: Optional[datetime] = None + """The date and time the tunnel was last modified.""" + + +class IPSECTunnelPSKGenerateResponse(BaseModel): + ipsec_tunnel_id: Optional[str] = None + """Identifier""" + + psk: Optional[str] = None + """A randomly generated or provided string for use in the IPsec tunnel.""" + + psk_metadata: Optional[PSKMetadata] = None + """The PSK metadata that includes when the PSK was generated.""" diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py new file mode 100644 index 00000000000..d1f1730d3dc --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py @@ -0,0 +1,73 @@ +# 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__ = ["IPSECTunnelUpdateParams", "HealthCheck"] + + +class IPSECTunnelUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + cloudflare_endpoint: Required[str] + """The IP address assigned to the Cloudflare side of the IPsec tunnel.""" + + interface_address: Required[str] + """ + A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + of the tunnel. Select the subnet from the following private IP space: + 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + """ + + name: Required[str] + """The name of the IPsec tunnel. The name cannot share a name with other tunnels.""" + + customer_endpoint: str + """The IP address assigned to the customer side of the IPsec tunnel.""" + + description: str + """An optional description forthe IPsec tunnel.""" + + health_check: HealthCheck + + psk: str + """A randomly generated or provided string for use in the IPsec tunnel.""" + + replay_protection: bool + """ + If `true`, then IPsec replay protection will be supported in the + Cloudflare-to-customer direction. + """ + + +class HealthCheck(TypedDict, total=False): + direction: Literal["unidirectional", "bidirectional"] + """The direction of the flow of the healthcheck. + + Either unidirectional, where the probe comes to you via the tunnel and the + result comes back to Cloudflare via the open Internet, or bidirectional where + both the probe and result come and go via the tunnel. Note in the case of + bidirecitonal healthchecks, the target field in health_check is ignored as the + interface_address is used to send traffic into the tunnel. + """ + + enabled: bool + """Determines whether to run healthchecks for a tunnel.""" + + rate: Literal["low", "mid", "high"] + """How frequent the health check is run. The default value is `mid`.""" + + target: str + """The destination address in a request type health check. + + After the healthcheck is decapsulated at the customer end of the tunnel, the + ICMP echo will be forwarded to this address. This field defaults to + `customer_gre_endpoint address`. This field is ignored for bidirectional + healthchecks as the interface_address (not assigned to the Cloudflare side of + the tunnel) is used as the target. + """ + + type: Literal["reply", "request"] + """The type of healthcheck to run, reply or request. The default value is `reply`.""" diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_update_response.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_response.py new file mode 100644 index 00000000000..8a7b92e2b11 --- /dev/null +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["IPSECTunnelUpdateResponse"] + + +class IPSECTunnelUpdateResponse(BaseModel): + modified: Optional[bool] = None + + modified_ipsec_tunnel: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/route_create_params.py b/src/cloudflare/types/magic_transit/route_create_params.py new file mode 100644 index 00000000000..6afc20132d1 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_create_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["RouteCreateParams"] + + +class RouteCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] diff --git a/src/cloudflare/types/magic_transit/route_create_response.py b/src/cloudflare/types/magic_transit/route_create_response.py new file mode 100644 index 00000000000..2d511d6402a --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_create_response.py @@ -0,0 +1,49 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RouteCreateResponse", "Route", "RouteScope"] + + +class RouteScope(BaseModel): + colo_names: Optional[List[str]] = None + """List of colo names for the ECMP scope.""" + + colo_regions: Optional[List[str]] = None + """List of colo regions for the ECMP scope.""" + + +class Route(BaseModel): + nexthop: str + """The next-hop IP Address for the static route.""" + + prefix: str + """IP Prefix in Classless Inter-Domain Routing format.""" + + priority: int + """Priority of the static route.""" + + id: Optional[str] = None + """Identifier""" + + created_on: Optional[datetime] = None + """When the route was created.""" + + description: Optional[str] = None + """An optional human provided description of the static route.""" + + modified_on: Optional[datetime] = None + """When the route was last modified.""" + + scope: Optional[RouteScope] = None + """Used only for ECMP routes.""" + + weight: Optional[int] = None + """Optional weight of the ECMP scope - if provided.""" + + +class RouteCreateResponse(BaseModel): + routes: Optional[List[Route]] = None diff --git a/src/cloudflare/types/magic_transit/route_delete_response.py b/src/cloudflare/types/magic_transit/route_delete_response.py new file mode 100644 index 00000000000..096e4ece8f1 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_delete_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["RouteDeleteResponse"] + + +class RouteDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_route: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/route_empty_params.py b/src/cloudflare/types/magic_transit/route_empty_params.py new file mode 100644 index 00000000000..19aee9d0a1a --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_empty_params.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, TypedDict + +__all__ = ["RouteEmptyParams", "Route"] + + +class RouteEmptyParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + routes: Required[Iterable[Route]] + + +class Route(TypedDict, total=False): + pass diff --git a/src/cloudflare/types/magic_transit/route_empty_response.py b/src/cloudflare/types/magic_transit/route_empty_response.py new file mode 100644 index 00000000000..d44759f75c6 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_empty_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["RouteEmptyResponse"] + + +class RouteEmptyResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_routes: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/route_get_response.py b/src/cloudflare/types/magic_transit/route_get_response.py new file mode 100644 index 00000000000..f23ba2c2ec4 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_get_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["RouteGetResponse"] + + +class RouteGetResponse(BaseModel): + route: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/route_list_response.py b/src/cloudflare/types/magic_transit/route_list_response.py new file mode 100644 index 00000000000..339f0fb5194 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_list_response.py @@ -0,0 +1,49 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RouteListResponse", "Route", "RouteScope"] + + +class RouteScope(BaseModel): + colo_names: Optional[List[str]] = None + """List of colo names for the ECMP scope.""" + + colo_regions: Optional[List[str]] = None + """List of colo regions for the ECMP scope.""" + + +class Route(BaseModel): + nexthop: str + """The next-hop IP Address for the static route.""" + + prefix: str + """IP Prefix in Classless Inter-Domain Routing format.""" + + priority: int + """Priority of the static route.""" + + id: Optional[str] = None + """Identifier""" + + created_on: Optional[datetime] = None + """When the route was created.""" + + description: Optional[str] = None + """An optional human provided description of the static route.""" + + modified_on: Optional[datetime] = None + """When the route was last modified.""" + + scope: Optional[RouteScope] = None + """Used only for ECMP routes.""" + + weight: Optional[int] = None + """Optional weight of the ECMP scope - if provided.""" + + +class RouteListResponse(BaseModel): + routes: Optional[List[Route]] = None diff --git a/src/cloudflare/types/magic_transit/route_update_params.py b/src/cloudflare/types/magic_transit/route_update_params.py new file mode 100644 index 00000000000..8c608ddbe47 --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_update_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, TypedDict + +__all__ = ["RouteUpdateParams", "Scope"] + + +class RouteUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + nexthop: Required[str] + """The next-hop IP Address for the static route.""" + + prefix: Required[str] + """IP Prefix in Classless Inter-Domain Routing format.""" + + priority: Required[int] + """Priority of the static route.""" + + description: str + """An optional human provided description of the static route.""" + + scope: Scope + """Used only for ECMP routes.""" + + weight: int + """Optional weight of the ECMP scope - if provided.""" + + +class Scope(TypedDict, total=False): + colo_names: List[str] + """List of colo names for the ECMP scope.""" + + colo_regions: List[str] + """List of colo regions for the ECMP scope.""" diff --git a/src/cloudflare/types/magic_transit/route_update_response.py b/src/cloudflare/types/magic_transit/route_update_response.py new file mode 100644 index 00000000000..33b497d969f --- /dev/null +++ b/src/cloudflare/types/magic_transit/route_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["RouteUpdateResponse"] + + +class RouteUpdateResponse(BaseModel): + modified: Optional[bool] = None + + modified_route: Optional[object] = None diff --git a/src/cloudflare/types/magic_transit/site_create_params.py b/src/cloudflare/types/magic_transit/site_create_params.py new file mode 100644 index 00000000000..1e17d1bf467 --- /dev/null +++ b/src/cloudflare/types/magic_transit/site_create_params.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["SiteCreateParams", "Site", "SiteLocation"] + + +class SiteCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site: Site + + +class SiteLocation(TypedDict, total=False): + lat: str + """Latitude""" + + lon: str + """Longitude""" + + +class Site(TypedDict, total=False): + name: Required[str] + """The name of the site.""" + + connector_id: str + """Magic WAN Connector identifier tag.""" + + description: str + + ha_mode: bool + """Site high availability mode. + + If set to true, the site can have two connectors and runs in high availability + mode. + """ + + location: SiteLocation + """Location of site in latitude and longitude.""" + + secondary_connector_id: str + """Magic WAN Connector identifier tag. Used when high availability mode is on.""" diff --git a/src/cloudflare/types/magic_transit/site_create_response.py b/src/cloudflare/types/magic_transit/site_create_response.py new file mode 100644 index 00000000000..7c275f45d48 --- /dev/null +++ b/src/cloudflare/types/magic_transit/site_create_response.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["SiteCreateResponse", "Site", "SiteLocation"] + + +class SiteLocation(BaseModel): + lat: Optional[str] = None + """Latitude""" + + lon: Optional[str] = None + """Longitude""" + + +class Site(BaseModel): + id: Optional[str] = None + """Identifier""" + + connector_id: Optional[str] = None + """Magic WAN Connector identifier tag.""" + + description: Optional[str] = None + + ha_mode: Optional[bool] = None + """Site high availability mode. + + If set to true, the site can have two connectors and runs in high availability + mode. + """ + + location: Optional[SiteLocation] = None + """Location of site in latitude and longitude.""" + + name: Optional[str] = None + """The name of the site.""" + + secondary_connector_id: Optional[str] = None + """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + + +class SiteCreateResponse(BaseModel): + site: Optional[Site] = None diff --git a/src/cloudflare/types/magic_transit/site_delete_response.py b/src/cloudflare/types/magic_transit/site_delete_response.py new file mode 100644 index 00000000000..3cbaf98bbd8 --- /dev/null +++ b/src/cloudflare/types/magic_transit/site_delete_response.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["SiteDeleteResponse", "DeletedSite", "DeletedSiteLocation"] + + +class DeletedSiteLocation(BaseModel): + lat: Optional[str] = None + """Latitude""" + + lon: Optional[str] = None + """Longitude""" + + +class DeletedSite(BaseModel): + id: Optional[str] = None + """Identifier""" + + connector_id: Optional[str] = None + """Magic WAN Connector identifier tag.""" + + description: Optional[str] = None + + ha_mode: Optional[bool] = None + """Site high availability mode. + + If set to true, the site can have two connectors and runs in high availability + mode. + """ + + location: Optional[DeletedSiteLocation] = None + """Location of site in latitude and longitude.""" + + name: Optional[str] = None + """The name of the site.""" + + secondary_connector_id: Optional[str] = None + """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + + +class SiteDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_site: Optional[DeletedSite] = None diff --git a/src/cloudflare/types/magic_transit/site_get_response.py b/src/cloudflare/types/magic_transit/site_get_response.py new file mode 100644 index 00000000000..561ac051c3e --- /dev/null +++ b/src/cloudflare/types/magic_transit/site_get_response.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["SiteGetResponse", "Site", "SiteLocation"] + + +class SiteLocation(BaseModel): + lat: Optional[str] = None + """Latitude""" + + lon: Optional[str] = None + """Longitude""" + + +class Site(BaseModel): + id: Optional[str] = None + """Identifier""" + + connector_id: Optional[str] = None + """Magic WAN Connector identifier tag.""" + + description: Optional[str] = None + + ha_mode: Optional[bool] = None + """Site high availability mode. + + If set to true, the site can have two connectors and runs in high availability + mode. + """ + + location: Optional[SiteLocation] = None + """Location of site in latitude and longitude.""" + + name: Optional[str] = None + """The name of the site.""" + + secondary_connector_id: Optional[str] = None + """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + + +class SiteGetResponse(BaseModel): + site: Optional[Site] = None diff --git a/src/cloudflare/types/magic_transit/site_list_response.py b/src/cloudflare/types/magic_transit/site_list_response.py new file mode 100644 index 00000000000..35c166fbe06 --- /dev/null +++ b/src/cloudflare/types/magic_transit/site_list_response.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["SiteListResponse", "Site", "SiteLocation"] + + +class SiteLocation(BaseModel): + lat: Optional[str] = None + """Latitude""" + + lon: Optional[str] = None + """Longitude""" + + +class Site(BaseModel): + id: Optional[str] = None + """Identifier""" + + connector_id: Optional[str] = None + """Magic WAN Connector identifier tag.""" + + description: Optional[str] = None + + ha_mode: Optional[bool] = None + """Site high availability mode. + + If set to true, the site can have two connectors and runs in high availability + mode. + """ + + location: Optional[SiteLocation] = None + """Location of site in latitude and longitude.""" + + name: Optional[str] = None + """The name of the site.""" + + secondary_connector_id: Optional[str] = None + """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + + +class SiteListResponse(BaseModel): + sites: Optional[List[Site]] = None diff --git a/src/cloudflare/types/magic_transit/site_update_params.py b/src/cloudflare/types/magic_transit/site_update_params.py new file mode 100644 index 00000000000..74c96c227de --- /dev/null +++ b/src/cloudflare/types/magic_transit/site_update_params.py @@ -0,0 +1,38 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["SiteUpdateParams", "Site", "SiteLocation"] + + +class SiteUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site: Site + + +class SiteLocation(TypedDict, total=False): + lat: str + """Latitude""" + + lon: str + """Longitude""" + + +class Site(TypedDict, total=False): + connector_id: str + """Magic WAN Connector identifier tag.""" + + description: str + + location: SiteLocation + """Location of site in latitude and longitude.""" + + name: str + """The name of the site.""" + + secondary_connector_id: str + """Magic WAN Connector identifier tag. Used when high availability mode is on.""" diff --git a/src/cloudflare/types/magic_transit/site_update_response.py b/src/cloudflare/types/magic_transit/site_update_response.py new file mode 100644 index 00000000000..421808a4a06 --- /dev/null +++ b/src/cloudflare/types/magic_transit/site_update_response.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["SiteUpdateResponse", "Site", "SiteLocation"] + + +class SiteLocation(BaseModel): + lat: Optional[str] = None + """Latitude""" + + lon: Optional[str] = None + """Longitude""" + + +class Site(BaseModel): + id: Optional[str] = None + """Identifier""" + + connector_id: Optional[str] = None + """Magic WAN Connector identifier tag.""" + + description: Optional[str] = None + + ha_mode: Optional[bool] = None + """Site high availability mode. + + If set to true, the site can have two connectors and runs in high availability + mode. + """ + + location: Optional[SiteLocation] = None + """Location of site in latitude and longitude.""" + + name: Optional[str] = None + """The name of the site.""" + + secondary_connector_id: Optional[str] = None + """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + + +class SiteUpdateResponse(BaseModel): + site: Optional[Site] = None diff --git a/src/cloudflare/types/magic_transit/sites/__init__.py b/src/cloudflare/types/magic_transit/sites/__init__.py index f8ee8b14b1c..22e047c3195 100644 --- a/src/cloudflare/types/magic_transit/sites/__init__.py +++ b/src/cloudflare/types/magic_transit/sites/__init__.py @@ -1,3 +1,25 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .acl_get_response import ACLGetResponse as ACLGetResponse +from .lan_get_response import LanGetResponse as LanGetResponse +from .wan_get_response import WanGetResponse as WanGetResponse +from .acl_create_params import ACLCreateParams as ACLCreateParams +from .acl_list_response import ACLListResponse as ACLListResponse +from .acl_update_params import ACLUpdateParams as ACLUpdateParams +from .lan_create_params import LanCreateParams as LanCreateParams +from .lan_list_response import LanListResponse as LanListResponse +from .lan_update_params import LanUpdateParams as LanUpdateParams +from .wan_create_params import WanCreateParams as WanCreateParams +from .wan_list_response import WanListResponse as WanListResponse +from .wan_update_params import WanUpdateParams as WanUpdateParams +from .acl_create_response import ACLCreateResponse as ACLCreateResponse +from .acl_delete_response import ACLDeleteResponse as ACLDeleteResponse +from .acl_update_response import ACLUpdateResponse as ACLUpdateResponse +from .lan_create_response import LanCreateResponse as LanCreateResponse +from .lan_delete_response import LanDeleteResponse as LanDeleteResponse +from .lan_update_response import LanUpdateResponse as LanUpdateResponse +from .wan_create_response import WanCreateResponse as WanCreateResponse +from .wan_delete_response import WanDeleteResponse as WanDeleteResponse +from .wan_update_response import WanUpdateResponse as WanUpdateResponse diff --git a/src/cloudflare/types/magic_transit/sites/acl_create_params.py b/src/cloudflare/types/magic_transit/sites/acl_create_params.py new file mode 100644 index 00000000000..c98363980a4 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_create_params.py @@ -0,0 +1,71 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union, Iterable +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ACLCreateParams", "ACL", "ACLLan1", "ACLLan2"] + + +class ACLCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + acl: ACL + + +class ACLLan1(TypedDict, total=False): + lan_id: Required[str] + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: str + """The name of the LAN based on the provided lan_id.""" + + ports: Iterable[int] + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: List[Union[str, str]] + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACLLan2(TypedDict, total=False): + lan_id: Required[str] + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: str + """The name of the LAN based on the provided lan_id.""" + + ports: Iterable[int] + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: List[Union[str, str]] + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACL(TypedDict, total=False): + lan_1: Required[ACLLan1] + + lan_2: Required[ACLLan2] + + name: Required[str] + """The name of the ACL.""" + + description: str + """Description for the ACL.""" + + protocols: List[Literal["tcp", "udp", "icmp"]] diff --git a/src/cloudflare/types/magic_transit/sites/acl_create_response.py b/src/cloudflare/types/magic_transit/sites/acl_create_response.py new file mode 100644 index 00000000000..ed1e407e1cd --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_create_response.py @@ -0,0 +1,71 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["ACLCreateResponse", "ACL", "ACLLan1", "ACLLan2"] + + +class ACLLan1(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACLLan2(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACL(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + """Description for the ACL.""" + + lan_1: Optional[ACLLan1] = None + + lan_2: Optional[ACLLan2] = None + + name: Optional[str] = None + """The name of the ACL.""" + + protocols: Optional[List[Literal["tcp", "udp", "icmp"]]] = None + + +class ACLCreateResponse(BaseModel): + acls: Optional[List[ACL]] = None diff --git a/src/cloudflare/types/magic_transit/sites/acl_delete_response.py b/src/cloudflare/types/magic_transit/sites/acl_delete_response.py new file mode 100644 index 00000000000..6dddb8088f5 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_delete_response.py @@ -0,0 +1,74 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["ACLDeleteResponse", "DeletedACL", "DeletedACLLan1", "DeletedACLLan2"] + + +class DeletedACLLan1(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class DeletedACLLan2(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class DeletedACL(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + """Description for the ACL.""" + + lan_1: Optional[DeletedACLLan1] = None + + lan_2: Optional[DeletedACLLan2] = None + + name: Optional[str] = None + """The name of the ACL.""" + + protocols: Optional[List[Literal["tcp", "udp", "icmp"]]] = None + + +class ACLDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_acl: Optional[DeletedACL] = None + """Bidirectional ACL policy for local network traffic within a site.""" diff --git a/src/cloudflare/types/magic_transit/sites/acl_get_response.py b/src/cloudflare/types/magic_transit/sites/acl_get_response.py new file mode 100644 index 00000000000..e1e517f232c --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_get_response.py @@ -0,0 +1,72 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["ACLGetResponse", "ACL", "ACLLan1", "ACLLan2"] + + +class ACLLan1(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACLLan2(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACL(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + """Description for the ACL.""" + + lan_1: Optional[ACLLan1] = None + + lan_2: Optional[ACLLan2] = None + + name: Optional[str] = None + """The name of the ACL.""" + + protocols: Optional[List[Literal["tcp", "udp", "icmp"]]] = None + + +class ACLGetResponse(BaseModel): + acl: Optional[ACL] = None + """Bidirectional ACL policy for local network traffic within a site.""" diff --git a/src/cloudflare/types/magic_transit/sites/acl_list_response.py b/src/cloudflare/types/magic_transit/sites/acl_list_response.py new file mode 100644 index 00000000000..214f7734b61 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_list_response.py @@ -0,0 +1,71 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["ACLListResponse", "ACL", "ACLLan1", "ACLLan2"] + + +class ACLLan1(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACLLan2(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACL(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + """Description for the ACL.""" + + lan_1: Optional[ACLLan1] = None + + lan_2: Optional[ACLLan2] = None + + name: Optional[str] = None + """The name of the ACL.""" + + protocols: Optional[List[Literal["tcp", "udp", "icmp"]]] = None + + +class ACLListResponse(BaseModel): + acls: Optional[List[ACL]] = None diff --git a/src/cloudflare/types/magic_transit/sites/acl_update_params.py b/src/cloudflare/types/magic_transit/sites/acl_update_params.py new file mode 100644 index 00000000000..e21d4d18036 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_update_params.py @@ -0,0 +1,74 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union, Iterable +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ACLUpdateParams", "ACL", "ACLLan1", "ACLLan2"] + + +class ACLUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + acl: ACL + + +class ACLLan1(TypedDict, total=False): + lan_id: Required[str] + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: str + """The name of the LAN based on the provided lan_id.""" + + ports: Iterable[int] + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: List[Union[str, str]] + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACLLan2(TypedDict, total=False): + lan_id: Required[str] + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: str + """The name of the LAN based on the provided lan_id.""" + + ports: Iterable[int] + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: List[Union[str, str]] + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACL(TypedDict, total=False): + description: str + """Description for the ACL.""" + + lan_1: ACLLan1 + + lan_2: ACLLan2 + + name: str + """The name of the ACL.""" + + protocols: List[Literal["tcp", "udp", "icmp"]] diff --git a/src/cloudflare/types/magic_transit/sites/acl_update_response.py b/src/cloudflare/types/magic_transit/sites/acl_update_response.py new file mode 100644 index 00000000000..982f491244f --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_update_response.py @@ -0,0 +1,72 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["ACLUpdateResponse", "ACL", "ACLLan1", "ACLLan2"] + + +class ACLLan1(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACLLan2(BaseModel): + lan_id: str + """The identifier for the LAN you want to create an ACL policy with.""" + + lan_name: Optional[str] = None + """The name of the LAN based on the provided lan_id.""" + + ports: Optional[List[int]] = None + """Array of ports on the provided LAN that will be included in the ACL. + + If no ports are provided, communication on any port on this LAN is allowed. + """ + + subnets: Optional[List[Union[str, str]]] = None + """Array of subnet IPs within the LAN that will be included in the ACL. + + If no subnets are provided, communication on any subnets on this LAN are + allowed. + """ + + +class ACL(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + """Description for the ACL.""" + + lan_1: Optional[ACLLan1] = None + + lan_2: Optional[ACLLan2] = None + + name: Optional[str] = None + """The name of the ACL.""" + + protocols: Optional[List[Literal["tcp", "udp", "icmp"]]] = None + + +class ACLUpdateResponse(BaseModel): + acl: Optional[ACL] = None + """Bidirectional ACL policy for local network traffic within a site.""" diff --git a/src/cloudflare/types/magic_transit/sites/lan_create_params.py b/src/cloudflare/types/magic_transit/sites/lan_create_params.py new file mode 100644 index 00000000000..0498c6dabde --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/lan_create_params.py @@ -0,0 +1,104 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Iterable +from typing_extensions import Required, TypedDict + +__all__ = [ + "LanCreateParams", + "Lan", + "LanNat", + "LanRoutedSubnet", + "LanRoutedSubnetNat", + "LanStaticAddressing", + "LanStaticAddressingDhcpRelay", + "LanStaticAddressingDhcpServer", +] + + +class LanCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + lan: Lan + + +class LanNat(TypedDict, total=False): + static_prefix: str + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnetNat(TypedDict, total=False): + static_prefix: str + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnet(TypedDict, total=False): + next_hop: Required[str] + """A valid IPv4 address.""" + + prefix: Required[str] + """A valid CIDR notation representing an IP range.""" + + nat: LanRoutedSubnetNat + + +class LanStaticAddressingDhcpRelay(TypedDict, total=False): + server_addresses: List[str] + """List of DHCP server IPs.""" + + +class LanStaticAddressingDhcpServer(TypedDict, total=False): + dhcp_pool_end: str + """A valid IPv4 address.""" + + dhcp_pool_start: str + """A valid IPv4 address.""" + + dns_server: str + """A valid IPv4 address.""" + + reservations: Dict[str, str] + """Mapping of MAC addresses to IP addresses""" + + +class LanStaticAddressing(TypedDict, total=False): + address: Required[str] + """A valid CIDR notation representing an IP range.""" + + dhcp_relay: LanStaticAddressingDhcpRelay + + dhcp_server: LanStaticAddressingDhcpServer + + secondary_address: str + """A valid CIDR notation representing an IP range.""" + + virtual_address: str + """A valid CIDR notation representing an IP range.""" + + +class Lan(TypedDict, total=False): + physport: Required[int] + + vlan_tag: Required[int] + """VLAN port number.""" + + description: str + + ha_link: bool + """mark true to use this LAN for HA probing. + + only works for site with HA turned on. only one LAN can be set as the ha_link. + """ + + nat: LanNat + + routed_subnets: Iterable[LanRoutedSubnet] + + static_addressing: LanStaticAddressing + """ + If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + """ diff --git a/src/cloudflare/types/magic_transit/sites/lan_create_response.py b/src/cloudflare/types/magic_transit/sites/lan_create_response.py new file mode 100644 index 00000000000..8d15e43d724 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/lan_create_response.py @@ -0,0 +1,106 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional + +from ...._models import BaseModel + +__all__ = [ + "LanCreateResponse", + "Lan", + "LanNat", + "LanRoutedSubnet", + "LanRoutedSubnetNat", + "LanStaticAddressing", + "LanStaticAddressingDhcpRelay", + "LanStaticAddressingDhcpServer", +] + + +class LanNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnetNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnet(BaseModel): + next_hop: str + """A valid IPv4 address.""" + + prefix: str + """A valid CIDR notation representing an IP range.""" + + nat: Optional[LanRoutedSubnetNat] = None + + +class LanStaticAddressingDhcpRelay(BaseModel): + server_addresses: Optional[List[str]] = None + """List of DHCP server IPs.""" + + +class LanStaticAddressingDhcpServer(BaseModel): + dhcp_pool_end: Optional[str] = None + """A valid IPv4 address.""" + + dhcp_pool_start: Optional[str] = None + """A valid IPv4 address.""" + + dns_server: Optional[str] = None + """A valid IPv4 address.""" + + reservations: Optional[Dict[str, str]] = None + """Mapping of MAC addresses to IP addresses""" + + +class LanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + dhcp_relay: Optional[LanStaticAddressingDhcpRelay] = None + + dhcp_server: Optional[LanStaticAddressingDhcpServer] = None + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + virtual_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class Lan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + ha_link: Optional[bool] = None + """mark true to use this LAN for HA probing. + + only works for site with HA turned on. only one LAN can be set as the ha_link. + """ + + nat: Optional[LanNat] = None + + physport: Optional[int] = None + + routed_subnets: Optional[List[LanRoutedSubnet]] = None + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[LanStaticAddressing] = None + """ + If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class LanCreateResponse(BaseModel): + lans: Optional[List[Lan]] = None diff --git a/src/cloudflare/types/magic_transit/sites/lan_delete_response.py b/src/cloudflare/types/magic_transit/sites/lan_delete_response.py new file mode 100644 index 00000000000..dbc2d282573 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/lan_delete_response.py @@ -0,0 +1,108 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional + +from ...._models import BaseModel + +__all__ = [ + "LanDeleteResponse", + "DeletedLan", + "DeletedLanNat", + "DeletedLanRoutedSubnet", + "DeletedLanRoutedSubnetNat", + "DeletedLanStaticAddressing", + "DeletedLanStaticAddressingDhcpRelay", + "DeletedLanStaticAddressingDhcpServer", +] + + +class DeletedLanNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class DeletedLanRoutedSubnetNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class DeletedLanRoutedSubnet(BaseModel): + next_hop: str + """A valid IPv4 address.""" + + prefix: str + """A valid CIDR notation representing an IP range.""" + + nat: Optional[DeletedLanRoutedSubnetNat] = None + + +class DeletedLanStaticAddressingDhcpRelay(BaseModel): + server_addresses: Optional[List[str]] = None + """List of DHCP server IPs.""" + + +class DeletedLanStaticAddressingDhcpServer(BaseModel): + dhcp_pool_end: Optional[str] = None + """A valid IPv4 address.""" + + dhcp_pool_start: Optional[str] = None + """A valid IPv4 address.""" + + dns_server: Optional[str] = None + """A valid IPv4 address.""" + + reservations: Optional[Dict[str, str]] = None + """Mapping of MAC addresses to IP addresses""" + + +class DeletedLanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + dhcp_relay: Optional[DeletedLanStaticAddressingDhcpRelay] = None + + dhcp_server: Optional[DeletedLanStaticAddressingDhcpServer] = None + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + virtual_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class DeletedLan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + ha_link: Optional[bool] = None + """mark true to use this LAN for HA probing. + + only works for site with HA turned on. only one LAN can be set as the ha_link. + """ + + nat: Optional[DeletedLanNat] = None + + physport: Optional[int] = None + + routed_subnets: Optional[List[DeletedLanRoutedSubnet]] = None + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[DeletedLanStaticAddressing] = None + """ + If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class LanDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_lan: Optional[DeletedLan] = None diff --git a/src/cloudflare/types/magic_transit/sites/lan_get_response.py b/src/cloudflare/types/magic_transit/sites/lan_get_response.py new file mode 100644 index 00000000000..1ab640b81ab --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/lan_get_response.py @@ -0,0 +1,106 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional + +from ...._models import BaseModel + +__all__ = [ + "LanGetResponse", + "Lan", + "LanNat", + "LanRoutedSubnet", + "LanRoutedSubnetNat", + "LanStaticAddressing", + "LanStaticAddressingDhcpRelay", + "LanStaticAddressingDhcpServer", +] + + +class LanNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnetNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnet(BaseModel): + next_hop: str + """A valid IPv4 address.""" + + prefix: str + """A valid CIDR notation representing an IP range.""" + + nat: Optional[LanRoutedSubnetNat] = None + + +class LanStaticAddressingDhcpRelay(BaseModel): + server_addresses: Optional[List[str]] = None + """List of DHCP server IPs.""" + + +class LanStaticAddressingDhcpServer(BaseModel): + dhcp_pool_end: Optional[str] = None + """A valid IPv4 address.""" + + dhcp_pool_start: Optional[str] = None + """A valid IPv4 address.""" + + dns_server: Optional[str] = None + """A valid IPv4 address.""" + + reservations: Optional[Dict[str, str]] = None + """Mapping of MAC addresses to IP addresses""" + + +class LanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + dhcp_relay: Optional[LanStaticAddressingDhcpRelay] = None + + dhcp_server: Optional[LanStaticAddressingDhcpServer] = None + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + virtual_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class Lan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + ha_link: Optional[bool] = None + """mark true to use this LAN for HA probing. + + only works for site with HA turned on. only one LAN can be set as the ha_link. + """ + + nat: Optional[LanNat] = None + + physport: Optional[int] = None + + routed_subnets: Optional[List[LanRoutedSubnet]] = None + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[LanStaticAddressing] = None + """ + If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class LanGetResponse(BaseModel): + lan: Optional[Lan] = None diff --git a/src/cloudflare/types/magic_transit/sites/lan_list_response.py b/src/cloudflare/types/magic_transit/sites/lan_list_response.py new file mode 100644 index 00000000000..2f50f57458e --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/lan_list_response.py @@ -0,0 +1,106 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional + +from ...._models import BaseModel + +__all__ = [ + "LanListResponse", + "Lan", + "LanNat", + "LanRoutedSubnet", + "LanRoutedSubnetNat", + "LanStaticAddressing", + "LanStaticAddressingDhcpRelay", + "LanStaticAddressingDhcpServer", +] + + +class LanNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnetNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnet(BaseModel): + next_hop: str + """A valid IPv4 address.""" + + prefix: str + """A valid CIDR notation representing an IP range.""" + + nat: Optional[LanRoutedSubnetNat] = None + + +class LanStaticAddressingDhcpRelay(BaseModel): + server_addresses: Optional[List[str]] = None + """List of DHCP server IPs.""" + + +class LanStaticAddressingDhcpServer(BaseModel): + dhcp_pool_end: Optional[str] = None + """A valid IPv4 address.""" + + dhcp_pool_start: Optional[str] = None + """A valid IPv4 address.""" + + dns_server: Optional[str] = None + """A valid IPv4 address.""" + + reservations: Optional[Dict[str, str]] = None + """Mapping of MAC addresses to IP addresses""" + + +class LanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + dhcp_relay: Optional[LanStaticAddressingDhcpRelay] = None + + dhcp_server: Optional[LanStaticAddressingDhcpServer] = None + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + virtual_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class Lan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + ha_link: Optional[bool] = None + """mark true to use this LAN for HA probing. + + only works for site with HA turned on. only one LAN can be set as the ha_link. + """ + + nat: Optional[LanNat] = None + + physport: Optional[int] = None + + routed_subnets: Optional[List[LanRoutedSubnet]] = None + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[LanStaticAddressing] = None + """ + If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class LanListResponse(BaseModel): + lans: Optional[List[Lan]] = None diff --git a/src/cloudflare/types/magic_transit/sites/lan_update_params.py b/src/cloudflare/types/magic_transit/sites/lan_update_params.py new file mode 100644 index 00000000000..2ded79f1d02 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/lan_update_params.py @@ -0,0 +1,101 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Iterable +from typing_extensions import Required, TypedDict + +__all__ = [ + "LanUpdateParams", + "Lan", + "LanNat", + "LanRoutedSubnet", + "LanRoutedSubnetNat", + "LanStaticAddressing", + "LanStaticAddressingDhcpRelay", + "LanStaticAddressingDhcpServer", +] + + +class LanUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + lan: Lan + + +class LanNat(TypedDict, total=False): + static_prefix: str + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnetNat(TypedDict, total=False): + static_prefix: str + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnet(TypedDict, total=False): + next_hop: Required[str] + """A valid IPv4 address.""" + + prefix: Required[str] + """A valid CIDR notation representing an IP range.""" + + nat: LanRoutedSubnetNat + + +class LanStaticAddressingDhcpRelay(TypedDict, total=False): + server_addresses: List[str] + """List of DHCP server IPs.""" + + +class LanStaticAddressingDhcpServer(TypedDict, total=False): + dhcp_pool_end: str + """A valid IPv4 address.""" + + dhcp_pool_start: str + """A valid IPv4 address.""" + + dns_server: str + """A valid IPv4 address.""" + + reservations: Dict[str, str] + """Mapping of MAC addresses to IP addresses""" + + +class LanStaticAddressing(TypedDict, total=False): + address: Required[str] + """A valid CIDR notation representing an IP range.""" + + dhcp_relay: LanStaticAddressingDhcpRelay + + dhcp_server: LanStaticAddressingDhcpServer + + secondary_address: str + """A valid CIDR notation representing an IP range.""" + + virtual_address: str + """A valid CIDR notation representing an IP range.""" + + +class Lan(TypedDict, total=False): + description: str + + nat: LanNat + + physport: int + + routed_subnets: Iterable[LanRoutedSubnet] + + static_addressing: LanStaticAddressing + """ + If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + """ + + vlan_tag: int + """VLAN port number.""" diff --git a/src/cloudflare/types/magic_transit/sites/lan_update_response.py b/src/cloudflare/types/magic_transit/sites/lan_update_response.py new file mode 100644 index 00000000000..f747831a358 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/lan_update_response.py @@ -0,0 +1,106 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional + +from ...._models import BaseModel + +__all__ = [ + "LanUpdateResponse", + "Lan", + "LanNat", + "LanRoutedSubnet", + "LanRoutedSubnetNat", + "LanStaticAddressing", + "LanStaticAddressingDhcpRelay", + "LanStaticAddressingDhcpServer", +] + + +class LanNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnetNat(BaseModel): + static_prefix: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class LanRoutedSubnet(BaseModel): + next_hop: str + """A valid IPv4 address.""" + + prefix: str + """A valid CIDR notation representing an IP range.""" + + nat: Optional[LanRoutedSubnetNat] = None + + +class LanStaticAddressingDhcpRelay(BaseModel): + server_addresses: Optional[List[str]] = None + """List of DHCP server IPs.""" + + +class LanStaticAddressingDhcpServer(BaseModel): + dhcp_pool_end: Optional[str] = None + """A valid IPv4 address.""" + + dhcp_pool_start: Optional[str] = None + """A valid IPv4 address.""" + + dns_server: Optional[str] = None + """A valid IPv4 address.""" + + reservations: Optional[Dict[str, str]] = None + """Mapping of MAC addresses to IP addresses""" + + +class LanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + dhcp_relay: Optional[LanStaticAddressingDhcpRelay] = None + + dhcp_server: Optional[LanStaticAddressingDhcpServer] = None + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + virtual_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class Lan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + ha_link: Optional[bool] = None + """mark true to use this LAN for HA probing. + + only works for site with HA turned on. only one LAN can be set as the ha_link. + """ + + nat: Optional[LanNat] = None + + physport: Optional[int] = None + + routed_subnets: Optional[List[LanRoutedSubnet]] = None + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[LanStaticAddressing] = None + """ + If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class LanUpdateResponse(BaseModel): + lan: Optional[Lan] = None diff --git a/src/cloudflare/types/magic_transit/sites/wan_create_params.py b/src/cloudflare/types/magic_transit/sites/wan_create_params.py new file mode 100644 index 00000000000..297e70cb958 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/wan_create_params.py @@ -0,0 +1,42 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["WanCreateParams", "Wan", "WanStaticAddressing"] + + +class WanCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + wan: Wan + + +class WanStaticAddressing(TypedDict, total=False): + address: Required[str] + """A valid CIDR notation representing an IP range.""" + + gateway_address: Required[str] + """A valid IPv4 address.""" + + secondary_address: str + """A valid CIDR notation representing an IP range.""" + + +class Wan(TypedDict, total=False): + physport: Required[int] + + vlan_tag: Required[int] + """VLAN port number.""" + + description: str + + priority: int + + static_addressing: WanStaticAddressing + """(optional) if omitted, use DHCP. + + Submit secondary_address when site is in high availability mode. + """ diff --git a/src/cloudflare/types/magic_transit/sites/wan_create_response.py b/src/cloudflare/types/magic_transit/sites/wan_create_response.py new file mode 100644 index 00000000000..3157d618a6b --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/wan_create_response.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ...._models import BaseModel + +__all__ = ["WanCreateResponse", "Wan", "WanStaticAddressing"] + + +class WanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + gateway_address: str + """A valid IPv4 address.""" + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class Wan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + physport: Optional[int] = None + + priority: Optional[int] = None + """Priority of WAN for traffic loadbalancing.""" + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[WanStaticAddressing] = None + """(optional) if omitted, use DHCP. + + Submit secondary_address when site is in high availability mode. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class WanCreateResponse(BaseModel): + wans: Optional[List[Wan]] = None diff --git a/src/cloudflare/types/magic_transit/sites/wan_delete_response.py b/src/cloudflare/types/magic_transit/sites/wan_delete_response.py new file mode 100644 index 00000000000..dea4458ac51 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/wan_delete_response.py @@ -0,0 +1,48 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["WanDeleteResponse", "DeletedWan", "DeletedWanStaticAddressing"] + + +class DeletedWanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + gateway_address: str + """A valid IPv4 address.""" + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class DeletedWan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + physport: Optional[int] = None + + priority: Optional[int] = None + """Priority of WAN for traffic loadbalancing.""" + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[DeletedWanStaticAddressing] = None + """(optional) if omitted, use DHCP. + + Submit secondary_address when site is in high availability mode. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class WanDeleteResponse(BaseModel): + deleted: Optional[bool] = None + + deleted_wan: Optional[DeletedWan] = None diff --git a/src/cloudflare/types/magic_transit/sites/wan_get_response.py b/src/cloudflare/types/magic_transit/sites/wan_get_response.py new file mode 100644 index 00000000000..4671f6d6c32 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/wan_get_response.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["WanGetResponse", "Wan", "WanStaticAddressing"] + + +class WanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + gateway_address: str + """A valid IPv4 address.""" + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class Wan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + physport: Optional[int] = None + + priority: Optional[int] = None + """Priority of WAN for traffic loadbalancing.""" + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[WanStaticAddressing] = None + """(optional) if omitted, use DHCP. + + Submit secondary_address when site is in high availability mode. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class WanGetResponse(BaseModel): + wan: Optional[Wan] = None diff --git a/src/cloudflare/types/magic_transit/sites/wan_list_response.py b/src/cloudflare/types/magic_transit/sites/wan_list_response.py new file mode 100644 index 00000000000..f77f765f0fa --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/wan_list_response.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ...._models import BaseModel + +__all__ = ["WanListResponse", "Wan", "WanStaticAddressing"] + + +class WanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + gateway_address: str + """A valid IPv4 address.""" + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class Wan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + physport: Optional[int] = None + + priority: Optional[int] = None + """Priority of WAN for traffic loadbalancing.""" + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[WanStaticAddressing] = None + """(optional) if omitted, use DHCP. + + Submit secondary_address when site is in high availability mode. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class WanListResponse(BaseModel): + wans: Optional[List[Wan]] = None diff --git a/src/cloudflare/types/magic_transit/sites/wan_update_params.py b/src/cloudflare/types/magic_transit/sites/wan_update_params.py new file mode 100644 index 00000000000..bf577e3b949 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/wan_update_params.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["WanUpdateParams", "Wan", "WanStaticAddressing"] + + +class WanUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + wan: Wan + + +class WanStaticAddressing(TypedDict, total=False): + address: Required[str] + """A valid CIDR notation representing an IP range.""" + + gateway_address: Required[str] + """A valid IPv4 address.""" + + secondary_address: str + """A valid CIDR notation representing an IP range.""" + + +class Wan(TypedDict, total=False): + description: str + + physport: int + + priority: int + + static_addressing: WanStaticAddressing + """(optional) if omitted, use DHCP. + + Submit secondary_address when site is in high availability mode. + """ + + vlan_tag: int + """VLAN port number.""" diff --git a/src/cloudflare/types/magic_transit/sites/wan_update_response.py b/src/cloudflare/types/magic_transit/sites/wan_update_response.py new file mode 100644 index 00000000000..0fc6a199a9d --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/wan_update_response.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["WanUpdateResponse", "Wan", "WanStaticAddressing"] + + +class WanStaticAddressing(BaseModel): + address: str + """A valid CIDR notation representing an IP range.""" + + gateway_address: str + """A valid IPv4 address.""" + + secondary_address: Optional[str] = None + """A valid CIDR notation representing an IP range.""" + + +class Wan(BaseModel): + id: Optional[str] = None + """Identifier""" + + description: Optional[str] = None + + physport: Optional[int] = None + + priority: Optional[int] = None + """Priority of WAN for traffic loadbalancing.""" + + site_id: Optional[str] = None + """Identifier""" + + static_addressing: Optional[WanStaticAddressing] = None + """(optional) if omitted, use DHCP. + + Submit secondary_address when site is in high availability mode. + """ + + vlan_tag: Optional[int] = None + """VLAN port number.""" + + +class WanUpdateResponse(BaseModel): + wan: Optional[Wan] = None diff --git a/tests/api_resources/dns/analytics/reports/test_bytimes.py b/tests/api_resources/dns/analytics/reports/test_bytimes.py new file mode 100644 index 00000000000..45e54b4766d --- /dev/null +++ b/tests/api_resources/dns/analytics/reports/test_bytimes.py @@ -0,0 +1,139 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.dns.analytics.reports import DNSDNSAnalyticsAPIReportBytime + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestBytimes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + bytime = client.dns.analytics.reports.bytimes.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + bytime = client.dns.analytics.reports.bytimes.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + dimensions="queryType", + filters="responseCode==NOERROR,queryType==A", + limit=100, + metrics="queryCount,uncachedCount", + since=parse_datetime("2023-11-11T12:00:00Z"), + sort="+responseCode,-queryName", + time_delta="hour", + until=parse_datetime("2023-11-11T13:00:00Z"), + ) + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.dns.analytics.reports.bytimes.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bytime = response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.dns.analytics.reports.bytimes.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bytime = response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.dns.analytics.reports.bytimes.with_raw_response.get( + zone_id="", + ) + + +class TestAsyncBytimes: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + bytime = await async_client.dns.analytics.reports.bytimes.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + bytime = await async_client.dns.analytics.reports.bytimes.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + dimensions="queryType", + filters="responseCode==NOERROR,queryType==A", + limit=100, + metrics="queryCount,uncachedCount", + since=parse_datetime("2023-11-11T12:00:00Z"), + sort="+responseCode,-queryName", + time_delta="hour", + until=parse_datetime("2023-11-11T13:00:00Z"), + ) + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.analytics.reports.bytimes.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bytime = await response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.analytics.reports.bytimes.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bytime = await response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.dns.analytics.reports.bytimes.with_raw_response.get( + zone_id="", + ) diff --git a/tests/api_resources/dns/analytics/test_reports.py b/tests/api_resources/dns/analytics/test_reports.py new file mode 100644 index 00000000000..3f9b8ec4bd0 --- /dev/null +++ b/tests/api_resources/dns/analytics/test_reports.py @@ -0,0 +1,137 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.dns.analytics import DNSDNSAnalyticsAPIReport + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestReports: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + report = client.dns.analytics.reports.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + report = client.dns.analytics.reports.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + dimensions="queryType", + filters="responseCode==NOERROR,queryType==A", + limit=100, + metrics="queryCount,uncachedCount", + since=parse_datetime("2023-11-11T12:00:00Z"), + sort="+responseCode,-queryName", + until=parse_datetime("2023-11-11T13:00:00Z"), + ) + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.dns.analytics.reports.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + report = response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.dns.analytics.reports.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + report = response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.dns.analytics.reports.with_raw_response.get( + zone_id="", + ) + + +class TestAsyncReports: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + report = await async_client.dns.analytics.reports.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + report = await async_client.dns.analytics.reports.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + dimensions="queryType", + filters="responseCode==NOERROR,queryType==A", + limit=100, + metrics="queryCount,uncachedCount", + since=parse_datetime("2023-11-11T12:00:00Z"), + sort="+responseCode,-queryName", + until=parse_datetime("2023-11-11T13:00:00Z"), + ) + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.analytics.reports.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + report = await response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.analytics.reports.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + report = await response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.dns.analytics.reports.with_raw_response.get( + zone_id="", + ) diff --git a/tests/api_resources/dns/firewall/analytics/reports/test_bytimes.py b/tests/api_resources/dns/firewall/analytics/reports/test_bytimes.py new file mode 100644 index 00000000000..7c748237dfb --- /dev/null +++ b/tests/api_resources/dns/firewall/analytics/reports/test_bytimes.py @@ -0,0 +1,161 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.dns.analytics.reports import DNSDNSAnalyticsAPIReportBytime + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestBytimes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + bytime = client.dns.firewall.analytics.reports.bytimes.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + bytime = client.dns.firewall.analytics.reports.bytimes.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + dimensions="queryType", + filters="responseCode==NOERROR,queryType==A", + limit=100, + metrics="queryCount,uncachedCount", + since=parse_datetime("2023-11-11T12:00:00Z"), + sort="+responseCode,-queryName", + time_delta="hour", + until=parse_datetime("2023-11-11T13:00:00Z"), + ) + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.dns.firewall.analytics.reports.bytimes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bytime = response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.dns.firewall.analytics.reports.bytimes.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bytime = response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.dns.firewall.analytics.reports.bytimes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dns_firewall_id` but received ''"): + client.dns.firewall.analytics.reports.bytimes.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncBytimes: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + bytime = await async_client.dns.firewall.analytics.reports.bytimes.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + bytime = await async_client.dns.firewall.analytics.reports.bytimes.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + dimensions="queryType", + filters="responseCode==NOERROR,queryType==A", + limit=100, + metrics="queryCount,uncachedCount", + since=parse_datetime("2023-11-11T12:00:00Z"), + sort="+responseCode,-queryName", + time_delta="hour", + until=parse_datetime("2023-11-11T13:00:00Z"), + ) + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.firewall.analytics.reports.bytimes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bytime = await response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.firewall.analytics.reports.bytimes.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bytime = await response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReportBytime, bytime, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.dns.firewall.analytics.reports.bytimes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dns_firewall_id` but received ''"): + await async_client.dns.firewall.analytics.reports.bytimes.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/dns/firewall/analytics/test_reports.py b/tests/api_resources/dns/firewall/analytics/test_reports.py new file mode 100644 index 00000000000..79fe457f9a6 --- /dev/null +++ b/tests/api_resources/dns/firewall/analytics/test_reports.py @@ -0,0 +1,159 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.dns.analytics import DNSDNSAnalyticsAPIReport + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestReports: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + report = client.dns.firewall.analytics.reports.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + report = client.dns.firewall.analytics.reports.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + dimensions="queryType", + filters="responseCode==NOERROR,queryType==A", + limit=100, + metrics="queryCount,uncachedCount", + since=parse_datetime("2023-11-11T12:00:00Z"), + sort="+responseCode,-queryName", + until=parse_datetime("2023-11-11T13:00:00Z"), + ) + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.dns.firewall.analytics.reports.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + report = response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.dns.firewall.analytics.reports.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + report = response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.dns.firewall.analytics.reports.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dns_firewall_id` but received ''"): + client.dns.firewall.analytics.reports.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncReports: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + report = await async_client.dns.firewall.analytics.reports.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + report = await async_client.dns.firewall.analytics.reports.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + dimensions="queryType", + filters="responseCode==NOERROR,queryType==A", + limit=100, + metrics="queryCount,uncachedCount", + since=parse_datetime("2023-11-11T12:00:00Z"), + sort="+responseCode,-queryName", + until=parse_datetime("2023-11-11T13:00:00Z"), + ) + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.firewall.analytics.reports.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + report = await response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.firewall.analytics.reports.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + report = await response.parse() + assert_matches_type(DNSDNSAnalyticsAPIReport, report, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.dns.firewall.analytics.reports.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dns_firewall_id` but received ''"): + await async_client.dns.firewall.analytics.reports.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/healthchecks/test_previews.py b/tests/api_resources/healthchecks/test_previews.py new file mode 100644 index 00000000000..6f97f8597e4 --- /dev/null +++ b/tests/api_resources/healthchecks/test_previews.py @@ -0,0 +1,403 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types import HealthchecksHealthchecks +from cloudflare.types.healthchecks import PreviewDeleteResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestPreviews: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + preview = client.healthchecks.previews.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + preview = client.healthchecks.previews.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + check_regions=["WEU", "ENAM"], + consecutive_fails=0, + consecutive_successes=0, + description="Health check for www.example.com", + http_config={ + "allow_insecure": True, + "expected_body": "success", + "expected_codes": ["2xx", "302"], + "follow_redirects": True, + "header": { + "Host": ["example.com"], + "X-App-ID": ["abc123"], + }, + "method": "GET", + "path": "/health", + "port": 0, + }, + interval=0, + retries=0, + suspended=True, + tcp_config={ + "method": "connection_established", + "port": 0, + }, + healthcheck_timeout=0, + type="HTTPS", + ) + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.healthchecks.previews.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + preview = response.parse() + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.healthchecks.previews.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + preview = response.parse() + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.previews.with_raw_response.create( + zone_id="", + address="www.example.com", + name="server-1", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + preview = client.healthchecks.previews.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(PreviewDeleteResponse, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.healthchecks.previews.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + preview = response.parse() + assert_matches_type(PreviewDeleteResponse, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.healthchecks.previews.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + preview = response.parse() + assert_matches_type(PreviewDeleteResponse, preview, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.previews.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + client.healthchecks.previews.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + preview = client.healthchecks.previews.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.healthchecks.previews.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + preview = response.parse() + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.healthchecks.previews.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + preview = response.parse() + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.previews.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + client.healthchecks.previews.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncPreviews: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + preview = await async_client.healthchecks.previews.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + preview = await async_client.healthchecks.previews.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + check_regions=["WEU", "ENAM"], + consecutive_fails=0, + consecutive_successes=0, + description="Health check for www.example.com", + http_config={ + "allow_insecure": True, + "expected_body": "success", + "expected_codes": ["2xx", "302"], + "follow_redirects": True, + "header": { + "Host": ["example.com"], + "X-App-ID": ["abc123"], + }, + "method": "GET", + "path": "/health", + "port": 0, + }, + interval=0, + retries=0, + suspended=True, + tcp_config={ + "method": "connection_established", + "port": 0, + }, + healthcheck_timeout=0, + type="HTTPS", + ) + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.previews.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + preview = await response.parse() + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.previews.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + preview = await response.parse() + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.previews.with_raw_response.create( + zone_id="", + address="www.example.com", + name="server-1", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + preview = await async_client.healthchecks.previews.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(PreviewDeleteResponse, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.previews.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + preview = await response.parse() + assert_matches_type(PreviewDeleteResponse, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.previews.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + preview = await response.parse() + assert_matches_type(PreviewDeleteResponse, preview, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.previews.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + await async_client.healthchecks.previews.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + preview = await async_client.healthchecks.previews.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.previews.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + preview = await response.parse() + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.previews.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + preview = await response.parse() + assert_matches_type(HealthchecksHealthchecks, preview, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.previews.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + await async_client.healthchecks.previews.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/sites/test_acls.py b/tests/api_resources/magic_transit/sites/test_acls.py new file mode 100644 index 00000000000..bcb8aae447b --- /dev/null +++ b/tests/api_resources/magic_transit/sites/test_acls.py @@ -0,0 +1,726 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.magic_transit.sites import ( + ACLGetResponse, + ACLListResponse, + ACLCreateResponse, + ACLDeleteResponse, + ACLUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestACLs: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLCreateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + acl={ + "description": "Allows local traffic between PIN pads and cash register.", + "lan_1": { + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + "lan_2": { + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + "name": "PIN Pad - Cash Register", + "protocols": ["tcp", "udp", "icmp"], + }, + ) + assert_matches_type(ACLCreateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACLCreateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACLCreateResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLUpdateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + acl={ + "description": "Allows local traffic between PIN pads and cash register.", + "lan_1": { + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + "lan_2": { + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + "name": "PIN Pad - Cash Register", + "protocols": ["tcp", "udp", "icmp"], + }, + ) + assert_matches_type(ACLUpdateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACLUpdateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACLUpdateResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_identifier` but received ''"): + client.magic_transit.sites.acls.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLListResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACLListResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACLListResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLDeleteResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACLDeleteResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACLDeleteResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_identifier` but received ''"): + client.magic_transit.sites.acls.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLGetResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACLGetResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACLGetResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_identifier` but received ''"): + client.magic_transit.sites.acls.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncACLs: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLCreateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + acl={ + "description": "Allows local traffic between PIN pads and cash register.", + "lan_1": { + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + "lan_2": { + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + "name": "PIN Pad - Cash Register", + "protocols": ["tcp", "udp", "icmp"], + }, + ) + assert_matches_type(ACLCreateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACLCreateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACLCreateResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLUpdateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + acl={ + "description": "Allows local traffic between PIN pads and cash register.", + "lan_1": { + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + "lan_2": { + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + "name": "PIN Pad - Cash Register", + "protocols": ["tcp", "udp", "icmp"], + }, + ) + assert_matches_type(ACLUpdateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACLUpdateResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACLUpdateResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_identifier` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLListResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACLListResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACLListResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLDeleteResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACLDeleteResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACLDeleteResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_identifier` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACLGetResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACLGetResponse, acl, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACLGetResponse, acl, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_identifier` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/sites/test_lans.py b/tests/api_resources/magic_transit/sites/test_lans.py new file mode 100644 index 00000000000..b321ff3e421 --- /dev/null +++ b/tests/api_resources/magic_transit/sites/test_lans.py @@ -0,0 +1,812 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.magic_transit.sites import ( + LanGetResponse, + LanListResponse, + LanCreateResponse, + LanDeleteResponse, + LanUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestLans: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanCreateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + lan={ + "description": "string", + "ha_link": True, + "nat": {"static_prefix": "192.0.2.0/24"}, + "physport": 1, + "routed_subnets": [ + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + ], + "static_addressing": { + "address": "192.0.2.0/24", + "dhcp_relay": {"server_addresses": ["192.0.2.1", "192.0.2.1", "192.0.2.1"]}, + "dhcp_server": { + "dhcp_pool_end": "192.0.2.1", + "dhcp_pool_start": "192.0.2.1", + "dns_server": "192.0.2.1", + "reservations": { + "00:11:22:33:44:55": "192.0.2.100", + "AA:BB:CC:DD:EE:FF": "192.168.1.101", + }, + }, + "secondary_address": "192.0.2.0/24", + "virtual_address": "192.0.2.0/24", + }, + "vlan_tag": 0, + }, + ) + assert_matches_type(LanCreateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.lans.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = response.parse() + assert_matches_type(LanCreateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.magic_transit.sites.lans.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = response.parse() + assert_matches_type(LanCreateResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanUpdateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + lan={ + "description": "string", + "nat": {"static_prefix": "192.0.2.0/24"}, + "physport": 1, + "routed_subnets": [ + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + ], + "static_addressing": { + "address": "192.0.2.0/24", + "dhcp_relay": {"server_addresses": ["192.0.2.1", "192.0.2.1", "192.0.2.1"]}, + "dhcp_server": { + "dhcp_pool_end": "192.0.2.1", + "dhcp_pool_start": "192.0.2.1", + "dns_server": "192.0.2.1", + "reservations": { + "00:11:22:33:44:55": "192.0.2.100", + "AA:BB:CC:DD:EE:FF": "192.168.1.101", + }, + }, + "secondary_address": "192.0.2.0/24", + "virtual_address": "192.0.2.0/24", + }, + "vlan_tag": 0, + }, + ) + assert_matches_type(LanUpdateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.lans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = response.parse() + assert_matches_type(LanUpdateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.sites.lans.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = response.parse() + assert_matches_type(LanUpdateResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `lan_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanListResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.lans.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = response.parse() + assert_matches_type(LanListResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.sites.lans.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = response.parse() + assert_matches_type(LanListResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanDeleteResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.lans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = response.parse() + assert_matches_type(LanDeleteResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.sites.lans.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = response.parse() + assert_matches_type(LanDeleteResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `lan_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanGetResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.lans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = response.parse() + assert_matches_type(LanGetResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.sites.lans.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = response.parse() + assert_matches_type(LanGetResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `lan_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncLans: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanCreateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + lan={ + "description": "string", + "ha_link": True, + "nat": {"static_prefix": "192.0.2.0/24"}, + "physport": 1, + "routed_subnets": [ + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + ], + "static_addressing": { + "address": "192.0.2.0/24", + "dhcp_relay": {"server_addresses": ["192.0.2.1", "192.0.2.1", "192.0.2.1"]}, + "dhcp_server": { + "dhcp_pool_end": "192.0.2.1", + "dhcp_pool_start": "192.0.2.1", + "dns_server": "192.0.2.1", + "reservations": { + "00:11:22:33:44:55": "192.0.2.100", + "AA:BB:CC:DD:EE:FF": "192.168.1.101", + }, + }, + "secondary_address": "192.0.2.0/24", + "virtual_address": "192.0.2.0/24", + }, + "vlan_tag": 0, + }, + ) + assert_matches_type(LanCreateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.lans.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = await response.parse() + assert_matches_type(LanCreateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.lans.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = await response.parse() + assert_matches_type(LanCreateResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanUpdateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + lan={ + "description": "string", + "nat": {"static_prefix": "192.0.2.0/24"}, + "physport": 1, + "routed_subnets": [ + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + ], + "static_addressing": { + "address": "192.0.2.0/24", + "dhcp_relay": {"server_addresses": ["192.0.2.1", "192.0.2.1", "192.0.2.1"]}, + "dhcp_server": { + "dhcp_pool_end": "192.0.2.1", + "dhcp_pool_start": "192.0.2.1", + "dns_server": "192.0.2.1", + "reservations": { + "00:11:22:33:44:55": "192.0.2.100", + "AA:BB:CC:DD:EE:FF": "192.168.1.101", + }, + }, + "secondary_address": "192.0.2.0/24", + "virtual_address": "192.0.2.0/24", + }, + "vlan_tag": 0, + }, + ) + assert_matches_type(LanUpdateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.lans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = await response.parse() + assert_matches_type(LanUpdateResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.lans.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = await response.parse() + assert_matches_type(LanUpdateResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `lan_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanListResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.lans.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = await response.parse() + assert_matches_type(LanListResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.lans.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = await response.parse() + assert_matches_type(LanListResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanDeleteResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.lans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = await response.parse() + assert_matches_type(LanDeleteResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.lans.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = await response.parse() + assert_matches_type(LanDeleteResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `lan_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LanGetResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.lans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = await response.parse() + assert_matches_type(LanGetResponse, lan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.lans.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = await response.parse() + assert_matches_type(LanGetResponse, lan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `lan_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/sites/test_wans.py b/tests/api_resources/magic_transit/sites/test_wans.py new file mode 100644 index 00000000000..76831883ad5 --- /dev/null +++ b/tests/api_resources/magic_transit/sites/test_wans.py @@ -0,0 +1,702 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.magic_transit.sites import ( + WanGetResponse, + WanListResponse, + WanCreateResponse, + WanDeleteResponse, + WanUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestWans: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanCreateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + wan={ + "description": "string", + "physport": 1, + "priority": 0, + "static_addressing": { + "address": "192.0.2.0/24", + "gateway_address": "192.0.2.1", + "secondary_address": "192.0.2.0/24", + }, + "vlan_tag": 0, + }, + ) + assert_matches_type(WanCreateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.wans.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = response.parse() + assert_matches_type(WanCreateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.magic_transit.sites.wans.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = response.parse() + assert_matches_type(WanCreateResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanUpdateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + wan={ + "description": "string", + "physport": 1, + "priority": 0, + "static_addressing": { + "address": "192.0.2.0/24", + "gateway_address": "192.0.2.1", + "secondary_address": "192.0.2.0/24", + }, + "vlan_tag": 0, + }, + ) + assert_matches_type(WanUpdateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.wans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = response.parse() + assert_matches_type(WanUpdateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.sites.wans.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = response.parse() + assert_matches_type(WanUpdateResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `wan_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanListResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.wans.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = response.parse() + assert_matches_type(WanListResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.sites.wans.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = response.parse() + assert_matches_type(WanListResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanDeleteResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.wans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = response.parse() + assert_matches_type(WanDeleteResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.sites.wans.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = response.parse() + assert_matches_type(WanDeleteResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `wan_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanGetResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.wans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = response.parse() + assert_matches_type(WanGetResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.sites.wans.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = response.parse() + assert_matches_type(WanGetResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `wan_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncWans: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanCreateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + wan={ + "description": "string", + "physport": 1, + "priority": 0, + "static_addressing": { + "address": "192.0.2.0/24", + "gateway_address": "192.0.2.1", + "secondary_address": "192.0.2.0/24", + }, + "vlan_tag": 0, + }, + ) + assert_matches_type(WanCreateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.wans.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = await response.parse() + assert_matches_type(WanCreateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.wans.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = await response.parse() + assert_matches_type(WanCreateResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanUpdateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + wan={ + "description": "string", + "physport": 1, + "priority": 0, + "static_addressing": { + "address": "192.0.2.0/24", + "gateway_address": "192.0.2.1", + "secondary_address": "192.0.2.0/24", + }, + "vlan_tag": 0, + }, + ) + assert_matches_type(WanUpdateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.wans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = await response.parse() + assert_matches_type(WanUpdateResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.wans.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = await response.parse() + assert_matches_type(WanUpdateResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `wan_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanListResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.wans.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = await response.parse() + assert_matches_type(WanListResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.wans.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = await response.parse() + assert_matches_type(WanListResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanDeleteResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.wans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = await response.parse() + assert_matches_type(WanDeleteResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.wans.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = await response.parse() + assert_matches_type(WanDeleteResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `wan_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WanGetResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.wans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = await response.parse() + assert_matches_type(WanGetResponse, wan, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.wans.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = await response.parse() + assert_matches_type(WanGetResponse, wan, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `wan_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_cf_interconnects.py b/tests/api_resources/magic_transit/test_cf_interconnects.py new file mode 100644 index 00000000000..1c04dbbae9f --- /dev/null +++ b/tests/api_resources/magic_transit/test_cf_interconnects.py @@ -0,0 +1,356 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.magic_transit import ( + CfInterconnectGetResponse, + CfInterconnectListResponse, + CfInterconnectUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestCfInterconnects: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + cf_interconnect = client.magic_transit.cf_interconnects.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + cf_interconnect = client.magic_transit.cf_interconnects.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Tunnel for Interconnect to ORD", + gre={"cloudflare_endpoint": "203.0.113.1"}, + health_check={ + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + interface_address="192.0.2.0/31", + mtu=0, + ) + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.cf_interconnects.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.cf_interconnects.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + cf_interconnect = client.magic_transit.cf_interconnects.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectListResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.cf_interconnects.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectListResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.cf_interconnects.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectListResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + cf_interconnect = client.magic_transit.cf_interconnects.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.cf_interconnects.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.cf_interconnects.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = response.parse() + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.cf_interconnects.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncCfInterconnects: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + cf_interconnect = await async_client.magic_transit.cf_interconnects.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + cf_interconnect = await async_client.magic_transit.cf_interconnects.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Tunnel for Interconnect to ORD", + gre={"cloudflare_endpoint": "203.0.113.1"}, + health_check={ + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + interface_address="192.0.2.0/31", + mtu=0, + ) + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.cf_interconnects.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.cf_interconnects.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectUpdateResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + cf_interconnect = await async_client.magic_transit.cf_interconnects.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectListResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.cf_interconnects.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectListResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.cf_interconnects.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectListResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + cf_interconnect = await async_client.magic_transit.cf_interconnects.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.cf_interconnects.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.cf_interconnects.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cf_interconnect = await response.parse() + assert_matches_type(CfInterconnectGetResponse, cf_interconnect, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.cf_interconnects.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_gre_tunnels.py b/tests/api_resources/magic_transit/test_gre_tunnels.py new file mode 100644 index 00000000000..31d91baf984 --- /dev/null +++ b/tests/api_resources/magic_transit/test_gre_tunnels.py @@ -0,0 +1,602 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.magic_transit import ( + GRETunnelGetResponse, + GRETunnelListResponse, + GRETunnelCreateResponse, + GRETunnelDeleteResponse, + GRETunnelUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestGRETunnels: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(GRETunnelCreateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.magic_transit.gre_tunnels.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = response.parse() + assert_matches_type(GRETunnelCreateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.magic_transit.gre_tunnels.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = response.parse() + assert_matches_type(GRETunnelCreateResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.create( + account_id="", + body={}, + ) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + mtu=0, + ttl=0, + ) + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.gre_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = response.parse() + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.gre_tunnels.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = response.parse() + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelListResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.gre_tunnels.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = response.parse() + assert_matches_type(GRETunnelListResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.gre_tunnels.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = response.parse() + assert_matches_type(GRETunnelListResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.gre_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = response.parse() + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.gre_tunnels.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = response.parse() + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + gre_tunnel = client.magic_transit.gre_tunnels.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.gre_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = response.parse() + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.gre_tunnels.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = response.parse() + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.gre_tunnels.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncGRETunnels: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(GRETunnelCreateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.gre_tunnels.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelCreateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.gre_tunnels.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelCreateResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.create( + account_id="", + body={}, + ) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + mtu=0, + ttl=0, + ) + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.gre_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.gre_tunnels.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelUpdateResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_gre_endpoint="203.0.113.1", + customer_gre_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="GRE_1", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelListResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.gre_tunnels.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelListResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.gre_tunnels.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelListResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.gre_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.gre_tunnels.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelDeleteResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + gre_tunnel = await async_client.magic_transit.gre_tunnels.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.gre_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.gre_tunnels.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + gre_tunnel = await response.parse() + assert_matches_type(GRETunnelGetResponse, gre_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.gre_tunnels.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_ipsec_tunnels.py b/tests/api_resources/magic_transit/test_ipsec_tunnels.py new file mode 100644 index 00000000000..10fb20f2edc --- /dev/null +++ b/tests/api_resources/magic_transit/test_ipsec_tunnels.py @@ -0,0 +1,757 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.magic_transit import ( + IPSECTunnelGetResponse, + IPSECTunnelListResponse, + IPSECTunnelCreateResponse, + IPSECTunnelDeleteResponse, + IPSECTunnelUpdateResponse, + IPSECTunnelPSKGenerateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestIPSECTunnels: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + assert_matches_type(IPSECTunnelCreateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + customer_endpoint="203.0.113.1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + psk="O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy", + replay_protection=False, + ) + assert_matches_type(IPSECTunnelCreateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelCreateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelCreateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.create( + account_id="", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + customer_endpoint="203.0.113.1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + psk="O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy", + replay_protection=False, + ) + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelListResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelListResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelListResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_psk_generate(self, client: Cloudflare) -> None: + ipsec_tunnel = client.magic_transit.ipsec_tunnels.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_psk_generate(self, client: Cloudflare) -> None: + response = client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_psk_generate(self, client: Cloudflare) -> None: + with client.magic_transit.ipsec_tunnels.with_streaming_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = response.parse() + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_psk_generate(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncIPSECTunnels: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + assert_matches_type(IPSECTunnelCreateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + customer_endpoint="203.0.113.1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + psk="O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy", + replay_protection=False, + ) + assert_matches_type(IPSECTunnelCreateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelCreateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelCreateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.create( + account_id="", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + customer_endpoint="203.0.113.1", + description="Tunnel for ISP X", + health_check={ + "direction": "bidirectional", + "enabled": True, + "rate": "low", + "target": "203.0.113.1", + "type": "request", + }, + psk="O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy", + replay_protection=False, + ) + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelUpdateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cloudflare_endpoint="203.0.113.1", + interface_address="192.0.2.0/31", + name="IPsec_1", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelListResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelListResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelListResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelDeleteResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelGetResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_psk_generate(self, async_client: AsyncCloudflare) -> None: + ipsec_tunnel = await async_client.magic_transit.ipsec_tunnels.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_psk_generate(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_psk_generate(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.ipsec_tunnels.with_streaming_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ipsec_tunnel = await response.parse() + assert_matches_type(IPSECTunnelPSKGenerateResponse, ipsec_tunnel, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_psk_generate(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tunnel_identifier` but received ''"): + await async_client.magic_transit.ipsec_tunnels.with_raw_response.psk_generate( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_routes.py b/tests/api_resources/magic_transit/test_routes.py new file mode 100644 index 00000000000..aa6fb26e1f7 --- /dev/null +++ b/tests/api_resources/magic_transit/test_routes.py @@ -0,0 +1,675 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.magic_transit import ( + RouteGetResponse, + RouteListResponse, + RouteEmptyResponse, + RouteCreateResponse, + RouteDeleteResponse, + RouteUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRoutes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(RouteCreateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteCreateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteCreateResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.create( + account_id="", + body={}, + ) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + description="New route for new prefix 203.0.113.1", + scope={ + "colo_names": ["den01", "den01", "den01"], + "colo_regions": ["APAC", "APAC", "APAC"], + }, + weight=0, + ) + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_identifier` but received ''"): + client.magic_transit.routes.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteListResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteListResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteListResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_identifier` but received ''"): + client.magic_transit.routes.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_empty(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.empty( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + routes=[{}, {}, {}], + ) + assert_matches_type(RouteEmptyResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_empty(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.empty( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + routes=[{}, {}, {}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteEmptyResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_empty(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.empty( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + routes=[{}, {}, {}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteEmptyResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_empty(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.empty( + account_id="", + routes=[{}, {}, {}], + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + route = client.magic_transit.routes.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteGetResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.routes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteGetResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.routes.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteGetResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.routes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_identifier` but received ''"): + client.magic_transit.routes.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncRoutes: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(RouteCreateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteCreateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteCreateResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.create( + account_id="", + body={}, + ) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + description="New route for new prefix 203.0.113.1", + scope={ + "colo_names": ["den01", "den01", "den01"], + "colo_regions": ["APAC", "APAC", "APAC"], + }, + weight=0, + ) + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteUpdateResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_identifier` but received ''"): + await async_client.magic_transit.routes.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + nexthop="203.0.113.1", + prefix="192.0.2.0/24", + priority=0, + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteListResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteListResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteListResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteDeleteResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_identifier` but received ''"): + await async_client.magic_transit.routes.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_empty(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.empty( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + routes=[{}, {}, {}], + ) + assert_matches_type(RouteEmptyResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_empty(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.empty( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + routes=[{}, {}, {}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteEmptyResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_empty(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.empty( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + routes=[{}, {}, {}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteEmptyResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_empty(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.empty( + account_id="", + routes=[{}, {}, {}], + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + route = await async_client.magic_transit.routes.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RouteGetResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.routes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteGetResponse, route, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.routes.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteGetResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.routes.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `route_identifier` but received ''"): + await async_client.magic_transit.routes.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_sites.py b/tests/api_resources/magic_transit/test_sites.py new file mode 100644 index 00000000000..28df8c5d1a7 --- /dev/null +++ b/tests/api_resources/magic_transit/test_sites.py @@ -0,0 +1,584 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.magic_transit import ( + SiteGetResponse, + SiteListResponse, + SiteCreateResponse, + SiteDeleteResponse, + SiteUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSites: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteCreateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site={ + "connector_id": "ac60d3d0435248289d446cedd870bcf4", + "description": "string", + "ha_mode": True, + "location": { + "lat": "string", + "lon": "string", + }, + "name": "site_1", + "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482", + }, + ) + assert_matches_type(SiteCreateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = response.parse() + assert_matches_type(SiteCreateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.magic_transit.sites.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = response.parse() + assert_matches_type(SiteCreateResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.with_raw_response.create( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteUpdateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site={ + "connector_id": "ac60d3d0435248289d446cedd870bcf4", + "description": "string", + "location": { + "lat": "string", + "lon": "string", + }, + "name": "site_1", + "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482", + }, + ) + assert_matches_type(SiteUpdateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = response.parse() + assert_matches_type(SiteUpdateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.sites.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = response.parse() + assert_matches_type(SiteUpdateResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteListResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = response.parse() + assert_matches_type(SiteListResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.sites.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = response.parse() + assert_matches_type(SiteListResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteDeleteResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = response.parse() + assert_matches_type(SiteDeleteResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.sites.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = response.parse() + assert_matches_type(SiteDeleteResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteGetResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = response.parse() + assert_matches_type(SiteGetResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.sites.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = response.parse() + assert_matches_type(SiteGetResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncSites: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteCreateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site={ + "connector_id": "ac60d3d0435248289d446cedd870bcf4", + "description": "string", + "ha_mode": True, + "location": { + "lat": "string", + "lon": "string", + }, + "name": "site_1", + "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482", + }, + ) + assert_matches_type(SiteCreateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = await response.parse() + assert_matches_type(SiteCreateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = await response.parse() + assert_matches_type(SiteCreateResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.create( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteUpdateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site={ + "connector_id": "ac60d3d0435248289d446cedd870bcf4", + "description": "string", + "location": { + "lat": "string", + "lon": "string", + }, + "name": "site_1", + "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482", + }, + ) + assert_matches_type(SiteUpdateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = await response.parse() + assert_matches_type(SiteUpdateResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = await response.parse() + assert_matches_type(SiteUpdateResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteListResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = await response.parse() + assert_matches_type(SiteListResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = await response.parse() + assert_matches_type(SiteListResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteDeleteResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = await response.parse() + assert_matches_type(SiteDeleteResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = await response.parse() + assert_matches_type(SiteDeleteResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SiteGetResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = await response.parse() + assert_matches_type(SiteGetResponse, site, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = await response.parse() + assert_matches_type(SiteGetResponse, site, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/test_healthchecks.py b/tests/api_resources/test_healthchecks.py new file mode 100644 index 00000000000..f6e27537930 --- /dev/null +++ b/tests/api_resources/test_healthchecks.py @@ -0,0 +1,886 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types import ( + HealthcheckListResponse, + HealthchecksHealthchecks, + HealthcheckDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestHealthchecks: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + check_regions=["WEU", "ENAM"], + consecutive_fails=0, + consecutive_successes=0, + description="Health check for www.example.com", + http_config={ + "allow_insecure": True, + "expected_body": "success", + "expected_codes": ["2xx", "302"], + "follow_redirects": True, + "header": { + "Host": ["example.com"], + "X-App-ID": ["abc123"], + }, + "method": "GET", + "path": "/health", + "port": 0, + }, + interval=0, + retries=0, + suspended=True, + tcp_config={ + "method": "connection_established", + "port": 0, + }, + healthcheck_timeout=0, + type="HTTPS", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.healthchecks.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.healthchecks.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.with_raw_response.create( + zone_id="", + address="www.example.com", + name="server-1", + ) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + check_regions=["WEU", "ENAM"], + consecutive_fails=0, + consecutive_successes=0, + description="Health check for www.example.com", + http_config={ + "allow_insecure": True, + "expected_body": "success", + "expected_codes": ["2xx", "302"], + "follow_redirects": True, + "header": { + "Host": ["example.com"], + "X-App-ID": ["abc123"], + }, + "method": "GET", + "path": "/health", + "port": 0, + }, + interval=0, + retries=0, + suspended=True, + tcp_config={ + "method": "connection_established", + "port": 0, + }, + healthcheck_timeout=0, + type="HTTPS", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.healthchecks.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.healthchecks.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + address="www.example.com", + name="server-1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + client.healthchecks.with_raw_response.update( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[HealthcheckListResponse], healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.healthchecks.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = response.parse() + assert_matches_type(Optional[HealthcheckListResponse], healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.healthchecks.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = response.parse() + assert_matches_type(Optional[HealthcheckListResponse], healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.with_raw_response.list( + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(HealthcheckDeleteResponse, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.healthchecks.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = response.parse() + assert_matches_type(HealthcheckDeleteResponse, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.healthchecks.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = response.parse() + assert_matches_type(HealthcheckDeleteResponse, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + client.healthchecks.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + check_regions=["WEU", "ENAM"], + consecutive_fails=0, + consecutive_successes=0, + description="Health check for www.example.com", + http_config={ + "allow_insecure": True, + "expected_body": "success", + "expected_codes": ["2xx", "302"], + "follow_redirects": True, + "header": { + "Host": ["example.com"], + "X-App-ID": ["abc123"], + }, + "method": "GET", + "path": "/health", + "port": 0, + }, + interval=0, + retries=0, + suspended=True, + tcp_config={ + "method": "connection_established", + "port": 0, + }, + healthcheck_timeout=0, + type="HTTPS", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.healthchecks.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.healthchecks.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + address="www.example.com", + name="server-1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + client.healthchecks.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + healthcheck = client.healthchecks.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.healthchecks.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.healthchecks.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.healthchecks.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + client.healthchecks.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncHealthchecks: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + check_regions=["WEU", "ENAM"], + consecutive_fails=0, + consecutive_successes=0, + description="Health check for www.example.com", + http_config={ + "allow_insecure": True, + "expected_body": "success", + "expected_codes": ["2xx", "302"], + "follow_redirects": True, + "header": { + "Host": ["example.com"], + "X-App-ID": ["abc123"], + }, + "method": "GET", + "path": "/health", + "port": 0, + }, + interval=0, + retries=0, + suspended=True, + tcp_config={ + "method": "connection_established", + "port": 0, + }, + healthcheck_timeout=0, + type="HTTPS", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = await response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = await response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.with_raw_response.create( + zone_id="", + address="www.example.com", + name="server-1", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + check_regions=["WEU", "ENAM"], + consecutive_fails=0, + consecutive_successes=0, + description="Health check for www.example.com", + http_config={ + "allow_insecure": True, + "expected_body": "success", + "expected_codes": ["2xx", "302"], + "follow_redirects": True, + "header": { + "Host": ["example.com"], + "X-App-ID": ["abc123"], + }, + "method": "GET", + "path": "/health", + "port": 0, + }, + interval=0, + retries=0, + suspended=True, + tcp_config={ + "method": "connection_established", + "port": 0, + }, + healthcheck_timeout=0, + type="HTTPS", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = await response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = await response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + address="www.example.com", + name="server-1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + await async_client.healthchecks.with_raw_response.update( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[HealthcheckListResponse], healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = await response.parse() + assert_matches_type(Optional[HealthcheckListResponse], healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = await response.parse() + assert_matches_type(Optional[HealthcheckListResponse], healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.with_raw_response.list( + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(HealthcheckDeleteResponse, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = await response.parse() + assert_matches_type(HealthcheckDeleteResponse, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = await response.parse() + assert_matches_type(HealthcheckDeleteResponse, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + await async_client.healthchecks.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + check_regions=["WEU", "ENAM"], + consecutive_fails=0, + consecutive_successes=0, + description="Health check for www.example.com", + http_config={ + "allow_insecure": True, + "expected_body": "success", + "expected_codes": ["2xx", "302"], + "follow_redirects": True, + "header": { + "Host": ["example.com"], + "X-App-ID": ["abc123"], + }, + "method": "GET", + "path": "/health", + "port": 0, + }, + interval=0, + retries=0, + suspended=True, + tcp_config={ + "method": "connection_established", + "port": 0, + }, + healthcheck_timeout=0, + type="HTTPS", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = await response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = await response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + address="www.example.com", + name="server-1", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + await async_client.healthchecks.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + address="www.example.com", + name="server-1", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + healthcheck = await async_client.healthchecks.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.healthchecks.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + healthcheck = await response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.healthchecks.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + healthcheck = await response.parse() + assert_matches_type(HealthchecksHealthchecks, healthcheck, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.healthchecks.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `healthcheck_id` but received ''"): + await async_client.healthchecks.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + )