diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 1c6fb51af7e..7e2afafa7f3 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -68667,6 +68667,68 @@ components: type: string x-enum-varnames: - MANAGED_ORGS + MatchingSignalAttributes: + description: Attributes of a matching security signal. + properties: + event_tracker_id: + description: The tracker ID linking the signal back to the originating event. Distinct from `id`, which identifies the matching signal itself. + example: AAAAAWgOAX0mtsWfeQAAAABzX1RyYWNrZXJfMTIzNDU2Nzg5MA + type: string + severity: + description: The severity of the signal. + example: high + type: string + title: + description: The title of the signal. + example: Unusual login activity detected + type: string + trigger_time_ms: + description: The Unix timestamp (in milliseconds) at which the signal was triggered. + example: 1707393746000 + format: int64 + type: integer + required: + - event_tracker_id + - severity + - title + - trigger_time_ms + type: object + MatchingSignalData: + description: A security signal that matches the queried event. + properties: + attributes: + $ref: "#/components/schemas/MatchingSignalAttributes" + id: + description: The ID of the matching signal. + example: AAAAAWgN8Xwgr1vKDQAAAABBV2dOOFh3ZzZobm1mWXJFYTR0OA + type: string + type: + $ref: "#/components/schemas/MatchingSignalType" + required: + - id + - type + - attributes + type: object + MatchingSignalType: + default: matching_signal + description: The type of the resource. The value should always be `matching_signal`. + enum: + - matching_signal + example: matching_signal + type: string + x-enum-varnames: + - MATCHING_SIGNAL + MatchingSignalsResponse: + description: Response containing the list of security signals matching an event. + properties: + data: + description: Array of matching signals. + items: + $ref: "#/components/schemas/MatchingSignalData" + type: array + required: + - data + type: object MaxSessionDurationType: description: Data type of a maximum session duration update. enum: [max_session_duration] @@ -209832,6 +209894,63 @@ paths: x-unstable: |- **Note**: This endpoint is in Preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/security_monitoring/events/{event_id}/matching_signals: + get: + description: Returns the list of security signals that match a given event on the given track. + operationId: GetMatchingSignals + parameters: + - description: The ID of the event to find matching signals for. + in: path + name: event_id + required: true + schema: + type: string + - description: The product track that the event belongs to. + in: query + name: track + required: true + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + event_tracker_id: AAAAAWgN8Xwgr1vKDQAAAABBV2dOOFh3ZzZobm1mWXJFYTR0OA + severity: high + title: Unusual login activity detected + trigger_time_ms: 1707393746000 + id: AAAAAWgN8Xwgr1vKDQAAAABBV2dOOFh3ZzZobm1mWXJFYTR0OA + type: matching_signal + schema: + $ref: "#/components/schemas/MatchingSignalsResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_signals_read + summary: Get signals matching an event + tags: ["Security Monitoring"] + x-permission: + operator: OR + permissions: + - security_monitoring_signals_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/security_monitoring/rules: get: description: List rules. diff --git a/examples/v2/security-monitoring/GetMatchingSignals.java b/examples/v2/security-monitoring/GetMatchingSignals.java new file mode 100644 index 00000000000..0cfcaeb8fc6 --- /dev/null +++ b/examples/v2/security-monitoring/GetMatchingSignals.java @@ -0,0 +1,25 @@ +// Get signals matching an event returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; +import com.datadog.api.client.v2.model.MatchingSignalsResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.getMatchingSignals", true); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + try { + MatchingSignalsResponse result = apiInstance.getMatchingSignals("event_id", "track"); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling SecurityMonitoringApi#getMatchingSignals"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 785bac2aa47..9249a340e76 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -1057,6 +1057,7 @@ public class ApiClient { put("v2.getFinding", false); put("v2.getHistoricalJob", false); put("v2.getIndicatorOfCompromise", false); + put("v2.getMatchingSignals", false); put("v2.getRuleVersionHistory", false); put("v2.getSecretsRules", false); put("v2.getSecurityFindingsAutomationDefaultInboxRule", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java b/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java index 18c7e065966..cc41252a35d 100644 --- a/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java @@ -70,6 +70,7 @@ import com.datadog.api.client.v2.model.ListSecurityFindingsResponse; import com.datadog.api.client.v2.model.ListVulnerabilitiesResponse; import com.datadog.api.client.v2.model.ListVulnerableAssetsResponse; +import com.datadog.api.client.v2.model.MatchingSignalsResponse; import com.datadog.api.client.v2.model.MuteFindingsRequest; import com.datadog.api.client.v2.model.MuteFindingsResponse; import com.datadog.api.client.v2.model.MuteRuleCreateRequest; @@ -12393,6 +12394,186 @@ public SecurityMonitoringSignalSuggestedActionsResponse getInvestigationLogQueri new GenericType() {}); } + /** + * Get signals matching an event. + * + *

See {@link #getMatchingSignalsWithHttpInfo}. + * + * @param eventId The ID of the event to find matching signals for. (required) + * @param track The product track that the event belongs to. (required) + * @return MatchingSignalsResponse + * @throws ApiException if fails to make API call + */ + public MatchingSignalsResponse getMatchingSignals(String eventId, String track) + throws ApiException { + return getMatchingSignalsWithHttpInfo(eventId, track).getData(); + } + + /** + * Get signals matching an event. + * + *

See {@link #getMatchingSignalsWithHttpInfoAsync}. + * + * @param eventId The ID of the event to find matching signals for. (required) + * @param track The product track that the event belongs to. (required) + * @return CompletableFuture<MatchingSignalsResponse> + */ + public CompletableFuture getMatchingSignalsAsync( + String eventId, String track) { + return getMatchingSignalsWithHttpInfoAsync(eventId, track) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Returns the list of security signals that match a given event on the given track. + * + * @param eventId The ID of the event to find matching signals for. (required) + * @param track The product track that the event belongs to. (required) + * @return ApiResponse<MatchingSignalsResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Not Authorized -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getMatchingSignalsWithHttpInfo( + String eventId, String track) throws ApiException { + // Check if unstable operation is enabled + String operationId = "getMatchingSignals"; + 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 = null; + + // verify the required parameter 'eventId' is set + if (eventId == null) { + throw new ApiException( + 400, "Missing the required parameter 'eventId' when calling getMatchingSignals"); + } + + // verify the required parameter 'track' is set + if (track == null) { + throw new ApiException( + 400, "Missing the required parameter 'track' when calling getMatchingSignals"); + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/events/{event_id}/matching_signals" + .replaceAll("\\{" + "event_id" + "\\}", apiClient.escapeString(eventId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "track", track)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getMatchingSignals", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get signals matching an event. + * + *

See {@link #getMatchingSignalsWithHttpInfo}. + * + * @param eventId The ID of the event to find matching signals for. (required) + * @param track The product track that the event belongs to. (required) + * @return CompletableFuture<ApiResponse<MatchingSignalsResponse>> + */ + public CompletableFuture> + getMatchingSignalsWithHttpInfoAsync(String eventId, String track) { + // Check if unstable operation is enabled + String operationId = "getMatchingSignals"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'eventId' is set + if (eventId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'eventId' when calling getMatchingSignals")); + return result; + } + + // verify the required parameter 'track' is set + if (track == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'track' when calling getMatchingSignals")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/events/{event_id}/matching_signals" + .replaceAll("\\{" + "event_id" + "\\}", apiClient.escapeString(eventId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "track", track)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getMatchingSignals", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** Manage optional parameters to getResourceEvaluationFilters. */ public static class GetResourceEvaluationFiltersOptionalParameters { private String cloudProvider; diff --git a/src/main/java/com/datadog/api/client/v2/model/MatchingSignalAttributes.java b/src/main/java/com/datadog/api/client/v2/model/MatchingSignalAttributes.java new file mode 100644 index 00000000000..3e231164943 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MatchingSignalAttributes.java @@ -0,0 +1,230 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes of a matching security signal. */ +@JsonPropertyOrder({ + MatchingSignalAttributes.JSON_PROPERTY_EVENT_TRACKER_ID, + MatchingSignalAttributes.JSON_PROPERTY_SEVERITY, + MatchingSignalAttributes.JSON_PROPERTY_TITLE, + MatchingSignalAttributes.JSON_PROPERTY_TRIGGER_TIME_MS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MatchingSignalAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_EVENT_TRACKER_ID = "event_tracker_id"; + private String eventTrackerId; + + public static final String JSON_PROPERTY_SEVERITY = "severity"; + private String severity; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + public static final String JSON_PROPERTY_TRIGGER_TIME_MS = "trigger_time_ms"; + private Long triggerTimeMs; + + public MatchingSignalAttributes() {} + + @JsonCreator + public MatchingSignalAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_EVENT_TRACKER_ID) String eventTrackerId, + @JsonProperty(required = true, value = JSON_PROPERTY_SEVERITY) String severity, + @JsonProperty(required = true, value = JSON_PROPERTY_TITLE) String title, + @JsonProperty(required = true, value = JSON_PROPERTY_TRIGGER_TIME_MS) Long triggerTimeMs) { + this.eventTrackerId = eventTrackerId; + this.severity = severity; + this.title = title; + this.triggerTimeMs = triggerTimeMs; + } + + public MatchingSignalAttributes eventTrackerId(String eventTrackerId) { + this.eventTrackerId = eventTrackerId; + return this; + } + + /** + * The tracker ID linking the signal back to the originating event. Distinct from id, + * which identifies the matching signal itself. + * + * @return eventTrackerId + */ + @JsonProperty(JSON_PROPERTY_EVENT_TRACKER_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getEventTrackerId() { + return eventTrackerId; + } + + public void setEventTrackerId(String eventTrackerId) { + this.eventTrackerId = eventTrackerId; + } + + public MatchingSignalAttributes severity(String severity) { + this.severity = severity; + return this; + } + + /** + * The severity of the signal. + * + * @return severity + */ + @JsonProperty(JSON_PROPERTY_SEVERITY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public MatchingSignalAttributes title(String title) { + this.title = title; + return this; + } + + /** + * The title of the signal. + * + * @return title + */ + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public MatchingSignalAttributes triggerTimeMs(Long triggerTimeMs) { + this.triggerTimeMs = triggerTimeMs; + return this; + } + + /** + * The Unix timestamp (in milliseconds) at which the signal was triggered. + * + * @return triggerTimeMs + */ + @JsonProperty(JSON_PROPERTY_TRIGGER_TIME_MS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getTriggerTimeMs() { + return triggerTimeMs; + } + + public void setTriggerTimeMs(Long triggerTimeMs) { + this.triggerTimeMs = triggerTimeMs; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return MatchingSignalAttributes + */ + @JsonAnySetter + public MatchingSignalAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this MatchingSignalAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MatchingSignalAttributes matchingSignalAttributes = (MatchingSignalAttributes) o; + return Objects.equals(this.eventTrackerId, matchingSignalAttributes.eventTrackerId) + && Objects.equals(this.severity, matchingSignalAttributes.severity) + && Objects.equals(this.title, matchingSignalAttributes.title) + && Objects.equals(this.triggerTimeMs, matchingSignalAttributes.triggerTimeMs) + && Objects.equals(this.additionalProperties, matchingSignalAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(eventTrackerId, severity, title, triggerTimeMs, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MatchingSignalAttributes {\n"); + sb.append(" eventTrackerId: ").append(toIndentedString(eventTrackerId)).append("\n"); + sb.append(" severity: ").append(toIndentedString(severity)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" triggerTimeMs: ").append(toIndentedString(triggerTimeMs)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MatchingSignalData.java b/src/main/java/com/datadog/api/client/v2/model/MatchingSignalData.java new file mode 100644 index 00000000000..c96fea69032 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MatchingSignalData.java @@ -0,0 +1,212 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A security signal that matches the queried event. */ +@JsonPropertyOrder({ + MatchingSignalData.JSON_PROPERTY_ATTRIBUTES, + MatchingSignalData.JSON_PROPERTY_ID, + MatchingSignalData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MatchingSignalData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private MatchingSignalAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private MatchingSignalType type = MatchingSignalType.MATCHING_SIGNAL; + + public MatchingSignalData() {} + + @JsonCreator + public MatchingSignalData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + MatchingSignalAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) MatchingSignalType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public MatchingSignalData attributes(MatchingSignalAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a matching security signal. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public MatchingSignalAttributes getAttributes() { + return attributes; + } + + public void setAttributes(MatchingSignalAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public MatchingSignalData id(String id) { + this.id = id; + return this; + } + + /** + * The ID of the matching signal. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public MatchingSignalData type(MatchingSignalType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type of the resource. The value should always be matching_signal. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public MatchingSignalType getType() { + return type; + } + + public void setType(MatchingSignalType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return MatchingSignalData + */ + @JsonAnySetter + public MatchingSignalData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this MatchingSignalData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MatchingSignalData matchingSignalData = (MatchingSignalData) o; + return Objects.equals(this.attributes, matchingSignalData.attributes) + && Objects.equals(this.id, matchingSignalData.id) + && Objects.equals(this.type, matchingSignalData.type) + && Objects.equals(this.additionalProperties, matchingSignalData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MatchingSignalData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MatchingSignalType.java b/src/main/java/com/datadog/api/client/v2/model/MatchingSignalType.java new file mode 100644 index 00000000000..fd80e89cd4b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MatchingSignalType.java @@ -0,0 +1,55 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The type of the resource. The value should always be matching_signal. */ +@JsonSerialize(using = MatchingSignalType.MatchingSignalTypeSerializer.class) +public class MatchingSignalType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("matching_signal")); + + public static final MatchingSignalType MATCHING_SIGNAL = + new MatchingSignalType("matching_signal"); + + MatchingSignalType(String value) { + super(value, allowedValues); + } + + public static class MatchingSignalTypeSerializer extends StdSerializer { + public MatchingSignalTypeSerializer(Class t) { + super(t); + } + + public MatchingSignalTypeSerializer() { + this(null); + } + + @Override + public void serialize(MatchingSignalType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static MatchingSignalType fromValue(String value) { + return new MatchingSignalType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MatchingSignalsResponse.java b/src/main/java/com/datadog/api/client/v2/model/MatchingSignalsResponse.java new file mode 100644 index 00000000000..7fda8c083cb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MatchingSignalsResponse.java @@ -0,0 +1,162 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Response containing the list of security signals matching an event. */ +@JsonPropertyOrder({MatchingSignalsResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MatchingSignalsResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = new ArrayList<>(); + + public MatchingSignalsResponse() {} + + @JsonCreator + public MatchingSignalsResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) List data) { + this.data = data; + for (MatchingSignalData item : data) { + this.unparsed |= item.unparsed; + } + } + + public MatchingSignalsResponse data(List data) { + this.data = data; + for (MatchingSignalData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public MatchingSignalsResponse addDataItem(MatchingSignalData dataItem) { + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * Array of matching signals. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + if (data != null) { + for (MatchingSignalData item : data) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return MatchingSignalsResponse + */ + @JsonAnySetter + public MatchingSignalsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this MatchingSignalsResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MatchingSignalsResponse matchingSignalsResponse = (MatchingSignalsResponse) o; + return Objects.equals(this.data, matchingSignalsResponse.data) + && Objects.equals(this.additionalProperties, matchingSignalsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MatchingSignalsResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature b/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature index a72d703edd3..bb21f193462 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature @@ -2532,6 +2532,33 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-siem + Scenario: Get signals matching an event returns "Bad Request" response + Given operation "GetMatchingSignals" enabled + And new "GetMatchingSignals" request + And request contains "event_id" parameter from "REPLACE.ME" + And request contains "track" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-siem + Scenario: Get signals matching an event returns "Not Found" response + Given operation "GetMatchingSignals" enabled + And new "GetMatchingSignals" request + And request contains "event_id" parameter from "REPLACE.ME" + And request contains "track" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/cloud-siem + Scenario: Get signals matching an event returns "OK" response + Given operation "GetMatchingSignals" enabled + And new "GetMatchingSignals" request + And request contains "event_id" parameter from "REPLACE.ME" + And request contains "track" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-siem Scenario: Get suggested actions for a signal returns "Not Found" response Given new "GetSuggestedActionsMatchingSignal" request diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index edb05f3dace..e1a1c161b90 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -8708,6 +8708,12 @@ "type": "safe" } }, + "GetMatchingSignals": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListSecurityMonitoringRules": { "tag": "Security Monitoring", "undo": {