diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5e1dce10cc1a..198c15204dc1 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -13006,6 +13006,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: @@ -23825,6 +23849,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: @@ -46712,6 +46787,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/cassettes/v2/Security-Monitoring_1187227211/Get-rule-version-history-returns-OK-response_620573261/frozen.json b/cassettes/v2/Security-Monitoring_1187227211/Get-rule-version-history-returns-OK-response_620573261/frozen.json new file mode 100644 index 000000000000..b55c487c5354 --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-rule-version-history-returns-OK-response_620573261/frozen.json @@ -0,0 +1 @@ +"2025-02-04T22:39:17.325Z" diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-rule-version-history-returns-OK-response_620573261/recording.har b/cassettes/v2/Security-Monitoring_1187227211/Get-rule-version-history-returns-OK-response_620573261/recording.har new file mode 100644 index 000000000000..cbb09e02f8ab --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-rule-version-history-returns-OK-response_620573261/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "Security Monitoring/Get rule version history returns \"OK\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "828d57e657b4424fe84a86d7f1db705f", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 420, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 588, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"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\"}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/rules" + }, + "response": { + "bodySize": 786, + "content": { + "mimeType": "application/json", + "size": 786, + "text": "{\"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\":\"\"}}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 654, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-02-04T22:39:17.727Z", + "time": 132 + }, + { + "_id": "09be8bb592c912411f3b4e3a4e3fb2d2", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + } + ], + "headersSize": 555, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/rules/gvq-qqd-jc7/version_history" + }, + "response": { + "bodySize": 915, + "content": { + "mimeType": "application/vnd.api+json", + "size": 915, + "text": "{\"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\":[]}}}}}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 662, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-02-04T22:39:17.865Z", + "time": 152 + }, + { + "_id": "cd1c79428cc1a501d7a7dd3c38ee275f", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "*/*" + } + ], + "headersSize": 536, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/rules/gvq-qqd-jc7" + }, + "response": { + "bodySize": 0, + "content": { + "mimeType": "text/plain", + "size": 0 + }, + "cookies": [], + "headers": [], + "headersSize": 601, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 204, + "statusText": "No Content" + }, + "startedDateTime": "2025-02-04T22:39:18.026Z", + "time": 116 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/examples/v2/security-monitoring/GetRuleVersionHistory.ts b/examples/v2/security-monitoring/GetRuleVersionHistory.ts new file mode 100644 index 000000000000..6e21ecab0fdb --- /dev/null +++ b/examples/v2/security-monitoring/GetRuleVersionHistory.ts @@ -0,0 +1,22 @@ +/** + * Get a rule's version history returns "OK" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +configuration.unstableOperations["v2.getRuleVersionHistory"] = true; +const apiInstance = new v2.SecurityMonitoringApi(configuration); + +const params: v2.SecurityMonitoringApiGetRuleVersionHistoryRequest = { + ruleId: "rule_id", +}; + +apiInstance + .getRuleVersionHistory(params) + .then((data: v2.GetRuleVersionHistoryResponse) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/examples/v2/security-monitoring/GetRuleVersionHistory_2467565841.ts b/examples/v2/security-monitoring/GetRuleVersionHistory_2467565841.ts new file mode 100644 index 000000000000..00042175714b --- /dev/null +++ b/examples/v2/security-monitoring/GetRuleVersionHistory_2467565841.ts @@ -0,0 +1,25 @@ +/** + * Get rule version history returns "OK" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +configuration.unstableOperations["v2.getRuleVersionHistory"] = true; +const apiInstance = new v2.SecurityMonitoringApi(configuration); + +// there is a valid "security_rule" in the system +const SECURITY_RULE_ID = process.env.SECURITY_RULE_ID as string; + +const params: v2.SecurityMonitoringApiGetRuleVersionHistoryRequest = { + ruleId: SECURITY_RULE_ID, +}; + +apiInstance + .getRuleVersionHistory(params) + .then((data: v2.GetRuleVersionHistoryResponse) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/features/support/scenarios_model_mapping.ts b/features/support/scenarios_model_mapping.ts index f6bc98447aab..077ef9c6d30e 100644 --- a/features/support/scenarios_model_mapping.ts +++ b/features/support/scenarios_model_mapping.ts @@ -5632,6 +5632,21 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = { }, "operationResponseType": "SecurityMonitoringRuleTestResponse", }, + "v2.GetRuleVersionHistory": { + "ruleId": { + "type": "string", + "format": "", + }, + "pageSize": { + "type": "number", + "format": "int64", + }, + "pageNumber": { + "type": "number", + "format": "int64", + }, + "operationResponseType": "GetRuleVersionHistoryResponse", + }, "v2.ListSecurityMonitoringSignals": { "filterQuery": { "type": "string", diff --git a/features/v2/security_monitoring.feature b/features/v2/security_monitoring.feature index ec4c3d3f39d9..ac0898d23a90 100644 --- a/features/v2/security_monitoring.feature +++ b/features/v2/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/features/v2/undo.json b/features/v2/undo.json index 288ca835fe71..fa6d0273dd2f 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2362,6 +2362,12 @@ "type": "idempotent" } }, + "GetRuleVersionHistory": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListSecurityMonitoringSignals": { "tag": "Security Monitoring", "undo": { diff --git a/packages/datadog-api-client-common/configuration.ts b/packages/datadog-api-client-common/configuration.ts index 5172d1fb753e..710a00c9aa6c 100644 --- a/packages/datadog-api-client-common/configuration.ts +++ b/packages/datadog-api-client-common/configuration.ts @@ -276,6 +276,7 @@ export function createConfiguration( "v2.deleteHistoricalJob": false, "v2.getFinding": false, "v2.getHistoricalJob": false, + "v2.getRuleVersionHistory": false, "v2.listFindings": false, "v2.listHistoricalJobs": false, "v2.muteFindings": false, diff --git a/packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts b/packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts index 829467908175..0c49fd7cad37 100644 --- a/packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts +++ b/packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts @@ -27,6 +27,7 @@ import { FindingEvaluation } from "../models/FindingEvaluation"; import { FindingStatus } from "../models/FindingStatus"; import { FindingVulnerabilityType } from "../models/FindingVulnerabilityType"; import { GetFindingResponse } from "../models/GetFindingResponse"; +import { GetRuleVersionHistoryResponse } from "../models/GetRuleVersionHistoryResponse"; import { GetSBOMResponse } from "../models/GetSBOMResponse"; import { HistoricalJobResponse } from "../models/HistoricalJobResponse"; import { JobCreateResponse } from "../models/JobCreateResponse"; @@ -954,6 +955,64 @@ export class SecurityMonitoringApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async getRuleVersionHistory( + ruleId: string, + pageSize?: number, + pageNumber?: number, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'getRuleVersionHistory'"); + if (!_config.unstableOperations["v2.getRuleVersionHistory"]) { + throw new Error("Unstable operation 'getRuleVersionHistory' is disabled"); + } + + // verify required parameter 'ruleId' is not null or undefined + if (ruleId === null || ruleId === undefined) { + throw new RequiredError("ruleId", "getRuleVersionHistory"); + } + + // Path Params + const localVarPath = + "/api/v2/security_monitoring/rules/{rule_id}/version_history".replace( + "{rule_id}", + encodeURIComponent(String(ruleId)) + ); + + // Make Request Context + const requestContext = _config + .getServer("v2.SecurityMonitoringApi.getRuleVersionHistory") + .makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Query Params + if (pageSize !== undefined) { + requestContext.setQueryParam( + "page[size]", + ObjectSerializer.serialize(pageSize, "number", "int64"), + "" + ); + } + if (pageNumber !== undefined) { + requestContext.setQueryParam( + "page[number]", + ObjectSerializer.serialize(pageNumber, "number", "int64"), + "" + ); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "AuthZ", + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async getSBOM( assetType: AssetType, filterAssetName: string, @@ -3987,6 +4046,69 @@ export class SecurityMonitoringApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getRuleVersionHistory + * @throws ApiException if the response code was not in [200, 299] + */ + public async getRuleVersionHistory( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 200) { + const body: GetRuleVersionHistoryResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "GetRuleVersionHistoryResponse" + ) as GetRuleVersionHistoryResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 404 || + response.httpStatusCode === 429 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: GetRuleVersionHistoryResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "GetRuleVersionHistoryResponse", + "" + ) as GetRuleVersionHistoryResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -6027,6 +6149,24 @@ export interface SecurityMonitoringApiGetHistoricalJobRequest { jobId: string; } +export interface SecurityMonitoringApiGetRuleVersionHistoryRequest { + /** + * The ID of the rule. + * @type string + */ + ruleId: string; + /** + * Size for a given page. The maximum allowed value is 100. + * @type number + */ + pageSize?: number; + /** + * Specific page number to return. + * @type number + */ + pageNumber?: number; +} + export interface SecurityMonitoringApiGetSBOMRequest { /** * The type of the asset for the SBOM request. @@ -7110,6 +7250,29 @@ export class SecurityMonitoringApi { }); } + /** + * Get a rule's version history. + * @param param The request object + */ + public getRuleVersionHistory( + param: SecurityMonitoringApiGetRuleVersionHistoryRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.getRuleVersionHistory( + param.ruleId, + param.pageSize, + param.pageNumber, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.getRuleVersionHistory(responseContext); + }); + }); + } + /** * Get a single SBOM related to an asset by its type and name. * @param param The request object diff --git a/packages/datadog-api-client-v2/index.ts b/packages/datadog-api-client-v2/index.ts index c55ac30bf827..585ed586c679 100644 --- a/packages/datadog-api-client-v2/index.ts +++ b/packages/datadog-api-client-v2/index.ts @@ -478,6 +478,7 @@ export { SecurityMonitoringApiEditSecurityMonitoringSignalStateRequest, SecurityMonitoringApiGetFindingRequest, SecurityMonitoringApiGetHistoricalJobRequest, + SecurityMonitoringApiGetRuleVersionHistoryRequest, SecurityMonitoringApiGetSBOMRequest, SecurityMonitoringApiGetSecurityFilterRequest, SecurityMonitoringApiGetSecurityMonitoringRuleRequest, @@ -1395,6 +1396,9 @@ export { GetDeviceResponse } from "./models/GetDeviceResponse"; export { GetFindingResponse } from "./models/GetFindingResponse"; export { GetInterfacesData } from "./models/GetInterfacesData"; export { GetInterfacesResponse } from "./models/GetInterfacesResponse"; +export { GetRuleVersionHistoryData } from "./models/GetRuleVersionHistoryData"; +export { GetRuleVersionHistoryDataType } from "./models/GetRuleVersionHistoryDataType"; +export { GetRuleVersionHistoryResponse } from "./models/GetRuleVersionHistoryResponse"; export { GetSBOMResponse } from "./models/GetSBOMResponse"; export { GetTeamMembershipsSort } from "./models/GetTeamMembershipsSort"; export { GetWorkflowResponse } from "./models/GetWorkflowResponse"; @@ -2074,6 +2078,10 @@ export { RuleSeverity } from "./models/RuleSeverity"; export { RuleType } from "./models/RuleType"; export { RuleTypesItems } from "./models/RuleTypesItems"; export { RuleUser } from "./models/RuleUser"; +export { RuleVersionHistory } from "./models/RuleVersionHistory"; +export { RuleVersions } from "./models/RuleVersions"; +export { RuleVersionUpdate } from "./models/RuleVersionUpdate"; +export { RuleVersionUpdateType } from "./models/RuleVersionUpdateType"; export { RUMAggregateBucketValue } from "./models/RUMAggregateBucketValue"; export { RUMAggregateBucketValueTimeseriesPoint } from "./models/RUMAggregateBucketValueTimeseriesPoint"; export { RUMAggregateRequest } from "./models/RUMAggregateRequest"; diff --git a/packages/datadog-api-client-v2/models/GetRuleVersionHistoryData.ts b/packages/datadog-api-client-v2/models/GetRuleVersionHistoryData.ts new file mode 100644 index 000000000000..140c9ddf9865 --- /dev/null +++ b/packages/datadog-api-client-v2/models/GetRuleVersionHistoryData.ts @@ -0,0 +1,70 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { GetRuleVersionHistoryDataType } from "./GetRuleVersionHistoryDataType"; +import { RuleVersionHistory } from "./RuleVersionHistory"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * Data for the rule version history. + */ +export class GetRuleVersionHistoryData { + /** + * Response object containing the version history of a rule. + */ + "attributes"?: RuleVersionHistory; + /** + * ID of the rule. + */ + "id"?: string; + /** + * Type of data. + */ + "type"?: GetRuleVersionHistoryDataType; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + attributes: { + baseName: "attributes", + type: "RuleVersionHistory", + }, + id: { + baseName: "id", + type: "string", + }, + type: { + baseName: "type", + type: "GetRuleVersionHistoryDataType", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "any", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GetRuleVersionHistoryData.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/GetRuleVersionHistoryDataType.ts b/packages/datadog-api-client-v2/models/GetRuleVersionHistoryDataType.ts new file mode 100644 index 000000000000..69b548936833 --- /dev/null +++ b/packages/datadog-api-client-v2/models/GetRuleVersionHistoryDataType.ts @@ -0,0 +1,16 @@ +/** + * 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 2020-Present Datadog, Inc. + */ + +import { UnparsedObject } from "../../datadog-api-client-common/util"; + +/** + * Type of data. + */ + +export type GetRuleVersionHistoryDataType = + | typeof GETRULEVERSIONHISTORYRESPONSE + | UnparsedObject; +export const GETRULEVERSIONHISTORYRESPONSE = "GetRuleVersionHistoryResponse"; diff --git a/packages/datadog-api-client-v2/models/GetRuleVersionHistoryResponse.ts b/packages/datadog-api-client-v2/models/GetRuleVersionHistoryResponse.ts new file mode 100644 index 000000000000..7910ba9a43b4 --- /dev/null +++ b/packages/datadog-api-client-v2/models/GetRuleVersionHistoryResponse.ts @@ -0,0 +1,53 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { GetRuleVersionHistoryData } from "./GetRuleVersionHistoryData"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * Response for getting the rule version history. + */ +export class GetRuleVersionHistoryResponse { + /** + * Data for the rule version history. + */ + "data"?: GetRuleVersionHistoryData; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "GetRuleVersionHistoryData", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "any", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GetRuleVersionHistoryResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/ObjectSerializer.ts b/packages/datadog-api-client-v2/models/ObjectSerializer.ts index 8147a2d06524..1fe6c1f3e781 100644 --- a/packages/datadog-api-client-v2/models/ObjectSerializer.ts +++ b/packages/datadog-api-client-v2/models/ObjectSerializer.ts @@ -589,6 +589,8 @@ import { GetDeviceResponse } from "./GetDeviceResponse"; import { GetFindingResponse } from "./GetFindingResponse"; import { GetInterfacesData } from "./GetInterfacesData"; import { GetInterfacesResponse } from "./GetInterfacesResponse"; +import { GetRuleVersionHistoryData } from "./GetRuleVersionHistoryData"; +import { GetRuleVersionHistoryResponse } from "./GetRuleVersionHistoryResponse"; import { GetSBOMResponse } from "./GetSBOMResponse"; import { GetWorkflowResponse } from "./GetWorkflowResponse"; import { GithubWebhookTrigger } from "./GithubWebhookTrigger"; @@ -1166,6 +1168,9 @@ import { RolesResponse } from "./RolesResponse"; import { RuleAttributes } from "./RuleAttributes"; import { RuleOutcomeRelationships } from "./RuleOutcomeRelationships"; import { RuleUser } from "./RuleUser"; +import { RuleVersionHistory } from "./RuleVersionHistory"; +import { RuleVersionUpdate } from "./RuleVersionUpdate"; +import { RuleVersions } from "./RuleVersions"; import { RumMetricCompute } from "./RumMetricCompute"; import { RumMetricCreateAttributes } from "./RumMetricCreateAttributes"; import { RumMetricCreateData } from "./RumMetricCreateData"; @@ -1892,6 +1897,7 @@ const enumsMap: { [key: string]: any[] } = { ], GCPSTSDelegateAccountType: ["gcp_sts_delegate"], GCPServiceAccountType: ["gcp_service_account"], + GetRuleVersionHistoryDataType: ["GetRuleVersionHistoryResponse"], GetTeamMembershipsSort: [ "manager_name", "-manager_name", @@ -2125,6 +2131,7 @@ const enumsMap: { [key: string]: any[] } = { "misconfiguration", "api_security", ], + RuleVersionUpdateType: ["create", "update", "delete"], RumMetricComputeAggregationType: ["count", "distribution"], RumMetricEventType: [ "session", @@ -3122,6 +3129,8 @@ const typeMap: { [index: string]: any } = { GetFindingResponse: GetFindingResponse, GetInterfacesData: GetInterfacesData, GetInterfacesResponse: GetInterfacesResponse, + GetRuleVersionHistoryData: GetRuleVersionHistoryData, + GetRuleVersionHistoryResponse: GetRuleVersionHistoryResponse, GetSBOMResponse: GetSBOMResponse, GetWorkflowResponse: GetWorkflowResponse, GithubWebhookTrigger: GithubWebhookTrigger, @@ -3752,6 +3761,9 @@ const typeMap: { [index: string]: any } = { RuleAttributes: RuleAttributes, RuleOutcomeRelationships: RuleOutcomeRelationships, RuleUser: RuleUser, + RuleVersionHistory: RuleVersionHistory, + RuleVersionUpdate: RuleVersionUpdate, + RuleVersions: RuleVersions, RumMetricCompute: RumMetricCompute, RumMetricCreateAttributes: RumMetricCreateAttributes, RumMetricCreateData: RumMetricCreateData, diff --git a/packages/datadog-api-client-v2/models/RuleVersionHistory.ts b/packages/datadog-api-client-v2/models/RuleVersionHistory.ts new file mode 100644 index 000000000000..88e678acc03b --- /dev/null +++ b/packages/datadog-api-client-v2/models/RuleVersionHistory.ts @@ -0,0 +1,62 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { RuleVersions } from "./RuleVersions"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * Response object containing the version history of a rule. + */ +export class RuleVersionHistory { + /** + * The number of rule versions. + */ + "count"?: number; + /** + * The `RuleVersionHistory` `data`. + */ + "data"?: { [key: string]: RuleVersions }; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + count: { + baseName: "count", + type: "number", + format: "int32", + }, + data: { + baseName: "data", + type: "{ [key: string]: RuleVersions; }", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "any", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return RuleVersionHistory.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/RuleVersionUpdate.ts b/packages/datadog-api-client-v2/models/RuleVersionUpdate.ts new file mode 100644 index 000000000000..5f78f9f5eb9d --- /dev/null +++ b/packages/datadog-api-client-v2/models/RuleVersionUpdate.ts @@ -0,0 +1,69 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { RuleVersionUpdateType } from "./RuleVersionUpdateType"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * A change in a rule version. + */ +export class RuleVersionUpdate { + /** + * The new value of the field. + */ + "change"?: string; + /** + * The field that was changed. + */ + "field"?: string; + /** + * The type of change. + */ + "type"?: RuleVersionUpdateType; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + change: { + baseName: "change", + type: "string", + }, + field: { + baseName: "field", + type: "string", + }, + type: { + baseName: "type", + type: "RuleVersionUpdateType", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "any", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return RuleVersionUpdate.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/RuleVersionUpdateType.ts b/packages/datadog-api-client-v2/models/RuleVersionUpdateType.ts new file mode 100644 index 000000000000..151fa316273c --- /dev/null +++ b/packages/datadog-api-client-v2/models/RuleVersionUpdateType.ts @@ -0,0 +1,20 @@ +/** + * 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 2020-Present Datadog, Inc. + */ + +import { UnparsedObject } from "../../datadog-api-client-common/util"; + +/** + * The type of change. + */ + +export type RuleVersionUpdateType = + | typeof CREATE + | typeof UPDATE + | typeof DELETE + | UnparsedObject; +export const CREATE = "create"; +export const UPDATE = "update"; +export const DELETE = "delete"; diff --git a/packages/datadog-api-client-v2/models/RuleVersions.ts b/packages/datadog-api-client-v2/models/RuleVersions.ts new file mode 100644 index 000000000000..89d493d30672 --- /dev/null +++ b/packages/datadog-api-client-v2/models/RuleVersions.ts @@ -0,0 +1,62 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { RuleVersionUpdate } from "./RuleVersionUpdate"; +import { SecurityMonitoringRuleResponse } from "./SecurityMonitoringRuleResponse"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * A rule version with a list of updates. + */ +export class RuleVersions { + /** + * A list of changes. + */ + "changes"?: Array; + /** + * Create a new rule. + */ + "rule"?: SecurityMonitoringRuleResponse; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + changes: { + baseName: "changes", + type: "Array", + }, + rule: { + baseName: "rule", + type: "SecurityMonitoringRuleResponse", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "any", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return RuleVersions.attributeTypeMap; + } + + public constructor() {} +}