From cd6aa14367d365c3a9908238c2dcac1bb3e6bbf1 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 12 Feb 2025 17:32:18 +0000 Subject: [PATCH] Regenerate client from commit 15c0cf6c of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 111 ++++++++ .../GetRuleVersionHistory.java | 25 ++ .../GetRuleVersionHistory_2467565841.java | 28 +++ .../com/datadog/api/client/ApiClient.java | 1 + .../client/v2/api/SecurityMonitoringApi.java | 237 ++++++++++++++++++ .../v2/model/GetRuleVersionHistoryData.java | 197 +++++++++++++++ .../model/GetRuleVersionHistoryDataType.java | 57 +++++ .../model/GetRuleVersionHistoryResponse.java | 137 ++++++++++ .../client/v2/model/RuleVersionHistory.java | 169 +++++++++++++ .../client/v2/model/RuleVersionUpdate.java | 195 ++++++++++++++ .../v2/model/RuleVersionUpdateType.java | 57 +++++ .../api/client/v2/model/RuleVersions.java | 176 +++++++++++++ ...version_history_returns_OK_response.freeze | 1 + ...e_version_history_returns_OK_response.json | 79 ++++++ .../client/v2/api/security_monitoring.feature | 37 +++ .../com/datadog/api/client/v2/api/undo.json | 6 + 17 files changed, 1517 insertions(+), 4 deletions(-) create mode 100644 examples/v2/security-monitoring/GetRuleVersionHistory.java create mode 100644 examples/v2/security-monitoring/GetRuleVersionHistory_2467565841.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryDataType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RuleVersionHistory.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RuleVersionUpdate.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RuleVersionUpdateType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RuleVersions.java create mode 100644 src/test/resources/cassettes/features/v2/Get_rule_version_history_returns_OK_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Get_rule_version_history_returns_OK_response.json diff --git a/.apigentools-info b/.apigentools-info index 6df66b943c6..1ac6fd8d28b 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-02-12 15:28:27.810725", - "spec_repo_commit": "b56263de" + "regenerated": "2025-02-12 17:30:28.793670", + "spec_repo_commit": "15c0cf6c" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-02-12 15:28:27.826384", - "spec_repo_commit": "b56263de" + "regenerated": "2025-02-12 17:30:28.808707", + "spec_repo_commit": "15c0cf6c" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index b0adf622a07..492b8c9c9b2 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -12683,6 +12683,30 @@ components: $ref: '#/components/schemas/GetInterfacesData' type: array type: object + GetRuleVersionHistoryData: + description: Data for the rule version history. + properties: + attributes: + $ref: '#/components/schemas/RuleVersionHistory' + id: + description: ID of the rule. + type: string + type: + $ref: '#/components/schemas/GetRuleVersionHistoryDataType' + type: object + GetRuleVersionHistoryDataType: + description: Type of data. + enum: + - GetRuleVersionHistoryResponse + type: string + x-enum-varnames: + - GETRULEVERSIONHISTORYRESPONSE + GetRuleVersionHistoryResponse: + description: Response for getting the rule version history. + properties: + data: + $ref: '#/components/schemas/GetRuleVersionHistoryData' + type: object GetSBOMResponse: description: The expected response schema when getting an SBOM. properties: @@ -23254,6 +23278,57 @@ components: example: John Doe type: string type: object + RuleVersionHistory: + description: Response object containing the version history of a rule. + properties: + count: + description: The number of rule versions. + format: int32 + maximum: 2147483647 + type: integer + data: + additionalProperties: + $ref: '#/components/schemas/RuleVersions' + description: A rule version with a list of updates. + description: The `RuleVersionHistory` `data`. + type: object + type: object + RuleVersionUpdate: + description: A change in a rule version. + properties: + change: + description: The new value of the field. + example: cloud_provider:aws + type: string + field: + description: The field that was changed. + example: Tags + type: string + type: + $ref: '#/components/schemas/RuleVersionUpdateType' + type: object + RuleVersionUpdateType: + description: The type of change. + enum: + - create + - update + - delete + type: string + x-enum-varnames: + - CREATE + - UPDATE + - DELETE + RuleVersions: + description: A rule version with a list of updates. + properties: + changes: + description: A list of changes. + items: + $ref: '#/components/schemas/RuleVersionUpdate' + type: array + rule: + $ref: '#/components/schemas/SecurityMonitoringRuleResponse' + type: object RumMetricCompute: description: The compute rule to compute the rum-based metric. properties: @@ -45723,6 +45798,42 @@ paths: operator: OR permissions: - security_monitoring_rules_write + /api/v2/security_monitoring/rules/{rule_id}/version_history: + get: + description: Get a rule's version history. + operationId: GetRuleVersionHistory + parameters: + - $ref: '#/components/parameters/SecurityMonitoringRuleID' + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GetRuleVersionHistoryResponse' + 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_rules_read + summary: Get a rule's version history + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_rules_read + x-unstable: '**Note**: This endpoint is in beta and may be subject to changes.' /api/v2/security_monitoring/signals: get: description: 'The list endpoint returns security signals that match a search diff --git a/examples/v2/security-monitoring/GetRuleVersionHistory.java b/examples/v2/security-monitoring/GetRuleVersionHistory.java new file mode 100644 index 00000000000..1042818c9af --- /dev/null +++ b/examples/v2/security-monitoring/GetRuleVersionHistory.java @@ -0,0 +1,25 @@ +// Get a rule's version history 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.GetRuleVersionHistoryResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.getRuleVersionHistory", true); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + try { + GetRuleVersionHistoryResponse result = apiInstance.getRuleVersionHistory("rule_id"); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling SecurityMonitoringApi#getRuleVersionHistory"); + 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/examples/v2/security-monitoring/GetRuleVersionHistory_2467565841.java b/examples/v2/security-monitoring/GetRuleVersionHistory_2467565841.java new file mode 100644 index 00000000000..fac2048c4e5 --- /dev/null +++ b/examples/v2/security-monitoring/GetRuleVersionHistory_2467565841.java @@ -0,0 +1,28 @@ +// Get rule version history 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.GetRuleVersionHistoryResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.getRuleVersionHistory", true); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "security_rule" in the system + String SECURITY_RULE_ID = System.getenv("SECURITY_RULE_ID"); + + try { + GetRuleVersionHistoryResponse result = apiInstance.getRuleVersionHistory(SECURITY_RULE_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling SecurityMonitoringApi#getRuleVersionHistory"); + 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 b37ee4f4722..adaf21149ac 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -421,6 +421,7 @@ public class ApiClient { put("v2.deleteHistoricalJob", false); put("v2.getFinding", false); put("v2.getHistoricalJob", false); + put("v2.getRuleVersionHistory", false); put("v2.listFindings", false); put("v2.listHistoricalJobs", false); put("v2.muteFindings", 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 f9bb931e684..781dde9d446 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 @@ -15,6 +15,7 @@ import com.datadog.api.client.v2.model.FindingStatus; import com.datadog.api.client.v2.model.FindingVulnerabilityType; import com.datadog.api.client.v2.model.GetFindingResponse; +import com.datadog.api.client.v2.model.GetRuleVersionHistoryResponse; import com.datadog.api.client.v2.model.GetSBOMResponse; import com.datadog.api.client.v2.model.HistoricalJobResponse; import com.datadog.api.client.v2.model.JobCreateResponse; @@ -3114,6 +3115,242 @@ public CompletableFuture> getHistoricalJobWit new GenericType() {}); } + /** Manage optional parameters to getRuleVersionHistory. */ + public static class GetRuleVersionHistoryOptionalParameters { + private Long pageSize; + private Long pageNumber; + + /** + * Set pageSize. + * + * @param pageSize Size for a given page. The maximum allowed value is 100. (optional, default + * to 10) + * @return GetRuleVersionHistoryOptionalParameters + */ + public GetRuleVersionHistoryOptionalParameters pageSize(Long pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * Set pageNumber. + * + * @param pageNumber Specific page number to return. (optional, default to 0) + * @return GetRuleVersionHistoryOptionalParameters + */ + public GetRuleVersionHistoryOptionalParameters pageNumber(Long pageNumber) { + this.pageNumber = pageNumber; + return this; + } + } + + /** + * Get a rule's version history. + * + *

See {@link #getRuleVersionHistoryWithHttpInfo}. + * + * @param ruleId The ID of the rule. (required) + * @return GetRuleVersionHistoryResponse + * @throws ApiException if fails to make API call + */ + public GetRuleVersionHistoryResponse getRuleVersionHistory(String ruleId) throws ApiException { + return getRuleVersionHistoryWithHttpInfo(ruleId, new GetRuleVersionHistoryOptionalParameters()) + .getData(); + } + + /** + * Get a rule's version history. + * + *

See {@link #getRuleVersionHistoryWithHttpInfoAsync}. + * + * @param ruleId The ID of the rule. (required) + * @return CompletableFuture<GetRuleVersionHistoryResponse> + */ + public CompletableFuture getRuleVersionHistoryAsync( + String ruleId) { + return getRuleVersionHistoryWithHttpInfoAsync( + ruleId, new GetRuleVersionHistoryOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get a rule's version history. + * + *

See {@link #getRuleVersionHistoryWithHttpInfo}. + * + * @param ruleId The ID of the rule. (required) + * @param parameters Optional parameters for the request. + * @return GetRuleVersionHistoryResponse + * @throws ApiException if fails to make API call + */ + public GetRuleVersionHistoryResponse getRuleVersionHistory( + String ruleId, GetRuleVersionHistoryOptionalParameters parameters) throws ApiException { + return getRuleVersionHistoryWithHttpInfo(ruleId, parameters).getData(); + } + + /** + * Get a rule's version history. + * + *

See {@link #getRuleVersionHistoryWithHttpInfoAsync}. + * + * @param ruleId The ID of the rule. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<GetRuleVersionHistoryResponse> + */ + public CompletableFuture getRuleVersionHistoryAsync( + String ruleId, GetRuleVersionHistoryOptionalParameters parameters) { + return getRuleVersionHistoryWithHttpInfoAsync(ruleId, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get a rule's version history. + * + * @param ruleId The ID of the rule. (required) + * @param parameters Optional parameters for the request. + * @return ApiResponse<GetRuleVersionHistoryResponse> + * @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 getRuleVersionHistoryWithHttpInfo( + String ruleId, GetRuleVersionHistoryOptionalParameters parameters) throws ApiException { + // Check if unstable operation is enabled + String operationId = "getRuleVersionHistory"; + 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 'ruleId' is set + if (ruleId == null) { + throw new ApiException( + 400, "Missing the required parameter 'ruleId' when calling getRuleVersionHistory"); + } + Long pageSize = parameters.pageSize; + Long pageNumber = parameters.pageNumber; + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/rules/{rule_id}/version_history" + .replaceAll("\\{" + "rule_id" + "\\}", apiClient.escapeString(ruleId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getRuleVersionHistory", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get a rule's version history. + * + *

See {@link #getRuleVersionHistoryWithHttpInfo}. + * + * @param ruleId The ID of the rule. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<GetRuleVersionHistoryResponse>> + */ + public CompletableFuture> + getRuleVersionHistoryWithHttpInfoAsync( + String ruleId, GetRuleVersionHistoryOptionalParameters parameters) { + // Check if unstable operation is enabled + String operationId = "getRuleVersionHistory"; + 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 'ruleId' is set + if (ruleId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'ruleId' when calling getRuleVersionHistory")); + return result; + } + Long pageSize = parameters.pageSize; + Long pageNumber = parameters.pageNumber; + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/rules/{rule_id}/version_history" + .replaceAll("\\{" + "rule_id" + "\\}", apiClient.escapeString(ruleId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getRuleVersionHistory", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } 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 getSBOM. */ public static class GetSBOMOptionalParameters { private String filterRepoDigest; diff --git a/src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryData.java b/src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryData.java new file mode 100644 index 00000000000..2137223fd28 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryData.java @@ -0,0 +1,197 @@ +/* + * 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.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; + +/** Data for the rule version history. */ +@JsonPropertyOrder({ + GetRuleVersionHistoryData.JSON_PROPERTY_ATTRIBUTES, + GetRuleVersionHistoryData.JSON_PROPERTY_ID, + GetRuleVersionHistoryData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class GetRuleVersionHistoryData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private RuleVersionHistory attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private GetRuleVersionHistoryDataType type; + + public GetRuleVersionHistoryData attributes(RuleVersionHistory attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Response object containing the version history of a rule. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RuleVersionHistory getAttributes() { + return attributes; + } + + public void setAttributes(RuleVersionHistory attributes) { + this.attributes = attributes; + } + + public GetRuleVersionHistoryData id(String id) { + this.id = id; + return this; + } + + /** + * ID of the rule. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public GetRuleVersionHistoryData type(GetRuleVersionHistoryDataType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of data. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public GetRuleVersionHistoryDataType getType() { + return type; + } + + public void setType(GetRuleVersionHistoryDataType 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 GetRuleVersionHistoryData + */ + @JsonAnySetter + public GetRuleVersionHistoryData 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 GetRuleVersionHistoryData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetRuleVersionHistoryData getRuleVersionHistoryData = (GetRuleVersionHistoryData) o; + return Objects.equals(this.attributes, getRuleVersionHistoryData.attributes) + && Objects.equals(this.id, getRuleVersionHistoryData.id) + && Objects.equals(this.type, getRuleVersionHistoryData.type) + && Objects.equals( + this.additionalProperties, getRuleVersionHistoryData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetRuleVersionHistoryData {\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/GetRuleVersionHistoryDataType.java b/src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryDataType.java new file mode 100644 index 00000000000..aa27344278a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryDataType.java @@ -0,0 +1,57 @@ +/* + * 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; + +/** Type of data. */ +@JsonSerialize(using = GetRuleVersionHistoryDataType.GetRuleVersionHistoryDataTypeSerializer.class) +public class GetRuleVersionHistoryDataType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("GetRuleVersionHistoryResponse")); + + public static final GetRuleVersionHistoryDataType GETRULEVERSIONHISTORYRESPONSE = + new GetRuleVersionHistoryDataType("GetRuleVersionHistoryResponse"); + + GetRuleVersionHistoryDataType(String value) { + super(value, allowedValues); + } + + public static class GetRuleVersionHistoryDataTypeSerializer + extends StdSerializer { + public GetRuleVersionHistoryDataTypeSerializer(Class t) { + super(t); + } + + public GetRuleVersionHistoryDataTypeSerializer() { + this(null); + } + + @Override + public void serialize( + GetRuleVersionHistoryDataType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static GetRuleVersionHistoryDataType fromValue(String value) { + return new GetRuleVersionHistoryDataType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryResponse.java b/src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryResponse.java new file mode 100644 index 00000000000..56d712a3cf5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GetRuleVersionHistoryResponse.java @@ -0,0 +1,137 @@ +/* + * 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.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; + +/** Response for getting the rule version history. */ +@JsonPropertyOrder({GetRuleVersionHistoryResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class GetRuleVersionHistoryResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private GetRuleVersionHistoryData data; + + public GetRuleVersionHistoryResponse data(GetRuleVersionHistoryData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data for the rule version history. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public GetRuleVersionHistoryData getData() { + return data; + } + + public void setData(GetRuleVersionHistoryData data) { + this.data = data; + } + + /** + * 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 GetRuleVersionHistoryResponse + */ + @JsonAnySetter + public GetRuleVersionHistoryResponse 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 GetRuleVersionHistoryResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetRuleVersionHistoryResponse getRuleVersionHistoryResponse = (GetRuleVersionHistoryResponse) o; + return Objects.equals(this.data, getRuleVersionHistoryResponse.data) + && Objects.equals( + this.additionalProperties, getRuleVersionHistoryResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetRuleVersionHistoryResponse {\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/main/java/com/datadog/api/client/v2/model/RuleVersionHistory.java b/src/main/java/com/datadog/api/client/v2/model/RuleVersionHistory.java new file mode 100644 index 00000000000..87f5955c18b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RuleVersionHistory.java @@ -0,0 +1,169 @@ +/* + * 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.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; + +/** Response object containing the version history of a rule. */ +@JsonPropertyOrder({RuleVersionHistory.JSON_PROPERTY_COUNT, RuleVersionHistory.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class RuleVersionHistory { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_COUNT = "count"; + private Integer count; + + public static final String JSON_PROPERTY_DATA = "data"; + private Map data = null; + + public RuleVersionHistory count(Integer count) { + this.count = count; + return this; + } + + /** + * The number of rule versions. maximum: 2147483647 + * + * @return count + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public RuleVersionHistory data(Map data) { + this.data = data; + return this; + } + + public RuleVersionHistory putDataItem(String key, RuleVersions dataItem) { + if (this.data == null) { + this.data = new HashMap<>(); + } + this.data.put(key, dataItem); + return this; + } + + /** + * The RuleVersionHistory data. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } + + /** + * 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 RuleVersionHistory + */ + @JsonAnySetter + public RuleVersionHistory 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 RuleVersionHistory object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RuleVersionHistory ruleVersionHistory = (RuleVersionHistory) o; + return Objects.equals(this.count, ruleVersionHistory.count) + && Objects.equals(this.data, ruleVersionHistory.data) + && Objects.equals(this.additionalProperties, ruleVersionHistory.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(count, data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RuleVersionHistory {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\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/main/java/com/datadog/api/client/v2/model/RuleVersionUpdate.java b/src/main/java/com/datadog/api/client/v2/model/RuleVersionUpdate.java new file mode 100644 index 00000000000..b435c669748 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RuleVersionUpdate.java @@ -0,0 +1,195 @@ +/* + * 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.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 change in a rule version. */ +@JsonPropertyOrder({ + RuleVersionUpdate.JSON_PROPERTY_CHANGE, + RuleVersionUpdate.JSON_PROPERTY_FIELD, + RuleVersionUpdate.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class RuleVersionUpdate { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CHANGE = "change"; + private String change; + + public static final String JSON_PROPERTY_FIELD = "field"; + private String field; + + public static final String JSON_PROPERTY_TYPE = "type"; + private RuleVersionUpdateType type; + + public RuleVersionUpdate change(String change) { + this.change = change; + return this; + } + + /** + * The new value of the field. + * + * @return change + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHANGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getChange() { + return change; + } + + public void setChange(String change) { + this.change = change; + } + + public RuleVersionUpdate field(String field) { + this.field = field; + return this; + } + + /** + * The field that was changed. + * + * @return field + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIELD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public RuleVersionUpdate type(RuleVersionUpdateType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type of change. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RuleVersionUpdateType getType() { + return type; + } + + public void setType(RuleVersionUpdateType 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 RuleVersionUpdate + */ + @JsonAnySetter + public RuleVersionUpdate 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 RuleVersionUpdate object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RuleVersionUpdate ruleVersionUpdate = (RuleVersionUpdate) o; + return Objects.equals(this.change, ruleVersionUpdate.change) + && Objects.equals(this.field, ruleVersionUpdate.field) + && Objects.equals(this.type, ruleVersionUpdate.type) + && Objects.equals(this.additionalProperties, ruleVersionUpdate.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(change, field, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RuleVersionUpdate {\n"); + sb.append(" change: ").append(toIndentedString(change)).append("\n"); + sb.append(" field: ").append(toIndentedString(field)).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/RuleVersionUpdateType.java b/src/main/java/com/datadog/api/client/v2/model/RuleVersionUpdateType.java new file mode 100644 index 00000000000..00fd1280204 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RuleVersionUpdateType.java @@ -0,0 +1,57 @@ +/* + * 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 change. */ +@JsonSerialize(using = RuleVersionUpdateType.RuleVersionUpdateTypeSerializer.class) +public class RuleVersionUpdateType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("create", "update", "delete")); + + public static final RuleVersionUpdateType CREATE = new RuleVersionUpdateType("create"); + public static final RuleVersionUpdateType UPDATE = new RuleVersionUpdateType("update"); + public static final RuleVersionUpdateType DELETE = new RuleVersionUpdateType("delete"); + + RuleVersionUpdateType(String value) { + super(value, allowedValues); + } + + public static class RuleVersionUpdateTypeSerializer extends StdSerializer { + public RuleVersionUpdateTypeSerializer(Class t) { + super(t); + } + + public RuleVersionUpdateTypeSerializer() { + this(null); + } + + @Override + public void serialize( + RuleVersionUpdateType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static RuleVersionUpdateType fromValue(String value) { + return new RuleVersionUpdateType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/RuleVersions.java b/src/main/java/com/datadog/api/client/v2/model/RuleVersions.java new file mode 100644 index 00000000000..b220bdd9700 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RuleVersions.java @@ -0,0 +1,176 @@ +/* + * 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.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; + +/** A rule version with a list of updates. */ +@JsonPropertyOrder({RuleVersions.JSON_PROPERTY_CHANGES, RuleVersions.JSON_PROPERTY_RULE}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class RuleVersions { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CHANGES = "changes"; + private List changes = null; + + public static final String JSON_PROPERTY_RULE = "rule"; + private SecurityMonitoringRuleResponse rule; + + public RuleVersions changes(List changes) { + this.changes = changes; + for (RuleVersionUpdate item : changes) { + this.unparsed |= item.unparsed; + } + return this; + } + + public RuleVersions addChangesItem(RuleVersionUpdate changesItem) { + if (this.changes == null) { + this.changes = new ArrayList<>(); + } + this.changes.add(changesItem); + this.unparsed |= changesItem.unparsed; + return this; + } + + /** + * A list of changes. + * + * @return changes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHANGES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getChanges() { + return changes; + } + + public void setChanges(List changes) { + this.changes = changes; + } + + public RuleVersions rule(SecurityMonitoringRuleResponse rule) { + this.rule = rule; + this.unparsed |= rule.unparsed; + return this; + } + + /** + * Create a new rule. + * + * @return rule + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RULE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public SecurityMonitoringRuleResponse getRule() { + return rule; + } + + public void setRule(SecurityMonitoringRuleResponse rule) { + this.rule = rule; + } + + /** + * 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 RuleVersions + */ + @JsonAnySetter + public RuleVersions 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 RuleVersions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RuleVersions ruleVersions = (RuleVersions) o; + return Objects.equals(this.changes, ruleVersions.changes) + && Objects.equals(this.rule, ruleVersions.rule) + && Objects.equals(this.additionalProperties, ruleVersions.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(changes, rule, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RuleVersions {\n"); + sb.append(" changes: ").append(toIndentedString(changes)).append("\n"); + sb.append(" rule: ").append(toIndentedString(rule)).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/cassettes/features/v2/Get_rule_version_history_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_rule_version_history_returns_OK_response.freeze new file mode 100644 index 00000000000..0ac7f76bc9b --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_rule_version_history_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-02-04T22:39:17.325Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_rule_version_history_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_rule_version_history_returns_OK_response.json new file mode 100644 index 00000000000..70e03e43c92 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_rule_version_history_returns_OK_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"cases\":[{\"condition\":\"a > 0\",\"name\":\"\",\"notifications\":[],\"status\":\"info\"}],\"filters\":[],\"isEnabled\":true,\"message\":\"Test rule\",\"name\":\"Test-Get_rule_version_history_returns_OK_response-1738708757\",\"options\":{\"evaluationWindow\":900,\"keepAlive\":3600,\"maxSignalDuration\":86400},\"queries\":[{\"aggregation\":\"count\",\"distinctFields\":[],\"groupByFields\":[],\"metrics\":[],\"query\":\"@test:true\"}],\"tags\":[],\"type\":\"log_detection\"}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security_monitoring/rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"name\":\"Test-Get_rule_version_history_returns_OK_response-1738708757\",\"createdAt\":1738708757817,\"isDefault\":false,\"isPartner\":false,\"isEnabled\":true,\"isBeta\":false,\"isDeleted\":false,\"isDeprecated\":false,\"queries\":[{\"query\":\"@test:true\",\"groupByFields\":[],\"hasOptionalGroupByFields\":false,\"distinctFields\":[],\"aggregation\":\"count\",\"name\":\"\"}],\"options\":{\"evaluationWindow\":900,\"detectionMethod\":\"threshold\",\"maxSignalDuration\":86400,\"keepAlive\":3600},\"cases\":[{\"name\":\"\",\"status\":\"info\",\"notifications\":[],\"condition\":\"a \\u003e 0\"}],\"message\":\"Test rule\",\"tags\":[],\"hasExtendedTitle\":false,\"type\":\"log_detection\",\"filters\":[],\"version\":1,\"id\":\"gvq-qqd-jc7\",\"blocking\":false,\"metadata\":{\"entities\":null,\"sources\":null},\"creator\":{\"handle\":\"\",\"name\":\"\"},\"updater\":{\"handle\":\"\",\"name\":\"\"}}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "828d57e6-57b4-424f-e84a-86d7f1db705f" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/security_monitoring/rules/gvq-qqd-jc7/version_history", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"gvq-qqd-jc7\",\"type\":\"GetRuleVersionHistoryResponse\",\"attributes\":{\"count\":1,\"data\":{\"1\":{\"rule\":{\"name\":\"Test-Get_rule_version_history_returns_OK_response-1738708757\",\"createdAt\":1738708757817,\"isDefault\":false,\"isPartner\":false,\"isEnabled\":true,\"isBeta\":false,\"isDeleted\":false,\"isDeprecated\":false,\"queries\":[{\"query\":\"@test:true\",\"groupByFields\":[],\"hasOptionalGroupByFields\":false,\"distinctFields\":[],\"aggregation\":\"count\",\"name\":\"\"}],\"options\":{\"evaluationWindow\":900,\"detectionMethod\":\"threshold\",\"maxSignalDuration\":86400,\"keepAlive\":3600},\"cases\":[{\"name\":\"\",\"status\":\"info\",\"notifications\":[],\"condition\":\"a \\u003e 0\"}],\"message\":\"Test rule\",\"tags\":[],\"hasExtendedTitle\":false,\"type\":\"log_detection\",\"filters\":[],\"version\":1,\"id\":\"gvq-qqd-jc7\",\"blocking\":false,\"metadata\":{\"entities\":null,\"sources\":null},\"creator\":{\"handle\":\"\",\"name\":\"\"},\"updater\":{\"handle\":\"\",\"name\":\"\"}},\"changes\":[]}}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "09be8bb5-92c9-1241-1f3b-4e3a4e3fb2d2" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security_monitoring/rules/gvq-qqd-jc7", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "cd1c7942-8cc1-a501-d7a7-dd3c38ee275f" + } +] \ No newline at end of file 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 ec4c3d3f39d..ac0898d23a9 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 @@ -599,6 +599,30 @@ Feature: Security Monitoring And the response "name" is equal to "{{ unique }}" And the response "id" has the same value as "security_rule.id" + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Get a rule's version history returns "Bad Request" response + Given operation "GetRuleVersionHistory" enabled + And new "GetRuleVersionHistory" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Get a rule's version history returns "Not Found" response + Given operation "GetRuleVersionHistory" enabled + And new "GetRuleVersionHistory" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Get a rule's version history returns "OK" response + Given operation "GetRuleVersionHistory" enabled + And new "GetRuleVersionHistory" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Get a security filter returns "Not Found" response Given new "GetSecurityFilter" request @@ -708,6 +732,19 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 Notification rule details. + @skip-go @skip-java @skip-ruby @team:DataDog/k9-cloud-security-platform + Scenario: Get rule version history returns "OK" response + Given operation "GetRuleVersionHistory" enabled + And new "GetRuleVersionHistory" request + And there is a valid "security_rule" in the system + And request contains "rule_id" parameter from "security_rule.id" + When the request is sent + Then the response status is 200 OK + And the response "data.id" has the same value as "security_rule.id" + And the response "data.type" is equal to "GetRuleVersionHistoryResponse" + And the response "data.attributes.count" is equal to 1 + And the response "data.attributes.data[1].rule.name" has the same value as "security_rule.name" + @team:DataDog/cloud-security-posture-management Scenario: Get the list of signal-based notification rules returns "The list of notification rules." response Given there is a valid "valid_signal_notification_rule" in the system 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 03717048ec6..21c8d4414bd 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 @@ -2362,6 +2362,12 @@ "type": "idempotent" } }, + "GetRuleVersionHistory": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListSecurityMonitoringSignals": { "tag": "Security Monitoring", "undo": {