From 85c52261ba33d752fa90ad151723e2daa5bbfa86 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Sat, 9 Mar 2024 06:14:47 +0000
Subject: [PATCH] feat: OpenAPI spec update via Stainless API (#103)
---
.stats.yml | 2 +-
api.md | 25 +-
src/cloudflare/_client.py | 8 +
src/cloudflare/resources/__init__.py | 14 +
.../alerting/v3/destinations/pagerduty.py | 4 +-
.../alerting/v3/destinations/webhooks.py | 10 +-
.../resources/alerting/v3/histories.py | 14 +-
.../resources/alerting/v3/policies.py | 14 +-
src/cloudflare/resources/audit_logs.py | 256 ++++++++++++++++++
src/cloudflare/types/__init__.py | 2 +
src/cloudflare/types/alerting/v3/__init__.py | 4 +-
...istory_list_response.py => aaa_history.py} | 4 +-
...policy_get_response.py => aaa_policies.py} | 10 +-
.../alerting/v3/destinations/__init__.py | 3 +-
.../alerting/v3/destinations/aaa_pagerduty.py | 15 +
...ebhook_get_response.py => aaa_webhooks.py} | 4 +-
.../destinations/pagerduty_create_response.py | 2 +-
.../v3/destinations/pagerduty_get_response.py | 17 +-
.../v3/destinations/webhook_list_response.py | 51 +---
.../types/alerting/v3/policy_create_params.py | 6 +-
.../types/alerting/v3/policy_list_response.py | 248 +----------------
.../types/alerting/v3/policy_update_params.py | 6 +-
src/cloudflare/types/audit_log_list_params.py | 72 +++++
.../types/audit_log_list_response.py | 80 ++++++
.../alerting/v3/destinations/test_webhooks.py | 14 +-
.../alerting/v3/test_histories.py | 18 +-
.../alerting/v3/test_policies.py | 14 +-
tests/api_resources/test_audit_logs.py | 152 +++++++++++
28 files changed, 687 insertions(+), 382 deletions(-)
create mode 100644 src/cloudflare/resources/audit_logs.py
rename src/cloudflare/types/alerting/v3/{history_list_response.py => aaa_history.py} (94%)
rename src/cloudflare/types/alerting/v3/{policy_get_response.py => aaa_policies.py} (97%)
create mode 100644 src/cloudflare/types/alerting/v3/destinations/aaa_pagerduty.py
rename src/cloudflare/types/alerting/v3/destinations/{webhook_get_response.py => aaa_webhooks.py} (95%)
create mode 100644 src/cloudflare/types/audit_log_list_params.py
create mode 100644 src/cloudflare/types/audit_log_list_response.py
create mode 100644 tests/api_resources/test_audit_logs.py
diff --git a/.stats.yml b/.stats.yml
index c620a2a73..d0e375fdc 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1 +1 @@
-configured_endpoints: 1255
+configured_endpoints: 1256
diff --git a/api.md b/api.md
index ba1618928..2b0d150c0 100644
--- a/api.md
+++ b/api.md
@@ -3410,6 +3410,18 @@ Methods:
- client.addressing.prefixes.delegations.list(prefix_id, \*, account_id) -> Optional
- client.addressing.prefixes.delegations.delete(delegation_id, \*, account_id, prefix_id) -> DelegationDeleteResponse
+# AuditLogs
+
+Types:
+
+```python
+from cloudflare.types import AuditLogListResponse
+```
+
+Methods:
+
+- client.audit_logs.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[AuditLogListResponse]
+
# Billing
## Profiles
@@ -4358,6 +4370,7 @@ Types:
```python
from cloudflare.types.alerting.v3.destinations import (
+ AaaPagerduty,
PagerdutyCreateResponse,
PagerdutyDeleteResponse,
PagerdutyGetResponse,
@@ -4378,11 +4391,11 @@ Types:
```python
from cloudflare.types.alerting.v3.destinations import (
+ AaaWebhooks,
WebhookCreateResponse,
WebhookUpdateResponse,
WebhookListResponse,
WebhookDeleteResponse,
- WebhookGetResponse,
)
```
@@ -4392,19 +4405,19 @@ Methods:
- client.alerting.v3.destinations.webhooks.update(webhook_id, \*, account_id, \*\*params) -> WebhookUpdateResponse
- client.alerting.v3.destinations.webhooks.list(\*, account_id) -> Optional
- client.alerting.v3.destinations.webhooks.delete(webhook_id, \*, account_id) -> Optional
-- client.alerting.v3.destinations.webhooks.get(webhook_id, \*, account_id) -> WebhookGetResponse
+- client.alerting.v3.destinations.webhooks.get(webhook_id, \*, account_id) -> AaaWebhooks
### Histories
Types:
```python
-from cloudflare.types.alerting.v3 import HistoryListResponse
+from cloudflare.types.alerting.v3 import AaaHistory
```
Methods:
-- client.alerting.v3.histories.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[HistoryListResponse]
+- client.alerting.v3.histories.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[AaaHistory]
### Policies
@@ -4412,11 +4425,11 @@ Types:
```python
from cloudflare.types.alerting.v3 import (
+ AaaPolicies,
PolicyCreateResponse,
PolicyUpdateResponse,
PolicyListResponse,
PolicyDeleteResponse,
- PolicyGetResponse,
)
```
@@ -4426,7 +4439,7 @@ Methods:
- client.alerting.v3.policies.update(policy_id, \*, account_id, \*\*params) -> PolicyUpdateResponse
- client.alerting.v3.policies.list(\*, account_id) -> Optional
- client.alerting.v3.policies.delete(policy_id, \*, account_id) -> Optional
-- client.alerting.v3.policies.get(policy_id, \*, account_id) -> PolicyGetResponse
+- client.alerting.v3.policies.get(policy_id, \*, account_id) -> AaaPolicies
# D1
diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py
index b80eea8c0..b21891ec0 100644
--- a/src/cloudflare/_client.py
+++ b/src/cloudflare/_client.py
@@ -91,6 +91,7 @@ class Cloudflare(SyncAPIClient):
url_normalization: resources.URLNormalization
spectrum: resources.Spectrum
addressing: resources.Addressing
+ audit_logs: resources.AuditLogs
billing: resources.Billing
brand_protection: resources.BrandProtection
diagnostics: resources.Diagnostics
@@ -243,6 +244,7 @@ class Cloudflare(SyncAPIClient):
self.url_normalization = resources.URLNormalization(self)
self.spectrum = resources.Spectrum(self)
self.addressing = resources.Addressing(self)
+ self.audit_logs = resources.AuditLogs(self)
self.billing = resources.Billing(self)
self.brand_protection = resources.BrandProtection(self)
self.diagnostics = resources.Diagnostics(self)
@@ -500,6 +502,7 @@ class AsyncCloudflare(AsyncAPIClient):
url_normalization: resources.AsyncURLNormalization
spectrum: resources.AsyncSpectrum
addressing: resources.AsyncAddressing
+ audit_logs: resources.AsyncAuditLogs
billing: resources.AsyncBilling
brand_protection: resources.AsyncBrandProtection
diagnostics: resources.AsyncDiagnostics
@@ -652,6 +655,7 @@ class AsyncCloudflare(AsyncAPIClient):
self.url_normalization = resources.AsyncURLNormalization(self)
self.spectrum = resources.AsyncSpectrum(self)
self.addressing = resources.AsyncAddressing(self)
+ self.audit_logs = resources.AsyncAuditLogs(self)
self.billing = resources.AsyncBilling(self)
self.brand_protection = resources.AsyncBrandProtection(self)
self.diagnostics = resources.AsyncDiagnostics(self)
@@ -910,6 +914,7 @@ class CloudflareWithRawResponse:
self.url_normalization = resources.URLNormalizationWithRawResponse(client.url_normalization)
self.spectrum = resources.SpectrumWithRawResponse(client.spectrum)
self.addressing = resources.AddressingWithRawResponse(client.addressing)
+ self.audit_logs = resources.AuditLogsWithRawResponse(client.audit_logs)
self.billing = resources.BillingWithRawResponse(client.billing)
self.brand_protection = resources.BrandProtectionWithRawResponse(client.brand_protection)
self.diagnostics = resources.DiagnosticsWithRawResponse(client.diagnostics)
@@ -997,6 +1002,7 @@ class AsyncCloudflareWithRawResponse:
self.url_normalization = resources.AsyncURLNormalizationWithRawResponse(client.url_normalization)
self.spectrum = resources.AsyncSpectrumWithRawResponse(client.spectrum)
self.addressing = resources.AsyncAddressingWithRawResponse(client.addressing)
+ self.audit_logs = resources.AsyncAuditLogsWithRawResponse(client.audit_logs)
self.billing = resources.AsyncBillingWithRawResponse(client.billing)
self.brand_protection = resources.AsyncBrandProtectionWithRawResponse(client.brand_protection)
self.diagnostics = resources.AsyncDiagnosticsWithRawResponse(client.diagnostics)
@@ -1086,6 +1092,7 @@ class CloudflareWithStreamedResponse:
self.url_normalization = resources.URLNormalizationWithStreamingResponse(client.url_normalization)
self.spectrum = resources.SpectrumWithStreamingResponse(client.spectrum)
self.addressing = resources.AddressingWithStreamingResponse(client.addressing)
+ self.audit_logs = resources.AuditLogsWithStreamingResponse(client.audit_logs)
self.billing = resources.BillingWithStreamingResponse(client.billing)
self.brand_protection = resources.BrandProtectionWithStreamingResponse(client.brand_protection)
self.diagnostics = resources.DiagnosticsWithStreamingResponse(client.diagnostics)
@@ -1177,6 +1184,7 @@ class AsyncCloudflareWithStreamedResponse:
self.url_normalization = resources.AsyncURLNormalizationWithStreamingResponse(client.url_normalization)
self.spectrum = resources.AsyncSpectrumWithStreamingResponse(client.spectrum)
self.addressing = resources.AsyncAddressingWithStreamingResponse(client.addressing)
+ self.audit_logs = resources.AsyncAuditLogsWithStreamingResponse(client.audit_logs)
self.billing = resources.AsyncBillingWithStreamingResponse(client.billing)
self.brand_protection = resources.AsyncBrandProtectionWithStreamingResponse(client.brand_protection)
self.diagnostics = resources.AsyncDiagnosticsWithStreamingResponse(client.diagnostics)
diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py
index ed95721fc..7ce862ee0 100644
--- a/src/cloudflare/resources/__init__.py
+++ b/src/cloudflare/resources/__init__.py
@@ -328,6 +328,14 @@ from .addressing import (
AddressingWithStreamingResponse,
AsyncAddressingWithStreamingResponse,
)
+from .audit_logs import (
+ AuditLogs,
+ AsyncAuditLogs,
+ AuditLogsWithRawResponse,
+ AsyncAuditLogsWithRawResponse,
+ AuditLogsWithStreamingResponse,
+ AsyncAuditLogsWithStreamingResponse,
+)
from .challenges import (
Challenges,
AsyncChallenges,
@@ -898,6 +906,12 @@ __all__ = [
"AsyncAddressingWithRawResponse",
"AddressingWithStreamingResponse",
"AsyncAddressingWithStreamingResponse",
+ "AuditLogs",
+ "AsyncAuditLogs",
+ "AuditLogsWithRawResponse",
+ "AsyncAuditLogsWithRawResponse",
+ "AuditLogsWithStreamingResponse",
+ "AsyncAuditLogsWithStreamingResponse",
"Billing",
"AsyncBilling",
"BillingWithRawResponse",
diff --git a/src/cloudflare/resources/alerting/v3/destinations/pagerduty.py b/src/cloudflare/resources/alerting/v3/destinations/pagerduty.py
index 97788a2cd..de094c27a 100644
--- a/src/cloudflare/resources/alerting/v3/destinations/pagerduty.py
+++ b/src/cloudflare/resources/alerting/v3/destinations/pagerduty.py
@@ -178,7 +178,7 @@ class Pagerduty(SyncAPIResource):
Args:
account_id: The account id
- token_id: The token integration key
+ token_id: The token id
extra_headers: Send extra headers
@@ -354,7 +354,7 @@ class AsyncPagerduty(AsyncAPIResource):
Args:
account_id: The account id
- token_id: The token integration key
+ token_id: The token id
extra_headers: Send extra headers
diff --git a/src/cloudflare/resources/alerting/v3/destinations/webhooks.py b/src/cloudflare/resources/alerting/v3/destinations/webhooks.py
index 7e62b0eae..f595622f2 100644
--- a/src/cloudflare/resources/alerting/v3/destinations/webhooks.py
+++ b/src/cloudflare/resources/alerting/v3/destinations/webhooks.py
@@ -24,7 +24,7 @@ from ....._base_client import (
make_request_options,
)
from .....types.alerting.v3.destinations import (
- WebhookGetResponse,
+ AaaWebhooks,
WebhookListResponse,
WebhookCreateResponse,
WebhookDeleteResponse,
@@ -267,7 +267,7 @@ class Webhooks(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> WebhookGetResponse:
+ ) -> AaaWebhooks:
"""
Get details for a single webhooks destination.
@@ -297,7 +297,7 @@ class Webhooks(SyncAPIResource):
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
- cast_to=cast(Type[WebhookGetResponse], ResultWrapper[WebhookGetResponse]),
+ cast_to=cast(Type[AaaWebhooks], ResultWrapper[AaaWebhooks]),
)
@@ -532,7 +532,7 @@ class AsyncWebhooks(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> WebhookGetResponse:
+ ) -> AaaWebhooks:
"""
Get details for a single webhooks destination.
@@ -562,7 +562,7 @@ class AsyncWebhooks(AsyncAPIResource):
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
- cast_to=cast(Type[WebhookGetResponse], ResultWrapper[WebhookGetResponse]),
+ cast_to=cast(Type[AaaWebhooks], ResultWrapper[AaaWebhooks]),
)
diff --git a/src/cloudflare/resources/alerting/v3/histories.py b/src/cloudflare/resources/alerting/v3/histories.py
index 6b05f723f..0e4f3399d 100644
--- a/src/cloudflare/resources/alerting/v3/histories.py
+++ b/src/cloudflare/resources/alerting/v3/histories.py
@@ -22,7 +22,7 @@ from ...._base_client import (
AsyncPaginator,
make_request_options,
)
-from ....types.alerting.v3 import HistoryListResponse, history_list_params
+from ....types.alerting.v3 import AaaHistory, history_list_params
__all__ = ["Histories", "AsyncHistories"]
@@ -50,7 +50,7 @@ class Histories(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> SyncV4PagePaginationArray[HistoryListResponse]:
+ ) -> SyncV4PagePaginationArray[AaaHistory]:
"""Gets a list of history records for notifications sent to an account.
The records
@@ -82,7 +82,7 @@ class Histories(SyncAPIResource):
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get_api_list(
f"/accounts/{account_id}/alerting/v3/history",
- page=SyncV4PagePaginationArray[HistoryListResponse],
+ page=SyncV4PagePaginationArray[AaaHistory],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -98,7 +98,7 @@ class Histories(SyncAPIResource):
history_list_params.HistoryListParams,
),
),
- model=HistoryListResponse,
+ model=AaaHistory,
)
@@ -125,7 +125,7 @@ class AsyncHistories(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncPaginator[HistoryListResponse, AsyncV4PagePaginationArray[HistoryListResponse]]:
+ ) -> AsyncPaginator[AaaHistory, AsyncV4PagePaginationArray[AaaHistory]]:
"""Gets a list of history records for notifications sent to an account.
The records
@@ -157,7 +157,7 @@ class AsyncHistories(AsyncAPIResource):
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get_api_list(
f"/accounts/{account_id}/alerting/v3/history",
- page=AsyncV4PagePaginationArray[HistoryListResponse],
+ page=AsyncV4PagePaginationArray[AaaHistory],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -173,7 +173,7 @@ class AsyncHistories(AsyncAPIResource):
history_list_params.HistoryListParams,
),
),
- model=HistoryListResponse,
+ model=AaaHistory,
)
diff --git a/src/cloudflare/resources/alerting/v3/policies.py b/src/cloudflare/resources/alerting/v3/policies.py
index 935119fd3..efee91f3f 100644
--- a/src/cloudflare/resources/alerting/v3/policies.py
+++ b/src/cloudflare/resources/alerting/v3/policies.py
@@ -25,7 +25,7 @@ from ...._base_client import (
make_request_options,
)
from ....types.alerting.v3 import (
- PolicyGetResponse,
+ AaaPolicies,
PolicyListResponse,
PolicyCreateResponse,
PolicyDeleteResponse,
@@ -100,7 +100,6 @@ class Policies(SyncAPIResource):
"secondary_dns_zone_validation_warning",
"sentinel_alert",
"stream_live_notifications",
- "traffic_anomalies_alert",
"tunnel_health_event",
"tunnel_update_event",
"universal_ssl_event_type",
@@ -230,7 +229,6 @@ class Policies(SyncAPIResource):
"secondary_dns_zone_validation_warning",
"sentinel_alert",
"stream_live_notifications",
- "traffic_anomalies_alert",
"tunnel_health_event",
"tunnel_update_event",
"universal_ssl_event_type",
@@ -409,7 +407,7 @@ class Policies(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> PolicyGetResponse:
+ ) -> AaaPolicies:
"""
Get details for a single policy.
@@ -439,7 +437,7 @@ class Policies(SyncAPIResource):
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
- cast_to=cast(Type[PolicyGetResponse], ResultWrapper[PolicyGetResponse]),
+ cast_to=cast(Type[AaaPolicies], ResultWrapper[AaaPolicies]),
)
@@ -506,7 +504,6 @@ class AsyncPolicies(AsyncAPIResource):
"secondary_dns_zone_validation_warning",
"sentinel_alert",
"stream_live_notifications",
- "traffic_anomalies_alert",
"tunnel_health_event",
"tunnel_update_event",
"universal_ssl_event_type",
@@ -636,7 +633,6 @@ class AsyncPolicies(AsyncAPIResource):
"secondary_dns_zone_validation_warning",
"sentinel_alert",
"stream_live_notifications",
- "traffic_anomalies_alert",
"tunnel_health_event",
"tunnel_update_event",
"universal_ssl_event_type",
@@ -815,7 +811,7 @@ class AsyncPolicies(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> PolicyGetResponse:
+ ) -> AaaPolicies:
"""
Get details for a single policy.
@@ -845,7 +841,7 @@ class AsyncPolicies(AsyncAPIResource):
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
- cast_to=cast(Type[PolicyGetResponse], ResultWrapper[PolicyGetResponse]),
+ cast_to=cast(Type[AaaPolicies], ResultWrapper[AaaPolicies]),
)
diff --git a/src/cloudflare/resources/audit_logs.py b/src/cloudflare/resources/audit_logs.py
new file mode 100644
index 000000000..95a2a6857
--- /dev/null
+++ b/src/cloudflare/resources/audit_logs.py
@@ -0,0 +1,256 @@
+# File generated from our OpenAPI spec by Stainless.
+
+from __future__ import annotations
+
+from typing import Union
+from datetime import datetime
+from typing_extensions import Literal
+
+import httpx
+
+from ..types import AuditLogListResponse, audit_log_list_params
+from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._utils import 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 ..pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
+from .._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
+
+__all__ = ["AuditLogs", "AsyncAuditLogs"]
+
+
+class AuditLogs(SyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> AuditLogsWithRawResponse:
+ return AuditLogsWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AuditLogsWithStreamingResponse:
+ return AuditLogsWithStreamingResponse(self)
+
+ def list(
+ self,
+ account_identifier: str,
+ *,
+ id: str | NotGiven = NOT_GIVEN,
+ action: audit_log_list_params.Action | NotGiven = NOT_GIVEN,
+ actor: audit_log_list_params.Actor | NotGiven = NOT_GIVEN,
+ before: Union[str, datetime] | NotGiven = NOT_GIVEN,
+ direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN,
+ export: bool | NotGiven = NOT_GIVEN,
+ hide_user_logs: bool | NotGiven = NOT_GIVEN,
+ page: float | NotGiven = NOT_GIVEN,
+ per_page: float | NotGiven = NOT_GIVEN,
+ since: Union[str, datetime] | NotGiven = NOT_GIVEN,
+ zone: audit_log_list_params.Zone | 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,
+ ) -> SyncV4PagePaginationArray[AuditLogListResponse]:
+ """Gets a list of audit logs for an account.
+
+ Can be filtered by who made the
+ change, on which zone, and the timeframe of the change.
+
+ Args:
+ account_identifier: Identifier
+
+ id: Finds a specific log by its ID.
+
+ before: Limits the returned results to logs older than the specified date. This can be a
+ date string `2019-04-30` or an absolute timestamp that conforms to RFC3339.
+
+ direction: Changes the direction of the chronological sorting.
+
+ export: Indicates that this request is an export of logs in CSV format.
+
+ hide_user_logs: Indicates whether or not to hide user level audit logs.
+
+ page: Defines which page of results to return.
+
+ per_page: Sets the number of results to return per page.
+
+ since: Limits the returned results to logs newer than the specified date. This can be a
+ date string `2019-04-30` or an absolute timestamp that conforms to RFC3339.
+
+ 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_identifier:
+ raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
+ return self._get_api_list(
+ f"/accounts/{account_identifier}/audit_logs",
+ page=SyncV4PagePaginationArray[AuditLogListResponse],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "id": id,
+ "action": action,
+ "actor": actor,
+ "before": before,
+ "direction": direction,
+ "export": export,
+ "hide_user_logs": hide_user_logs,
+ "page": page,
+ "per_page": per_page,
+ "since": since,
+ "zone": zone,
+ },
+ audit_log_list_params.AuditLogListParams,
+ ),
+ ),
+ model=AuditLogListResponse,
+ )
+
+
+class AsyncAuditLogs(AsyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> AsyncAuditLogsWithRawResponse:
+ return AsyncAuditLogsWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncAuditLogsWithStreamingResponse:
+ return AsyncAuditLogsWithStreamingResponse(self)
+
+ def list(
+ self,
+ account_identifier: str,
+ *,
+ id: str | NotGiven = NOT_GIVEN,
+ action: audit_log_list_params.Action | NotGiven = NOT_GIVEN,
+ actor: audit_log_list_params.Actor | NotGiven = NOT_GIVEN,
+ before: Union[str, datetime] | NotGiven = NOT_GIVEN,
+ direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN,
+ export: bool | NotGiven = NOT_GIVEN,
+ hide_user_logs: bool | NotGiven = NOT_GIVEN,
+ page: float | NotGiven = NOT_GIVEN,
+ per_page: float | NotGiven = NOT_GIVEN,
+ since: Union[str, datetime] | NotGiven = NOT_GIVEN,
+ zone: audit_log_list_params.Zone | 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,
+ ) -> AsyncPaginator[AuditLogListResponse, AsyncV4PagePaginationArray[AuditLogListResponse]]:
+ """Gets a list of audit logs for an account.
+
+ Can be filtered by who made the
+ change, on which zone, and the timeframe of the change.
+
+ Args:
+ account_identifier: Identifier
+
+ id: Finds a specific log by its ID.
+
+ before: Limits the returned results to logs older than the specified date. This can be a
+ date string `2019-04-30` or an absolute timestamp that conforms to RFC3339.
+
+ direction: Changes the direction of the chronological sorting.
+
+ export: Indicates that this request is an export of logs in CSV format.
+
+ hide_user_logs: Indicates whether or not to hide user level audit logs.
+
+ page: Defines which page of results to return.
+
+ per_page: Sets the number of results to return per page.
+
+ since: Limits the returned results to logs newer than the specified date. This can be a
+ date string `2019-04-30` or an absolute timestamp that conforms to RFC3339.
+
+ 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_identifier:
+ raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
+ return self._get_api_list(
+ f"/accounts/{account_identifier}/audit_logs",
+ page=AsyncV4PagePaginationArray[AuditLogListResponse],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "id": id,
+ "action": action,
+ "actor": actor,
+ "before": before,
+ "direction": direction,
+ "export": export,
+ "hide_user_logs": hide_user_logs,
+ "page": page,
+ "per_page": per_page,
+ "since": since,
+ "zone": zone,
+ },
+ audit_log_list_params.AuditLogListParams,
+ ),
+ ),
+ model=AuditLogListResponse,
+ )
+
+
+class AuditLogsWithRawResponse:
+ def __init__(self, audit_logs: AuditLogs) -> None:
+ self._audit_logs = audit_logs
+
+ self.list = to_raw_response_wrapper(
+ audit_logs.list,
+ )
+
+
+class AsyncAuditLogsWithRawResponse:
+ def __init__(self, audit_logs: AsyncAuditLogs) -> None:
+ self._audit_logs = audit_logs
+
+ self.list = async_to_raw_response_wrapper(
+ audit_logs.list,
+ )
+
+
+class AuditLogsWithStreamingResponse:
+ def __init__(self, audit_logs: AuditLogs) -> None:
+ self._audit_logs = audit_logs
+
+ self.list = to_streamed_response_wrapper(
+ audit_logs.list,
+ )
+
+
+class AsyncAuditLogsWithStreamingResponse:
+ def __init__(self, audit_logs: AsyncAuditLogs) -> None:
+ self._audit_logs = audit_logs
+
+ self.list = async_to_streamed_response_wrapper(
+ audit_logs.list,
+ )
diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py
index 7e8f624f1..ab606de81 100644
--- a/src/cloudflare/types/__init__.py
+++ b/src/cloudflare/types/__init__.py
@@ -53,6 +53,7 @@ from .stream_list_response import StreamListResponse as StreamListResponse
from .zone_create_response import ZoneCreateResponse as ZoneCreateResponse
from .zone_delete_response import ZoneDeleteResponse as ZoneDeleteResponse
from .account_update_params import AccountUpdateParams as AccountUpdateParams
+from .audit_log_list_params import AuditLogListParams as AuditLogListParams
from .calls_app_with_secret import CallsAppWithSecret as CallsAppWithSecret
from .origin_ca_certificate import OriginCACertificate as OriginCACertificate
from .pagerule_get_response import PageruleGetResponse as PageruleGetResponse
@@ -74,6 +75,7 @@ from .pagerule_update_params import PageruleUpdateParams as PageruleUpdateParams
from .rate_limit_edit_params import RateLimitEditParams as RateLimitEditParams
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
diff --git a/src/cloudflare/types/alerting/v3/__init__.py b/src/cloudflare/types/alerting/v3/__init__.py
index 864f58958..8d33feba0 100644
--- a/src/cloudflare/types/alerting/v3/__init__.py
+++ b/src/cloudflare/types/alerting/v3/__init__.py
@@ -2,12 +2,12 @@
from __future__ import annotations
+from .aaa_history import AaaHistory as AaaHistory
+from .aaa_policies import AaaPolicies as AaaPolicies
from .history_list_params import HistoryListParams as HistoryListParams
-from .policy_get_response import PolicyGetResponse as PolicyGetResponse
from .policy_create_params import PolicyCreateParams as PolicyCreateParams
from .policy_list_response import PolicyListResponse as PolicyListResponse
from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams
-from .history_list_response import HistoryListResponse as HistoryListResponse
from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse
from .policy_delete_response import PolicyDeleteResponse as PolicyDeleteResponse
from .policy_update_response import PolicyUpdateResponse as PolicyUpdateResponse
diff --git a/src/cloudflare/types/alerting/v3/history_list_response.py b/src/cloudflare/types/alerting/v3/aaa_history.py
similarity index 94%
rename from src/cloudflare/types/alerting/v3/history_list_response.py
rename to src/cloudflare/types/alerting/v3/aaa_history.py
index dd9c1d26f..ae07972ba 100644
--- a/src/cloudflare/types/alerting/v3/history_list_response.py
+++ b/src/cloudflare/types/alerting/v3/aaa_history.py
@@ -6,10 +6,10 @@ from typing_extensions import Literal
from ...._models import BaseModel
-__all__ = ["HistoryListResponse"]
+__all__ = ["AaaHistory"]
-class HistoryListResponse(BaseModel):
+class AaaHistory(BaseModel):
id: Optional[str] = None
"""UUID"""
diff --git a/src/cloudflare/types/alerting/v3/policy_get_response.py b/src/cloudflare/types/alerting/v3/aaa_policies.py
similarity index 97%
rename from src/cloudflare/types/alerting/v3/policy_get_response.py
rename to src/cloudflare/types/alerting/v3/aaa_policies.py
index 20c421a91..2e865f6f1 100644
--- a/src/cloudflare/types/alerting/v3/policy_get_response.py
+++ b/src/cloudflare/types/alerting/v3/aaa_policies.py
@@ -6,7 +6,7 @@ from typing_extensions import Literal
from ...._models import BaseModel
-__all__ = ["PolicyGetResponse", "Filters", "Mechanisms"]
+__all__ = ["AaaPolicies", "Filters", "Mechanisms"]
class Filters(BaseModel):
@@ -17,10 +17,7 @@ class Filters(BaseModel):
"""Used for configuring radar_notification"""
affected_components: Optional[List[str]] = None
- """Used for configuring incident_alert.
-
- A list of identifiers for each component to monitor.
- """
+ """Used for configuring incident_alert"""
affected_locations: Optional[List[str]] = None
"""Used for configuring radar_notification"""
@@ -145,7 +142,7 @@ class Mechanisms(BaseModel):
"""UUID"""
-class PolicyGetResponse(BaseModel):
+class AaaPolicies(BaseModel):
id: Optional[str] = None
"""The unique identifier of a notification policy"""
@@ -200,7 +197,6 @@ class PolicyGetResponse(BaseModel):
"secondary_dns_zone_validation_warning",
"sentinel_alert",
"stream_live_notifications",
- "traffic_anomalies_alert",
"tunnel_health_event",
"tunnel_update_event",
"universal_ssl_event_type",
diff --git a/src/cloudflare/types/alerting/v3/destinations/__init__.py b/src/cloudflare/types/alerting/v3/destinations/__init__.py
index e5eb6975d..e6c8be3d2 100644
--- a/src/cloudflare/types/alerting/v3/destinations/__init__.py
+++ b/src/cloudflare/types/alerting/v3/destinations/__init__.py
@@ -2,7 +2,8 @@
from __future__ import annotations
-from .webhook_get_response import WebhookGetResponse as WebhookGetResponse
+from .aaa_webhooks import AaaWebhooks as AaaWebhooks
+from .aaa_pagerduty import AaaPagerduty as AaaPagerduty
from .eligible_get_response import EligibleGetResponse as EligibleGetResponse
from .webhook_create_params import WebhookCreateParams as WebhookCreateParams
from .webhook_list_response import WebhookListResponse as WebhookListResponse
diff --git a/src/cloudflare/types/alerting/v3/destinations/aaa_pagerduty.py b/src/cloudflare/types/alerting/v3/destinations/aaa_pagerduty.py
new file mode 100644
index 000000000..0e4dc6dd8
--- /dev/null
+++ b/src/cloudflare/types/alerting/v3/destinations/aaa_pagerduty.py
@@ -0,0 +1,15 @@
+# File generated from our OpenAPI spec by Stainless.
+
+from typing import Optional
+
+from ....._models import BaseModel
+
+__all__ = ["AaaPagerduty"]
+
+
+class AaaPagerduty(BaseModel):
+ id: Optional[str] = None
+ """UUID"""
+
+ name: Optional[str] = None
+ """The name of the pagerduty service."""
diff --git a/src/cloudflare/types/alerting/v3/destinations/webhook_get_response.py b/src/cloudflare/types/alerting/v3/destinations/aaa_webhooks.py
similarity index 95%
rename from src/cloudflare/types/alerting/v3/destinations/webhook_get_response.py
rename to src/cloudflare/types/alerting/v3/destinations/aaa_webhooks.py
index 36a3d6a9e..d946d3ccd 100644
--- a/src/cloudflare/types/alerting/v3/destinations/webhook_get_response.py
+++ b/src/cloudflare/types/alerting/v3/destinations/aaa_webhooks.py
@@ -6,10 +6,10 @@ from typing_extensions import Literal
from ....._models import BaseModel
-__all__ = ["WebhookGetResponse"]
+__all__ = ["AaaWebhooks"]
-class WebhookGetResponse(BaseModel):
+class AaaWebhooks(BaseModel):
id: Optional[str] = None
"""The unique identifier of a webhook"""
diff --git a/src/cloudflare/types/alerting/v3/destinations/pagerduty_create_response.py b/src/cloudflare/types/alerting/v3/destinations/pagerduty_create_response.py
index 33c032724..7d057611e 100644
--- a/src/cloudflare/types/alerting/v3/destinations/pagerduty_create_response.py
+++ b/src/cloudflare/types/alerting/v3/destinations/pagerduty_create_response.py
@@ -9,4 +9,4 @@ __all__ = ["PagerdutyCreateResponse"]
class PagerdutyCreateResponse(BaseModel):
id: Optional[str] = None
- """token in form of UUID"""
+ """UUID"""
diff --git a/src/cloudflare/types/alerting/v3/destinations/pagerduty_get_response.py b/src/cloudflare/types/alerting/v3/destinations/pagerduty_get_response.py
index ca2aacc88..38b479178 100644
--- a/src/cloudflare/types/alerting/v3/destinations/pagerduty_get_response.py
+++ b/src/cloudflare/types/alerting/v3/destinations/pagerduty_get_response.py
@@ -1,18 +1,9 @@
# File generated from our OpenAPI spec by Stainless.
-from typing import List, Optional
+from typing import List
-from ....._models import BaseModel
+from .aaa_pagerduty import AaaPagerduty
-__all__ = ["PagerdutyGetResponse", "PagerdutyGetResponseItem"]
+__all__ = ["PagerdutyGetResponse"]
-
-class PagerdutyGetResponseItem(BaseModel):
- id: Optional[str] = None
- """UUID"""
-
- name: Optional[str] = None
- """The name of the pagerduty service."""
-
-
-PagerdutyGetResponse = List[PagerdutyGetResponseItem]
+PagerdutyGetResponse = List[AaaPagerduty]
diff --git a/src/cloudflare/types/alerting/v3/destinations/webhook_list_response.py b/src/cloudflare/types/alerting/v3/destinations/webhook_list_response.py
index 874aca6ee..dec65b851 100644
--- a/src/cloudflare/types/alerting/v3/destinations/webhook_list_response.py
+++ b/src/cloudflare/types/alerting/v3/destinations/webhook_list_response.py
@@ -1,52 +1,9 @@
# File generated from our OpenAPI spec by Stainless.
-from typing import List, Optional
-from datetime import datetime
-from typing_extensions import Literal
+from typing import List
-from ....._models import BaseModel
+from .aaa_webhooks import AaaWebhooks
-__all__ = ["WebhookListResponse", "WebhookListResponseItem"]
+__all__ = ["WebhookListResponse"]
-
-class WebhookListResponseItem(BaseModel):
- id: Optional[str] = None
- """The unique identifier of a webhook"""
-
- created_at: Optional[datetime] = None
- """Timestamp of when the webhook destination was created."""
-
- last_failure: Optional[datetime] = None
- """
- Timestamp of the last time an attempt to dispatch a notification to this webhook
- failed.
- """
-
- last_success: Optional[datetime] = None
- """
- Timestamp of the last time Cloudflare was able to successfully dispatch a
- notification using this webhook.
- """
-
- name: Optional[str] = None
- """The name of the webhook destination.
-
- This will be included in the request body when you receive a webhook
- notification.
- """
-
- secret: Optional[str] = None
- """
- Optional secret that will be passed in the `cf-webhook-auth` header when
- dispatching generic webhook notifications or formatted for supported
- destinations. Secrets are not returned in any API response body.
- """
-
- type: Optional[Literal["slack", "generic", "gchat"]] = None
- """Type of webhook endpoint."""
-
- url: Optional[str] = None
- """The POST endpoint to call when dispatching a notification."""
-
-
-WebhookListResponse = List[WebhookListResponseItem]
+WebhookListResponse = List[AaaWebhooks]
diff --git a/src/cloudflare/types/alerting/v3/policy_create_params.py b/src/cloudflare/types/alerting/v3/policy_create_params.py
index 5d67bd623..62a51457a 100644
--- a/src/cloudflare/types/alerting/v3/policy_create_params.py
+++ b/src/cloudflare/types/alerting/v3/policy_create_params.py
@@ -63,7 +63,6 @@ class PolicyCreateParams(TypedDict, total=False):
"secondary_dns_zone_validation_warning",
"sentinel_alert",
"stream_live_notifications",
- "traffic_anomalies_alert",
"tunnel_health_event",
"tunnel_update_event",
"universal_ssl_event_type",
@@ -113,10 +112,7 @@ class Filters(TypedDict, total=False):
"""Used for configuring radar_notification"""
affected_components: List[str]
- """Used for configuring incident_alert.
-
- A list of identifiers for each component to monitor.
- """
+ """Used for configuring incident_alert"""
affected_locations: List[str]
"""Used for configuring radar_notification"""
diff --git a/src/cloudflare/types/alerting/v3/policy_list_response.py b/src/cloudflare/types/alerting/v3/policy_list_response.py
index ea077ccc1..184ef5948 100644
--- a/src/cloudflare/types/alerting/v3/policy_list_response.py
+++ b/src/cloudflare/types/alerting/v3/policy_list_response.py
@@ -1,249 +1,9 @@
# File generated from our OpenAPI spec by Stainless.
-from typing import Dict, List, Union, Optional
-from datetime import datetime
-from typing_extensions import Literal
+from typing import List
-from ...._models import BaseModel
+from .aaa_policies import AaaPolicies
-__all__ = [
- "PolicyListResponse",
- "PolicyListResponseItem",
- "PolicyListResponseItemFilters",
- "PolicyListResponseItemMechanisms",
-]
+__all__ = ["PolicyListResponse"]
-
-class PolicyListResponseItemFilters(BaseModel):
- actions: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- affected_asns: Optional[List[str]] = None
- """Used for configuring radar_notification"""
-
- affected_components: Optional[List[str]] = None
- """Used for configuring incident_alert.
-
- A list of identifiers for each component to monitor.
- """
-
- affected_locations: Optional[List[str]] = None
- """Used for configuring radar_notification"""
-
- airport_code: Optional[List[str]] = None
- """Used for configuring maintenance_event_notification"""
-
- alert_trigger_preferences: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- alert_trigger_preferences_value: Optional[List[Literal["99.0", "98.0", "97.0"]]] = None
- """Used for configuring magic_tunnel_health_check_event"""
-
- enabled: Optional[List[str]] = None
- """Used for configuring load_balancing_pool_enablement_alert"""
-
- environment: Optional[List[str]] = None
- """Used for configuring pages_event_alert"""
-
- event: Optional[List[str]] = None
- """Used for configuring pages_event_alert"""
-
- event_source: Optional[List[str]] = None
- """Used for configuring load_balancing_health_alert"""
-
- event_type: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- group_by: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- health_check_id: Optional[List[str]] = None
- """Used for configuring health_check_status_notification"""
-
- incident_impact: Optional[
- List[
- Literal[
- "INCIDENT_IMPACT_NONE", "INCIDENT_IMPACT_MINOR", "INCIDENT_IMPACT_MAJOR", "INCIDENT_IMPACT_CRITICAL"
- ]
- ]
- ] = None
- """Used for configuring incident_alert"""
-
- input_id: Optional[List[str]] = None
- """Used for configuring stream_live_notifications"""
-
- limit: Optional[List[str]] = None
- """Used for configuring billing_usage_alert"""
-
- logo_tag: Optional[List[str]] = None
- """Used for configuring logo_match_alert"""
-
- megabits_per_second: Optional[List[str]] = None
- """Used for configuring advanced_ddos_attack_l4_alert"""
-
- new_health: Optional[List[str]] = None
- """Used for configuring load_balancing_health_alert"""
-
- new_status: Optional[List[str]] = None
- """Used for configuring tunnel_health_event"""
-
- packets_per_second: Optional[List[str]] = None
- """Used for configuring advanced_ddos_attack_l4_alert"""
-
- pool_id: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- product: Optional[List[str]] = None
- """Used for configuring billing_usage_alert"""
-
- project_id: Optional[List[str]] = None
- """Used for configuring pages_event_alert"""
-
- protocol: Optional[List[str]] = None
- """Used for configuring advanced_ddos_attack_l4_alert"""
-
- query_tag: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- requests_per_second: Optional[List[str]] = None
- """Used for configuring advanced_ddos_attack_l7_alert"""
-
- selectors: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- services: Optional[List[str]] = None
- """Used for configuring clickhouse_alert_fw_ent_anomaly"""
-
- slo: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- status: Optional[List[str]] = None
- """Used for configuring health_check_status_notification"""
-
- target_hostname: Optional[List[str]] = None
- """Used for configuring advanced_ddos_attack_l7_alert"""
-
- target_ip: Optional[List[str]] = None
- """Used for configuring advanced_ddos_attack_l4_alert"""
-
- target_zone_name: Optional[List[str]] = None
- """Used for configuring advanced_ddos_attack_l7_alert"""
-
- traffic_exclusions: Optional[List[Literal["security_events"]]] = None
- """Used for configuring traffic_anomalies_alert"""
-
- tunnel_id: Optional[List[str]] = None
- """Used for configuring tunnel_health_event"""
-
- tunnel_name: Optional[List[str]] = None
- """Used for configuring magic_tunnel_health_check_event"""
-
- where: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
- zones: Optional[List[str]] = None
- """Usage depends on specific alert type"""
-
-
-class PolicyListResponseItemMechanisms(BaseModel):
- id: Union[str, str, None] = None
- """UUID"""
-
-
-class PolicyListResponseItem(BaseModel):
- id: Optional[str] = None
- """The unique identifier of a notification policy"""
-
- alert_type: Optional[
- Literal[
- "access_custom_certificate_expiration_type",
- "advanced_ddos_attack_l4_alert",
- "advanced_ddos_attack_l7_alert",
- "advanced_http_alert_error",
- "bgp_hijack_notification",
- "billing_usage_alert",
- "block_notification_block_removed",
- "block_notification_new_block",
- "block_notification_review_rejected",
- "brand_protection_alert",
- "brand_protection_digest",
- "clickhouse_alert_fw_anomaly",
- "clickhouse_alert_fw_ent_anomaly",
- "custom_ssl_certificate_event_type",
- "dedicated_ssl_certificate_event_type",
- "dos_attack_l4",
- "dos_attack_l7",
- "expiring_service_token_alert",
- "failing_logpush_job_disabled_alert",
- "fbm_auto_advertisement",
- "fbm_dosd_attack",
- "fbm_volumetric_attack",
- "health_check_status_notification",
- "hostname_aop_custom_certificate_expiration_type",
- "http_alert_edge_error",
- "http_alert_origin_error",
- "incident_alert",
- "load_balancing_health_alert",
- "load_balancing_pool_enablement_alert",
- "logo_match_alert",
- "magic_tunnel_health_check_event",
- "maintenance_event_notification",
- "mtls_certificate_store_certificate_expiration_type",
- "pages_event_alert",
- "radar_notification",
- "real_origin_monitoring",
- "scriptmonitor_alert_new_code_change_detections",
- "scriptmonitor_alert_new_hosts",
- "scriptmonitor_alert_new_malicious_hosts",
- "scriptmonitor_alert_new_malicious_scripts",
- "scriptmonitor_alert_new_malicious_url",
- "scriptmonitor_alert_new_max_length_resource_url",
- "scriptmonitor_alert_new_resources",
- "secondary_dns_all_primaries_failing",
- "secondary_dns_primaries_failing",
- "secondary_dns_zone_successfully_updated",
- "secondary_dns_zone_validation_warning",
- "sentinel_alert",
- "stream_live_notifications",
- "traffic_anomalies_alert",
- "tunnel_health_event",
- "tunnel_update_event",
- "universal_ssl_event_type",
- "web_analytics_metrics_update",
- "zone_aop_custom_certificate_expiration_type",
- ]
- ] = None
- """Refers to which event will trigger a Notification dispatch.
-
- You can use the endpoint to get available alert types which then will give you a
- list of possible values.
- """
-
- created: Optional[datetime] = None
-
- description: Optional[str] = None
- """Optional description for the Notification policy."""
-
- enabled: Optional[bool] = None
- """Whether or not the Notification policy is enabled."""
-
- filters: Optional[PolicyListResponseItemFilters] = None
- """
- Optional filters that allow you to be alerted only on a subset of events for
- that alert type based on some criteria. This is only available for select alert
- types. See alert type documentation for more details.
- """
-
- mechanisms: Optional[Dict[str, List[PolicyListResponseItemMechanisms]]] = None
- """List of IDs that will be used when dispatching a notification.
-
- IDs for email type will be the email address.
- """
-
- modified: Optional[datetime] = None
-
- name: Optional[str] = None
- """Name of the policy."""
-
-
-PolicyListResponse = List[PolicyListResponseItem]
+PolicyListResponse = List[AaaPolicies]
diff --git a/src/cloudflare/types/alerting/v3/policy_update_params.py b/src/cloudflare/types/alerting/v3/policy_update_params.py
index b26a6fa02..f628760ae 100644
--- a/src/cloudflare/types/alerting/v3/policy_update_params.py
+++ b/src/cloudflare/types/alerting/v3/policy_update_params.py
@@ -62,7 +62,6 @@ class PolicyUpdateParams(TypedDict, total=False):
"secondary_dns_zone_validation_warning",
"sentinel_alert",
"stream_live_notifications",
- "traffic_anomalies_alert",
"tunnel_health_event",
"tunnel_update_event",
"universal_ssl_event_type",
@@ -106,10 +105,7 @@ class Filters(TypedDict, total=False):
"""Used for configuring radar_notification"""
affected_components: List[str]
- """Used for configuring incident_alert.
-
- A list of identifiers for each component to monitor.
- """
+ """Used for configuring incident_alert"""
affected_locations: List[str]
"""Used for configuring radar_notification"""
diff --git a/src/cloudflare/types/audit_log_list_params.py b/src/cloudflare/types/audit_log_list_params.py
new file mode 100644
index 000000000..1b40cf1bd
--- /dev/null
+++ b/src/cloudflare/types/audit_log_list_params.py
@@ -0,0 +1,72 @@
+# File generated from our OpenAPI spec by Stainless.
+
+from __future__ import annotations
+
+from typing import Union
+from datetime import datetime
+from typing_extensions import Literal, Annotated, TypedDict
+
+from .._utils import PropertyInfo
+
+__all__ = ["AuditLogListParams", "Action", "Actor", "Zone"]
+
+
+class AuditLogListParams(TypedDict, total=False):
+ id: str
+ """Finds a specific log by its ID."""
+
+ action: Action
+
+ actor: Actor
+
+ before: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
+ """Limits the returned results to logs older than the specified date.
+
+ This can be a date string `2019-04-30` or an absolute timestamp that conforms to
+ RFC3339.
+ """
+
+ direction: Literal["desc", "asc"]
+ """Changes the direction of the chronological sorting."""
+
+ export: bool
+ """Indicates that this request is an export of logs in CSV format."""
+
+ hide_user_logs: bool
+ """Indicates whether or not to hide user level audit logs."""
+
+ page: float
+ """Defines which page of results to return."""
+
+ per_page: float
+ """Sets the number of results to return per page."""
+
+ since: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
+ """Limits the returned results to logs newer than the specified date.
+
+ This can be a date string `2019-04-30` or an absolute timestamp that conforms to
+ RFC3339.
+ """
+
+ zone: Zone
+
+
+class Action(TypedDict, total=False):
+ type: str
+ """Filters by the action type."""
+
+
+class Actor(TypedDict, total=False):
+ email: str
+ """Filters by the email address of the actor that made the change."""
+
+ ip: str
+ """
+ Filters by the IP address of the request that made the change by specific IP
+ address or valid CIDR Range.
+ """
+
+
+class Zone(TypedDict, total=False):
+ name: str
+ """Filters by the name of the zone associated to the change."""
diff --git a/src/cloudflare/types/audit_log_list_response.py b/src/cloudflare/types/audit_log_list_response.py
new file mode 100644
index 000000000..df04022ce
--- /dev/null
+++ b/src/cloudflare/types/audit_log_list_response.py
@@ -0,0 +1,80 @@
+# File generated from our OpenAPI spec by Stainless.
+
+from typing import Optional
+from datetime import datetime
+from typing_extensions import Literal
+
+from pydantic import Field as FieldInfo
+
+from .._models import BaseModel
+
+__all__ = ["AuditLogListResponse", "Action", "Actor", "Owner", "Resource"]
+
+
+class Action(BaseModel):
+ result: Optional[bool] = None
+ """A boolean that indicates if the action attempted was successful."""
+
+ type: Optional[str] = None
+ """A short string that describes the action that was performed."""
+
+
+class Actor(BaseModel):
+ id: Optional[str] = None
+ """The ID of the actor that performed the action.
+
+ If a user performed the action, this will be their User ID.
+ """
+
+ email: Optional[str] = None
+ """The email of the user that performed the action."""
+
+ ip: Optional[str] = None
+ """The IP address of the request that performed the action."""
+
+ type: Optional[Literal["user", "admin", "Cloudflare"]] = None
+ """The type of actor, whether a User, Cloudflare Admin, or an Automated System."""
+
+
+class Owner(BaseModel):
+ id: Optional[str] = None
+ """Identifier"""
+
+
+class Resource(BaseModel):
+ id: Optional[str] = None
+ """An identifier for the resource that was affected by the action."""
+
+ type: Optional[str] = None
+ """A short string that describes the resource that was affected by the action."""
+
+
+class AuditLogListResponse(BaseModel):
+ id: Optional[str] = None
+ """A string that uniquely identifies the audit log."""
+
+ action: Optional[Action] = None
+
+ actor: Optional[Actor] = None
+
+ interface: Optional[str] = None
+ """The source of the event."""
+
+ metadata: Optional[object] = None
+ """An object which can lend more context to the action being logged.
+
+ This is a flexible value and varies between different actions.
+ """
+
+ new_value: Optional[str] = FieldInfo(alias="newValue", default=None)
+ """The new value of the resource that was modified."""
+
+ old_value: Optional[str] = FieldInfo(alias="oldValue", default=None)
+ """The value of the resource before it was modified."""
+
+ owner: Optional[Owner] = None
+
+ resource: Optional[Resource] = None
+
+ when: Optional[datetime] = None
+ """A UTC RFC3339 timestamp that specifies when the action being logged occured."""
diff --git a/tests/api_resources/alerting/v3/destinations/test_webhooks.py b/tests/api_resources/alerting/v3/destinations/test_webhooks.py
index e42e20c99..bf2dfea6d 100644
--- a/tests/api_resources/alerting/v3/destinations/test_webhooks.py
+++ b/tests/api_resources/alerting/v3/destinations/test_webhooks.py
@@ -10,7 +10,7 @@ import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.types.alerting.v3.destinations import (
- WebhookGetResponse,
+ AaaWebhooks,
WebhookListResponse,
WebhookCreateResponse,
WebhookDeleteResponse,
@@ -259,7 +259,7 @@ class TestWebhooks:
"b115d5ec-15c6-41ee-8b76-92c449b5227b",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(WebhookGetResponse, webhook, path=["response"])
+ assert_matches_type(AaaWebhooks, webhook, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -272,7 +272,7 @@ class TestWebhooks:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
webhook = response.parse()
- assert_matches_type(WebhookGetResponse, webhook, path=["response"])
+ assert_matches_type(AaaWebhooks, webhook, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -285,7 +285,7 @@ class TestWebhooks:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
webhook = response.parse()
- assert_matches_type(WebhookGetResponse, webhook, path=["response"])
+ assert_matches_type(AaaWebhooks, webhook, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -544,7 +544,7 @@ class TestAsyncWebhooks:
"b115d5ec-15c6-41ee-8b76-92c449b5227b",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(WebhookGetResponse, webhook, path=["response"])
+ assert_matches_type(AaaWebhooks, webhook, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -557,7 +557,7 @@ class TestAsyncWebhooks:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
webhook = await response.parse()
- assert_matches_type(WebhookGetResponse, webhook, path=["response"])
+ assert_matches_type(AaaWebhooks, webhook, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -570,7 +570,7 @@ class TestAsyncWebhooks:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
webhook = await response.parse()
- assert_matches_type(WebhookGetResponse, webhook, path=["response"])
+ assert_matches_type(AaaWebhooks, webhook, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/alerting/v3/test_histories.py b/tests/api_resources/alerting/v3/test_histories.py
index ef3ea0d02..34f5f07e0 100644
--- a/tests/api_resources/alerting/v3/test_histories.py
+++ b/tests/api_resources/alerting/v3/test_histories.py
@@ -11,7 +11,7 @@ from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare._utils import parse_datetime
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
-from cloudflare.types.alerting.v3 import HistoryListResponse
+from cloudflare.types.alerting.v3 import AaaHistory
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -25,7 +25,7 @@ class TestHistories:
history = client.alerting.v3.histories.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(SyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
+ assert_matches_type(SyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -37,7 +37,7 @@ class TestHistories:
per_page=5,
since=parse_datetime("2022-05-19T20:29:58.679897Z"),
)
- assert_matches_type(SyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
+ assert_matches_type(SyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -49,7 +49,7 @@ class TestHistories:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
history = response.parse()
- assert_matches_type(SyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
+ assert_matches_type(SyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -61,7 +61,7 @@ class TestHistories:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
history = response.parse()
- assert_matches_type(SyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
+ assert_matches_type(SyncV4PagePaginationArray[AaaHistory], history, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -83,7 +83,7 @@ class TestAsyncHistories:
history = await async_client.alerting.v3.histories.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(AsyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
+ assert_matches_type(AsyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -95,7 +95,7 @@ class TestAsyncHistories:
per_page=5,
since=parse_datetime("2022-05-19T20:29:58.679897Z"),
)
- assert_matches_type(AsyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
+ assert_matches_type(AsyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -107,7 +107,7 @@ class TestAsyncHistories:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
history = await response.parse()
- assert_matches_type(AsyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
+ assert_matches_type(AsyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -119,7 +119,7 @@ class TestAsyncHistories:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
history = await response.parse()
- assert_matches_type(AsyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
+ assert_matches_type(AsyncV4PagePaginationArray[AaaHistory], history, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/alerting/v3/test_policies.py b/tests/api_resources/alerting/v3/test_policies.py
index bd7f0cf2d..0ae10d7f2 100644
--- a/tests/api_resources/alerting/v3/test_policies.py
+++ b/tests/api_resources/alerting/v3/test_policies.py
@@ -10,7 +10,7 @@ import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.types.alerting.v3 import (
- PolicyGetResponse,
+ AaaPolicies,
PolicyListResponse,
PolicyCreateResponse,
PolicyDeleteResponse,
@@ -369,7 +369,7 @@ class TestPolicies:
"0da2b59e-f118-439d-8097-bdfb215203c9",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(PolicyGetResponse, policy, path=["response"])
+ assert_matches_type(AaaPolicies, policy, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -382,7 +382,7 @@ class TestPolicies:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = response.parse()
- assert_matches_type(PolicyGetResponse, policy, path=["response"])
+ assert_matches_type(AaaPolicies, policy, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -395,7 +395,7 @@ class TestPolicies:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = response.parse()
- assert_matches_type(PolicyGetResponse, policy, path=["response"])
+ assert_matches_type(AaaPolicies, policy, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -764,7 +764,7 @@ class TestAsyncPolicies:
"0da2b59e-f118-439d-8097-bdfb215203c9",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(PolicyGetResponse, policy, path=["response"])
+ assert_matches_type(AaaPolicies, policy, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -777,7 +777,7 @@ class TestAsyncPolicies:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = await response.parse()
- assert_matches_type(PolicyGetResponse, policy, path=["response"])
+ assert_matches_type(AaaPolicies, policy, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -790,7 +790,7 @@ class TestAsyncPolicies:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = await response.parse()
- assert_matches_type(PolicyGetResponse, policy, path=["response"])
+ assert_matches_type(AaaPolicies, policy, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/test_audit_logs.py b/tests/api_resources/test_audit_logs.py
new file mode 100644
index 000000000..a204006f8
--- /dev/null
+++ b/tests/api_resources/test_audit_logs.py
@@ -0,0 +1,152 @@
+# File generated from our OpenAPI spec by Stainless.
+
+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 AuditLogListResponse
+from cloudflare._utils import parse_datetime
+from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestAuditLogs:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_list(self, client: Cloudflare) -> None:
+ audit_log = client.audit_logs.list(
+ "023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(SyncV4PagePaginationArray[AuditLogListResponse], audit_log, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_list_with_all_params(self, client: Cloudflare) -> None:
+ audit_log = client.audit_logs.list(
+ "023e105f4ecef8ad9ca31a8372d0c353",
+ id="f174be97-19b1-40d6-954d-70cd5fbd52db",
+ action={"type": "add"},
+ actor={
+ "ip": "17.168.228.63",
+ "email": "alice@example.com",
+ },
+ before=parse_datetime("2019-04-30T01:12:20Z"),
+ direction="desc",
+ export=True,
+ hide_user_logs=True,
+ page=50,
+ per_page=25,
+ since=parse_datetime("2019-04-30T01:12:20Z"),
+ zone={"name": "example.com"},
+ )
+ assert_matches_type(SyncV4PagePaginationArray[AuditLogListResponse], audit_log, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_list(self, client: Cloudflare) -> None:
+ response = client.audit_logs.with_raw_response.list(
+ "023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ audit_log = response.parse()
+ assert_matches_type(SyncV4PagePaginationArray[AuditLogListResponse], audit_log, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_list(self, client: Cloudflare) -> None:
+ with client.audit_logs.with_streaming_response.list(
+ "023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ audit_log = response.parse()
+ assert_matches_type(SyncV4PagePaginationArray[AuditLogListResponse], audit_log, 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_identifier` but received ''"):
+ client.audit_logs.with_raw_response.list(
+ "",
+ )
+
+
+class TestAsyncAuditLogs:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
+ audit_log = await async_client.audit_logs.list(
+ "023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(AsyncV4PagePaginationArray[AuditLogListResponse], audit_log, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ audit_log = await async_client.audit_logs.list(
+ "023e105f4ecef8ad9ca31a8372d0c353",
+ id="f174be97-19b1-40d6-954d-70cd5fbd52db",
+ action={"type": "add"},
+ actor={
+ "ip": "17.168.228.63",
+ "email": "alice@example.com",
+ },
+ before=parse_datetime("2019-04-30T01:12:20Z"),
+ direction="desc",
+ export=True,
+ hide_user_logs=True,
+ page=50,
+ per_page=25,
+ since=parse_datetime("2019-04-30T01:12:20Z"),
+ zone={"name": "example.com"},
+ )
+ assert_matches_type(AsyncV4PagePaginationArray[AuditLogListResponse], audit_log, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.audit_logs.with_raw_response.list(
+ "023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ audit_log = await response.parse()
+ assert_matches_type(AsyncV4PagePaginationArray[AuditLogListResponse], audit_log, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.audit_logs.with_streaming_response.list(
+ "023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ audit_log = await response.parse()
+ assert_matches_type(AsyncV4PagePaginationArray[AuditLogListResponse], audit_log, 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_identifier` but received ''"):
+ await async_client.audit_logs.with_raw_response.list(
+ "",
+ )