From 7a5aa485cdffc4ad944e834c210c66fe2cedc394 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 22 Jan 2025 10:04:11 +0000 Subject: [PATCH] Regenerate client from commit 2cc8ad41 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 4 + .generator/schemas/v2/openapi.yaml | 709 ++++++++ .../CreateSignalNotificationRule.java | 56 + .../CreateVulnerabilityNotificationRule.java | 57 + .../DeleteSignalNotificationRule.java | 27 + .../DeleteVulnerabilityNotificationRule.java | 28 + .../GetSignalNotificationRule.java | 29 + .../GetSignalNotificationRules.java | 22 + .../GetVulnerabilityNotificationRule.java | 31 + .../GetVulnerabilityNotificationRules.java | 23 + .../PatchSignalNotificationRule.java | 63 + .../PatchVulnerabilityNotificationRule.java | 64 + .../client/v2/api/SecurityMonitoringApi.java | 1532 ++++++++++++++++- .../CreateNotificationRuleParameters.java | 139 ++ .../CreateNotificationRuleParametersData.java | 187 ++ ...ificationRuleParametersDataAttributes.java | 277 +++ .../api/client/v2/model/NotificationRule.java | 215 +++ .../v2/model/NotificationRuleAttributes.java | 429 +++++ .../v2/model/NotificationRuleResponse.java | 140 ++ .../v2/model/NotificationRulesType.java | 56 + .../PatchNotificationRuleParameters.java | 139 ++ .../PatchNotificationRuleParametersData.java | 216 +++ ...ificationRuleParametersDataAttributes.java | 300 ++++ .../api/client/v2/model/RuleSeverity.java | 59 + .../api/client/v2/model/RuleTypesItems.java | 93 + .../datadog/api/client/v2/model/RuleUser.java | 161 ++ .../api/client/v2/model/Selectors.java | 259 +++ .../api/client/v2/model/TriggerSource.java | 59 + ...ated_the_notification_rule_response.freeze | 1 + ...reated_the_notification_rule_response.json | 53 + ...ated_the_notification_rule_response.freeze | 1 + ...reated_the_notification_rule_response.json | 53 + ...sed_rule_returns_Not_Found_response.freeze | 1 + ...based_rule_returns_Not_Found_response.json | 28 + ..._Rule_successfully_deleted_response.freeze | 1 + ...ns_Rule_successfully_deleted_response.json | 79 + ...sed_rule_returns_Not_Found_response.freeze | 1 + ...based_rule_returns_Not_Found_response.json | 28 + ..._Rule_successfully_deleted_response.freeze | 1 + ...ns_Rule_successfully_deleted_response.json | 79 + ...sed_rule_returns_Not_Found_response.freeze | 1 + ...based_rule_returns_Not_Found_response.json | 28 + ..._Notification_rule_details_response.freeze | 1 + ...ns_Notification_rule_details_response.json | 79 + ...sed_rule_returns_Not_Found_response.freeze | 1 + ...based_rule_returns_Not_Found_response.json | 28 + ..._Notification_rule_details_response.freeze | 1 + ...ns_Notification_rule_details_response.json | 79 + ...list_of_notification_rules_response.freeze | 1 + ...e_list_of_notification_rules_response.json | 79 + ...list_of_notification_rules_response.freeze | 1 + ...e_list_of_notification_rules_response.json | 79 + ...d_rule_returns_Bad_Request_response.freeze | 1 + ...sed_rule_returns_Bad_Request_response.json | 83 + ...sed_rule_returns_Not_Found_response.freeze | 1 + ...based_rule_returns_Not_Found_response.json | 32 + ..._rule_successfully_patched_response.freeze | 1 + ...on_rule_successfully_patched_response.json | 83 + ...d_rule_returns_Bad_Request_response.freeze | 1 + ...sed_rule_returns_Bad_Request_response.json | 83 + ...sed_rule_returns_Not_Found_response.freeze | 1 + ...based_rule_returns_Not_Found_response.json | 32 + ..._rule_successfully_patched_response.freeze | 1 + ...on_rule_successfully_patched_response.json | 83 + .../com/datadog/api/client/v2/api/given.json | 24 + .../client/v2/api/security_monitoring.feature | 184 ++ .../com/datadog/api/client/v2/api/undo.json | 74 + 68 files changed, 6690 insertions(+), 80 deletions(-) create mode 100644 examples/v2/security-monitoring/CreateSignalNotificationRule.java create mode 100644 examples/v2/security-monitoring/CreateVulnerabilityNotificationRule.java create mode 100644 examples/v2/security-monitoring/DeleteSignalNotificationRule.java create mode 100644 examples/v2/security-monitoring/DeleteVulnerabilityNotificationRule.java create mode 100644 examples/v2/security-monitoring/GetSignalNotificationRule.java create mode 100644 examples/v2/security-monitoring/GetSignalNotificationRules.java create mode 100644 examples/v2/security-monitoring/GetVulnerabilityNotificationRule.java create mode 100644 examples/v2/security-monitoring/GetVulnerabilityNotificationRules.java create mode 100644 examples/v2/security-monitoring/PatchSignalNotificationRule.java create mode 100644 examples/v2/security-monitoring/PatchVulnerabilityNotificationRule.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParameters.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParametersData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParametersDataAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/NotificationRule.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/NotificationRuleAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/NotificationRuleResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/NotificationRulesType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParameters.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParametersData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParametersDataAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RuleSeverity.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RuleTypesItems.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RuleUser.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/Selectors.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/TriggerSource.java create mode 100644 src/test/resources/cassettes/features/v2/Create_a_new_signal_based_rule_returns_Successfully_created_the_notification_rule_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Create_a_new_signal_based_rule_returns_Successfully_created_the_notification_rule_response.json create mode 100644 src/test/resources/cassettes/features/v2/Create_a_new_vulnerability_based_rule_returns_Successfully_created_the_notification_rule_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Create_a_new_vulnerability_based_rule_returns_Successfully_created_the_notification_rule_response.json create mode 100644 src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Not_Found_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Not_Found_response.json create mode 100644 src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response.json create mode 100644 src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Not_Found_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Not_Found_response.json create mode 100644 src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response.json create mode 100644 src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Not_Found_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Not_Found_response.json create mode 100644 src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response.json create mode 100644 src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Not_Found_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Not_Found_response.json create mode 100644 src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response.json create mode 100644 src/test/resources/cassettes/features/v2/Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response.json create mode 100644 src/test/resources/cassettes/features/v2/Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response.json create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Bad_Request_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Bad_Request_response.json create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Not_Found_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Not_Found_response.json create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response.json create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Bad_Request_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Bad_Request_response.json create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Not_Found_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Not_Found_response.json create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response.json diff --git a/.apigentools-info b/.apigentools-info index cc08c003690..18f8f20bf65 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-21 14:16:35.887810", - "spec_repo_commit": "0bbc13ae" + "regenerated": "2025-01-22 10:02:19.481839", + "spec_repo_commit": "2cc8ad41" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-21 14:16:35.904462", - "spec_repo_commit": "0bbc13ae" + "regenerated": "2025-01-22 10:02:19.497224", + "spec_repo_commit": "2cc8ad41" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 655dc2c655a..c4d78fe19a9 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -23737,6 +23737,10 @@ components: security_monitoring_filters_write: Create, edit, and delete Security Filters. security_monitoring_findings_read: View a list of findings that include both misconfigurations and identity risks. + security_monitoring_notification_profiles_read: View Rule Security Notification + rules. + security_monitoring_notification_profiles_write: Create, edit, and delete + Security Notification rules. security_monitoring_rules_read: Read Detection Rules. security_monitoring_rules_write: Create and edit Detection Rules. security_monitoring_signals_read: View Security Signals. diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 3b81448eef7..218a35cb823 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -794,6 +794,17 @@ components: schema: $ref: '#/components/schemas/APIErrorResponse' description: Not Found + NotificationRulesList: + content: + application/json: + schema: + properties: + data: + items: + $ref: '#/components/schemas/NotificationRule' + type: array + type: object + description: The list of notification rules PreconditionFailedResponse: content: application/json: @@ -836,6 +847,13 @@ components: schema: $ref: '#/components/schemas/APIErrorResponse' description: Unauthorized + UnprocessableEntityResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: The server cannot process the request because it contains invalid + data. schemas: APIErrorResponse: description: API error response. @@ -7403,6 +7421,42 @@ components: meta: $ref: '#/components/schemas/DataDeletionResponseMeta' type: object + CreateNotificationRuleParameters: + description: Body of the notification rule create request + properties: + data: + $ref: '#/components/schemas/CreateNotificationRuleParametersData' + type: object + CreateNotificationRuleParametersData: + description: 'Data of the notification rule create request: the rule type, and + the rule attributes. All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/CreateNotificationRuleParametersDataAttributes' + type: + $ref: '#/components/schemas/NotificationRulesType' + required: + - attributes + - type + type: object + CreateNotificationRuleParametersDataAttributes: + description: Attributes of the notification rule create request. + properties: + enabled: + $ref: '#/components/schemas/Enabled' + name: + $ref: '#/components/schemas/RuleName' + selectors: + $ref: '#/components/schemas/Selectors' + targets: + $ref: '#/components/schemas/Targets' + time_aggregation: + $ref: '#/components/schemas/TimeAggregation' + required: + - selectors + - name + - targets + type: object CreateOpenAPIResponse: description: Response for `CreateOpenAPI` operation. properties: @@ -9115,6 +9169,11 @@ components: type: number type: array type: object + Date: + description: Date as Unix timestamp in milliseconds + example: 1722439510282 + format: int64 + type: integer DeleteAppResponse: description: The definition of `DeleteAppResponse` object. properties: @@ -10297,6 +10356,10 @@ components: - score - severity type: object + Enabled: + description: Field used to enable or disable the rule. + example: true + type: boolean EntityAttributes: description: Entity attributes. properties: @@ -13237,6 +13300,10 @@ components: - APP_SEC_HOST_COUNT - OBSERVABILITY_PIPELINES_BYTES_PROCESSSED - LAMBDA_TRACED_INVOCATIONS_COUNT + ID: + description: The ID of a notification rule + example: aaa-bbb-ccc + type: string IPAllowlistAttributes: description: Attributes of the IP allowlist. properties: @@ -19373,6 +19440,84 @@ components: meta: $ref: '#/components/schemas/MonthlyCostAttributionMeta' type: object + NotificationRule: + description: 'Notification rules allow full control over notifications generated + by the various Datadog security products. + + They allow user to define the conditions under which a notification should + be generated (based on rule severities, + + rule types, rule tags, etc..), and the targets to notify. + + A notification rule is composed of a rule id, a rule type, and the rule attributes. + All fields are required. + + ' + properties: + attributes: + $ref: '#/components/schemas/NotificationRuleAttributes' + id: + $ref: '#/components/schemas/ID' + type: + $ref: '#/components/schemas/NotificationRulesType' + required: + - attributes + - id + - type + type: object + NotificationRuleAttributes: + description: Attributes of the notification rule + properties: + created_at: + $ref: '#/components/schemas/Date' + created_by: + $ref: '#/components/schemas/RuleUser' + enabled: + $ref: '#/components/schemas/Enabled' + modified_at: + $ref: '#/components/schemas/Date' + modified_by: + $ref: '#/components/schemas/RuleUser' + name: + $ref: '#/components/schemas/RuleName' + selectors: + $ref: '#/components/schemas/Selectors' + targets: + $ref: '#/components/schemas/Targets' + time_aggregation: + $ref: '#/components/schemas/TimeAggregation' + version: + $ref: '#/components/schemas/Version' + required: + - created_at + - created_by + - enabled + - modified_at + - modified_by + - name + - selectors + - targets + - version + type: object + NotificationRuleQuery: + description: The query is composed of one or several key:value pairs, which + can be used to filter security issues on tags and attributes. + example: (source:production_service OR env:prod) + type: string + NotificationRuleResponse: + description: Response object which includes a notification rule. + properties: + data: + $ref: '#/components/schemas/NotificationRule' + type: object + NotificationRulesType: + description: The rule type associated to notification rules + enum: + - notification_rules + example: notification_rules + type: string + x-enum-varnames: + - NOTIFICATION_RULES NullableRelationshipToUser: description: Relationship to user. nullable: true @@ -20226,6 +20371,44 @@ components: $ref: '#/components/schemas/ApplicationKeyResponseIncludedItem' type: array type: object + PatchNotificationRuleParameters: + description: Body of the notification rule patch request + properties: + data: + $ref: '#/components/schemas/PatchNotificationRuleParametersData' + type: object + PatchNotificationRuleParametersData: + description: 'Data of the notification rule patch request: the rule id, the + rule type, and the rule attributes. All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/PatchNotificationRuleParametersDataAttributes' + id: + $ref: '#/components/schemas/ID' + type: + $ref: '#/components/schemas/NotificationRulesType' + required: + - attributes + - id + - type + type: object + PatchNotificationRuleParametersDataAttributes: + description: Attributes of the notification rule patch request. It is required + to update the version of the rule when patching it. + properties: + enabled: + $ref: '#/components/schemas/Enabled' + name: + $ref: '#/components/schemas/RuleName' + selectors: + $ref: '#/components/schemas/Selectors' + targets: + $ref: '#/components/schemas/Targets' + time_aggregation: + $ref: '#/components/schemas/TimeAggregation' + version: + $ref: '#/components/schemas/Version' + type: object Permission: description: Permission object. properties: @@ -22907,12 +23090,34 @@ components: description: The unique ID for a scorecard rule. example: q8MQxk8TCqrHnWkx type: string + RuleName: + description: Name of the notification rule + example: Rule 1 + type: string RuleOutcomeRelationships: description: The JSON:API relationship to a scorecard rule. properties: rule: $ref: '#/components/schemas/RelationshipToOutcome' type: object + RuleSeverity: + description: Severity of a security rule + enum: + - critical + - high + - medium + - low + - unknown + - info + example: critical + type: string + x-enum-varnames: + - CRITICAL + - HIGH + - MEDIUM + - LOW + - UNKNOWN + - INFO RuleType: default: rule description: The JSON:API type for scorecard rules. @@ -22922,6 +23127,69 @@ components: type: string x-enum-varnames: - RULE + RuleTypes: + description: Security rule types used to filter signals and vulnerabilities + generating notifications. + example: + - misconfiguration + - attack_path + items: + $ref: '#/components/schemas/RuleTypesItems' + type: array + RuleTypesItems: + description: 'Security rule types which can be used in notification rules. + + Signal-based notification rules can filter signals based on rule types application_security, + log_detection, + + workload_security, signal_correlation, cloud_configuration and infrastructure_configuration. + + Vulnerability-based notification rules can filter vulnerabilities based on + rule types application_code_vulnerability, + + application_library_vulnerability, attack_path, container_image_vulnerability, + identity_risk, misconfiguration and api_security.' + enum: + - application_security + - log_detection + - workload_security + - signal_correlation + - cloud_configuration + - infrastructure_configuration + - application_code_vulnerability + - application_library_vulnerability + - attack_path + - container_image_vulnerability + - identity_risk + - misconfiguration + - api_security + type: string + x-enum-varnames: + - APPLICATION_SECURITY + - LOG_DETECTION + - WORKLOAD_SECURITY + - SIGNAL_CORRELATION + - CLOUD_CONFIGURATION + - INFRASTRUCTURE_CONFIGURATION + - APPLICATION_CODE_VULNERABILITY + - APPLICATION_LIBRARY_VULNERABILITY + - ATTACK_PATH + - CONTAINER_IMAGE_VULNERABILITY + - IDENTITY_RISK + - MISCONFIGURATION + - API_SECURITY + RuleUser: + description: User creating or modifying a rule + properties: + handle: + description: The user handle. + example: john.doe@domain.com + type: string + name: + description: The user name. + example: John Doe + type: string + type: object RumMetricCompute: description: The compute rule to compute the rum-based metric. properties: @@ -25702,6 +25970,29 @@ components: nullable: true type: string type: object + Selectors: + description: 'Selectors are used to filter security issues for which notifications + should be generated. + + Users can specify rule severities, rule types, a query to filter security + issues on tags and attributes, and the trigger source. + + Only the trigger_source field is required.' + properties: + query: + $ref: '#/components/schemas/NotificationRuleQuery' + rule_types: + $ref: '#/components/schemas/RuleTypes' + severities: + description: The security rules severities to consider + items: + $ref: '#/components/schemas/RuleSeverity' + type: array + trigger_source: + $ref: '#/components/schemas/TriggerSource' + required: + - trigger_source + type: object SensitiveDataScannerConfigRequest: description: Group reorder request. properties: @@ -28376,6 +28667,20 @@ components: description: Tag associated with your event. type: string type: array + Targets: + description: 'List of recipients to notify when a notification rule is triggered. + Many different target types are supported, + + such as email addresses, Slack channels, and PagerDuty services. + + The appropriate integrations need to be properly configured to send notifications + to the specified targets.' + example: + - '@john.doe@email.com' + items: + description: Recipients to notify + type: string + type: array Team: description: A team properties: @@ -28952,6 +29257,22 @@ components: description: Offset type. type: string type: object + TimeAggregation: + description: 'Time aggregation period (in seconds) is used to aggregate the + results of the notification rule evaluation. + + Results are aggregated over a selected time frame using a rolling window, + which updates with each new evaluation. + + Notifications will only be sent for new issues discovered during the window. + + Time aggregation is only available for vulnerability-based notification rules. + When omitted or set to 0, no aggregation + + is done.' + example: 86400 + format: int64 + type: integer TimeseriesFormulaQueryRequest: description: A request wrapper around a single timeseries query to be executed. properties: @@ -29144,6 +29465,20 @@ components: type: string x-enum-varnames: - SECRET + TriggerSource: + description: 'The type of security issues on which the rule applies. Notification + rules based on security signals need to use the trigger source "security_signals", + + while notification rules based on security vulnerabilities need to use the + trigger source "security_findings".' + enum: + - security_findings + - security_signals + example: security_findings + type: string + x-enum-varnames: + - SECURITY_FINDINGS + - SECURITY_SIGNALS Unit: description: Object containing the metric unit family, scale factor, name, and short name. @@ -30069,6 +30404,12 @@ components: type: string x-enum-varnames: - USERS + Version: + description: Version of the notification rule. It is updated when the rule is + modified. + example: 1 + format: int64 + type: integer VulnerabilitiesType: description: The JSON:API type. enum: @@ -30660,6 +31001,10 @@ components: security_monitoring_filters_write: Create, edit, and delete Security Filters. security_monitoring_findings_read: View a list of findings that include both misconfigurations and identity risks. + security_monitoring_notification_profiles_read: View Rule Security Notification + rules. + security_monitoring_notification_profiles_write: Create, edit, and delete + Security Notification rules. security_monitoring_rules_read: Read Detection Rules. security_monitoring_rules_write: Create and edit Detection Rules. security_monitoring_signals_read: View Security Signals. @@ -43321,6 +43666,188 @@ paths: operator: OR permissions: - security_monitoring_cws_agent_rules_read + /api/v2/security/signals/notification_rules: + get: + description: Returns the list of notification rules for security signals + operationId: GetSignalNotificationRules + responses: + '200': + $ref: '#/components/responses/NotificationRulesList' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_read + summary: Get the list of signal-based rules + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_read + post: + description: Create a new notification rule for security signals and return + the created rule. + operationId: CreateSignalNotificationRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateNotificationRuleParameters' + description: 'The body of the create notification rule request is composed + of the rule type and the rule attributes: + + the rule name, the selectors, the notification targets, and the rule enabled + status. + + ' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRuleResponse' + description: Successfully created the notification rule + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_write + summary: Create a new signal-based rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_write + /api/v2/security/signals/notification_rules/{id}: + delete: + description: Delete a notification rule for security signals. + operationId: DeleteSignalNotificationRule + parameters: + - description: ID of the notification rule + in: path + name: id + required: true + schema: + type: string + responses: + '204': + description: Rule successfully deleted + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_write + summary: Delete a signal-based rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_write + get: + description: Get the details of a notification rule for security signals. + operationId: GetSignalNotificationRule + parameters: + - description: ID of the notification rule + in: path + name: id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRuleResponse' + description: Notification rule details + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_read + summary: Get details of a signal-based rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_read + patch: + description: Partially update the notification rule. All fields are optional; + if a field is not provided, it will not be updated. + operationId: PatchSignalNotificationRule + parameters: + - description: ID of the notification rule + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatchNotificationRuleParameters' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRuleResponse' + description: Notification rule successfully patched + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '422': + $ref: '#/components/responses/UnprocessableEntityResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_write + summary: Patch a signal-based rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_write /api/v2/security/vulnerabilities: get: description: "Get a list of vulnerabilities.\n\n### Pagination\n\nPagination @@ -43700,6 +44227,188 @@ paths: x-unstable: '**Note**: Note: This endpoint is a private preview. If you are interested in accessing this API, please [fill this form](https://forms.gle/kMYC1sDr6WDUBDsx9).' + /api/v2/security/vulnerabilities/notification_rules: + get: + description: Returns the list of notification rules for security vulnerabilities + operationId: GetVulnerabilityNotificationRules + responses: + '200': + $ref: '#/components/responses/NotificationRulesList' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_read + summary: Get the list of vulnerability-based rules + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_read + post: + description: Create a new notification rule for security vulnerabilities and + return the created rule. + operationId: CreateVulnerabilityNotificationRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateNotificationRuleParameters' + description: 'The body of the create notification rule request is composed + of the rule type and the rule attributes: + + the rule name, the selectors, the notification targets, and the rule enabled + status. + + ' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRuleResponse' + description: Successfully created the notification rule + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_write + summary: Create a new vulnerability-based rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_write + /api/v2/security/vulnerabilities/notification_rules/{id}: + delete: + description: Delete a notification rule for security vulnerabilities. + operationId: DeleteVulnerabilityNotificationRule + parameters: + - description: ID of the notification rule + in: path + name: id + required: true + schema: + type: string + responses: + '204': + description: Rule successfully deleted + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_write + summary: Delete a vulnerability-based rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_write + get: + description: Get the details of a notification rule for security vulnerabilities. + operationId: GetVulnerabilityNotificationRule + parameters: + - description: ID of the notification rule + in: path + name: id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRuleResponse' + description: Notification rule details + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_read + summary: Get details of a vulnerability-based rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_read + patch: + description: Partially update the notification rule. All fields are optional; + if a field is not provided, it will not be updated. + operationId: PatchVulnerabilityNotificationRule + parameters: + - description: ID of the notification rule + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatchNotificationRuleParameters' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRuleResponse' + description: Notification rule successfully patched + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '422': + $ref: '#/components/responses/UnprocessableEntityResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_write + summary: Patch a vulnerability-based rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_monitoring_notification_profiles_write /api/v2/security_monitoring/cloud_workload_security/agent_rules: get: description: Get the list of Agent rules. diff --git a/examples/v2/security-monitoring/CreateSignalNotificationRule.java b/examples/v2/security-monitoring/CreateSignalNotificationRule.java new file mode 100644 index 00000000000..ca18e2e7882 --- /dev/null +++ b/examples/v2/security-monitoring/CreateSignalNotificationRule.java @@ -0,0 +1,56 @@ +// Create a new signal-based rule returns "Successfully created the notification rule" 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.CreateNotificationRuleParameters; +import com.datadog.api.client.v2.model.CreateNotificationRuleParametersData; +import com.datadog.api.client.v2.model.CreateNotificationRuleParametersDataAttributes; +import com.datadog.api.client.v2.model.NotificationRuleResponse; +import com.datadog.api.client.v2.model.NotificationRulesType; +import com.datadog.api.client.v2.model.RuleSeverity; +import com.datadog.api.client.v2.model.RuleTypesItems; +import com.datadog.api.client.v2.model.Selectors; +import com.datadog.api.client.v2.model.TriggerSource; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + CreateNotificationRuleParameters body = + new CreateNotificationRuleParameters() + .data( + new CreateNotificationRuleParametersData() + .attributes( + new CreateNotificationRuleParametersDataAttributes() + .enabled(true) + .name("Rule 1") + .selectors( + new Selectors() + .query("(source:production_service OR env:prod)") + .ruleTypes( + Arrays.asList( + RuleTypesItems.MISCONFIGURATION, + RuleTypesItems.ATTACK_PATH)) + .severities(Collections.singletonList(RuleSeverity.CRITICAL)) + .triggerSource(TriggerSource.SECURITY_FINDINGS)) + .targets(Collections.singletonList("@john.doe@email.com")) + .timeAggregation(86400L)) + .type(NotificationRulesType.NOTIFICATION_RULES)); + + try { + NotificationRuleResponse result = apiInstance.createSignalNotificationRule(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#createSignalNotificationRule"); + 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/CreateVulnerabilityNotificationRule.java b/examples/v2/security-monitoring/CreateVulnerabilityNotificationRule.java new file mode 100644 index 00000000000..3bcec9a27c2 --- /dev/null +++ b/examples/v2/security-monitoring/CreateVulnerabilityNotificationRule.java @@ -0,0 +1,57 @@ +// Create a new vulnerability-based rule returns "Successfully created the notification rule" +// 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.CreateNotificationRuleParameters; +import com.datadog.api.client.v2.model.CreateNotificationRuleParametersData; +import com.datadog.api.client.v2.model.CreateNotificationRuleParametersDataAttributes; +import com.datadog.api.client.v2.model.NotificationRuleResponse; +import com.datadog.api.client.v2.model.NotificationRulesType; +import com.datadog.api.client.v2.model.RuleSeverity; +import com.datadog.api.client.v2.model.RuleTypesItems; +import com.datadog.api.client.v2.model.Selectors; +import com.datadog.api.client.v2.model.TriggerSource; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + CreateNotificationRuleParameters body = + new CreateNotificationRuleParameters() + .data( + new CreateNotificationRuleParametersData() + .attributes( + new CreateNotificationRuleParametersDataAttributes() + .enabled(true) + .name("Rule 1") + .selectors( + new Selectors() + .query("(source:production_service OR env:prod)") + .ruleTypes( + Arrays.asList( + RuleTypesItems.MISCONFIGURATION, + RuleTypesItems.ATTACK_PATH)) + .severities(Collections.singletonList(RuleSeverity.CRITICAL)) + .triggerSource(TriggerSource.SECURITY_FINDINGS)) + .targets(Collections.singletonList("@john.doe@email.com")) + .timeAggregation(86400L)) + .type(NotificationRulesType.NOTIFICATION_RULES)); + + try { + NotificationRuleResponse result = apiInstance.createVulnerabilityNotificationRule(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#createVulnerabilityNotificationRule"); + 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/DeleteSignalNotificationRule.java b/examples/v2/security-monitoring/DeleteSignalNotificationRule.java new file mode 100644 index 00000000000..1d4099f1468 --- /dev/null +++ b/examples/v2/security-monitoring/DeleteSignalNotificationRule.java @@ -0,0 +1,27 @@ +// Delete a signal-based rule returns "Rule successfully deleted" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "valid_signal_notification_rule" in the system + String VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID = + System.getenv("VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID"); + + try { + apiInstance.deleteSignalNotificationRule(VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#deleteSignalNotificationRule"); + 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/DeleteVulnerabilityNotificationRule.java b/examples/v2/security-monitoring/DeleteVulnerabilityNotificationRule.java new file mode 100644 index 00000000000..7cc784282a3 --- /dev/null +++ b/examples/v2/security-monitoring/DeleteVulnerabilityNotificationRule.java @@ -0,0 +1,28 @@ +// Delete a vulnerability-based rule returns "Rule successfully deleted" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "valid_vulnerability_notification_rule" in the system + String VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID = + System.getenv("VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID"); + + try { + apiInstance.deleteVulnerabilityNotificationRule( + VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#deleteVulnerabilityNotificationRule"); + 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/GetSignalNotificationRule.java b/examples/v2/security-monitoring/GetSignalNotificationRule.java new file mode 100644 index 00000000000..54156090dc5 --- /dev/null +++ b/examples/v2/security-monitoring/GetSignalNotificationRule.java @@ -0,0 +1,29 @@ +// Get details of a signal-based rule returns "Notification rule details" 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.NotificationRuleResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "valid_signal_notification_rule" in the system + String VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID = + System.getenv("VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID"); + + try { + NotificationRuleResponse result = + apiInstance.getSignalNotificationRule(VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling SecurityMonitoringApi#getSignalNotificationRule"); + 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/GetSignalNotificationRules.java b/examples/v2/security-monitoring/GetSignalNotificationRules.java new file mode 100644 index 00000000000..78963cf2aa3 --- /dev/null +++ b/examples/v2/security-monitoring/GetSignalNotificationRules.java @@ -0,0 +1,22 @@ +// Get the list of signal-based rules returns "The list of notification rules" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + try { + apiInstance.getSignalNotificationRules(); + } catch (ApiException e) { + System.err.println("Exception when calling SecurityMonitoringApi#getSignalNotificationRules"); + 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/GetVulnerabilityNotificationRule.java b/examples/v2/security-monitoring/GetVulnerabilityNotificationRule.java new file mode 100644 index 00000000000..3963c945a25 --- /dev/null +++ b/examples/v2/security-monitoring/GetVulnerabilityNotificationRule.java @@ -0,0 +1,31 @@ +// Get details of a vulnerability-based rule returns "Notification rule details" 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.NotificationRuleResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "valid_vulnerability_notification_rule" in the system + String VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID = + System.getenv("VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID"); + + try { + NotificationRuleResponse result = + apiInstance.getVulnerabilityNotificationRule( + VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#getVulnerabilityNotificationRule"); + 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/GetVulnerabilityNotificationRules.java b/examples/v2/security-monitoring/GetVulnerabilityNotificationRules.java new file mode 100644 index 00000000000..78c943caedd --- /dev/null +++ b/examples/v2/security-monitoring/GetVulnerabilityNotificationRules.java @@ -0,0 +1,23 @@ +// Get the list of vulnerability-based rules returns "The list of notification rules" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + try { + apiInstance.getVulnerabilityNotificationRules(); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#getVulnerabilityNotificationRules"); + 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/PatchSignalNotificationRule.java b/examples/v2/security-monitoring/PatchSignalNotificationRule.java new file mode 100644 index 00000000000..cfc00d0d79d --- /dev/null +++ b/examples/v2/security-monitoring/PatchSignalNotificationRule.java @@ -0,0 +1,63 @@ +// Patch a signal-based rule returns "Notification rule successfully patched" 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.NotificationRuleResponse; +import com.datadog.api.client.v2.model.NotificationRulesType; +import com.datadog.api.client.v2.model.PatchNotificationRuleParameters; +import com.datadog.api.client.v2.model.PatchNotificationRuleParametersData; +import com.datadog.api.client.v2.model.PatchNotificationRuleParametersDataAttributes; +import com.datadog.api.client.v2.model.RuleSeverity; +import com.datadog.api.client.v2.model.RuleTypesItems; +import com.datadog.api.client.v2.model.Selectors; +import com.datadog.api.client.v2.model.TriggerSource; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "valid_signal_notification_rule" in the system + String VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID = + System.getenv("VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID"); + + PatchNotificationRuleParameters body = + new PatchNotificationRuleParameters() + .data( + new PatchNotificationRuleParametersData() + .attributes( + new PatchNotificationRuleParametersDataAttributes() + .enabled(true) + .name("Rule 1") + .selectors( + new Selectors() + .query("(source:production_service OR env:prod)") + .ruleTypes( + Arrays.asList( + RuleTypesItems.MISCONFIGURATION, + RuleTypesItems.ATTACK_PATH)) + .severities(Collections.singletonList(RuleSeverity.CRITICAL)) + .triggerSource(TriggerSource.SECURITY_FINDINGS)) + .targets(Collections.singletonList("@john.doe@email.com")) + .timeAggregation(86400L) + .version(1L)) + .id(VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID) + .type(NotificationRulesType.NOTIFICATION_RULES)); + + try { + NotificationRuleResponse result = + apiInstance.patchSignalNotificationRule(VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#patchSignalNotificationRule"); + 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/PatchVulnerabilityNotificationRule.java b/examples/v2/security-monitoring/PatchVulnerabilityNotificationRule.java new file mode 100644 index 00000000000..f954ba15bac --- /dev/null +++ b/examples/v2/security-monitoring/PatchVulnerabilityNotificationRule.java @@ -0,0 +1,64 @@ +// Patch a vulnerability-based rule returns "Notification rule successfully patched" 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.NotificationRuleResponse; +import com.datadog.api.client.v2.model.NotificationRulesType; +import com.datadog.api.client.v2.model.PatchNotificationRuleParameters; +import com.datadog.api.client.v2.model.PatchNotificationRuleParametersData; +import com.datadog.api.client.v2.model.PatchNotificationRuleParametersDataAttributes; +import com.datadog.api.client.v2.model.RuleSeverity; +import com.datadog.api.client.v2.model.RuleTypesItems; +import com.datadog.api.client.v2.model.Selectors; +import com.datadog.api.client.v2.model.TriggerSource; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "valid_vulnerability_notification_rule" in the system + String VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID = + System.getenv("VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID"); + + PatchNotificationRuleParameters body = + new PatchNotificationRuleParameters() + .data( + new PatchNotificationRuleParametersData() + .attributes( + new PatchNotificationRuleParametersDataAttributes() + .enabled(true) + .name("Rule 1") + .selectors( + new Selectors() + .query("(source:production_service OR env:prod)") + .ruleTypes( + Arrays.asList( + RuleTypesItems.MISCONFIGURATION, + RuleTypesItems.ATTACK_PATH)) + .severities(Collections.singletonList(RuleSeverity.CRITICAL)) + .triggerSource(TriggerSource.SECURITY_FINDINGS)) + .targets(Collections.singletonList("@john.doe@email.com")) + .timeAggregation(86400L) + .version(1L)) + .id(VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID) + .type(NotificationRulesType.NOTIFICATION_RULES)); + + try { + NotificationRuleResponse result = + apiInstance.patchVulnerabilityNotificationRule( + VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#patchVulnerabilityNotificationRule"); + 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/v2/api/SecurityMonitoringApi.java b/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java index 2cad3609da1..dd72bb1dc13 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 @@ -9,6 +9,7 @@ import com.datadog.api.client.v2.model.BulkMuteFindingsRequest; import com.datadog.api.client.v2.model.BulkMuteFindingsResponse; import com.datadog.api.client.v2.model.ConvertJobResultsToSignalsRequest; +import com.datadog.api.client.v2.model.CreateNotificationRuleParameters; import com.datadog.api.client.v2.model.Finding; import com.datadog.api.client.v2.model.FindingEvaluation; import com.datadog.api.client.v2.model.FindingStatus; @@ -20,6 +21,8 @@ import com.datadog.api.client.v2.model.ListHistoricalJobsResponse; import com.datadog.api.client.v2.model.ListVulnerabilitiesResponse; import com.datadog.api.client.v2.model.ListVulnerableAssetsResponse; +import com.datadog.api.client.v2.model.NotificationRuleResponse; +import com.datadog.api.client.v2.model.PatchNotificationRuleParameters; import com.datadog.api.client.v2.model.RunHistoricalJobRequest; import com.datadog.api.client.v2.model.SecurityFilterCreateRequest; import com.datadog.api.client.v2.model.SecurityFilterResponse; @@ -1101,6 +1104,292 @@ public SecurityMonitoringSuppressionResponse createSecurityMonitoringSuppression new GenericType() {}); } + /** + * Create a new signal-based rule. + * + *

See {@link #createSignalNotificationRuleWithHttpInfo}. + * + * @param body The body of the create notification rule request is composed of the rule type and + * the rule attributes: the rule name, the selectors, the notification targets, and the rule + * enabled status. (required) + * @return NotificationRuleResponse + * @throws ApiException if fails to make API call + */ + public NotificationRuleResponse createSignalNotificationRule( + CreateNotificationRuleParameters body) throws ApiException { + return createSignalNotificationRuleWithHttpInfo(body).getData(); + } + + /** + * Create a new signal-based rule. + * + *

See {@link #createSignalNotificationRuleWithHttpInfoAsync}. + * + * @param body The body of the create notification rule request is composed of the rule type and + * the rule attributes: the rule name, the selectors, the notification targets, and the rule + * enabled status. (required) + * @return CompletableFuture<NotificationRuleResponse> + */ + public CompletableFuture createSignalNotificationRuleAsync( + CreateNotificationRuleParameters body) { + return createSignalNotificationRuleWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create a new notification rule for security signals and return the created rule. + * + * @param body The body of the create notification rule request is composed of the rule type and + * the rule attributes: the rule name, the selectors, the notification targets, and the rule + * enabled status. (required) + * @return ApiResponse<NotificationRuleResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
201 Successfully created the notification rule -
400 Bad Request -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse createSignalNotificationRuleWithHttpInfo( + CreateNotificationRuleParameters body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createSignalNotificationRule"); + } + // create path and map variables + String localVarPath = "/api/v2/security/signals/notification_rules"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.createSignalNotificationRule", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Create a new signal-based rule. + * + *

See {@link #createSignalNotificationRuleWithHttpInfo}. + * + * @param body The body of the create notification rule request is composed of the rule type and + * the rule attributes: the rule name, the selectors, the notification targets, and the rule + * enabled status. (required) + * @return CompletableFuture<ApiResponse<NotificationRuleResponse>> + */ + public CompletableFuture> + createSignalNotificationRuleWithHttpInfoAsync(CreateNotificationRuleParameters body) { + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling createSignalNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/security/signals/notification_rules"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.createSignalNotificationRule", + localVarPath, + new ArrayList(), + 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( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Create a new vulnerability-based rule. + * + *

See {@link #createVulnerabilityNotificationRuleWithHttpInfo}. + * + * @param body The body of the create notification rule request is composed of the rule type and + * the rule attributes: the rule name, the selectors, the notification targets, and the rule + * enabled status. (required) + * @return NotificationRuleResponse + * @throws ApiException if fails to make API call + */ + public NotificationRuleResponse createVulnerabilityNotificationRule( + CreateNotificationRuleParameters body) throws ApiException { + return createVulnerabilityNotificationRuleWithHttpInfo(body).getData(); + } + + /** + * Create a new vulnerability-based rule. + * + *

See {@link #createVulnerabilityNotificationRuleWithHttpInfoAsync}. + * + * @param body The body of the create notification rule request is composed of the rule type and + * the rule attributes: the rule name, the selectors, the notification targets, and the rule + * enabled status. (required) + * @return CompletableFuture<NotificationRuleResponse> + */ + public CompletableFuture createVulnerabilityNotificationRuleAsync( + CreateNotificationRuleParameters body) { + return createVulnerabilityNotificationRuleWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create a new notification rule for security vulnerabilities and return the created rule. + * + * @param body The body of the create notification rule request is composed of the rule type and + * the rule attributes: the rule name, the selectors, the notification targets, and the rule + * enabled status. (required) + * @return ApiResponse<NotificationRuleResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
201 Successfully created the notification rule -
400 Bad Request -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse createVulnerabilityNotificationRuleWithHttpInfo( + CreateNotificationRuleParameters body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, + "Missing the required parameter 'body' when calling createVulnerabilityNotificationRule"); + } + // create path and map variables + String localVarPath = "/api/v2/security/vulnerabilities/notification_rules"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.createVulnerabilityNotificationRule", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Create a new vulnerability-based rule. + * + *

See {@link #createVulnerabilityNotificationRuleWithHttpInfo}. + * + * @param body The body of the create notification rule request is composed of the rule type and + * the rule attributes: the rule name, the selectors, the notification targets, and the rule + * enabled status. (required) + * @return CompletableFuture<ApiResponse<NotificationRuleResponse>> + */ + public CompletableFuture> + createVulnerabilityNotificationRuleWithHttpInfoAsync(CreateNotificationRuleParameters body) { + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " createVulnerabilityNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/security/vulnerabilities/notification_rules"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.createVulnerabilityNotificationRule", + localVarPath, + new ArrayList(), + 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( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Delete an existing job. * @@ -1670,33 +1959,27 @@ public CompletableFuture> deleteSecurityMonitoringSuppressionW } /** - * Modify the triage assignee of a security signal. + * Delete a signal-based rule. * - *

See {@link #editSecurityMonitoringSignalAssigneeWithHttpInfo}. + *

See {@link #deleteSignalNotificationRuleWithHttpInfo}. * - * @param signalId The ID of the signal. (required) - * @param body Attributes describing the signal update. (required) - * @return SecurityMonitoringSignalTriageUpdateResponse + * @param id ID of the notification rule (required) * @throws ApiException if fails to make API call */ - public SecurityMonitoringSignalTriageUpdateResponse editSecurityMonitoringSignalAssignee( - String signalId, SecurityMonitoringSignalAssigneeUpdateRequest body) throws ApiException { - return editSecurityMonitoringSignalAssigneeWithHttpInfo(signalId, body).getData(); + public void deleteSignalNotificationRule(String id) throws ApiException { + deleteSignalNotificationRuleWithHttpInfo(id); } /** - * Modify the triage assignee of a security signal. + * Delete a signal-based rule. * - *

See {@link #editSecurityMonitoringSignalAssigneeWithHttpInfoAsync}. + *

See {@link #deleteSignalNotificationRuleWithHttpInfoAsync}. * - * @param signalId The ID of the signal. (required) - * @param body Attributes describing the signal update. (required) - * @return CompletableFuture<SecurityMonitoringSignalTriageUpdateResponse> + * @param id ID of the notification rule (required) + * @return CompletableFuture */ - public CompletableFuture - editSecurityMonitoringSignalAssigneeAsync( - String signalId, SecurityMonitoringSignalAssigneeUpdateRequest body) { - return editSecurityMonitoringSignalAssigneeWithHttpInfoAsync(signalId, body) + public CompletableFuture deleteSignalNotificationRuleAsync(String id) { + return deleteSignalNotificationRuleWithHttpInfoAsync(id) .thenApply( response -> { return response.getData(); @@ -1704,74 +1987,351 @@ public SecurityMonitoringSignalTriageUpdateResponse editSecurityMonitoringSignal } /** - * Modify the triage assignee of a security signal. + * Delete a notification rule for security signals. * - * @param signalId The ID of the signal. (required) - * @param body Attributes describing the signal update. (required) - * @return ApiResponse<SecurityMonitoringSignalTriageUpdateResponse> + * @param id ID of the notification rule (required) + * @return ApiResponse<Void> * @throws ApiException if fails to make API call * @http.response.details * * * - * - * + * * * * *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
204 Rule successfully deleted -
403 Forbidden -
404 Not Found -
429 Too many requests -
*/ - public ApiResponse - editSecurityMonitoringSignalAssigneeWithHttpInfo( - String signalId, SecurityMonitoringSignalAssigneeUpdateRequest body) throws ApiException { - Object localVarPostBody = body; - - // verify the required parameter 'signalId' is set - if (signalId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'signalId' when calling" - + " editSecurityMonitoringSignalAssignee"); - } + public ApiResponse deleteSignalNotificationRuleWithHttpInfo(String id) throws ApiException { + Object localVarPostBody = null; - // verify the required parameter 'body' is set - if (body == null) { + // verify the required parameter 'id' is set + if (id == null) { throw new ApiException( - 400, - "Missing the required parameter 'body' when calling" - + " editSecurityMonitoringSignalAssignee"); + 400, "Missing the required parameter 'id' when calling deleteSignalNotificationRule"); } // create path and map variables String localVarPath = - "/api/v2/security_monitoring/signals/{signal_id}/assignee" - .replaceAll("\\{" + "signal_id" + "\\}", apiClient.escapeString(signalId.toString())); + "/api/v2/security/signals/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); Map localVarHeaderParams = new HashMap(); Invocation.Builder builder = apiClient.createBuilder( - "v2.SecurityMonitoringApi.editSecurityMonitoringSignalAssignee", + "v2.SecurityMonitoringApi.deleteSignalNotificationRule", localVarPath, new ArrayList(), localVarHeaderParams, new HashMap(), - new String[] {"application/json"}, - new String[] {"apiKeyAuth", "appKeyAuth"}); + new String[] {"*/*"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); return apiClient.invokeAPI( - "PATCH", + "DELETE", builder, localVarHeaderParams, - new String[] {"application/json"}, + new String[] {}, localVarPostBody, new HashMap(), false, - new GenericType() {}); + null); } /** - * Modify the triage assignee of a security signal. + * Delete a signal-based rule. * - *

See {@link #editSecurityMonitoringSignalAssigneeWithHttpInfo}. + *

See {@link #deleteSignalNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteSignalNotificationRuleWithHttpInfoAsync( + String id) { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'id' when calling deleteSignalNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security/signals/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.deleteSignalNotificationRule", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete a vulnerability-based rule. + * + *

See {@link #deleteVulnerabilityNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @throws ApiException if fails to make API call + */ + public void deleteVulnerabilityNotificationRule(String id) throws ApiException { + deleteVulnerabilityNotificationRuleWithHttpInfo(id); + } + + /** + * Delete a vulnerability-based rule. + * + *

See {@link #deleteVulnerabilityNotificationRuleWithHttpInfoAsync}. + * + * @param id ID of the notification rule (required) + * @return CompletableFuture + */ + public CompletableFuture deleteVulnerabilityNotificationRuleAsync(String id) { + return deleteVulnerabilityNotificationRuleWithHttpInfoAsync(id) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Delete a notification rule for security vulnerabilities. + * + * @param id ID of the notification rule (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 Rule successfully deleted -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse deleteVulnerabilityNotificationRuleWithHttpInfo(String id) + throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException( + 400, + "Missing the required parameter 'id' when calling deleteVulnerabilityNotificationRule"); + } + // create path and map variables + String localVarPath = + "/api/v2/security/vulnerabilities/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.deleteVulnerabilityNotificationRule", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete a vulnerability-based rule. + * + *

See {@link #deleteVulnerabilityNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteVulnerabilityNotificationRuleWithHttpInfoAsync( + String id) { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'id' when calling" + + " deleteVulnerabilityNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security/vulnerabilities/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.deleteVulnerabilityNotificationRule", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Modify the triage assignee of a security signal. + * + *

See {@link #editSecurityMonitoringSignalAssigneeWithHttpInfo}. + * + * @param signalId The ID of the signal. (required) + * @param body Attributes describing the signal update. (required) + * @return SecurityMonitoringSignalTriageUpdateResponse + * @throws ApiException if fails to make API call + */ + public SecurityMonitoringSignalTriageUpdateResponse editSecurityMonitoringSignalAssignee( + String signalId, SecurityMonitoringSignalAssigneeUpdateRequest body) throws ApiException { + return editSecurityMonitoringSignalAssigneeWithHttpInfo(signalId, body).getData(); + } + + /** + * Modify the triage assignee of a security signal. + * + *

See {@link #editSecurityMonitoringSignalAssigneeWithHttpInfoAsync}. + * + * @param signalId The ID of the signal. (required) + * @param body Attributes describing the signal update. (required) + * @return CompletableFuture<SecurityMonitoringSignalTriageUpdateResponse> + */ + public CompletableFuture + editSecurityMonitoringSignalAssigneeAsync( + String signalId, SecurityMonitoringSignalAssigneeUpdateRequest body) { + return editSecurityMonitoringSignalAssigneeWithHttpInfoAsync(signalId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Modify the triage assignee of a security signal. + * + * @param signalId The ID of the signal. (required) + * @param body Attributes describing the signal update. (required) + * @return ApiResponse<SecurityMonitoringSignalTriageUpdateResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse + editSecurityMonitoringSignalAssigneeWithHttpInfo( + String signalId, SecurityMonitoringSignalAssigneeUpdateRequest body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'signalId' is set + if (signalId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'signalId' when calling" + + " editSecurityMonitoringSignalAssignee"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " editSecurityMonitoringSignalAssignee"); + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/signals/{signal_id}/assignee" + .replaceAll("\\{" + "signal_id" + "\\}", apiClient.escapeString(signalId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.editSecurityMonitoringSignalAssignee", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Modify the triage assignee of a security signal. + * + *

See {@link #editSecurityMonitoringSignalAssigneeWithHttpInfo}. * * @param signalId The ID of the signal. (required) * @param body Attributes describing the signal update. (required) @@ -3064,33 +3624,527 @@ public SecurityMonitoringSuppressionResponse getSecurityMonitoringSuppression( } /** - * Get a suppression rule. + * Get a suppression rule. + * + *

See {@link #getSecurityMonitoringSuppressionWithHttpInfo}. + * + * @param suppressionId The ID of the suppression rule (required) + * @return CompletableFuture<ApiResponse<SecurityMonitoringSuppressionResponse>> + */ + public CompletableFuture> + getSecurityMonitoringSuppressionWithHttpInfoAsync(String suppressionId) { + Object localVarPostBody = null; + + // verify the required parameter 'suppressionId' is set + if (suppressionId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'suppressionId' when calling" + + " getSecurityMonitoringSuppression")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/configuration/suppressions/{suppression_id}" + .replaceAll( + "\\{" + "suppression_id" + "\\}", apiClient.escapeString(suppressionId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getSecurityMonitoringSuppression", + localVarPath, + new ArrayList(), + 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() {}); + } + + /** + * Get details of a signal-based rule. + * + *

See {@link #getSignalNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @return NotificationRuleResponse + * @throws ApiException if fails to make API call + */ + public NotificationRuleResponse getSignalNotificationRule(String id) throws ApiException { + return getSignalNotificationRuleWithHttpInfo(id).getData(); + } + + /** + * Get details of a signal-based rule. + * + *

See {@link #getSignalNotificationRuleWithHttpInfoAsync}. + * + * @param id ID of the notification rule (required) + * @return CompletableFuture<NotificationRuleResponse> + */ + public CompletableFuture getSignalNotificationRuleAsync(String id) { + return getSignalNotificationRuleWithHttpInfoAsync(id) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get the details of a notification rule for security signals. + * + * @param id ID of the notification rule (required) + * @return ApiResponse<NotificationRuleResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 Notification rule details -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getSignalNotificationRuleWithHttpInfo(String id) + throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException( + 400, "Missing the required parameter 'id' when calling getSignalNotificationRule"); + } + // create path and map variables + String localVarPath = + "/api/v2/security/signals/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getSignalNotificationRule", + localVarPath, + new ArrayList(), + 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 details of a signal-based rule. + * + *

See {@link #getSignalNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @return CompletableFuture<ApiResponse<NotificationRuleResponse>> + */ + public CompletableFuture> + getSignalNotificationRuleWithHttpInfoAsync(String id) { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'id' when calling getSignalNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security/signals/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getSignalNotificationRule", + localVarPath, + new ArrayList(), + 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() {}); + } + + /** + * Get the list of signal-based rules. + * + *

See {@link #getSignalNotificationRulesWithHttpInfo}. + * + * @return Object + * @throws ApiException if fails to make API call + */ + public Object getSignalNotificationRules() throws ApiException { + return getSignalNotificationRulesWithHttpInfo().getData(); + } + + /** + * Get the list of signal-based rules. + * + *

See {@link #getSignalNotificationRulesWithHttpInfoAsync}. + * + * @return CompletableFuture<Object> + */ + public CompletableFuture getSignalNotificationRulesAsync() { + return getSignalNotificationRulesWithHttpInfoAsync() + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Returns the list of notification rules for security signals + * + * @return ApiResponse<Object> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 The list of notification rules -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse getSignalNotificationRulesWithHttpInfo() throws ApiException { + Object localVarPostBody = null; + // create path and map variables + String localVarPath = "/api/v2/security/signals/notification_rules"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getSignalNotificationRules", + localVarPath, + new ArrayList(), + 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 the list of signal-based rules. + * + *

See {@link #getSignalNotificationRulesWithHttpInfo}. + * + * @return CompletableFuture<ApiResponse<Object>> + */ + public CompletableFuture> getSignalNotificationRulesWithHttpInfoAsync() { + Object localVarPostBody = null; + // create path and map variables + String localVarPath = "/api/v2/security/signals/notification_rules"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getSignalNotificationRules", + localVarPath, + new ArrayList(), + 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() {}); + } + + /** + * Get details of a vulnerability-based rule. + * + *

See {@link #getVulnerabilityNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @return NotificationRuleResponse + * @throws ApiException if fails to make API call + */ + public NotificationRuleResponse getVulnerabilityNotificationRule(String id) throws ApiException { + return getVulnerabilityNotificationRuleWithHttpInfo(id).getData(); + } + + /** + * Get details of a vulnerability-based rule. + * + *

See {@link #getVulnerabilityNotificationRuleWithHttpInfoAsync}. + * + * @param id ID of the notification rule (required) + * @return CompletableFuture<NotificationRuleResponse> + */ + public CompletableFuture getVulnerabilityNotificationRuleAsync( + String id) { + return getVulnerabilityNotificationRuleWithHttpInfoAsync(id) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get the details of a notification rule for security vulnerabilities. + * + * @param id ID of the notification rule (required) + * @return ApiResponse<NotificationRuleResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 Notification rule details -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getVulnerabilityNotificationRuleWithHttpInfo( + String id) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException( + 400, "Missing the required parameter 'id' when calling getVulnerabilityNotificationRule"); + } + // create path and map variables + String localVarPath = + "/api/v2/security/vulnerabilities/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getVulnerabilityNotificationRule", + localVarPath, + new ArrayList(), + 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 details of a vulnerability-based rule. + * + *

See {@link #getVulnerabilityNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @return CompletableFuture<ApiResponse<NotificationRuleResponse>> + */ + public CompletableFuture> + getVulnerabilityNotificationRuleWithHttpInfoAsync(String id) { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'id' when calling getVulnerabilityNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security/vulnerabilities/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getVulnerabilityNotificationRule", + localVarPath, + new ArrayList(), + 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() {}); + } + + /** + * Get the list of vulnerability-based rules. + * + *

See {@link #getVulnerabilityNotificationRulesWithHttpInfo}. + * + * @return Object + * @throws ApiException if fails to make API call + */ + public Object getVulnerabilityNotificationRules() throws ApiException { + return getVulnerabilityNotificationRulesWithHttpInfo().getData(); + } + + /** + * Get the list of vulnerability-based rules. + * + *

See {@link #getVulnerabilityNotificationRulesWithHttpInfoAsync}. + * + * @return CompletableFuture<Object> + */ + public CompletableFuture getVulnerabilityNotificationRulesAsync() { + return getVulnerabilityNotificationRulesWithHttpInfoAsync() + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Returns the list of notification rules for security vulnerabilities + * + * @return ApiResponse<Object> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 The list of notification rules -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse getVulnerabilityNotificationRulesWithHttpInfo() throws ApiException { + Object localVarPostBody = null; + // create path and map variables + String localVarPath = "/api/v2/security/vulnerabilities/notification_rules"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.getVulnerabilityNotificationRules", + localVarPath, + new ArrayList(), + 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 the list of vulnerability-based rules. * - *

See {@link #getSecurityMonitoringSuppressionWithHttpInfo}. + *

See {@link #getVulnerabilityNotificationRulesWithHttpInfo}. * - * @param suppressionId The ID of the suppression rule (required) - * @return CompletableFuture<ApiResponse<SecurityMonitoringSuppressionResponse>> + * @return CompletableFuture<ApiResponse<Object>> */ - public CompletableFuture> - getSecurityMonitoringSuppressionWithHttpInfoAsync(String suppressionId) { + public CompletableFuture> + getVulnerabilityNotificationRulesWithHttpInfoAsync() { Object localVarPostBody = null; - - // verify the required parameter 'suppressionId' is set - if (suppressionId == null) { - CompletableFuture> result = - new CompletableFuture<>(); - result.completeExceptionally( - new ApiException( - 400, - "Missing the required parameter 'suppressionId' when calling" - + " getSecurityMonitoringSuppression")); - return result; - } // create path and map variables - String localVarPath = - "/api/v2/security_monitoring/configuration/suppressions/{suppression_id}" - .replaceAll( - "\\{" + "suppression_id" + "\\}", apiClient.escapeString(suppressionId.toString())); + String localVarPath = "/api/v2/security/vulnerabilities/notification_rules"; Map localVarHeaderParams = new HashMap(); @@ -3098,7 +4152,7 @@ public SecurityMonitoringSuppressionResponse getSecurityMonitoringSuppression( try { builder = apiClient.createBuilder( - "v2.SecurityMonitoringApi.getSecurityMonitoringSuppression", + "v2.SecurityMonitoringApi.getVulnerabilityNotificationRules", localVarPath, new ArrayList(), localVarHeaderParams, @@ -3106,8 +4160,7 @@ public SecurityMonitoringSuppressionResponse getSecurityMonitoringSuppression( new String[] {"application/json"}, new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); } catch (ApiException ex) { - CompletableFuture> result = - new CompletableFuture<>(); + CompletableFuture> result = new CompletableFuture<>(); result.completeExceptionally(ex); return result; } @@ -3119,7 +4172,7 @@ public SecurityMonitoringSuppressionResponse getSecurityMonitoringSuppression( localVarPostBody, new HashMap(), false, - new GenericType() {}); + new GenericType() {}); } /** Manage optional parameters to listFindings. */ @@ -6317,6 +7370,333 @@ public CompletableFuture> muteFindingsWith new GenericType() {}); } + /** + * Patch a signal-based rule. + * + *

See {@link #patchSignalNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @param body (required) + * @return NotificationRuleResponse + * @throws ApiException if fails to make API call + */ + public NotificationRuleResponse patchSignalNotificationRule( + String id, PatchNotificationRuleParameters body) throws ApiException { + return patchSignalNotificationRuleWithHttpInfo(id, body).getData(); + } + + /** + * Patch a signal-based rule. + * + *

See {@link #patchSignalNotificationRuleWithHttpInfoAsync}. + * + * @param id ID of the notification rule (required) + * @param body (required) + * @return CompletableFuture<NotificationRuleResponse> + */ + public CompletableFuture patchSignalNotificationRuleAsync( + String id, PatchNotificationRuleParameters body) { + return patchSignalNotificationRuleWithHttpInfoAsync(id, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Partially update the notification rule. All fields are optional; if a field is not provided, it + * will not be updated. + * + * @param id ID of the notification rule (required) + * @param body (required) + * @return ApiResponse<NotificationRuleResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 Notification rule successfully patched -
400 Bad Request -
403 Forbidden -
404 Not Found -
422 The server cannot process the request because it contains invalid data. -
429 Too many requests -
+ */ + public ApiResponse patchSignalNotificationRuleWithHttpInfo( + String id, PatchNotificationRuleParameters body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException( + 400, "Missing the required parameter 'id' when calling patchSignalNotificationRule"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling patchSignalNotificationRule"); + } + // create path and map variables + String localVarPath = + "/api/v2/security/signals/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.patchSignalNotificationRule", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Patch a signal-based rule. + * + *

See {@link #patchSignalNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<NotificationRuleResponse>> + */ + public CompletableFuture> + patchSignalNotificationRuleWithHttpInfoAsync( + String id, PatchNotificationRuleParameters body) { + Object localVarPostBody = body; + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'id' when calling patchSignalNotificationRule")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling patchSignalNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security/signals/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.patchSignalNotificationRule", + localVarPath, + new ArrayList(), + 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( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Patch a vulnerability-based rule. + * + *

See {@link #patchVulnerabilityNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @param body (required) + * @return NotificationRuleResponse + * @throws ApiException if fails to make API call + */ + public NotificationRuleResponse patchVulnerabilityNotificationRule( + String id, PatchNotificationRuleParameters body) throws ApiException { + return patchVulnerabilityNotificationRuleWithHttpInfo(id, body).getData(); + } + + /** + * Patch a vulnerability-based rule. + * + *

See {@link #patchVulnerabilityNotificationRuleWithHttpInfoAsync}. + * + * @param id ID of the notification rule (required) + * @param body (required) + * @return CompletableFuture<NotificationRuleResponse> + */ + public CompletableFuture patchVulnerabilityNotificationRuleAsync( + String id, PatchNotificationRuleParameters body) { + return patchVulnerabilityNotificationRuleWithHttpInfoAsync(id, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Partially update the notification rule. All fields are optional; if a field is not provided, it + * will not be updated. + * + * @param id ID of the notification rule (required) + * @param body (required) + * @return ApiResponse<NotificationRuleResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 Notification rule successfully patched -
400 Bad Request -
403 Forbidden -
404 Not Found -
422 The server cannot process the request because it contains invalid data. -
429 Too many requests -
+ */ + public ApiResponse patchVulnerabilityNotificationRuleWithHttpInfo( + String id, PatchNotificationRuleParameters body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException( + 400, + "Missing the required parameter 'id' when calling patchVulnerabilityNotificationRule"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, + "Missing the required parameter 'body' when calling patchVulnerabilityNotificationRule"); + } + // create path and map variables + String localVarPath = + "/api/v2/security/vulnerabilities/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.patchVulnerabilityNotificationRule", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Patch a vulnerability-based rule. + * + *

See {@link #patchVulnerabilityNotificationRuleWithHttpInfo}. + * + * @param id ID of the notification rule (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<NotificationRuleResponse>> + */ + public CompletableFuture> + patchVulnerabilityNotificationRuleWithHttpInfoAsync( + String id, PatchNotificationRuleParameters body) { + Object localVarPostBody = body; + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'id' when calling" + + " patchVulnerabilityNotificationRule")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " patchVulnerabilityNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security/vulnerabilities/notification_rules/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.patchVulnerabilityNotificationRule", + localVarPath, + new ArrayList(), + 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( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Run a historical job. * diff --git a/src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParameters.java b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParameters.java new file mode 100644 index 00000000000..f8f58766a39 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParameters.java @@ -0,0 +1,139 @@ +/* + * 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; + +/** Body of the notification rule create request */ +@JsonPropertyOrder({CreateNotificationRuleParameters.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateNotificationRuleParameters { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private CreateNotificationRuleParametersData data; + + public CreateNotificationRuleParameters data(CreateNotificationRuleParametersData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data of the notification rule create request: the rule type, and the rule attributes. All + * fields are required. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public CreateNotificationRuleParametersData getData() { + return data; + } + + public void setData(CreateNotificationRuleParametersData 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 CreateNotificationRuleParameters + */ + @JsonAnySetter + public CreateNotificationRuleParameters 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 CreateNotificationRuleParameters object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateNotificationRuleParameters createNotificationRuleParameters = + (CreateNotificationRuleParameters) o; + return Objects.equals(this.data, createNotificationRuleParameters.data) + && Objects.equals( + this.additionalProperties, createNotificationRuleParameters.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationRuleParameters {\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/CreateNotificationRuleParametersData.java b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParametersData.java new file mode 100644 index 00000000000..d0642b66bd7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParametersData.java @@ -0,0 +1,187 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Data of the notification rule create request: the rule type, and the rule attributes. All fields + * are required. + */ +@JsonPropertyOrder({ + CreateNotificationRuleParametersData.JSON_PROPERTY_ATTRIBUTES, + CreateNotificationRuleParametersData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateNotificationRuleParametersData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private CreateNotificationRuleParametersDataAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationRulesType type; + + public CreateNotificationRuleParametersData() {} + + @JsonCreator + public CreateNotificationRuleParametersData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + CreateNotificationRuleParametersDataAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) NotificationRulesType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public CreateNotificationRuleParametersData attributes( + CreateNotificationRuleParametersDataAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of the notification rule create request. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public CreateNotificationRuleParametersDataAttributes getAttributes() { + return attributes; + } + + public void setAttributes(CreateNotificationRuleParametersDataAttributes attributes) { + this.attributes = attributes; + } + + public CreateNotificationRuleParametersData type(NotificationRulesType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The rule type associated to notification rules + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationRulesType getType() { + return type; + } + + public void setType(NotificationRulesType 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 CreateNotificationRuleParametersData + */ + @JsonAnySetter + public CreateNotificationRuleParametersData 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 CreateNotificationRuleParametersData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateNotificationRuleParametersData createNotificationRuleParametersData = + (CreateNotificationRuleParametersData) o; + return Objects.equals(this.attributes, createNotificationRuleParametersData.attributes) + && Objects.equals(this.type, createNotificationRuleParametersData.type) + && Objects.equals( + this.additionalProperties, createNotificationRuleParametersData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationRuleParametersData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).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/CreateNotificationRuleParametersDataAttributes.java b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParametersDataAttributes.java new file mode 100644 index 00000000000..91003b5ada8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationRuleParametersDataAttributes.java @@ -0,0 +1,277 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Attributes of the notification rule create request. */ +@JsonPropertyOrder({ + CreateNotificationRuleParametersDataAttributes.JSON_PROPERTY_ENABLED, + CreateNotificationRuleParametersDataAttributes.JSON_PROPERTY_NAME, + CreateNotificationRuleParametersDataAttributes.JSON_PROPERTY_SELECTORS, + CreateNotificationRuleParametersDataAttributes.JSON_PROPERTY_TARGETS, + CreateNotificationRuleParametersDataAttributes.JSON_PROPERTY_TIME_AGGREGATION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateNotificationRuleParametersDataAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ENABLED = "enabled"; + private Boolean enabled; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SELECTORS = "selectors"; + private Selectors selectors; + + public static final String JSON_PROPERTY_TARGETS = "targets"; + private List targets = new ArrayList<>(); + + public static final String JSON_PROPERTY_TIME_AGGREGATION = "time_aggregation"; + private Long timeAggregation; + + public CreateNotificationRuleParametersDataAttributes() {} + + @JsonCreator + public CreateNotificationRuleParametersDataAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_SELECTORS) Selectors selectors, + @JsonProperty(required = true, value = JSON_PROPERTY_TARGETS) List targets) { + this.name = name; + this.selectors = selectors; + this.unparsed |= selectors.unparsed; + this.targets = targets; + } + + public CreateNotificationRuleParametersDataAttributes enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Field used to enable or disable the rule. + * + * @return enabled + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public CreateNotificationRuleParametersDataAttributes name(String name) { + this.name = name; + return this; + } + + /** + * Name of the notification rule + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CreateNotificationRuleParametersDataAttributes selectors(Selectors selectors) { + this.selectors = selectors; + this.unparsed |= selectors.unparsed; + return this; + } + + /** + * Selectors are used to filter security issues for which notifications should be generated. Users + * can specify rule severities, rule types, a query to filter security issues on tags and + * attributes, and the trigger source. Only the trigger_source field is required. + * + * @return selectors + */ + @JsonProperty(JSON_PROPERTY_SELECTORS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Selectors getSelectors() { + return selectors; + } + + public void setSelectors(Selectors selectors) { + this.selectors = selectors; + } + + public CreateNotificationRuleParametersDataAttributes targets(List targets) { + this.targets = targets; + return this; + } + + public CreateNotificationRuleParametersDataAttributes addTargetsItem(String targetsItem) { + this.targets.add(targetsItem); + return this; + } + + /** + * List of recipients to notify when a notification rule is triggered. Many different target types + * are supported, such as email addresses, Slack channels, and PagerDuty services. The appropriate + * integrations need to be properly configured to send notifications to the specified targets. + * + * @return targets + */ + @JsonProperty(JSON_PROPERTY_TARGETS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + } + + public CreateNotificationRuleParametersDataAttributes timeAggregation(Long timeAggregation) { + this.timeAggregation = timeAggregation; + return this; + } + + /** + * Time aggregation period (in seconds) is used to aggregate the results of the notification rule + * evaluation. Results are aggregated over a selected time frame using a rolling window, which + * updates with each new evaluation. Notifications will only be sent for new issues discovered + * during the window. Time aggregation is only available for vulnerability-based notification + * rules. When omitted or set to 0, no aggregation is done. + * + * @return timeAggregation + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIME_AGGREGATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getTimeAggregation() { + return timeAggregation; + } + + public void setTimeAggregation(Long timeAggregation) { + this.timeAggregation = timeAggregation; + } + + /** + * 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 CreateNotificationRuleParametersDataAttributes + */ + @JsonAnySetter + public CreateNotificationRuleParametersDataAttributes 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 CreateNotificationRuleParametersDataAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateNotificationRuleParametersDataAttributes createNotificationRuleParametersDataAttributes = + (CreateNotificationRuleParametersDataAttributes) o; + return Objects.equals(this.enabled, createNotificationRuleParametersDataAttributes.enabled) + && Objects.equals(this.name, createNotificationRuleParametersDataAttributes.name) + && Objects.equals(this.selectors, createNotificationRuleParametersDataAttributes.selectors) + && Objects.equals(this.targets, createNotificationRuleParametersDataAttributes.targets) + && Objects.equals( + this.timeAggregation, createNotificationRuleParametersDataAttributes.timeAggregation) + && Objects.equals( + this.additionalProperties, + createNotificationRuleParametersDataAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, name, selectors, targets, timeAggregation, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationRuleParametersDataAttributes {\n"); + sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" selectors: ").append(toIndentedString(selectors)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" timeAggregation: ").append(toIndentedString(timeAggregation)).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/NotificationRule.java b/src/main/java/com/datadog/api/client/v2/model/NotificationRule.java new file mode 100644 index 00000000000..ddde5e5ab05 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationRule.java @@ -0,0 +1,215 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Notification rules allow full control over notifications generated by the various Datadog + * security products. They allow user to define the conditions under which a notification should be + * generated (based on rule severities, rule types, rule tags, etc..), and the targets to notify. A + * notification rule is composed of a rule id, a rule type, and the rule attributes. All fields are + * required. + */ +@JsonPropertyOrder({ + NotificationRule.JSON_PROPERTY_ATTRIBUTES, + NotificationRule.JSON_PROPERTY_ID, + NotificationRule.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationRule { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private NotificationRuleAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationRulesType type; + + public NotificationRule() {} + + @JsonCreator + public NotificationRule( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + NotificationRuleAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) NotificationRulesType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public NotificationRule attributes(NotificationRuleAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of the notification rule + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationRuleAttributes getAttributes() { + return attributes; + } + + public void setAttributes(NotificationRuleAttributes attributes) { + this.attributes = attributes; + } + + public NotificationRule id(String id) { + this.id = id; + return this; + } + + /** + * The ID of a notification rule + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public NotificationRule type(NotificationRulesType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The rule type associated to notification rules + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationRulesType getType() { + return type; + } + + public void setType(NotificationRulesType 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 NotificationRule + */ + @JsonAnySetter + public NotificationRule 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 NotificationRule object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationRule notificationRule = (NotificationRule) o; + return Objects.equals(this.attributes, notificationRule.attributes) + && Objects.equals(this.id, notificationRule.id) + && Objects.equals(this.type, notificationRule.type) + && Objects.equals(this.additionalProperties, notificationRule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationRule {\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/NotificationRuleAttributes.java b/src/main/java/com/datadog/api/client/v2/model/NotificationRuleAttributes.java new file mode 100644 index 00000000000..3c3f3c9bf65 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationRuleAttributes.java @@ -0,0 +1,429 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Attributes of the notification rule */ +@JsonPropertyOrder({ + NotificationRuleAttributes.JSON_PROPERTY_CREATED_AT, + NotificationRuleAttributes.JSON_PROPERTY_CREATED_BY, + NotificationRuleAttributes.JSON_PROPERTY_ENABLED, + NotificationRuleAttributes.JSON_PROPERTY_MODIFIED_AT, + NotificationRuleAttributes.JSON_PROPERTY_MODIFIED_BY, + NotificationRuleAttributes.JSON_PROPERTY_NAME, + NotificationRuleAttributes.JSON_PROPERTY_SELECTORS, + NotificationRuleAttributes.JSON_PROPERTY_TARGETS, + NotificationRuleAttributes.JSON_PROPERTY_TIME_AGGREGATION, + NotificationRuleAttributes.JSON_PROPERTY_VERSION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationRuleAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private Long createdAt; + + public static final String JSON_PROPERTY_CREATED_BY = "created_by"; + private RuleUser createdBy; + + public static final String JSON_PROPERTY_ENABLED = "enabled"; + private Boolean enabled; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + private Long modifiedAt; + + public static final String JSON_PROPERTY_MODIFIED_BY = "modified_by"; + private RuleUser modifiedBy; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SELECTORS = "selectors"; + private Selectors selectors; + + public static final String JSON_PROPERTY_TARGETS = "targets"; + private List targets = new ArrayList<>(); + + public static final String JSON_PROPERTY_TIME_AGGREGATION = "time_aggregation"; + private Long timeAggregation; + + public static final String JSON_PROPERTY_VERSION = "version"; + private Long version; + + public NotificationRuleAttributes() {} + + @JsonCreator + public NotificationRuleAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_CREATED_AT) Long createdAt, + @JsonProperty(required = true, value = JSON_PROPERTY_CREATED_BY) RuleUser createdBy, + @JsonProperty(required = true, value = JSON_PROPERTY_ENABLED) Boolean enabled, + @JsonProperty(required = true, value = JSON_PROPERTY_MODIFIED_AT) Long modifiedAt, + @JsonProperty(required = true, value = JSON_PROPERTY_MODIFIED_BY) RuleUser modifiedBy, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_SELECTORS) Selectors selectors, + @JsonProperty(required = true, value = JSON_PROPERTY_TARGETS) List targets, + @JsonProperty(required = true, value = JSON_PROPERTY_VERSION) Long version) { + this.createdAt = createdAt; + this.createdBy = createdBy; + this.unparsed |= createdBy.unparsed; + this.enabled = enabled; + this.modifiedAt = modifiedAt; + this.modifiedBy = modifiedBy; + this.unparsed |= modifiedBy.unparsed; + this.name = name; + this.selectors = selectors; + this.unparsed |= selectors.unparsed; + this.targets = targets; + this.version = version; + } + + public NotificationRuleAttributes createdAt(Long createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Date as Unix timestamp in milliseconds + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Long createdAt) { + this.createdAt = createdAt; + } + + public NotificationRuleAttributes createdBy(RuleUser createdBy) { + this.createdBy = createdBy; + this.unparsed |= createdBy.unparsed; + return this; + } + + /** + * User creating or modifying a rule + * + * @return createdBy + */ + @JsonProperty(JSON_PROPERTY_CREATED_BY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public RuleUser getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(RuleUser createdBy) { + this.createdBy = createdBy; + } + + public NotificationRuleAttributes enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Field used to enable or disable the rule. + * + * @return enabled + */ + @JsonProperty(JSON_PROPERTY_ENABLED) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public NotificationRuleAttributes modifiedAt(Long modifiedAt) { + this.modifiedAt = modifiedAt; + return this; + } + + /** + * Date as Unix timestamp in milliseconds + * + * @return modifiedAt + */ + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getModifiedAt() { + return modifiedAt; + } + + public void setModifiedAt(Long modifiedAt) { + this.modifiedAt = modifiedAt; + } + + public NotificationRuleAttributes modifiedBy(RuleUser modifiedBy) { + this.modifiedBy = modifiedBy; + this.unparsed |= modifiedBy.unparsed; + return this; + } + + /** + * User creating or modifying a rule + * + * @return modifiedBy + */ + @JsonProperty(JSON_PROPERTY_MODIFIED_BY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public RuleUser getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(RuleUser modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public NotificationRuleAttributes name(String name) { + this.name = name; + return this; + } + + /** + * Name of the notification rule + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public NotificationRuleAttributes selectors(Selectors selectors) { + this.selectors = selectors; + this.unparsed |= selectors.unparsed; + return this; + } + + /** + * Selectors are used to filter security issues for which notifications should be generated. Users + * can specify rule severities, rule types, a query to filter security issues on tags and + * attributes, and the trigger source. Only the trigger_source field is required. + * + * @return selectors + */ + @JsonProperty(JSON_PROPERTY_SELECTORS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Selectors getSelectors() { + return selectors; + } + + public void setSelectors(Selectors selectors) { + this.selectors = selectors; + } + + public NotificationRuleAttributes targets(List targets) { + this.targets = targets; + return this; + } + + public NotificationRuleAttributes addTargetsItem(String targetsItem) { + this.targets.add(targetsItem); + return this; + } + + /** + * List of recipients to notify when a notification rule is triggered. Many different target types + * are supported, such as email addresses, Slack channels, and PagerDuty services. The appropriate + * integrations need to be properly configured to send notifications to the specified targets. + * + * @return targets + */ + @JsonProperty(JSON_PROPERTY_TARGETS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + } + + public NotificationRuleAttributes timeAggregation(Long timeAggregation) { + this.timeAggregation = timeAggregation; + return this; + } + + /** + * Time aggregation period (in seconds) is used to aggregate the results of the notification rule + * evaluation. Results are aggregated over a selected time frame using a rolling window, which + * updates with each new evaluation. Notifications will only be sent for new issues discovered + * during the window. Time aggregation is only available for vulnerability-based notification + * rules. When omitted or set to 0, no aggregation is done. + * + * @return timeAggregation + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIME_AGGREGATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getTimeAggregation() { + return timeAggregation; + } + + public void setTimeAggregation(Long timeAggregation) { + this.timeAggregation = timeAggregation; + } + + public NotificationRuleAttributes version(Long version) { + this.version = version; + return this; + } + + /** + * Version of the notification rule. It is updated when the rule is modified. + * + * @return version + */ + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getVersion() { + return version; + } + + public void setVersion(Long version) { + this.version = version; + } + + /** + * 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 NotificationRuleAttributes + */ + @JsonAnySetter + public NotificationRuleAttributes 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 NotificationRuleAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationRuleAttributes notificationRuleAttributes = (NotificationRuleAttributes) o; + return Objects.equals(this.createdAt, notificationRuleAttributes.createdAt) + && Objects.equals(this.createdBy, notificationRuleAttributes.createdBy) + && Objects.equals(this.enabled, notificationRuleAttributes.enabled) + && Objects.equals(this.modifiedAt, notificationRuleAttributes.modifiedAt) + && Objects.equals(this.modifiedBy, notificationRuleAttributes.modifiedBy) + && Objects.equals(this.name, notificationRuleAttributes.name) + && Objects.equals(this.selectors, notificationRuleAttributes.selectors) + && Objects.equals(this.targets, notificationRuleAttributes.targets) + && Objects.equals(this.timeAggregation, notificationRuleAttributes.timeAggregation) + && Objects.equals(this.version, notificationRuleAttributes.version) + && Objects.equals( + this.additionalProperties, notificationRuleAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + createdAt, + createdBy, + enabled, + modifiedAt, + modifiedBy, + name, + selectors, + targets, + timeAggregation, + version, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationRuleAttributes {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" createdBy: ").append(toIndentedString(createdBy)).append("\n"); + sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); + sb.append(" modifiedBy: ").append(toIndentedString(modifiedBy)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" selectors: ").append(toIndentedString(selectors)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" timeAggregation: ").append(toIndentedString(timeAggregation)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).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/NotificationRuleResponse.java b/src/main/java/com/datadog/api/client/v2/model/NotificationRuleResponse.java new file mode 100644 index 00000000000..733bc078f44 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationRuleResponse.java @@ -0,0 +1,140 @@ +/* + * 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 which includes a notification rule. */ +@JsonPropertyOrder({NotificationRuleResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationRuleResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private NotificationRule data; + + public NotificationRuleResponse data(NotificationRule data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Notification rules allow full control over notifications generated by the various Datadog + * security products. They allow user to define the conditions under which a notification should + * be generated (based on rule severities, rule types, rule tags, etc..), and the targets to + * notify. A notification rule is composed of a rule id, a rule type, and the rule attributes. All + * fields are required. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NotificationRule getData() { + return data; + } + + public void setData(NotificationRule 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 NotificationRuleResponse + */ + @JsonAnySetter + public NotificationRuleResponse 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 NotificationRuleResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationRuleResponse notificationRuleResponse = (NotificationRuleResponse) o; + return Objects.equals(this.data, notificationRuleResponse.data) + && Objects.equals(this.additionalProperties, notificationRuleResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationRuleResponse {\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/NotificationRulesType.java b/src/main/java/com/datadog/api/client/v2/model/NotificationRulesType.java new file mode 100644 index 00000000000..3a3d1143ea1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationRulesType.java @@ -0,0 +1,56 @@ +/* + * 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 rule type associated to notification rules */ +@JsonSerialize(using = NotificationRulesType.NotificationRulesTypeSerializer.class) +public class NotificationRulesType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("notification_rules")); + + public static final NotificationRulesType NOTIFICATION_RULES = + new NotificationRulesType("notification_rules"); + + NotificationRulesType(String value) { + super(value, allowedValues); + } + + public static class NotificationRulesTypeSerializer extends StdSerializer { + public NotificationRulesTypeSerializer(Class t) { + super(t); + } + + public NotificationRulesTypeSerializer() { + this(null); + } + + @Override + public void serialize( + NotificationRulesType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static NotificationRulesType fromValue(String value) { + return new NotificationRulesType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParameters.java b/src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParameters.java new file mode 100644 index 00000000000..b89ff25e898 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParameters.java @@ -0,0 +1,139 @@ +/* + * 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; + +/** Body of the notification rule patch request */ +@JsonPropertyOrder({PatchNotificationRuleParameters.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PatchNotificationRuleParameters { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private PatchNotificationRuleParametersData data; + + public PatchNotificationRuleParameters data(PatchNotificationRuleParametersData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data of the notification rule patch request: the rule id, the rule type, and the rule + * attributes. All fields are required. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public PatchNotificationRuleParametersData getData() { + return data; + } + + public void setData(PatchNotificationRuleParametersData 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 PatchNotificationRuleParameters + */ + @JsonAnySetter + public PatchNotificationRuleParameters 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 PatchNotificationRuleParameters object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PatchNotificationRuleParameters patchNotificationRuleParameters = + (PatchNotificationRuleParameters) o; + return Objects.equals(this.data, patchNotificationRuleParameters.data) + && Objects.equals( + this.additionalProperties, patchNotificationRuleParameters.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PatchNotificationRuleParameters {\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/PatchNotificationRuleParametersData.java b/src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParametersData.java new file mode 100644 index 00000000000..fd23fddc140 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParametersData.java @@ -0,0 +1,216 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Data of the notification rule patch request: the rule id, the rule type, and the rule attributes. + * All fields are required. + */ +@JsonPropertyOrder({ + PatchNotificationRuleParametersData.JSON_PROPERTY_ATTRIBUTES, + PatchNotificationRuleParametersData.JSON_PROPERTY_ID, + PatchNotificationRuleParametersData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PatchNotificationRuleParametersData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private PatchNotificationRuleParametersDataAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationRulesType type; + + public PatchNotificationRuleParametersData() {} + + @JsonCreator + public PatchNotificationRuleParametersData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + PatchNotificationRuleParametersDataAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) NotificationRulesType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public PatchNotificationRuleParametersData attributes( + PatchNotificationRuleParametersDataAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of the notification rule patch request. It is required to update the version of the + * rule when patching it. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PatchNotificationRuleParametersDataAttributes getAttributes() { + return attributes; + } + + public void setAttributes(PatchNotificationRuleParametersDataAttributes attributes) { + this.attributes = attributes; + } + + public PatchNotificationRuleParametersData id(String id) { + this.id = id; + return this; + } + + /** + * The ID of a notification rule + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public PatchNotificationRuleParametersData type(NotificationRulesType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The rule type associated to notification rules + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationRulesType getType() { + return type; + } + + public void setType(NotificationRulesType 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 PatchNotificationRuleParametersData + */ + @JsonAnySetter + public PatchNotificationRuleParametersData 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 PatchNotificationRuleParametersData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PatchNotificationRuleParametersData patchNotificationRuleParametersData = + (PatchNotificationRuleParametersData) o; + return Objects.equals(this.attributes, patchNotificationRuleParametersData.attributes) + && Objects.equals(this.id, patchNotificationRuleParametersData.id) + && Objects.equals(this.type, patchNotificationRuleParametersData.type) + && Objects.equals( + this.additionalProperties, patchNotificationRuleParametersData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PatchNotificationRuleParametersData {\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/PatchNotificationRuleParametersDataAttributes.java b/src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParametersDataAttributes.java new file mode 100644 index 00000000000..294f41473b6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PatchNotificationRuleParametersDataAttributes.java @@ -0,0 +1,300 @@ +/* + * 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; + +/** + * Attributes of the notification rule patch request. It is required to update the version of the + * rule when patching it. + */ +@JsonPropertyOrder({ + PatchNotificationRuleParametersDataAttributes.JSON_PROPERTY_ENABLED, + PatchNotificationRuleParametersDataAttributes.JSON_PROPERTY_NAME, + PatchNotificationRuleParametersDataAttributes.JSON_PROPERTY_SELECTORS, + PatchNotificationRuleParametersDataAttributes.JSON_PROPERTY_TARGETS, + PatchNotificationRuleParametersDataAttributes.JSON_PROPERTY_TIME_AGGREGATION, + PatchNotificationRuleParametersDataAttributes.JSON_PROPERTY_VERSION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PatchNotificationRuleParametersDataAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ENABLED = "enabled"; + private Boolean enabled; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SELECTORS = "selectors"; + private Selectors selectors; + + public static final String JSON_PROPERTY_TARGETS = "targets"; + private List targets = null; + + public static final String JSON_PROPERTY_TIME_AGGREGATION = "time_aggregation"; + private Long timeAggregation; + + public static final String JSON_PROPERTY_VERSION = "version"; + private Long version; + + public PatchNotificationRuleParametersDataAttributes enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Field used to enable or disable the rule. + * + * @return enabled + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public PatchNotificationRuleParametersDataAttributes name(String name) { + this.name = name; + return this; + } + + /** + * Name of the notification rule + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public PatchNotificationRuleParametersDataAttributes selectors(Selectors selectors) { + this.selectors = selectors; + this.unparsed |= selectors.unparsed; + return this; + } + + /** + * Selectors are used to filter security issues for which notifications should be generated. Users + * can specify rule severities, rule types, a query to filter security issues on tags and + * attributes, and the trigger source. Only the trigger_source field is required. + * + * @return selectors + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SELECTORS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Selectors getSelectors() { + return selectors; + } + + public void setSelectors(Selectors selectors) { + this.selectors = selectors; + } + + public PatchNotificationRuleParametersDataAttributes targets(List targets) { + this.targets = targets; + return this; + } + + public PatchNotificationRuleParametersDataAttributes addTargetsItem(String targetsItem) { + if (this.targets == null) { + this.targets = new ArrayList<>(); + } + this.targets.add(targetsItem); + return this; + } + + /** + * List of recipients to notify when a notification rule is triggered. Many different target types + * are supported, such as email addresses, Slack channels, and PagerDuty services. The appropriate + * integrations need to be properly configured to send notifications to the specified targets. + * + * @return targets + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TARGETS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + } + + public PatchNotificationRuleParametersDataAttributes timeAggregation(Long timeAggregation) { + this.timeAggregation = timeAggregation; + return this; + } + + /** + * Time aggregation period (in seconds) is used to aggregate the results of the notification rule + * evaluation. Results are aggregated over a selected time frame using a rolling window, which + * updates with each new evaluation. Notifications will only be sent for new issues discovered + * during the window. Time aggregation is only available for vulnerability-based notification + * rules. When omitted or set to 0, no aggregation is done. + * + * @return timeAggregation + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIME_AGGREGATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getTimeAggregation() { + return timeAggregation; + } + + public void setTimeAggregation(Long timeAggregation) { + this.timeAggregation = timeAggregation; + } + + public PatchNotificationRuleParametersDataAttributes version(Long version) { + this.version = version; + return this; + } + + /** + * Version of the notification rule. It is updated when the rule is modified. + * + * @return version + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getVersion() { + return version; + } + + public void setVersion(Long version) { + this.version = version; + } + + /** + * 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 PatchNotificationRuleParametersDataAttributes + */ + @JsonAnySetter + public PatchNotificationRuleParametersDataAttributes 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 PatchNotificationRuleParametersDataAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PatchNotificationRuleParametersDataAttributes patchNotificationRuleParametersDataAttributes = + (PatchNotificationRuleParametersDataAttributes) o; + return Objects.equals(this.enabled, patchNotificationRuleParametersDataAttributes.enabled) + && Objects.equals(this.name, patchNotificationRuleParametersDataAttributes.name) + && Objects.equals(this.selectors, patchNotificationRuleParametersDataAttributes.selectors) + && Objects.equals(this.targets, patchNotificationRuleParametersDataAttributes.targets) + && Objects.equals( + this.timeAggregation, patchNotificationRuleParametersDataAttributes.timeAggregation) + && Objects.equals(this.version, patchNotificationRuleParametersDataAttributes.version) + && Objects.equals( + this.additionalProperties, + patchNotificationRuleParametersDataAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + enabled, name, selectors, targets, timeAggregation, version, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PatchNotificationRuleParametersDataAttributes {\n"); + sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" selectors: ").append(toIndentedString(selectors)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" timeAggregation: ").append(toIndentedString(timeAggregation)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).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/RuleSeverity.java b/src/main/java/com/datadog/api/client/v2/model/RuleSeverity.java new file mode 100644 index 00000000000..035fbd8f49a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RuleSeverity.java @@ -0,0 +1,59 @@ +/* + * 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; + +/** Severity of a security rule */ +@JsonSerialize(using = RuleSeverity.RuleSeveritySerializer.class) +public class RuleSeverity extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("critical", "high", "medium", "low", "unknown", "info")); + + public static final RuleSeverity CRITICAL = new RuleSeverity("critical"); + public static final RuleSeverity HIGH = new RuleSeverity("high"); + public static final RuleSeverity MEDIUM = new RuleSeverity("medium"); + public static final RuleSeverity LOW = new RuleSeverity("low"); + public static final RuleSeverity UNKNOWN = new RuleSeverity("unknown"); + public static final RuleSeverity INFO = new RuleSeverity("info"); + + RuleSeverity(String value) { + super(value, allowedValues); + } + + public static class RuleSeveritySerializer extends StdSerializer { + public RuleSeveritySerializer(Class t) { + super(t); + } + + public RuleSeveritySerializer() { + this(null); + } + + @Override + public void serialize(RuleSeverity value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static RuleSeverity fromValue(String value) { + return new RuleSeverity(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/RuleTypesItems.java b/src/main/java/com/datadog/api/client/v2/model/RuleTypesItems.java new file mode 100644 index 00000000000..c8306a69de5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RuleTypesItems.java @@ -0,0 +1,93 @@ +/* + * 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; + +/** + * Security rule types which can be used in notification rules. Signal-based notification rules can + * filter signals based on rule types application_security, log_detection, workload_security, + * signal_correlation, cloud_configuration and infrastructure_configuration. Vulnerability-based + * notification rules can filter vulnerabilities based on rule types application_code_vulnerability, + * application_library_vulnerability, attack_path, container_image_vulnerability, identity_risk, + * misconfiguration and api_security. + */ +@JsonSerialize(using = RuleTypesItems.RuleTypesItemsSerializer.class) +public class RuleTypesItems extends ModelEnum { + + private static final Set allowedValues = + new HashSet( + Arrays.asList( + "application_security", + "log_detection", + "workload_security", + "signal_correlation", + "cloud_configuration", + "infrastructure_configuration", + "application_code_vulnerability", + "application_library_vulnerability", + "attack_path", + "container_image_vulnerability", + "identity_risk", + "misconfiguration", + "api_security")); + + public static final RuleTypesItems APPLICATION_SECURITY = + new RuleTypesItems("application_security"); + public static final RuleTypesItems LOG_DETECTION = new RuleTypesItems("log_detection"); + public static final RuleTypesItems WORKLOAD_SECURITY = new RuleTypesItems("workload_security"); + public static final RuleTypesItems SIGNAL_CORRELATION = new RuleTypesItems("signal_correlation"); + public static final RuleTypesItems CLOUD_CONFIGURATION = + new RuleTypesItems("cloud_configuration"); + public static final RuleTypesItems INFRASTRUCTURE_CONFIGURATION = + new RuleTypesItems("infrastructure_configuration"); + public static final RuleTypesItems APPLICATION_CODE_VULNERABILITY = + new RuleTypesItems("application_code_vulnerability"); + public static final RuleTypesItems APPLICATION_LIBRARY_VULNERABILITY = + new RuleTypesItems("application_library_vulnerability"); + public static final RuleTypesItems ATTACK_PATH = new RuleTypesItems("attack_path"); + public static final RuleTypesItems CONTAINER_IMAGE_VULNERABILITY = + new RuleTypesItems("container_image_vulnerability"); + public static final RuleTypesItems IDENTITY_RISK = new RuleTypesItems("identity_risk"); + public static final RuleTypesItems MISCONFIGURATION = new RuleTypesItems("misconfiguration"); + public static final RuleTypesItems API_SECURITY = new RuleTypesItems("api_security"); + + RuleTypesItems(String value) { + super(value, allowedValues); + } + + public static class RuleTypesItemsSerializer extends StdSerializer { + public RuleTypesItemsSerializer(Class t) { + super(t); + } + + public RuleTypesItemsSerializer() { + this(null); + } + + @Override + public void serialize(RuleTypesItems value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static RuleTypesItems fromValue(String value) { + return new RuleTypesItems(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/RuleUser.java b/src/main/java/com/datadog/api/client/v2/model/RuleUser.java new file mode 100644 index 00000000000..e69baa164da --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RuleUser.java @@ -0,0 +1,161 @@ +/* + * 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; + +/** User creating or modifying a rule */ +@JsonPropertyOrder({RuleUser.JSON_PROPERTY_HANDLE, RuleUser.JSON_PROPERTY_NAME}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class RuleUser { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_HANDLE = "handle"; + private String handle; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public RuleUser handle(String handle) { + this.handle = handle; + return this; + } + + /** + * The user handle. + * + * @return handle + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_HANDLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getHandle() { + return handle; + } + + public void setHandle(String handle) { + this.handle = handle; + } + + public RuleUser name(String name) { + this.name = name; + return this; + } + + /** + * The user name. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * 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 RuleUser + */ + @JsonAnySetter + public RuleUser 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 RuleUser object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RuleUser ruleUser = (RuleUser) o; + return Objects.equals(this.handle, ruleUser.handle) + && Objects.equals(this.name, ruleUser.name) + && Objects.equals(this.additionalProperties, ruleUser.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(handle, name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RuleUser {\n"); + sb.append(" handle: ").append(toIndentedString(handle)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/Selectors.java b/src/main/java/com/datadog/api/client/v2/model/Selectors.java new file mode 100644 index 00000000000..26a47c5243f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/Selectors.java @@ -0,0 +1,259 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * Selectors are used to filter security issues for which notifications should be generated. Users + * can specify rule severities, rule types, a query to filter security issues on tags and + * attributes, and the trigger source. Only the trigger_source field is required. + */ +@JsonPropertyOrder({ + Selectors.JSON_PROPERTY_QUERY, + Selectors.JSON_PROPERTY_RULE_TYPES, + Selectors.JSON_PROPERTY_SEVERITIES, + Selectors.JSON_PROPERTY_TRIGGER_SOURCE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class Selectors { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_QUERY = "query"; + private String query; + + public static final String JSON_PROPERTY_RULE_TYPES = "rule_types"; + private List ruleTypes = null; + + public static final String JSON_PROPERTY_SEVERITIES = "severities"; + private List severities = null; + + public static final String JSON_PROPERTY_TRIGGER_SOURCE = "trigger_source"; + private TriggerSource triggerSource; + + public Selectors() {} + + @JsonCreator + public Selectors( + @JsonProperty(required = true, value = JSON_PROPERTY_TRIGGER_SOURCE) + TriggerSource triggerSource) { + this.triggerSource = triggerSource; + this.unparsed |= !triggerSource.isValid(); + } + + public Selectors query(String query) { + this.query = query; + return this; + } + + /** + * The query is composed of one or several key:value pairs, which can be used to filter security + * issues on tags and attributes. + * + * @return query + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_QUERY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public Selectors ruleTypes(List ruleTypes) { + this.ruleTypes = ruleTypes; + return this; + } + + public Selectors addRuleTypesItem(RuleTypesItems ruleTypesItem) { + if (this.ruleTypes == null) { + this.ruleTypes = new ArrayList<>(); + } + this.ruleTypes.add(ruleTypesItem); + this.unparsed |= !ruleTypesItem.isValid(); + return this; + } + + /** + * Security rule types used to filter signals and vulnerabilities generating notifications. + * + * @return ruleTypes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RULE_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getRuleTypes() { + return ruleTypes; + } + + public void setRuleTypes(List ruleTypes) { + this.ruleTypes = ruleTypes; + } + + public Selectors severities(List severities) { + this.severities = severities; + return this; + } + + public Selectors addSeveritiesItem(RuleSeverity severitiesItem) { + if (this.severities == null) { + this.severities = new ArrayList<>(); + } + this.severities.add(severitiesItem); + this.unparsed |= !severitiesItem.isValid(); + return this; + } + + /** + * The security rules severities to consider + * + * @return severities + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SEVERITIES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getSeverities() { + return severities; + } + + public void setSeverities(List severities) { + this.severities = severities; + } + + public Selectors triggerSource(TriggerSource triggerSource) { + this.triggerSource = triggerSource; + this.unparsed |= !triggerSource.isValid(); + return this; + } + + /** + * The type of security issues on which the rule applies. Notification rules based on security + * signals need to use the trigger source "security_signals", while notification rules based on + * security vulnerabilities need to use the trigger source "security_findings". + * + * @return triggerSource + */ + @JsonProperty(JSON_PROPERTY_TRIGGER_SOURCE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public TriggerSource getTriggerSource() { + return triggerSource; + } + + public void setTriggerSource(TriggerSource triggerSource) { + if (!triggerSource.isValid()) { + this.unparsed = true; + } + this.triggerSource = triggerSource; + } + + /** + * 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 Selectors + */ + @JsonAnySetter + public Selectors 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 Selectors object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Selectors selectors = (Selectors) o; + return Objects.equals(this.query, selectors.query) + && Objects.equals(this.ruleTypes, selectors.ruleTypes) + && Objects.equals(this.severities, selectors.severities) + && Objects.equals(this.triggerSource, selectors.triggerSource) + && Objects.equals(this.additionalProperties, selectors.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(query, ruleTypes, severities, triggerSource, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Selectors {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb.append(" ruleTypes: ").append(toIndentedString(ruleTypes)).append("\n"); + sb.append(" severities: ").append(toIndentedString(severities)).append("\n"); + sb.append(" triggerSource: ").append(toIndentedString(triggerSource)).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/TriggerSource.java b/src/main/java/com/datadog/api/client/v2/model/TriggerSource.java new file mode 100644 index 00000000000..19cd1820e94 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/TriggerSource.java @@ -0,0 +1,59 @@ +/* + * 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 security issues on which the rule applies. Notification rules based on security + * signals need to use the trigger source "security_signals", while notification rules based on + * security vulnerabilities need to use the trigger source "security_findings". + */ +@JsonSerialize(using = TriggerSource.TriggerSourceSerializer.class) +public class TriggerSource extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("security_findings", "security_signals")); + + public static final TriggerSource SECURITY_FINDINGS = new TriggerSource("security_findings"); + public static final TriggerSource SECURITY_SIGNALS = new TriggerSource("security_signals"); + + TriggerSource(String value) { + super(value, allowedValues); + } + + public static class TriggerSourceSerializer extends StdSerializer { + public TriggerSourceSerializer(Class t) { + super(t); + } + + public TriggerSourceSerializer() { + this(null); + } + + @Override + public void serialize(TriggerSource value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static TriggerSource fromValue(String value) { + return new TriggerSource(value); + } +} diff --git a/src/test/resources/cassettes/features/v2/Create_a_new_signal_based_rule_returns_Successfully_created_the_notification_rule_response.freeze b/src/test/resources/cassettes/features/v2/Create_a_new_signal_based_rule_returns_Successfully_created_the_notification_rule_response.freeze new file mode 100644 index 00000000000..d013b137455 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_a_new_signal_based_rule_returns_Successfully_created_the_notification_rule_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:49:57.801Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_a_new_signal_based_rule_returns_Successfully_created_the_notification_rule_response.json b/src/test/resources/cassettes/features/v2/Create_a_new_signal_based_rule_returns_Successfully_created_the_notification_rule_response.json new file mode 100644 index 00000000000..bb7227853c2 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_a_new_signal_based_rule_returns_Successfully_created_the_notification_rule_response.json @@ -0,0 +1,53 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Rule 1\",\"selectors\":{\"query\":\"(source:production_service OR env:prod)\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/signals/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"rko-c7a-mx9\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539398227,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539398227,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"(source:production_service OR env:prod)\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "5bf44d5d-e1c1-c14f-2dba-99bb7cf73c43" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/signals/notification_rules/rko-c7a-mx9", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "65940df2-7165-43be-63cd-0c88fa4ab6c4" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_a_new_vulnerability_based_rule_returns_Successfully_created_the_notification_rule_response.freeze b/src/test/resources/cassettes/features/v2/Create_a_new_vulnerability_based_rule_returns_Successfully_created_the_notification_rule_response.freeze new file mode 100644 index 00000000000..4a1ded127d1 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_a_new_vulnerability_based_rule_returns_Successfully_created_the_notification_rule_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:49:58.794Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_a_new_vulnerability_based_rule_returns_Successfully_created_the_notification_rule_response.json b/src/test/resources/cassettes/features/v2/Create_a_new_vulnerability_based_rule_returns_Successfully_created_the_notification_rule_response.json new file mode 100644 index 00000000000..ee54874f64d --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_a_new_vulnerability_based_rule_returns_Successfully_created_the_notification_rule_response.json @@ -0,0 +1,53 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Rule 1\",\"selectors\":{\"query\":\"(source:production_service OR env:prod)\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/vulnerabilities/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"1hi-lla-3nx\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539399145,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539399145,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"(source:production_service OR env:prod)\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "a79fd497-19e9-0c50-3012-6159be5aefbb" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/vulnerabilities/notification_rules/1hi-lla-3nx", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "cc811688-6d4c-6aa9-6647-aaddd04cbe8e" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..5ed3da99691 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:04.605Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Not_Found_response.json new file mode 100644 index 00000000000..0c4f9b586db --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Not_Found_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/signals/notification_rules/000-000-000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"not_found(Notification rule with id '000-000-000' not found)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e356bda8-89ed-0de9-8744-3d65e3d953a2" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response.freeze b/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response.freeze new file mode 100644 index 00000000000..5b9cab2f5f9 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:05.107Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response.json b/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response.json new file mode 100644 index 00000000000..0c2be6f660b --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response-1737539405\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"signal_correlation\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"]},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/signals/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"ukc-0jn-maf\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539405540,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539405540,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response-1737539405\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"signal_correlation\"],\"query\":\"env:test\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":0,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e385b163-cbd6-556f-39e7-16ae7bef03d3" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/signals/notification_rules/ukc-0jn-maf", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "24bff9b1-26ff-eb98-5877-830324b017d5" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/signals/notification_rules/ukc-0jn-maf", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"not_found(Notification rule with id 'ukc-0jn-maf' not found)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "24bff9b1-26ff-eb98-5877-830324b017d6" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..31d1497fde4 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:08.134Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Not_Found_response.json new file mode 100644 index 00000000000..ccd2db2b5e8 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Not_Found_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/vulnerabilities/notification_rules/000-000-000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"not_found(Notification rule with id '000-000-000' not found)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "4b1315fa-b301-c24b-ba6e-3ccfd9e4a397" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response.freeze b/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response.freeze new file mode 100644 index 00000000000..f80fa530897 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:08.640Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response.json b/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response.json new file mode 100644 index 00000000000..80479b1f067 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response-1737539408\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/vulnerabilities/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"qip-ygy-7ke\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539409090,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539409090,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response-1737539408\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"env:test\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "50d0c430-b069-bea7-2cb7-e01f5606f2a0" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/vulnerabilities/notification_rules/qip-ygy-7ke", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "96091228-30c8-41ff-1ec2-ab44f253f547" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/vulnerabilities/notification_rules/qip-ygy-7ke", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"not_found(Notification rule with id 'qip-ygy-7ke' not found)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "96091228-30c8-41ff-1ec2-ab44f253f548" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..6d4de62a52a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:23.414Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Not_Found_response.json new file mode 100644 index 00000000000..d0285577d06 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Not_Found_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/security/signals/notification_rules/000-000-000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"not_found(Notification rule with id '000-000-000' not found)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "0026f70f-05fe-8623-231c-ee2a2db002ee" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response.freeze b/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response.freeze new file mode 100644 index 00000000000..fe7b63784cc --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:23.939Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response.json b/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response.json new file mode 100644 index 00000000000..fefdafabc35 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response-1737539423\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"signal_correlation\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"]},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/signals/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"t8x-amt-d52\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539424372,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539424372,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response-1737539423\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"signal_correlation\"],\"query\":\"env:test\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":0,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "29368e79-b2ec-a95d-c369-41b91eb90923" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/security/signals/notification_rules/t8x-amt-d52", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"t8x-amt-d52\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539424372,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539424372,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response-1737539423\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"signal_correlation\"],\"query\":\"env:test\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":0,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "58e91536-7bbf-ff62-20dd-7ae23357e8b6" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/signals/notification_rules/t8x-amt-d52", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "4d28667f-8beb-eb45-0738-cc1bdc66886a" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..d1e8767198e --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:25.480Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Not_Found_response.json new file mode 100644 index 00000000000..3696130a342 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Not_Found_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/security/vulnerabilities/notification_rules/000-000-000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"not_found(Notification rule with id '000-000-000' not found)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "aa7130e1-5276-d0eb-1975-6119f11b88b5" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response.freeze b/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response.freeze new file mode 100644 index 00000000000..1aed5057f55 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:25.988Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response.json b/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response.json new file mode 100644 index 00000000000..4f06ce267c7 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response-1737539425\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/vulnerabilities/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"aqq-x71-k2h\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539426417,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539426417,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response-1737539425\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"env:test\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "5778da1b-3c9c-64c2-b284-bc31178c06e9" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/security/vulnerabilities/notification_rules/aqq-x71-k2h", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"aqq-x71-k2h\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539426417,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539426417,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response-1737539425\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"env:test\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "0da93ac2-0fb5-f863-d785-6665162a4ee5" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/vulnerabilities/notification_rules/aqq-x71-k2h", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "0d749378-1f41-b033-e698-800883f6ba6d" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response.freeze b/src/test/resources/cassettes/features/v2/Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response.freeze new file mode 100644 index 00000000000..0ba2a36a140 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:27.496Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response.json b/src/test/resources/cassettes/features/v2/Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response.json new file mode 100644 index 00000000000..f03f8862811 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response-1737539427\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"signal_correlation\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"]},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/signals/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"dr3-owt-amk\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539427926,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539427926,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response-1737539427\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"signal_correlation\"],\"query\":\"env:test\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":0,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "1449b0ce-1f3c-30b4-b0dc-61b9c8bcd3a0" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/security/signals/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[{\"id\":\"hwk-zqh-vg4\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699905830776,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-List_notification_profiles_returns_OK_response-1699905830\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"fsm-4am-ozw\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699905832107,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_notification_profile_returns_OK_response-1699905832\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"px4-xrb-b9v\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699905992485,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Create_a_notification_profile_returns_OK_response-1699905992\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"application_security\",\"log_detection\"],\"query\":\"(env:\\\"prod\\\" OR @env:\\\"prod\\\") AND (test:\\\"123\\\" OR @test:\\\"123\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@slack-test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"ukt-yim-ouw\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699905996937,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_notification_profile_by_ID_returns_OK_response-1699905996\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"tpj-yqn-fcw\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699905997240,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-List_notification_profiles_returns_OK_response-1699905997\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"tv9-9dw-fbd\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699905998529,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_notification_profile_returns_OK_response-1699905998\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"pdt-i8z-vcs\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906082093,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Create_a_notification_profile_returns_OK_response-1699906081\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"application_security\",\"log_detection\"],\"query\":\"(env:\\\"prod\\\" OR @env:\\\"prod\\\") AND (test:\\\"123\\\" OR @test:\\\"123\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@slack-test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"tlb-cvk-wup\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906087769,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_notification_profile_by_ID_returns_OK_response-1699906087\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"sqp-oih-tp8\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906088050,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-List_notification_profiles_returns_OK_response-1699906087\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"zll-nff-pbx\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906089134,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_notification_profile_returns_OK_response-1699906089\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"4u9-ooz-fwf\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906572841,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Create_a_notification_profile_returns_OK_response-1699906572\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"application_security\",\"log_detection\"],\"query\":\"(env:\\\"prod\\\" OR @env:\\\"prod\\\") AND (test:\\\"123\\\" OR @test:\\\"123\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@slack-test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"lny-xec-2r7\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906577427,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_notification_profile_by_ID_returns_OK_response-1699906577\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"qfa-6nt-wn2\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906577706,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-List_notification_profiles_returns_OK_response-1699906577\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"zcr-tja-rut\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906578815,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_notification_profile_returns_OK_response-1699906578\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":3}},{\"id\":\"rca-ogs-ckx\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906789206,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Create_a_notification_profile_returns_OK_response-1699906789\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"application_security\",\"log_detection\"],\"query\":\"(env:\\\"prod\\\" OR @env:\\\"prod\\\") AND (test:\\\"123\\\" OR @test:\\\"123\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@slack-test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"dis-abp-grp\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906793874,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_notification_profile_by_ID_returns_OK_response-1699906793\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"n5i-avj-8br\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906794201,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-List_notification_profiles_returns_OK_response-1699906794\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"wct-cix-3ay\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699906795311,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":false,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_notification_profile_returns_OK_response-1699906795\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test2\"],\"time_aggregation\":0,\"version\":3}},{\"id\":\"pyf-t6u-dxp\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699907487559,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Create_a_notification_profile_returns_OK_response-1699907487\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"application_security\",\"log_detection\"],\"query\":\"(env:\\\"prod\\\" OR @env:\\\"prod\\\") AND (test:\\\"123\\\" OR @test:\\\"123\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@slack-test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"vwj-uew-mas\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699907492243,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_notification_profile_by_ID_returns_OK_response-1699907492\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"a1y-ysu-rvw\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699907492600,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-List_notification_profiles_returns_OK_response-1699907492\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"kq1-edx-tkt\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699907493778,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":false,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_notification_profile_returns_OK_response-1699907493\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test2\"],\"time_aggregation\":0,\"version\":3}},{\"id\":\"4i4-raj-t0a\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699908569876,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Create_a_notification_profile_returns_OK_response-1699908569\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"application_security\",\"log_detection\"],\"query\":\"(env:\\\"prod\\\" OR @env:\\\"prod\\\") AND (test:\\\"123\\\" OR @test:\\\"123\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@slack-test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"ncy-2zl-jge\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699908575238,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_notification_profile_by_ID_returns_OK_response-1699908575\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"(fim:\\\"true\\\" OR @fim:\\\"true\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"tiq-glx-quq\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699908575600,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-List_notification_profiles_returns_OK_response-1699908575\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"(fim:\\\"true\\\" OR @fim:\\\"true\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test\"],\"time_aggregation\":0,\"version\":2}},{\"id\":\"ue7-0sv-du1\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1699908576920,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":false,\"modified_at\":1725452072048,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_notification_profile_returns_OK_response-1699908576\",\"selectors\":{\"severities\":[\"high\"],\"rule_types\":[\"log_detection\",\"cloud_configuration\"],\"query\":\"(fim:\\\"true\\\" OR @fim:\\\"true\\\")\",\"trigger_source\":\"security_signals\"},\"targets\":[\"test2\"],\"time_aggregation\":0,\"version\":3}},{\"id\":\"dr3-owt-amk\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539427926,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539427926,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response-1737539427\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"signal_correlation\"],\"query\":\"env:test\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":0,\"version\":1}}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "f6b346e6-ddaf-c00f-81e2-42ae9307c4dc" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/signals/notification_rules/dr3-owt-amk", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "66824560-d478-a7b1-38ca-cbf40ea71a71" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response.freeze b/src/test/resources/cassettes/features/v2/Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response.freeze new file mode 100644 index 00000000000..e2d0798f523 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:28.875Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response.json b/src/test/resources/cassettes/features/v2/Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response.json new file mode 100644 index 00000000000..4c6fa7cade7 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response-1737539428\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/vulnerabilities/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"ua9-ppq-acw\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539429310,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539429310,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response-1737539428\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"env:test\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "03848f15-0f68-0cfe-b9d5-566050dbdc43" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/security/vulnerabilities/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[{\"id\":\"ua9-ppq-acw\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539429310,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539429310,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response-1737539428\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"env:test\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400,\"version\":1}}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "caecc365-7099-2afc-7929-2f6d9e89c640" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/vulnerabilities/notification_rules/ua9-ppq-acw", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "889d7ca2-e7d3-0066-3aa8-c077c0c327f2" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..50ebef7d381 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:35.238Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Bad_Request_response.json new file mode 100644 index 00000000000..e9115871c39 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Bad_Request_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Patch_a_signal_based_rule_returns_Bad_Request_response-1737539435\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"signal_correlation\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"]},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/signals/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"urx-vcd-58d\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539435658,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539435658,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Patch_a_signal_based_rule_returns_Bad_Request_response-1737539435\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"signal_correlation\"],\"query\":\"env:test\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":0,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "a85afce0-0d29-afc4-bbb4-59317a7479c2" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Rule 1\",\"selectors\":{\"query\":\"(source:production_service OR env:prod)\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400},\"id\":\"aaa-bbb-ccc\",\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/security/signals/notification_rules/urx-vcd-58d", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"input_validation_error(Field 'data.attributes.version' is invalid: Specify the notification rule version to update, it cannot be 0.)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "b36f2974-fa13-04dd-b7f7-ea68d9475efd" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/signals/notification_rules/urx-vcd-58d", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "284d6f25-21c9-5253-0bab-9accac95b745" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..cbf78aceabd --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:36.599Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Not_Found_response.json new file mode 100644 index 00000000000..462ae5941b4 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Not_Found_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Rule 1\",\"selectors\":{\"query\":\"(source:production_service OR env:prod)\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400,\"version\":1},\"id\":\"aaa-bbb-ccc\",\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/security/signals/notification_rules/000-000-000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"not_found(Notification rule with id '000-000-000' not found)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "62abf924-4a38-7064-242c-8912d1c733b5" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response.freeze b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response.freeze new file mode 100644 index 00000000000..dbfecb7971f --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:37.086Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response.json b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response.json new file mode 100644 index 00000000000..f6cc82b130f --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response-1737539437\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"signal_correlation\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"]},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/signals/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"h6x-nyx-fkm\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539437401,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539437401,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response-1737539437\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"signal_correlation\"],\"query\":\"env:test\",\"trigger_source\":\"security_signals\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":0,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "3eb7e8c4-d487-ba87-c770-e7808401c4ec" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Rule 1\",\"selectors\":{\"query\":\"(source:production_service OR env:prod)\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400,\"version\":1},\"id\":\"aaa-bbb-ccc\",\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/security/signals/notification_rules/h6x-nyx-fkm", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"h6x-nyx-fkm\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539437401,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539437810,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"(source:production_service OR env:prod)\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400,\"version\":2}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "f4aa973f-45ec-fc59-24de-6ca7ad03345c" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/signals/notification_rules/h6x-nyx-fkm", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "8f4400e7-2104-8b85-1569-048ed64694c7" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..fcdc31ed0f0 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:38.399Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Bad_Request_response.json new file mode 100644 index 00000000000..30bdbf8cadc --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Bad_Request_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Patch_a_vulnerability_based_rule_returns_Bad_Request_response-1737539438\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/vulnerabilities/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"ks5-ywq-grp\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539438831,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539438831,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Patch_a_vulnerability_based_rule_returns_Bad_Request_response-1737539438\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"env:test\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "ad12b284-6671-5e3c-c12a-f909c401de8a" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Rule 1\",\"selectors\":{\"query\":\"(source:production_service OR env:prod)\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400},\"id\":\"aaa-bbb-ccc\",\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/security/vulnerabilities/notification_rules/ks5-ywq-grp", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"input_validation_error(Field 'data.attributes.version' is invalid: Specify the notification rule version to update, it cannot be 0.)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "f361b399-f42d-b29f-de49-bfea9bbb7f8a" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/vulnerabilities/notification_rules/ks5-ywq-grp", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "be665bec-3834-2cb9-f7b5-ac1e15cbe737" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..f24abb9c921 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:39.942Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Not_Found_response.json new file mode 100644 index 00000000000..daed87e0e1d --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Not_Found_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Rule 1\",\"selectors\":{\"query\":\"(source:production_service OR env:prod)\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400,\"version\":1},\"id\":\"aaa-bbb-ccc\",\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/security/vulnerabilities/notification_rules/000-000-000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"not_found(Notification rule with id '000-000-000' not found)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "a144d830-121c-d511-de9a-314da73879a6" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response.freeze b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response.freeze new file mode 100644 index 00000000000..e2e97276a9e --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response.freeze @@ -0,0 +1 @@ +2025-01-22T09:50:40.442Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response.json b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response.json new file mode 100644 index 00000000000..dd4b87e7784 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Test-Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response-1737539440\",\"selectors\":{\"query\":\"env:test\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security/vulnerabilities/notification_rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"a40-xl3-95h\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539440872,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539440872,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response-1737539440\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"env:test\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@email@email.com\"],\"time_aggregation\":86400,\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d0871f78-ba58-2af0-a502-2b9d7ad22431" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"enabled\":true,\"name\":\"Rule 1\",\"selectors\":{\"query\":\"(source:production_service OR env:prod)\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"],\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400,\"version\":1},\"id\":\"aaa-bbb-ccc\",\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/security/vulnerabilities/notification_rules/a40-xl3-95h", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"a40-xl3-95h\",\"type\":\"notification_rules\",\"attributes\":{\"created_at\":1737539440872,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1737539441254,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"selectors\":{\"severities\":[\"critical\"],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"query\":\"(source:production_service OR env:prod)\",\"trigger_source\":\"security_findings\"},\"targets\":[\"@john.doe@email.com\"],\"time_aggregation\":86400,\"version\":2}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "5439d21b-dbb9-2801-8b21-4bf9b3c92e31" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security/vulnerabilities/notification_rules/a40-xl3-95h", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "dbf58e9e-f2cd-8ce8-1a38-5fb5cae335ee" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/given.json b/src/test/resources/com/datadog/api/client/v2/api/given.json index e5c2cbcc488..a4729ae0c58 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/given.json +++ b/src/test/resources/com/datadog/api/client/v2/api/given.json @@ -547,6 +547,30 @@ "tag": "Service Scorecards", "operationId": "CreateScorecardRule" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"notification_rules\",\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"selectors\": {\n \"rule_types\": [\"signal_correlation\"],\n \"trigger_source\": \"security_signals\",\n \"severities\": [\"critical\"],\n \"query\": \"env:test\"\n },\n \"targets\": [\"@email@email.com\"],\n \"enabled\": true\n }\n }\n}" + } + ], + "step": "there is a valid \"valid_signal_notification_rule\" in the system", + "key": "valid_signal_notification_rule", + "tag": "Security Monitoring", + "operationId": "CreateSignalNotificationRule" + }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"notification_rules\",\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"selectors\": {\n \"rule_types\": [\"misconfiguration\", \"attack_path\"],\n \"trigger_source\": \"security_findings\",\n \"severities\": [\"critical\"],\n \"query\": \"env:test\"\n },\n \"time_aggregation\": 86400,\n \"targets\": [\"@email@email.com\"],\n \"enabled\": true\n }\n }\n}" + } + ], + "step": "there is a valid \"valid_vulnerability_notification_rule\" in the system", + "key": "valid_vulnerability_notification_rule", + "tag": "Security Monitoring", + "operationId": "CreateVulnerabilityNotificationRule" + }, { "parameters": [ { 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 362378f6349..83711f6b454 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 @@ -235,6 +235,34 @@ Feature: Security Monitoring And the response "message" is equal to "Test rule" And the response "isEnabled" is equal to true + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Create a new signal-based rule returns "Bad Request" response + Given new "CreateSignalNotificationRule" request + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Create a new signal-based rule returns "Successfully created the notification rule" response + Given new "CreateSignalNotificationRule" request + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} + When the request is sent + Then the response status is 201 Successfully created the notification rule + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Create a new vulnerability-based rule returns "Bad Request" response + Given new "CreateVulnerabilityNotificationRule" request + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Create a new vulnerability-based rule returns "Successfully created the notification rule" response + Given new "CreateVulnerabilityNotificationRule" request + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} + When the request is sent + Then the response status is 201 Successfully created the notification rule + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Create a security filter returns "Bad Request" response Given new "CreateSecurityFilter" request @@ -325,6 +353,21 @@ Feature: Security Monitoring When the request is sent Then the response status is 204 OK + @team:DataDog/cloud-security-posture-management + Scenario: Delete a signal-based rule returns "Not Found" response + Given new "DeleteSignalNotificationRule" request + And request contains "id" parameter with value "000-000-000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Delete a signal-based rule returns "Rule successfully deleted" response + Given there is a valid "valid_signal_notification_rule" in the system + And new "DeleteSignalNotificationRule" request + And request contains "id" parameter from "valid_signal_notification_rule.data.id" + When the request is sent + Then the response status is 204 Rule successfully deleted + @skip @team:DataDog/k9-cloud-security-platform Scenario: Delete a suppression rule returns "Not Found" response Given new "DeleteSecurityMonitoringSuppression" request @@ -340,6 +383,21 @@ Feature: Security Monitoring When the request is sent Then the response status is 204 OK + @team:DataDog/cloud-security-posture-management + Scenario: Delete a vulnerability-based rule returns "Not Found" response + Given new "DeleteVulnerabilityNotificationRule" request + And request contains "id" parameter with value "000-000-000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Delete a vulnerability-based rule returns "Rule successfully deleted" response + Given there is a valid "valid_vulnerability_notification_rule" in the system + And new "DeleteVulnerabilityNotificationRule" request + And request contains "id" parameter from "valid_vulnerability_notification_rule.data.id" + When the request is sent + Then the response status is 204 Rule successfully deleted + @team:DataDog/k9-cloud-security-platform Scenario: Delete an existing job returns "Bad Request" response Given operation "DeleteHistoricalJob" enabled @@ -572,6 +630,64 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Get details of a signal-based rule returns "Bad Request" response + Given new "GetSignalNotificationRule" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Get details of a signal-based rule returns "Not Found" response + Given new "GetSignalNotificationRule" request + And request contains "id" parameter with value "000-000-000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Get details of a signal-based rule returns "Notification rule details" response + Given there is a valid "valid_signal_notification_rule" in the system + And new "GetSignalNotificationRule" request + And request contains "id" parameter from "valid_signal_notification_rule.data.id" + When the request is sent + Then the response status is 200 Notification rule details + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Get details of a vulnerability-based rule returns "Bad Request" response + Given new "GetVulnerabilityNotificationRule" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Get details of a vulnerability-based rule returns "Not Found" response + Given new "GetVulnerabilityNotificationRule" request + And request contains "id" parameter with value "000-000-000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Get details of a vulnerability-based rule returns "Notification rule details" response + Given there is a valid "valid_vulnerability_notification_rule" in the system + And new "GetVulnerabilityNotificationRule" request + And request contains "id" parameter from "valid_vulnerability_notification_rule.data.id" + When the request is sent + Then the response status is 200 Notification rule details + + @team:DataDog/cloud-security-posture-management + Scenario: Get the list of signal-based rules returns "The list of notification rules" response + Given there is a valid "valid_signal_notification_rule" in the system + And new "GetSignalNotificationRules" request + When the request is sent + Then the response status is 200 The list of notification rules + + @team:DataDog/cloud-security-posture-management + Scenario: Get the list of vulnerability-based rules returns "The list of notification rules" response + Given there is a valid "valid_vulnerability_notification_rule" in the system + And new "GetVulnerabilityNotificationRules" request + When the request is sent + Then the response status is 200 The list of notification rules + @generated @skip @team:DataDog/cloud-security-posture-management Scenario: List findings returns "Bad Request: The server cannot process the request due to invalid syntax in the request." response Given operation "ListFindings" enabled @@ -746,6 +862,74 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @team:DataDog/cloud-security-posture-management + Scenario: Patch a signal-based rule returns "Bad Request" response + Given new "PatchSignalNotificationRule" request + And there is a valid "valid_signal_notification_rule" in the system + And request contains "id" parameter from "valid_signal_notification_rule.data.id" + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Patch a signal-based rule returns "Not Found" response + Given new "PatchSignalNotificationRule" request + And request contains "id" parameter with value "000-000-000" + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Patch a signal-based rule returns "Notification rule successfully patched" response + Given new "PatchSignalNotificationRule" request + And there is a valid "valid_signal_notification_rule" in the system + And request contains "id" parameter from "valid_signal_notification_rule.data.id" + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + When the request is sent + Then the response status is 200 Notification rule successfully patched + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Patch a signal-based rule returns "The server cannot process the request because it contains invalid data." response + Given new "PatchSignalNotificationRule" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + When the request is sent + Then the response status is 422 The server cannot process the request because it contains invalid data. + + @team:DataDog/cloud-security-posture-management + Scenario: Patch a vulnerability-based rule returns "Bad Request" response + Given new "PatchVulnerabilityNotificationRule" request + And there is a valid "valid_vulnerability_notification_rule" in the system + And request contains "id" parameter from "valid_vulnerability_notification_rule.data.id" + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Patch a vulnerability-based rule returns "Not Found" response + Given new "PatchVulnerabilityNotificationRule" request + And request contains "id" parameter with value "000-000-000" + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Patch a vulnerability-based rule returns "Notification rule successfully patched" response + Given new "PatchVulnerabilityNotificationRule" request + And there is a valid "valid_vulnerability_notification_rule" in the system + And request contains "id" parameter from "valid_vulnerability_notification_rule.data.id" + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + When the request is sent + Then the response status is 200 Notification rule successfully patched + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Patch a vulnerability-based rule returns "The server cannot process the request because it contains invalid data." response + Given new "PatchVulnerabilityNotificationRule" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + When the request is sent + Then the response status is 422 The server cannot process the request because it contains invalid data. + @team:DataDog/k9-cloud-security-platform Scenario: Run a historical job returns "Bad Request" response Given operation "RunHistoricalJob" enabled 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 d1258a8d92c..f72eeb5390e 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 @@ -2061,12 +2061,86 @@ "type": "safe" } }, + "GetSignalNotificationRules": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "CreateSignalNotificationRule": { + "tag": "Security Monitoring", + "undo": { + "operationId": "DeleteSignalNotificationRule", + "parameters": [ + { + "name": "id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteSignalNotificationRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "GetSignalNotificationRule": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "PatchSignalNotificationRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, "ListVulnerabilities": { "tag": "Security Monitoring", "undo": { "type": "safe" } }, + "GetVulnerabilityNotificationRules": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "CreateVulnerabilityNotificationRule": { + "tag": "Security Monitoring", + "undo": { + "operationId": "DeleteVulnerabilityNotificationRule", + "parameters": [ + { + "name": "id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteVulnerabilityNotificationRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "GetVulnerabilityNotificationRule": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "PatchVulnerabilityNotificationRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, "ListCloudWorkloadSecurityAgentRules": { "tag": "CSM Threats", "undo": {