Skip to content
Open
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
381 changes: 381 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/datadog_api_client.v2.api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ datadog\_api\_client.v2.api.downtimes\_api module
:members:
:show-inheritance:

datadog\_api\_client.v2.api.email\_transport\_api module
--------------------------------------------------------

.. automodule:: datadog_api_client.v2.api.email_transport_api
:members:
:show-inheritance:

datadog\_api\_client.v2.api.entity\_risk\_scores\_api module
------------------------------------------------------------

Expand Down
91 changes: 91 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35018,6 +35018,97 @@ datadog\_api\_client.v2.model.token\_type module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log module
------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_attributes module
------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_attributes
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_email module
-------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_email
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_ip\_attribute module
---------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_ip_attribute
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_message module
---------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_message
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_message\_auth module
---------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_message_auth
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_message\_custom\_args module
-----------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_message_custom_args
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_message\_id module
-------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_message_id
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_message\_response module
-------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_message_response
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_message\_timestamp module
--------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_message_timestamp
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_network module
---------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_network
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_network\_ip module
-------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_network_ip
:members:
:show-inheritance:

datadog\_api\_client.v2.model.transport\_webhook\_log\_org\_metadata module
---------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.transport_webhook_log_org_metadata
:members:
:show-inheritance:

datadog\_api\_client.v2.model.trigger module
--------------------------------------------

Expand Down
105 changes: 105 additions & 0 deletions examples/v2/email-transport/CreateEmailTransportWebhookIntake.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
"""
Ingest email transport webhook events returns "No Content" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.email_transport_api import EmailTransportApi
from datadog_api_client.v2.model.transport_webhook_log import TransportWebhookLog
from datadog_api_client.v2.model.transport_webhook_log_attributes import TransportWebhookLogAttributes
from datadog_api_client.v2.model.transport_webhook_log_email import TransportWebhookLogEmail
from datadog_api_client.v2.model.transport_webhook_log_ip_attribute import TransportWebhookLogIpAttribute
from datadog_api_client.v2.model.transport_webhook_log_message import TransportWebhookLogMessage
from datadog_api_client.v2.model.transport_webhook_log_message_auth import TransportWebhookLogMessageAuth
from datadog_api_client.v2.model.transport_webhook_log_message_custom_args import TransportWebhookLogMessageCustomArgs
from datadog_api_client.v2.model.transport_webhook_log_message_id import TransportWebhookLogMessageId
from datadog_api_client.v2.model.transport_webhook_log_message_response import TransportWebhookLogMessageResponse
from datadog_api_client.v2.model.transport_webhook_log_message_timestamp import TransportWebhookLogMessageTimestamp
from datadog_api_client.v2.model.transport_webhook_log_network import TransportWebhookLogNetwork
from datadog_api_client.v2.model.transport_webhook_log_network_ip import TransportWebhookLogNetworkIp
from datadog_api_client.v2.model.transport_webhook_log_org_metadata import TransportWebhookLogOrgMetadata
from datetime import datetime
from dateutil.tz import tzutc

body = [
TransportWebhookLog(
attributes=TransportWebhookLogAttributes(
category=[
"transactional",
],
email=TransportWebhookLogEmail(
address="user@example.com",
domain="example.com",
subject="[Monitor Alert] CPU usage is high",
type=[
"transactional",
],
),
email_id="abc123-def456",
email_type_display_name="Monitor Alert",
message=TransportWebhookLogMessage(
auth=TransportWebhookLogMessageAuth(
delivered_with_tls="TLSv1.2",
),
custom_args=TransportWebhookLogMessageCustomArgs(
email_id="abc123-def456",
email_type_display_name="Monitor Alert",
org_uuid="8dee7c38-00cb-11ea-a77b-8b5a08d3b091",
queue_time="2024-01-15T10:29:00Z",
subject="[Monitor Alert] CPU usage is high",
),
id=TransportWebhookLogMessageId(
message_id="<message-id@example.com>",
smtp_id="<abc123@mail.example.com>",
transport_event_id="evt_abc123",
),
name="delivered",
response=TransportWebhookLogMessageResponse(
enhanced_smtp_code="2.0.0",
reason="250 2.0.0 OK",
smtp_code="250",
),
sender_ip="192.168.1.1",
timestamp=TransportWebhookLogMessageTimestamp(
event_timestamp=1705312200.0,
lifetime=3.2,
queue_time=1.5,
scheduled_time=1705312190.0,
),
),
network=TransportWebhookLogNetwork(
ip=TransportWebhookLogNetworkIp(
attributes=[
TransportWebhookLogIpAttribute(
ip="192.168.1.1",
source=[
"sendgrid",
],
),
],
list=[
"192.168.1.1",
],
),
),
org=1234,
org_metadata=TransportWebhookLogOrgMetadata(),
org_uuid="8dee7c38-00cb-11ea-a77b-8b5a08d3b091",
queue_time="2024-01-15T10:29:00Z",
subject="[Monitor Alert] CPU usage is high",
useragent="Mozilla/5.0",
),
date=datetime(2024, 1, 15, 10, 30, tzinfo=tzutc()),
log_id="AQAAAZPHnBT0TwJAdgAAAABBWlBIblVlNEFBQ0dFMmVkYTFDSnRR",
source="sendgrid",
status="info",
tags=[
"env:production",
],
),
]

configuration = Configuration()
configuration.unstable_operations["create_email_transport_webhook_intake"] = True
with ApiClient(configuration) as api_client:
api_instance = EmailTransportApi(api_client)
api_instance.create_email_transport_webhook_intake(body=body)
1 change: 1 addition & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def __init__(
"v2.trigger_deployment_gates_evaluation": False,
"v2.update_deployment_gate": False,
"v2.update_deployment_rule": False,
"v2.create_email_transport_webhook_intake": False,
"v2.create_hamr_org_connection": False,
"v2.get_hamr_org_connection": False,
"v2.create_global_incident_handle": False,
Expand Down
60 changes: 60 additions & 0 deletions src/datadog_api_client/v2/api/email_transport_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Any, Dict, List

from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
from datadog_api_client.configuration import Configuration
from datadog_api_client.v2.model.transport_webhook_log import TransportWebhookLog


class EmailTransportApi:
"""
Endpoints for receiving email transport webhook events for audit trail processing.
"""

def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient(Configuration())
self.api_client = api_client

self._create_email_transport_webhook_intake_endpoint = _Endpoint(
settings={
"response_type": None,
"auth": ["apiKeyAuth", "appKeyAuth"],
"endpoint_path": "/api/v2/email/transport/webhook_intake",
"operation_id": "create_email_transport_webhook_intake",
"http_method": "POST",
"version": "v2",
},
params_map={
"body": {
"required": True,
"openapi_types": ([TransportWebhookLog],),
"location": "body",
"collection_format": "multi",
},
},
headers_map={"accept": ["*/*"], "content_type": ["application/json"]},
api_client=api_client,
)

def create_email_transport_webhook_intake(
self,
body: List[TransportWebhookLog],
) -> None:
"""Ingest email transport webhook events.

Receives a batch of email transport webhook log events and emits an audit trail entry
for each event with a final delivery status (delivered, dropped, or bounced).
Only authorized organizations can submit events.

:type body: [TransportWebhookLog]
:rtype: None
"""
kwargs: Dict[str, Any] = {}
kwargs["body"] = body

return self._create_email_transport_webhook_intake_endpoint.call_with_http_info(**kwargs)
2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from datadog_api_client.v2.api.deployment_gates_api import DeploymentGatesApi
from datadog_api_client.v2.api.domain_allowlist_api import DomainAllowlistApi
from datadog_api_client.v2.api.downtimes_api import DowntimesApi
from datadog_api_client.v2.api.email_transport_api import EmailTransportApi
from datadog_api_client.v2.api.entity_risk_scores_api import EntityRiskScoresApi
from datadog_api_client.v2.api.error_tracking_api import ErrorTrackingApi
from datadog_api_client.v2.api.events_api import EventsApi
Expand Down Expand Up @@ -149,6 +150,7 @@
"DeploymentGatesApi",
"DomainAllowlistApi",
"DowntimesApi",
"EmailTransportApi",
"EntityRiskScoresApi",
"ErrorTrackingApi",
"EventsApi",
Expand Down
80 changes: 80 additions & 0 deletions src/datadog_api_client/v2/model/transport_webhook_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import List, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
datetime,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.transport_webhook_log_attributes import TransportWebhookLogAttributes


class TransportWebhookLog(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.transport_webhook_log_attributes import TransportWebhookLogAttributes

return {
"attributes": (TransportWebhookLogAttributes,),
"date": (datetime,),
"log_id": (str,),
"source": (str,),
"status": (str,),
"tags": ([str],),
}

attribute_map = {
"attributes": "attributes",
"date": "date",
"log_id": "log_id",
"source": "source",
"status": "status",
"tags": "tags",
}

def __init__(
self_,
attributes: TransportWebhookLogAttributes,
date: datetime,
log_id: str,
source: str,
status: str,
tags: List[str],
**kwargs,
):
"""
A single email transport webhook log event.

:param attributes: Top-level attributes for the webhook log event, including delivery status, recipient details, and provider metadata.
:type attributes: TransportWebhookLogAttributes

:param date: The ISO 8601 timestamp of the event.
:type date: datetime

:param log_id: The unique log event identifier.
:type log_id: str

:param source: The email transport provider.
:type source: str

:param status: The log status level.
:type status: str

:param tags: A list of tags associated with the event.
:type tags: [str]
"""
super().__init__(kwargs)

self_.attributes = attributes
self_.date = date
self_.log_id = log_id
self_.source = source
self_.status = status
self_.tags = tags
Loading
Loading