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

Large diffs are not rendered by default.

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

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.EmailTransportApi;
import com.datadog.api.client.v2.model.TransportWebhookLog;
import com.datadog.api.client.v2.model.TransportWebhookLogAttributes;
import com.datadog.api.client.v2.model.TransportWebhookLogEmail;
import com.datadog.api.client.v2.model.TransportWebhookLogIpAttribute;
import com.datadog.api.client.v2.model.TransportWebhookLogMessage;
import com.datadog.api.client.v2.model.TransportWebhookLogMessageAuth;
import com.datadog.api.client.v2.model.TransportWebhookLogMessageCustomArgs;
import com.datadog.api.client.v2.model.TransportWebhookLogMessageId;
import com.datadog.api.client.v2.model.TransportWebhookLogMessageResponse;
import com.datadog.api.client.v2.model.TransportWebhookLogMessageTimestamp;
import com.datadog.api.client.v2.model.TransportWebhookLogNetwork;
import com.datadog.api.client.v2.model.TransportWebhookLogNetworkIp;
import com.datadog.api.client.v2.model.TransportWebhookLogOrgMetadata;
import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.List;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.createEmailTransportWebhookIntake", true);
EmailTransportApi apiInstance = new EmailTransportApi(defaultClient);

List<TransportWebhookLog> body =
Collections.singletonList(
new TransportWebhookLog()
.attributes(
new TransportWebhookLogAttributes()
.category(Collections.singletonList("transactional"))
.email(
new TransportWebhookLogEmail()
.address("user@example.com")
.domain("example.com")
.subject("[Monitor Alert] CPU usage is high")
.type(Collections.singletonList("transactional")))
.emailId("abc123-def456")
.emailTypeDisplayName("Monitor Alert")
.message(
new TransportWebhookLogMessage()
.auth(
new TransportWebhookLogMessageAuth()
.deliveredWithTls("TLSv1.2"))
.customArgs(
new TransportWebhookLogMessageCustomArgs()
.emailId("abc123-def456")
.emailTypeDisplayName("Monitor Alert")
.orgUuid("8dee7c38-00cb-11ea-a77b-8b5a08d3b091")
.queueTime("2024-01-15T10:29:00Z")
.subject("[Monitor Alert] CPU usage is high"))
.id(
new TransportWebhookLogMessageId()
.messageId("<message-id@example.com>")
.smtpId("<abc123@mail.example.com>")
.transportEventId("evt_abc123"))
.name("delivered")
.response(
new TransportWebhookLogMessageResponse()
.enhancedSmtpCode("2.0.0")
.reason("250 2.0.0 OK")
.smtpCode("250"))
.senderIp("192.168.1.1")
.timestamp(
new TransportWebhookLogMessageTimestamp()
.eventTimestamp(1705312200.0)
.lifetime(3.2)
.queueTime(1.5)
.scheduledTime(1705312190.0)))
.network(
new TransportWebhookLogNetwork()
.ip(
new TransportWebhookLogNetworkIp()
.attributes(
Collections.singletonList(
new TransportWebhookLogIpAttribute()
.ip("192.168.1.1")
.source(Collections.singletonList("sendgrid"))))
.list(Collections.singletonList("192.168.1.1"))))
.org(1234L)
.orgMetadata(new TransportWebhookLogOrgMetadata())
.orgUuid("8dee7c38-00cb-11ea-a77b-8b5a08d3b091")
.queueTime("2024-01-15T10:29:00Z")
.subject("[Monitor Alert] CPU usage is high")
.useragent("Mozilla/5.0"))
.date(OffsetDateTime.parse("2024-01-15T10:30:00Z"))
.logId("AQAAAZPHnBT0TwJAdgAAAABBWlBIblVlNEFBQ0dFMmVkYTFDSnRR")
.source("sendgrid")
.status("info")
.tags(Collections.singletonList("env:production")));

try {
apiInstance.createEmailTransportWebhookIntake(body);
} catch (ApiException e) {
System.err.println(
"Exception when calling EmailTransportApi#createEmailTransportWebhookIntake");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
1 change: 1 addition & 0 deletions src/main/java/com/datadog/api/client/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ public class ApiClient {
put("v2.triggerDeploymentGatesEvaluation", false);
put("v2.updateDeploymentGate", false);
put("v2.updateDeploymentRule", false);
put("v2.createEmailTransportWebhookIntake", false);
put("v2.createHamrOrgConnection", false);
put("v2.getHamrOrgConnection", false);
put("v2.createGlobalIncidentHandle", false);
Expand Down
199 changes: 199 additions & 0 deletions src/main/java/com/datadog/api/client/v2/api/EmailTransportApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
package com.datadog.api.client.v2.api;

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.ApiResponse;
import com.datadog.api.client.Pair;
import com.datadog.api.client.v2.model.TransportWebhookLog;
import jakarta.ws.rs.client.Invocation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
public class EmailTransportApi {
private ApiClient apiClient;

public EmailTransportApi() {
this(ApiClient.getDefaultApiClient());
}

public EmailTransportApi(ApiClient apiClient) {
this.apiClient = apiClient;
}

/**
* Get the API client.
*
* @return API client
*/
public ApiClient getApiClient() {
return apiClient;
}

/**
* Set the API client.
*
* @param apiClient an instance of API client
*/
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}

/**
* Ingest email transport webhook events.
*
* <p>See {@link #createEmailTransportWebhookIntakeWithHttpInfo}.
*
* @param body (required)
* @throws ApiException if fails to make API call
*/
public void createEmailTransportWebhookIntake(List<TransportWebhookLog> body)
throws ApiException {
createEmailTransportWebhookIntakeWithHttpInfo(body);
}

/**
* Ingest email transport webhook events.
*
* <p>See {@link #createEmailTransportWebhookIntakeWithHttpInfoAsync}.
*
* @param body (required)
* @return CompletableFuture
*/
public CompletableFuture<Void> createEmailTransportWebhookIntakeAsync(
List<TransportWebhookLog> body) {
return createEmailTransportWebhookIntakeWithHttpInfoAsync(body)
.thenApply(
response -> {
return response.getData();
});
}

/**
* 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.
*
* @param body (required)
* @return ApiResponse&lt;Void&gt;
* @throws ApiException if fails to make API call
* @http.response.details
* <table border="1">
* <caption>Response details</caption>
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 204 </td><td> No Content </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
* </table>
*/
public ApiResponse<Void> createEmailTransportWebhookIntakeWithHttpInfo(
List<TransportWebhookLog> body) throws ApiException {
// Check if unstable operation is enabled
String operationId = "createEmailTransportWebhookIntake";
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
} else {
throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId));
}
Object localVarPostBody = body;

// verify the required parameter 'body' is set
if (body == null) {
throw new ApiException(
400,
"Missing the required parameter 'body' when calling createEmailTransportWebhookIntake");
}
// create path and map variables
String localVarPath = "/api/v2/email/transport/webhook_intake";

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder =
apiClient.createBuilder(
"v2.EmailTransportApi.createEmailTransportWebhookIntake",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"*/*"},
new String[] {"apiKeyAuth", "appKeyAuth"});
return apiClient.invokeAPI(
"POST",
builder,
localVarHeaderParams,
new String[] {"application/json"},
localVarPostBody,
new HashMap<String, Object>(),
false,
null);
}

/**
* Ingest email transport webhook events.
*
* <p>See {@link #createEmailTransportWebhookIntakeWithHttpInfo}.
*
* @param body (required)
* @return CompletableFuture&lt;ApiResponse&lt;Void&gt;&gt;
*/
public CompletableFuture<ApiResponse<Void>> createEmailTransportWebhookIntakeWithHttpInfoAsync(
List<TransportWebhookLog> body) {
// Check if unstable operation is enabled
String operationId = "createEmailTransportWebhookIntake";
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
} else {
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
result.completeExceptionally(
new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)));
return result;
}
Object localVarPostBody = body;

// verify the required parameter 'body' is set
if (body == null) {
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
result.completeExceptionally(
new ApiException(
400,
"Missing the required parameter 'body' when calling"
+ " createEmailTransportWebhookIntake"));
return result;
}
// create path and map variables
String localVarPath = "/api/v2/email/transport/webhook_intake";

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder;
try {
builder =
apiClient.createBuilder(
"v2.EmailTransportApi.createEmailTransportWebhookIntake",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"*/*"},
new String[] {"apiKeyAuth", "appKeyAuth"});
} catch (ApiException ex) {
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
result.completeExceptionally(ex);
return result;
}
return apiClient.invokeAPIAsync(
"POST",
builder,
localVarHeaderParams,
new String[] {"application/json"},
localVarPostBody,
new HashMap<String, Object>(),
false,
null);
}
}
Loading
Loading