Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #152

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 1235
configured_endpoints: 1288
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
247 changes: 246 additions & 1 deletion api.md

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/cloudflare/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
)
Expand Down Expand Up @@ -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)
Expand All @@ -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
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion src/cloudflare/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
28 changes: 28 additions & 0 deletions src/cloudflare/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,14 @@
URLScannerWithStreamingResponse,
AsyncURLScannerWithStreamingResponse,
)
from .healthchecks import (
Healthchecks,
AsyncHealthchecks,
HealthchecksWithRawResponse,
AsyncHealthchecksWithRawResponse,
HealthchecksWithStreamingResponse,
AsyncHealthchecksWithStreamingResponse,
)
from .email_routing import (
EmailRouting,
AsyncEmailRouting,
Expand All @@ -408,6 +416,14 @@
EmailRoutingWithStreamingResponse,
AsyncEmailRoutingWithStreamingResponse,
)
from .magic_transit import (
MagicTransit,
AsyncMagicTransit,
MagicTransitWithRawResponse,
AsyncMagicTransitWithRawResponse,
MagicTransitWithStreamingResponse,
AsyncMagicTransitWithStreamingResponse,
)
from .secondary_dns import (
SecondaryDNS,
AsyncSecondaryDNS,
Expand Down Expand Up @@ -770,6 +786,12 @@
"AsyncFirewallWithRawResponse",
"FirewallWithStreamingResponse",
"AsyncFirewallWithStreamingResponse",
"Healthchecks",
"AsyncHealthchecks",
"HealthchecksWithRawResponse",
"AsyncHealthchecksWithRawResponse",
"HealthchecksWithStreamingResponse",
"AsyncHealthchecksWithStreamingResponse",
"KeylessCertificates",
"AsyncKeylessCertificates",
"KeylessCertificatesWithRawResponse",
Expand Down Expand Up @@ -920,6 +942,12 @@
"AsyncIntelWithRawResponse",
"IntelWithStreamingResponse",
"AsyncIntelWithStreamingResponse",
"MagicTransit",
"AsyncMagicTransit",
"MagicTransitWithRawResponse",
"AsyncMagicTransitWithRawResponse",
"MagicTransitWithStreamingResponse",
"AsyncMagicTransitWithStreamingResponse",
"MagicNetworkMonitoring",
"AsyncMagicNetworkMonitoring",
"MagicNetworkMonitoringWithRawResponse",
Expand Down
14 changes: 14 additions & 0 deletions src/cloudflare/resources/dns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
FirewallWithStreamingResponse,
AsyncFirewallWithStreamingResponse,
)
from .analytics import (
Analytics,
AsyncAnalytics,
AnalyticsWithRawResponse,
AsyncAnalyticsWithRawResponse,
AnalyticsWithStreamingResponse,
AsyncAnalyticsWithStreamingResponse,
)

__all__ = [
"Records",
Expand All @@ -32,6 +40,12 @@
"AsyncRecordsWithRawResponse",
"RecordsWithStreamingResponse",
"AsyncRecordsWithStreamingResponse",
"Analytics",
"AsyncAnalytics",
"AnalyticsWithRawResponse",
"AsyncAnalyticsWithRawResponse",
"AnalyticsWithStreamingResponse",
"AsyncAnalyticsWithStreamingResponse",
"Firewall",
"AsyncFirewall",
"FirewallWithRawResponse",
Expand Down
33 changes: 33 additions & 0 deletions src/cloudflare/resources/dns/analytics/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
81 changes: 81 additions & 0 deletions src/cloudflare/resources/dns/analytics/analytics.py
Original file line number Diff line number Diff line change
@@ -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)
33 changes: 33 additions & 0 deletions src/cloudflare/resources/dns/analytics/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
Loading