diff --git a/.apigentools-info b/.apigentools-info index 1db9df7f536..5a6f366194e 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-23 22:24:37.362825", - "spec_repo_commit": "6a31fa8c" + "regenerated": "2025-01-24 15:02:23.857181", + "spec_repo_commit": "582cdbd4" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-23 22:24:37.394984", - "spec_repo_commit": "6a31fa8c" + "regenerated": "2025-01-24 15:02:23.873604", + "spec_repo_commit": "582cdbd4" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index d19602bb8e4..2c7c126ce50 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -23747,6 +23747,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 1f5214bdc2a..c8e2261b218 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: @@ -13245,6 +13308,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: @@ -19407,6 +19474,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 users to define the conditions under which a notification should + be generated (based on rule severities, + + rule types, rule tags, and so on), 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 @@ -20260,6 +20405,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: @@ -22941,12 +23124,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. @@ -22956,6 +23161,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: @@ -25873,6 +26141,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: @@ -28565,6 +28856,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: @@ -29141,6 +29446,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 are only 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: @@ -29333,6 +29654,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. @@ -30258,6 +30593,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: @@ -30849,6 +31190,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. @@ -43576,6 +43921,188 @@ paths: x-unstable: '**Note**: This endpoint is a private preview. If you are interested in accessing this API, please [fill out this form](https://forms.gle/kMYC1sDr6WDUBDsx9).' + /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 is not 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 @@ -43955,6 +44482,188 @@ paths: x-unstable: '**Note**: This endpoint is a private preview. If you are interested in accessing this API, please [fill out 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 is not 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/api/datadogV2/api_security_monitoring.go b/api/datadogV2/api_security_monitoring.go index f98108991a7..3f8c7c5729d 100644 --- a/api/datadogV2/api_security_monitoring.go +++ b/api/datadogV2/api_security_monitoring.go @@ -529,6 +529,152 @@ func (a *SecurityMonitoringApi) CreateSecurityMonitoringSuppression(ctx _context return localVarReturnValue, localVarHTTPResponse, nil } +// CreateSignalNotificationRule Create a new signal-based rule. +// Create a new notification rule for security signals and return the created rule. +func (a *SecurityMonitoringApi) CreateSignalNotificationRule(ctx _context.Context, body CreateNotificationRuleParameters) (NotificationRuleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue NotificationRuleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.CreateSignalNotificationRule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/signals/notification_rules" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// CreateVulnerabilityNotificationRule Create a new vulnerability-based rule. +// Create a new notification rule for security vulnerabilities and return the created rule. +func (a *SecurityMonitoringApi) CreateVulnerabilityNotificationRule(ctx _context.Context, body CreateNotificationRuleParameters) (NotificationRuleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue NotificationRuleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.CreateVulnerabilityNotificationRule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/vulnerabilities/notification_rules" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // DeleteHistoricalJob Delete an existing job. // Delete an existing job. func (a *SecurityMonitoringApi) DeleteHistoricalJob(ctx _context.Context, jobId string) (*_nethttp.Response, error) { @@ -782,6 +928,128 @@ func (a *SecurityMonitoringApi) DeleteSecurityMonitoringSuppression(ctx _context return localVarHTTPResponse, nil } +// DeleteSignalNotificationRule Delete a signal-based rule. +// Delete a notification rule for security signals. +func (a *SecurityMonitoringApi) DeleteSignalNotificationRule(ctx _context.Context, id string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.DeleteSignalNotificationRule") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/signals/notification_rules/{id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// DeleteVulnerabilityNotificationRule Delete a vulnerability-based rule. +// Delete a notification rule for security vulnerabilities. +func (a *SecurityMonitoringApi) DeleteVulnerabilityNotificationRule(ctx _context.Context, id string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.DeleteVulnerabilityNotificationRule") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/vulnerabilities/notification_rules/{id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // EditSecurityMonitoringSignalAssignee Modify the triage assignee of a security signal. // Modify the triage assignee of a security signal. func (a *SecurityMonitoringApi) EditSecurityMonitoringSignalAssignee(ctx _context.Context, signalId string, body SecurityMonitoringSignalAssigneeUpdateRequest) (SecurityMonitoringSignalTriageUpdateResponse, *_nethttp.Response, error) { @@ -1169,7 +1437,341 @@ func (a *SecurityMonitoringApi) GetHistoricalJob(ctx _context.Context, jobId str ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// GetSBOMOptionalParameters holds optional parameters for GetSBOM. +type GetSBOMOptionalParameters struct { + FilterRepoDigest *string +} + +// NewGetSBOMOptionalParameters creates an empty struct for parameters. +func NewGetSBOMOptionalParameters() *GetSBOMOptionalParameters { + this := GetSBOMOptionalParameters{} + return &this +} + +// WithFilterRepoDigest sets the corresponding parameter name and returns the struct. +func (r *GetSBOMOptionalParameters) WithFilterRepoDigest(filterRepoDigest string) *GetSBOMOptionalParameters { + r.FilterRepoDigest = &filterRepoDigest + return r +} + +// GetSBOM Get SBOM. +// Get a single SBOM related to an asset by its type and name. +func (a *SecurityMonitoringApi) GetSBOM(ctx _context.Context, assetType AssetType, filterAssetName string, o ...GetSBOMOptionalParameters) (GetSBOMResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GetSBOMResponse + optionalParams GetSBOMOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetSBOMOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.GetSBOM" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSBOM") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/sboms/{asset_type}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{asset_type}", _neturl.PathEscape(datadog.ParameterToString(assetType, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarQueryParams.Add("filter[asset_name]", datadog.ParameterToString(filterAssetName, "")) + if optionalParams.FilterRepoDigest != nil { + localVarQueryParams.Add("filter[repo_digest]", datadog.ParameterToString(*optionalParams.FilterRepoDigest, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// GetSecurityFilter Get a security filter. +// Get the details of a specific security filter. +// +// See the [security filter guide](https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/) +// for more examples. +func (a *SecurityMonitoringApi) GetSecurityFilter(ctx _context.Context, securityFilterId string) (SecurityFilterResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SecurityFilterResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSecurityFilter") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{security_filter_id}", _neturl.PathEscape(datadog.ParameterToString(securityFilterId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// GetSecurityMonitoringRule Get a rule's details. +// Get a rule's details. +func (a *SecurityMonitoringApi) GetSecurityMonitoringRule(ctx _context.Context, ruleId string) (SecurityMonitoringRuleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SecurityMonitoringRuleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSecurityMonitoringRule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security_monitoring/rules/{rule_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{rule_id}", _neturl.PathEscape(datadog.ParameterToString(ruleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// GetSecurityMonitoringSignal Get a signal's details. +// Get a signal's details. +func (a *SecurityMonitoringApi) GetSecurityMonitoringSignal(ctx _context.Context, signalId string) (SecurityMonitoringSignalResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SecurityMonitoringSignalResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSecurityMonitoringSignal") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security_monitoring/signals/{signal_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{signal_id}", _neturl.PathEscape(datadog.ParameterToString(signalId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -1192,64 +1794,26 @@ func (a *SecurityMonitoringApi) GetHistoricalJob(ctx _context.Context, jobId str return localVarReturnValue, localVarHTTPResponse, nil } -// GetSBOMOptionalParameters holds optional parameters for GetSBOM. -type GetSBOMOptionalParameters struct { - FilterRepoDigest *string -} - -// NewGetSBOMOptionalParameters creates an empty struct for parameters. -func NewGetSBOMOptionalParameters() *GetSBOMOptionalParameters { - this := GetSBOMOptionalParameters{} - return &this -} - -// WithFilterRepoDigest sets the corresponding parameter name and returns the struct. -func (r *GetSBOMOptionalParameters) WithFilterRepoDigest(filterRepoDigest string) *GetSBOMOptionalParameters { - r.FilterRepoDigest = &filterRepoDigest - return r -} - -// GetSBOM Get SBOM. -// Get a single SBOM related to an asset by its type and name. -func (a *SecurityMonitoringApi) GetSBOM(ctx _context.Context, assetType AssetType, filterAssetName string, o ...GetSBOMOptionalParameters) (GetSBOMResponse, *_nethttp.Response, error) { +// GetSecurityMonitoringSuppression Get a suppression rule. +// Get the details of a specific suppression rule. +func (a *SecurityMonitoringApi) GetSecurityMonitoringSuppression(ctx _context.Context, suppressionId string) (SecurityMonitoringSuppressionResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue GetSBOMResponse - optionalParams GetSBOMOptionalParameters + localVarReturnValue SecurityMonitoringSuppressionResponse ) - if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetSBOMOptionalParameters is allowed") - } - if len(o) == 1 { - optionalParams = o[0] - } - - operationId := "v2.GetSBOM" - isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) - if !isOperationEnabled { - return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} - } - if isOperationEnabled && a.Client.Cfg.Debug { - _log.Printf("WARNING: Using unstable operation '%s'", operationId) - } - - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSBOM") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSecurityMonitoringSuppression") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/security/sboms/{asset_type}" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{asset_type}", _neturl.PathEscape(datadog.ParameterToString(assetType, ""))) + localVarPath := localBasePath + "/api/v2/security_monitoring/configuration/suppressions/{suppression_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{suppression_id}", _neturl.PathEscape(datadog.ParameterToString(suppressionId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} localVarFormParams := _neturl.Values{} - localVarQueryParams.Add("filter[asset_name]", datadog.ParameterToString(filterAssetName, "")) - if optionalParams.FilterRepoDigest != nil { - localVarQueryParams.Add("filter[repo_digest]", datadog.ParameterToString(*optionalParams.FilterRepoDigest, "")) - } localVarHeaderParams["Accept"] = "application/json" datadog.SetAuthKeys( @@ -1278,16 +1842,7 @@ func (a *SecurityMonitoringApi) GetSBOM(ctx _context.Context, assetType AssetTyp ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { - var v JSONAPIErrorResponse - err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.ErrorModel = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - if localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -1310,25 +1865,22 @@ func (a *SecurityMonitoringApi) GetSBOM(ctx _context.Context, assetType AssetTyp return localVarReturnValue, localVarHTTPResponse, nil } -// GetSecurityFilter Get a security filter. -// Get the details of a specific security filter. -// -// See the [security filter guide](https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/) -// for more examples. -func (a *SecurityMonitoringApi) GetSecurityFilter(ctx _context.Context, securityFilterId string) (SecurityFilterResponse, *_nethttp.Response, error) { +// GetSignalNotificationRule Get details of a signal-based rule. +// Get the details of a notification rule for security signals. +func (a *SecurityMonitoringApi) GetSignalNotificationRule(ctx _context.Context, id string) (NotificationRuleResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue SecurityFilterResponse + localVarReturnValue NotificationRuleResponse ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSecurityFilter") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSignalNotificationRule") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{security_filter_id}", _neturl.PathEscape(datadog.ParameterToString(securityFilterId, ""))) + localVarPath := localBasePath + "/api/v2/security/signals/notification_rules/{id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -1361,7 +1913,7 @@ func (a *SecurityMonitoringApi) GetSecurityFilter(ctx _context.Context, security ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -1384,22 +1936,21 @@ func (a *SecurityMonitoringApi) GetSecurityFilter(ctx _context.Context, security return localVarReturnValue, localVarHTTPResponse, nil } -// GetSecurityMonitoringRule Get a rule's details. -// Get a rule's details. -func (a *SecurityMonitoringApi) GetSecurityMonitoringRule(ctx _context.Context, ruleId string) (SecurityMonitoringRuleResponse, *_nethttp.Response, error) { +// GetSignalNotificationRules Get the list of signal-based rules. +// Returns the list of notification rules for security signals. +func (a *SecurityMonitoringApi) GetSignalNotificationRules(ctx _context.Context) (interface{}, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue SecurityMonitoringRuleResponse + localVarReturnValue interface{} ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSecurityMonitoringRule") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSignalNotificationRules") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/security_monitoring/rules/{rule_id}" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{rule_id}", _neturl.PathEscape(datadog.ParameterToString(ruleId, ""))) + localVarPath := localBasePath + "/api/v2/security/signals/notification_rules" localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -1432,7 +1983,7 @@ func (a *SecurityMonitoringApi) GetSecurityMonitoringRule(ctx _context.Context, ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -1455,22 +2006,22 @@ func (a *SecurityMonitoringApi) GetSecurityMonitoringRule(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, nil } -// GetSecurityMonitoringSignal Get a signal's details. -// Get a signal's details. -func (a *SecurityMonitoringApi) GetSecurityMonitoringSignal(ctx _context.Context, signalId string) (SecurityMonitoringSignalResponse, *_nethttp.Response, error) { +// GetVulnerabilityNotificationRule Get details of a vulnerability-based rule. +// Get the details of a notification rule for security vulnerabilities. +func (a *SecurityMonitoringApi) GetVulnerabilityNotificationRule(ctx _context.Context, id string) (NotificationRuleResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue SecurityMonitoringSignalResponse + localVarReturnValue NotificationRuleResponse ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSecurityMonitoringSignal") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetVulnerabilityNotificationRule") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/security_monitoring/signals/{signal_id}" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{signal_id}", _neturl.PathEscape(datadog.ParameterToString(signalId, ""))) + localVarPath := localBasePath + "/api/v2/security/vulnerabilities/notification_rules/{id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -1503,7 +2054,7 @@ func (a *SecurityMonitoringApi) GetSecurityMonitoringSignal(ctx _context.Context ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -1526,22 +2077,21 @@ func (a *SecurityMonitoringApi) GetSecurityMonitoringSignal(ctx _context.Context return localVarReturnValue, localVarHTTPResponse, nil } -// GetSecurityMonitoringSuppression Get a suppression rule. -// Get the details of a specific suppression rule. -func (a *SecurityMonitoringApi) GetSecurityMonitoringSuppression(ctx _context.Context, suppressionId string) (SecurityMonitoringSuppressionResponse, *_nethttp.Response, error) { +// GetVulnerabilityNotificationRules Get the list of vulnerability-based rules. +// Returns the list of notification rules for security vulnerabilities. +func (a *SecurityMonitoringApi) GetVulnerabilityNotificationRules(ctx _context.Context) (interface{}, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue SecurityMonitoringSuppressionResponse + localVarReturnValue interface{} ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSecurityMonitoringSuppression") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetVulnerabilityNotificationRules") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/security_monitoring/configuration/suppressions/{suppression_id}" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{suppression_id}", _neturl.PathEscape(datadog.ParameterToString(suppressionId, ""))) + localVarPath := localBasePath + "/api/v2/security/vulnerabilities/notification_rules" localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -1574,7 +2124,7 @@ func (a *SecurityMonitoringApi) GetSecurityMonitoringSuppression(ctx _context.Co ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -3462,6 +4012,172 @@ func (a *SecurityMonitoringApi) MuteFindings(ctx _context.Context, body BulkMute return localVarReturnValue, localVarHTTPResponse, nil } +// PatchSignalNotificationRule Patch a signal-based rule. +// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. +func (a *SecurityMonitoringApi) PatchSignalNotificationRule(ctx _context.Context, id string, body PatchNotificationRuleParameters) (NotificationRuleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue NotificationRuleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.PatchSignalNotificationRule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/signals/notification_rules/{id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 422 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// PatchVulnerabilityNotificationRule Patch a vulnerability-based rule. +// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. +func (a *SecurityMonitoringApi) PatchVulnerabilityNotificationRule(ctx _context.Context, id string, body PatchNotificationRuleParameters) (NotificationRuleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue NotificationRuleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.PatchVulnerabilityNotificationRule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/vulnerabilities/notification_rules/{id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 422 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // RunHistoricalJob Run a historical job. // Run a historical job. func (a *SecurityMonitoringApi) RunHistoricalJob(ctx _context.Context, body RunHistoricalJobRequest) (JobCreateResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index b95975c6842..bef0a4dc055 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -304,10 +304,14 @@ // - [SecurityMonitoringApi.CreateSecurityFilter] // - [SecurityMonitoringApi.CreateSecurityMonitoringRule] // - [SecurityMonitoringApi.CreateSecurityMonitoringSuppression] +// - [SecurityMonitoringApi.CreateSignalNotificationRule] +// - [SecurityMonitoringApi.CreateVulnerabilityNotificationRule] // - [SecurityMonitoringApi.DeleteHistoricalJob] // - [SecurityMonitoringApi.DeleteSecurityFilter] // - [SecurityMonitoringApi.DeleteSecurityMonitoringRule] // - [SecurityMonitoringApi.DeleteSecurityMonitoringSuppression] +// - [SecurityMonitoringApi.DeleteSignalNotificationRule] +// - [SecurityMonitoringApi.DeleteVulnerabilityNotificationRule] // - [SecurityMonitoringApi.EditSecurityMonitoringSignalAssignee] // - [SecurityMonitoringApi.EditSecurityMonitoringSignalIncidents] // - [SecurityMonitoringApi.EditSecurityMonitoringSignalState] @@ -318,6 +322,10 @@ // - [SecurityMonitoringApi.GetSecurityMonitoringRule] // - [SecurityMonitoringApi.GetSecurityMonitoringSignal] // - [SecurityMonitoringApi.GetSecurityMonitoringSuppression] +// - [SecurityMonitoringApi.GetSignalNotificationRule] +// - [SecurityMonitoringApi.GetSignalNotificationRules] +// - [SecurityMonitoringApi.GetVulnerabilityNotificationRule] +// - [SecurityMonitoringApi.GetVulnerabilityNotificationRules] // - [SecurityMonitoringApi.ListFindings] // - [SecurityMonitoringApi.ListHistoricalJobs] // - [SecurityMonitoringApi.ListSecurityFilters] @@ -327,6 +335,8 @@ // - [SecurityMonitoringApi.ListVulnerabilities] // - [SecurityMonitoringApi.ListVulnerableAssets] // - [SecurityMonitoringApi.MuteFindings] +// - [SecurityMonitoringApi.PatchSignalNotificationRule] +// - [SecurityMonitoringApi.PatchVulnerabilityNotificationRule] // - [SecurityMonitoringApi.RunHistoricalJob] // - [SecurityMonitoringApi.SearchSecurityMonitoringSignals] // - [SecurityMonitoringApi.TestExistingSecurityMonitoringRule] diff --git a/api/datadogV2/model_create_notification_rule_parameters.go b/api/datadogV2/model_create_notification_rule_parameters.go new file mode 100644 index 00000000000..9970ead9930 --- /dev/null +++ b/api/datadogV2/model_create_notification_rule_parameters.go @@ -0,0 +1,111 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateNotificationRuleParameters Body of the notification rule create request. +type CreateNotificationRuleParameters struct { + // Data of the notification rule create request: the rule type, and the rule attributes. All fields are required. + Data *CreateNotificationRuleParametersData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateNotificationRuleParameters instantiates a new CreateNotificationRuleParameters object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateNotificationRuleParameters() *CreateNotificationRuleParameters { + this := CreateNotificationRuleParameters{} + return &this +} + +// NewCreateNotificationRuleParametersWithDefaults instantiates a new CreateNotificationRuleParameters object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateNotificationRuleParametersWithDefaults() *CreateNotificationRuleParameters { + this := CreateNotificationRuleParameters{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CreateNotificationRuleParameters) GetData() CreateNotificationRuleParametersData { + if o == nil || o.Data == nil { + var ret CreateNotificationRuleParametersData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateNotificationRuleParameters) GetDataOk() (*CreateNotificationRuleParametersData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *CreateNotificationRuleParameters) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given CreateNotificationRuleParametersData and assigns it to the Data field. +func (o *CreateNotificationRuleParameters) SetData(v CreateNotificationRuleParametersData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateNotificationRuleParameters) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateNotificationRuleParameters) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateNotificationRuleParametersData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_notification_rule_parameters_data.go b/api/datadogV2/model_create_notification_rule_parameters_data.go new file mode 100644 index 00000000000..23b6d78fcd2 --- /dev/null +++ b/api/datadogV2/model_create_notification_rule_parameters_data.go @@ -0,0 +1,146 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateNotificationRuleParametersData Data of the notification rule create request: the rule type, and the rule attributes. All fields are required. +type CreateNotificationRuleParametersData struct { + // Attributes of the notification rule create request. + Attributes CreateNotificationRuleParametersDataAttributes `json:"attributes"` + // The rule type associated to notification rules. + Type NotificationRulesType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateNotificationRuleParametersData instantiates a new CreateNotificationRuleParametersData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateNotificationRuleParametersData(attributes CreateNotificationRuleParametersDataAttributes, typeVar NotificationRulesType) *CreateNotificationRuleParametersData { + this := CreateNotificationRuleParametersData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewCreateNotificationRuleParametersDataWithDefaults instantiates a new CreateNotificationRuleParametersData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateNotificationRuleParametersDataWithDefaults() *CreateNotificationRuleParametersData { + this := CreateNotificationRuleParametersData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *CreateNotificationRuleParametersData) GetAttributes() CreateNotificationRuleParametersDataAttributes { + if o == nil { + var ret CreateNotificationRuleParametersDataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *CreateNotificationRuleParametersData) GetAttributesOk() (*CreateNotificationRuleParametersDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *CreateNotificationRuleParametersData) SetAttributes(v CreateNotificationRuleParametersDataAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *CreateNotificationRuleParametersData) GetType() NotificationRulesType { + if o == nil { + var ret NotificationRulesType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *CreateNotificationRuleParametersData) GetTypeOk() (*NotificationRulesType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateNotificationRuleParametersData) SetType(v NotificationRulesType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateNotificationRuleParametersData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateNotificationRuleParametersData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CreateNotificationRuleParametersDataAttributes `json:"attributes"` + Type *NotificationRulesType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_notification_rule_parameters_data_attributes.go b/api/datadogV2/model_create_notification_rule_parameters_data_attributes.go new file mode 100644 index 00000000000..21fd9c7d527 --- /dev/null +++ b/api/datadogV2/model_create_notification_rule_parameters_data_attributes.go @@ -0,0 +1,252 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateNotificationRuleParametersDataAttributes Attributes of the notification rule create request. +type CreateNotificationRuleParametersDataAttributes struct { + // Field used to enable or disable the rule. + Enabled *bool `json:"enabled,omitempty"` + // Name of the notification rule. + Name string `json:"name"` + // 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. + Selectors Selectors `json:"selectors"` + // 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. + Targets []string `json:"targets"` + // 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 are only 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. + TimeAggregation *int64 `json:"time_aggregation,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateNotificationRuleParametersDataAttributes instantiates a new CreateNotificationRuleParametersDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateNotificationRuleParametersDataAttributes(name string, selectors Selectors, targets []string) *CreateNotificationRuleParametersDataAttributes { + this := CreateNotificationRuleParametersDataAttributes{} + this.Name = name + this.Selectors = selectors + this.Targets = targets + return &this +} + +// NewCreateNotificationRuleParametersDataAttributesWithDefaults instantiates a new CreateNotificationRuleParametersDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateNotificationRuleParametersDataAttributesWithDefaults() *CreateNotificationRuleParametersDataAttributes { + this := CreateNotificationRuleParametersDataAttributes{} + return &this +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *CreateNotificationRuleParametersDataAttributes) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateNotificationRuleParametersDataAttributes) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *CreateNotificationRuleParametersDataAttributes) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *CreateNotificationRuleParametersDataAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetName returns the Name field value. +func (o *CreateNotificationRuleParametersDataAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *CreateNotificationRuleParametersDataAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CreateNotificationRuleParametersDataAttributes) SetName(v string) { + o.Name = v +} + +// GetSelectors returns the Selectors field value. +func (o *CreateNotificationRuleParametersDataAttributes) GetSelectors() Selectors { + if o == nil { + var ret Selectors + return ret + } + return o.Selectors +} + +// GetSelectorsOk returns a tuple with the Selectors field value +// and a boolean to check if the value has been set. +func (o *CreateNotificationRuleParametersDataAttributes) GetSelectorsOk() (*Selectors, bool) { + if o == nil { + return nil, false + } + return &o.Selectors, true +} + +// SetSelectors sets field value. +func (o *CreateNotificationRuleParametersDataAttributes) SetSelectors(v Selectors) { + o.Selectors = v +} + +// GetTargets returns the Targets field value. +func (o *CreateNotificationRuleParametersDataAttributes) GetTargets() []string { + if o == nil { + var ret []string + return ret + } + return o.Targets +} + +// GetTargetsOk returns a tuple with the Targets field value +// and a boolean to check if the value has been set. +func (o *CreateNotificationRuleParametersDataAttributes) GetTargetsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Targets, true +} + +// SetTargets sets field value. +func (o *CreateNotificationRuleParametersDataAttributes) SetTargets(v []string) { + o.Targets = v +} + +// GetTimeAggregation returns the TimeAggregation field value if set, zero value otherwise. +func (o *CreateNotificationRuleParametersDataAttributes) GetTimeAggregation() int64 { + if o == nil || o.TimeAggregation == nil { + var ret int64 + return ret + } + return *o.TimeAggregation +} + +// GetTimeAggregationOk returns a tuple with the TimeAggregation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateNotificationRuleParametersDataAttributes) GetTimeAggregationOk() (*int64, bool) { + if o == nil || o.TimeAggregation == nil { + return nil, false + } + return o.TimeAggregation, true +} + +// HasTimeAggregation returns a boolean if a field has been set. +func (o *CreateNotificationRuleParametersDataAttributes) HasTimeAggregation() bool { + return o != nil && o.TimeAggregation != nil +} + +// SetTimeAggregation gets a reference to the given int64 and assigns it to the TimeAggregation field. +func (o *CreateNotificationRuleParametersDataAttributes) SetTimeAggregation(v int64) { + o.TimeAggregation = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateNotificationRuleParametersDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + toSerialize["name"] = o.Name + toSerialize["selectors"] = o.Selectors + toSerialize["targets"] = o.Targets + if o.TimeAggregation != nil { + toSerialize["time_aggregation"] = o.TimeAggregation + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateNotificationRuleParametersDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name"` + Selectors *Selectors `json:"selectors"` + Targets *[]string `json:"targets"` + TimeAggregation *int64 `json:"time_aggregation,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Selectors == nil { + return fmt.Errorf("required field selectors missing") + } + if all.Targets == nil { + return fmt.Errorf("required field targets missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"enabled", "name", "selectors", "targets", "time_aggregation"}) + } else { + return err + } + + hasInvalidField := false + o.Enabled = all.Enabled + o.Name = *all.Name + if all.Selectors.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Selectors = *all.Selectors + o.Targets = *all.Targets + o.TimeAggregation = all.TimeAggregation + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_notification_rule.go b/api/datadogV2/model_notification_rule.go new file mode 100644 index 00000000000..0f81a6b9b9f --- /dev/null +++ b/api/datadogV2/model_notification_rule.go @@ -0,0 +1,181 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// NotificationRule Notification rules allow full control over notifications generated by the various Datadog security products. +// They allow users to define the conditions under which a notification should be generated (based on rule severities, +// rule types, rule tags, and so on), 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. +type NotificationRule struct { + // Attributes of the notification rule. + Attributes NotificationRuleAttributes `json:"attributes"` + // The ID of a notification rule. + Id string `json:"id"` + // The rule type associated to notification rules. + Type NotificationRulesType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewNotificationRule instantiates a new NotificationRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewNotificationRule(attributes NotificationRuleAttributes, id string, typeVar NotificationRulesType) *NotificationRule { + this := NotificationRule{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewNotificationRuleWithDefaults instantiates a new NotificationRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewNotificationRuleWithDefaults() *NotificationRule { + this := NotificationRule{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *NotificationRule) GetAttributes() NotificationRuleAttributes { + if o == nil { + var ret NotificationRuleAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *NotificationRule) GetAttributesOk() (*NotificationRuleAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *NotificationRule) SetAttributes(v NotificationRuleAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *NotificationRule) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *NotificationRule) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *NotificationRule) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *NotificationRule) GetType() NotificationRulesType { + if o == nil { + var ret NotificationRulesType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *NotificationRule) GetTypeOk() (*NotificationRulesType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *NotificationRule) SetType(v NotificationRulesType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o NotificationRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *NotificationRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *NotificationRuleAttributes `json:"attributes"` + Id *string `json:"id"` + Type *NotificationRulesType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_notification_rule_attributes.go b/api/datadogV2/model_notification_rule_attributes.go new file mode 100644 index 00000000000..3c95e211c86 --- /dev/null +++ b/api/datadogV2/model_notification_rule_attributes.go @@ -0,0 +1,415 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// NotificationRuleAttributes Attributes of the notification rule. +type NotificationRuleAttributes struct { + // Date as Unix timestamp in milliseconds. + CreatedAt int64 `json:"created_at"` + // User creating or modifying a rule. + CreatedBy RuleUser `json:"created_by"` + // Field used to enable or disable the rule. + Enabled bool `json:"enabled"` + // Date as Unix timestamp in milliseconds. + ModifiedAt int64 `json:"modified_at"` + // User creating or modifying a rule. + ModifiedBy RuleUser `json:"modified_by"` + // Name of the notification rule. + Name string `json:"name"` + // 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. + Selectors Selectors `json:"selectors"` + // 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. + Targets []string `json:"targets"` + // 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 are only 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. + TimeAggregation *int64 `json:"time_aggregation,omitempty"` + // Version of the notification rule. It is updated when the rule is modified. + Version int64 `json:"version"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewNotificationRuleAttributes instantiates a new NotificationRuleAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewNotificationRuleAttributes(createdAt int64, createdBy RuleUser, enabled bool, modifiedAt int64, modifiedBy RuleUser, name string, selectors Selectors, targets []string, version int64) *NotificationRuleAttributes { + this := NotificationRuleAttributes{} + this.CreatedAt = createdAt + this.CreatedBy = createdBy + this.Enabled = enabled + this.ModifiedAt = modifiedAt + this.ModifiedBy = modifiedBy + this.Name = name + this.Selectors = selectors + this.Targets = targets + this.Version = version + return &this +} + +// NewNotificationRuleAttributesWithDefaults instantiates a new NotificationRuleAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewNotificationRuleAttributesWithDefaults() *NotificationRuleAttributes { + this := NotificationRuleAttributes{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *NotificationRuleAttributes) GetCreatedAt() int64 { + if o == nil { + var ret int64 + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetCreatedAtOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *NotificationRuleAttributes) SetCreatedAt(v int64) { + o.CreatedAt = v +} + +// GetCreatedBy returns the CreatedBy field value. +func (o *NotificationRuleAttributes) GetCreatedBy() RuleUser { + if o == nil { + var ret RuleUser + return ret + } + return o.CreatedBy +} + +// GetCreatedByOk returns a tuple with the CreatedBy field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetCreatedByOk() (*RuleUser, bool) { + if o == nil { + return nil, false + } + return &o.CreatedBy, true +} + +// SetCreatedBy sets field value. +func (o *NotificationRuleAttributes) SetCreatedBy(v RuleUser) { + o.CreatedBy = v +} + +// GetEnabled returns the Enabled field value. +func (o *NotificationRuleAttributes) GetEnabled() bool { + if o == nil { + var ret bool + return ret + } + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Enabled, true +} + +// SetEnabled sets field value. +func (o *NotificationRuleAttributes) SetEnabled(v bool) { + o.Enabled = v +} + +// GetModifiedAt returns the ModifiedAt field value. +func (o *NotificationRuleAttributes) GetModifiedAt() int64 { + if o == nil { + var ret int64 + return ret + } + return o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetModifiedAtOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedAt, true +} + +// SetModifiedAt sets field value. +func (o *NotificationRuleAttributes) SetModifiedAt(v int64) { + o.ModifiedAt = v +} + +// GetModifiedBy returns the ModifiedBy field value. +func (o *NotificationRuleAttributes) GetModifiedBy() RuleUser { + if o == nil { + var ret RuleUser + return ret + } + return o.ModifiedBy +} + +// GetModifiedByOk returns a tuple with the ModifiedBy field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetModifiedByOk() (*RuleUser, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedBy, true +} + +// SetModifiedBy sets field value. +func (o *NotificationRuleAttributes) SetModifiedBy(v RuleUser) { + o.ModifiedBy = v +} + +// GetName returns the Name field value. +func (o *NotificationRuleAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *NotificationRuleAttributes) SetName(v string) { + o.Name = v +} + +// GetSelectors returns the Selectors field value. +func (o *NotificationRuleAttributes) GetSelectors() Selectors { + if o == nil { + var ret Selectors + return ret + } + return o.Selectors +} + +// GetSelectorsOk returns a tuple with the Selectors field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetSelectorsOk() (*Selectors, bool) { + if o == nil { + return nil, false + } + return &o.Selectors, true +} + +// SetSelectors sets field value. +func (o *NotificationRuleAttributes) SetSelectors(v Selectors) { + o.Selectors = v +} + +// GetTargets returns the Targets field value. +func (o *NotificationRuleAttributes) GetTargets() []string { + if o == nil { + var ret []string + return ret + } + return o.Targets +} + +// GetTargetsOk returns a tuple with the Targets field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetTargetsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Targets, true +} + +// SetTargets sets field value. +func (o *NotificationRuleAttributes) SetTargets(v []string) { + o.Targets = v +} + +// GetTimeAggregation returns the TimeAggregation field value if set, zero value otherwise. +func (o *NotificationRuleAttributes) GetTimeAggregation() int64 { + if o == nil || o.TimeAggregation == nil { + var ret int64 + return ret + } + return *o.TimeAggregation +} + +// GetTimeAggregationOk returns a tuple with the TimeAggregation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetTimeAggregationOk() (*int64, bool) { + if o == nil || o.TimeAggregation == nil { + return nil, false + } + return o.TimeAggregation, true +} + +// HasTimeAggregation returns a boolean if a field has been set. +func (o *NotificationRuleAttributes) HasTimeAggregation() bool { + return o != nil && o.TimeAggregation != nil +} + +// SetTimeAggregation gets a reference to the given int64 and assigns it to the TimeAggregation field. +func (o *NotificationRuleAttributes) SetTimeAggregation(v int64) { + o.TimeAggregation = &v +} + +// GetVersion returns the Version field value. +func (o *NotificationRuleAttributes) GetVersion() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Version +} + +// GetVersionOk returns a tuple with the Version field value +// and a boolean to check if the value has been set. +func (o *NotificationRuleAttributes) GetVersionOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Version, true +} + +// SetVersion sets field value. +func (o *NotificationRuleAttributes) SetVersion(v int64) { + o.Version = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o NotificationRuleAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["created_at"] = o.CreatedAt + toSerialize["created_by"] = o.CreatedBy + toSerialize["enabled"] = o.Enabled + toSerialize["modified_at"] = o.ModifiedAt + toSerialize["modified_by"] = o.ModifiedBy + toSerialize["name"] = o.Name + toSerialize["selectors"] = o.Selectors + toSerialize["targets"] = o.Targets + if o.TimeAggregation != nil { + toSerialize["time_aggregation"] = o.TimeAggregation + } + toSerialize["version"] = o.Version + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *NotificationRuleAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *int64 `json:"created_at"` + CreatedBy *RuleUser `json:"created_by"` + Enabled *bool `json:"enabled"` + ModifiedAt *int64 `json:"modified_at"` + ModifiedBy *RuleUser `json:"modified_by"` + Name *string `json:"name"` + Selectors *Selectors `json:"selectors"` + Targets *[]string `json:"targets"` + TimeAggregation *int64 `json:"time_aggregation,omitempty"` + Version *int64 `json:"version"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.CreatedBy == nil { + return fmt.Errorf("required field created_by missing") + } + if all.Enabled == nil { + return fmt.Errorf("required field enabled missing") + } + if all.ModifiedAt == nil { + return fmt.Errorf("required field modified_at missing") + } + if all.ModifiedBy == nil { + return fmt.Errorf("required field modified_by missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Selectors == nil { + return fmt.Errorf("required field selectors missing") + } + if all.Targets == nil { + return fmt.Errorf("required field targets missing") + } + if all.Version == nil { + return fmt.Errorf("required field version missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_at", "created_by", "enabled", "modified_at", "modified_by", "name", "selectors", "targets", "time_aggregation", "version"}) + } else { + return err + } + + hasInvalidField := false + o.CreatedAt = *all.CreatedAt + if all.CreatedBy.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.CreatedBy = *all.CreatedBy + o.Enabled = *all.Enabled + o.ModifiedAt = *all.ModifiedAt + if all.ModifiedBy.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.ModifiedBy = *all.ModifiedBy + o.Name = *all.Name + if all.Selectors.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Selectors = *all.Selectors + o.Targets = *all.Targets + o.TimeAggregation = all.TimeAggregation + o.Version = *all.Version + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_notification_rule_response.go b/api/datadogV2/model_notification_rule_response.go new file mode 100644 index 00000000000..c8b343da8b5 --- /dev/null +++ b/api/datadogV2/model_notification_rule_response.go @@ -0,0 +1,115 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// NotificationRuleResponse Response object which includes a notification rule. +type NotificationRuleResponse struct { + // Notification rules allow full control over notifications generated by the various Datadog security products. + // They allow users to define the conditions under which a notification should be generated (based on rule severities, + // rule types, rule tags, and so on), 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. + // + Data *NotificationRule `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewNotificationRuleResponse instantiates a new NotificationRuleResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewNotificationRuleResponse() *NotificationRuleResponse { + this := NotificationRuleResponse{} + return &this +} + +// NewNotificationRuleResponseWithDefaults instantiates a new NotificationRuleResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewNotificationRuleResponseWithDefaults() *NotificationRuleResponse { + this := NotificationRuleResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *NotificationRuleResponse) GetData() NotificationRule { + if o == nil || o.Data == nil { + var ret NotificationRule + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *NotificationRuleResponse) GetDataOk() (*NotificationRule, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *NotificationRuleResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given NotificationRule and assigns it to the Data field. +func (o *NotificationRuleResponse) SetData(v NotificationRule) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o NotificationRuleResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *NotificationRuleResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *NotificationRule `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_notification_rules_type.go b/api/datadogV2/model_notification_rules_type.go new file mode 100644 index 00000000000..eecdb200249 --- /dev/null +++ b/api/datadogV2/model_notification_rules_type.go @@ -0,0 +1,64 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// NotificationRulesType The rule type associated to notification rules. +type NotificationRulesType string + +// List of NotificationRulesType. +const ( + NOTIFICATIONRULESTYPE_NOTIFICATION_RULES NotificationRulesType = "notification_rules" +) + +var allowedNotificationRulesTypeEnumValues = []NotificationRulesType{ + NOTIFICATIONRULESTYPE_NOTIFICATION_RULES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *NotificationRulesType) GetAllowedValues() []NotificationRulesType { + return allowedNotificationRulesTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *NotificationRulesType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = NotificationRulesType(value) + return nil +} + +// NewNotificationRulesTypeFromValue returns a pointer to a valid NotificationRulesType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewNotificationRulesTypeFromValue(v string) (*NotificationRulesType, error) { + ev := NotificationRulesType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for NotificationRulesType: valid values are %v", v, allowedNotificationRulesTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v NotificationRulesType) IsValid() bool { + for _, existing := range allowedNotificationRulesTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to NotificationRulesType value. +func (v NotificationRulesType) Ptr() *NotificationRulesType { + return &v +} diff --git a/api/datadogV2/model_patch_notification_rule_parameters.go b/api/datadogV2/model_patch_notification_rule_parameters.go new file mode 100644 index 00000000000..716980cad06 --- /dev/null +++ b/api/datadogV2/model_patch_notification_rule_parameters.go @@ -0,0 +1,111 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchNotificationRuleParameters Body of the notification rule patch request. +type PatchNotificationRuleParameters struct { + // Data of the notification rule patch request: the rule ID, the rule type, and the rule attributes. All fields are required. + Data *PatchNotificationRuleParametersData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPatchNotificationRuleParameters instantiates a new PatchNotificationRuleParameters object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewPatchNotificationRuleParameters() *PatchNotificationRuleParameters { + this := PatchNotificationRuleParameters{} + return &this +} + +// NewPatchNotificationRuleParametersWithDefaults instantiates a new PatchNotificationRuleParameters object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewPatchNotificationRuleParametersWithDefaults() *PatchNotificationRuleParameters { + this := PatchNotificationRuleParameters{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *PatchNotificationRuleParameters) GetData() PatchNotificationRuleParametersData { + if o == nil || o.Data == nil { + var ret PatchNotificationRuleParametersData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParameters) GetDataOk() (*PatchNotificationRuleParametersData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *PatchNotificationRuleParameters) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given PatchNotificationRuleParametersData and assigns it to the Data field. +func (o *PatchNotificationRuleParameters) SetData(v PatchNotificationRuleParametersData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchNotificationRuleParameters) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchNotificationRuleParameters) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PatchNotificationRuleParametersData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_notification_rule_parameters_data.go b/api/datadogV2/model_patch_notification_rule_parameters_data.go new file mode 100644 index 00000000000..21a7cf03c25 --- /dev/null +++ b/api/datadogV2/model_patch_notification_rule_parameters_data.go @@ -0,0 +1,178 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchNotificationRuleParametersData Data of the notification rule patch request: the rule ID, the rule type, and the rule attributes. All fields are required. +type PatchNotificationRuleParametersData struct { + // Attributes of the notification rule patch request. It is required to update the version of the rule when patching it. + Attributes PatchNotificationRuleParametersDataAttributes `json:"attributes"` + // The ID of a notification rule. + Id string `json:"id"` + // The rule type associated to notification rules. + Type NotificationRulesType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPatchNotificationRuleParametersData instantiates a new PatchNotificationRuleParametersData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewPatchNotificationRuleParametersData(attributes PatchNotificationRuleParametersDataAttributes, id string, typeVar NotificationRulesType) *PatchNotificationRuleParametersData { + this := PatchNotificationRuleParametersData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewPatchNotificationRuleParametersDataWithDefaults instantiates a new PatchNotificationRuleParametersData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewPatchNotificationRuleParametersDataWithDefaults() *PatchNotificationRuleParametersData { + this := PatchNotificationRuleParametersData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *PatchNotificationRuleParametersData) GetAttributes() PatchNotificationRuleParametersDataAttributes { + if o == nil { + var ret PatchNotificationRuleParametersDataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersData) GetAttributesOk() (*PatchNotificationRuleParametersDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *PatchNotificationRuleParametersData) SetAttributes(v PatchNotificationRuleParametersDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *PatchNotificationRuleParametersData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PatchNotificationRuleParametersData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *PatchNotificationRuleParametersData) GetType() NotificationRulesType { + if o == nil { + var ret NotificationRulesType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersData) GetTypeOk() (*NotificationRulesType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PatchNotificationRuleParametersData) SetType(v NotificationRulesType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchNotificationRuleParametersData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchNotificationRuleParametersData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PatchNotificationRuleParametersDataAttributes `json:"attributes"` + Id *string `json:"id"` + Type *NotificationRulesType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_notification_rule_parameters_data_attributes.go b/api/datadogV2/model_patch_notification_rule_parameters_data_attributes.go new file mode 100644 index 00000000000..5f970c57cb0 --- /dev/null +++ b/api/datadogV2/model_patch_notification_rule_parameters_data_attributes.go @@ -0,0 +1,294 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchNotificationRuleParametersDataAttributes Attributes of the notification rule patch request. It is required to update the version of the rule when patching it. +type PatchNotificationRuleParametersDataAttributes struct { + // Field used to enable or disable the rule. + Enabled *bool `json:"enabled,omitempty"` + // Name of the notification rule. + Name *string `json:"name,omitempty"` + // 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. + Selectors *Selectors `json:"selectors,omitempty"` + // 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. + Targets []string `json:"targets,omitempty"` + // 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 are only 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. + TimeAggregation *int64 `json:"time_aggregation,omitempty"` + // Version of the notification rule. It is updated when the rule is modified. + Version *int64 `json:"version,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPatchNotificationRuleParametersDataAttributes instantiates a new PatchNotificationRuleParametersDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewPatchNotificationRuleParametersDataAttributes() *PatchNotificationRuleParametersDataAttributes { + this := PatchNotificationRuleParametersDataAttributes{} + return &this +} + +// NewPatchNotificationRuleParametersDataAttributesWithDefaults instantiates a new PatchNotificationRuleParametersDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewPatchNotificationRuleParametersDataAttributesWithDefaults() *PatchNotificationRuleParametersDataAttributes { + this := PatchNotificationRuleParametersDataAttributes{} + return &this +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *PatchNotificationRuleParametersDataAttributes) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersDataAttributes) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *PatchNotificationRuleParametersDataAttributes) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *PatchNotificationRuleParametersDataAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *PatchNotificationRuleParametersDataAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersDataAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *PatchNotificationRuleParametersDataAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *PatchNotificationRuleParametersDataAttributes) SetName(v string) { + o.Name = &v +} + +// GetSelectors returns the Selectors field value if set, zero value otherwise. +func (o *PatchNotificationRuleParametersDataAttributes) GetSelectors() Selectors { + if o == nil || o.Selectors == nil { + var ret Selectors + return ret + } + return *o.Selectors +} + +// GetSelectorsOk returns a tuple with the Selectors field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersDataAttributes) GetSelectorsOk() (*Selectors, bool) { + if o == nil || o.Selectors == nil { + return nil, false + } + return o.Selectors, true +} + +// HasSelectors returns a boolean if a field has been set. +func (o *PatchNotificationRuleParametersDataAttributes) HasSelectors() bool { + return o != nil && o.Selectors != nil +} + +// SetSelectors gets a reference to the given Selectors and assigns it to the Selectors field. +func (o *PatchNotificationRuleParametersDataAttributes) SetSelectors(v Selectors) { + o.Selectors = &v +} + +// GetTargets returns the Targets field value if set, zero value otherwise. +func (o *PatchNotificationRuleParametersDataAttributes) GetTargets() []string { + if o == nil || o.Targets == nil { + var ret []string + return ret + } + return o.Targets +} + +// GetTargetsOk returns a tuple with the Targets field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersDataAttributes) GetTargetsOk() (*[]string, bool) { + if o == nil || o.Targets == nil { + return nil, false + } + return &o.Targets, true +} + +// HasTargets returns a boolean if a field has been set. +func (o *PatchNotificationRuleParametersDataAttributes) HasTargets() bool { + return o != nil && o.Targets != nil +} + +// SetTargets gets a reference to the given []string and assigns it to the Targets field. +func (o *PatchNotificationRuleParametersDataAttributes) SetTargets(v []string) { + o.Targets = v +} + +// GetTimeAggregation returns the TimeAggregation field value if set, zero value otherwise. +func (o *PatchNotificationRuleParametersDataAttributes) GetTimeAggregation() int64 { + if o == nil || o.TimeAggregation == nil { + var ret int64 + return ret + } + return *o.TimeAggregation +} + +// GetTimeAggregationOk returns a tuple with the TimeAggregation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersDataAttributes) GetTimeAggregationOk() (*int64, bool) { + if o == nil || o.TimeAggregation == nil { + return nil, false + } + return o.TimeAggregation, true +} + +// HasTimeAggregation returns a boolean if a field has been set. +func (o *PatchNotificationRuleParametersDataAttributes) HasTimeAggregation() bool { + return o != nil && o.TimeAggregation != nil +} + +// SetTimeAggregation gets a reference to the given int64 and assigns it to the TimeAggregation field. +func (o *PatchNotificationRuleParametersDataAttributes) SetTimeAggregation(v int64) { + o.TimeAggregation = &v +} + +// GetVersion returns the Version field value if set, zero value otherwise. +func (o *PatchNotificationRuleParametersDataAttributes) GetVersion() int64 { + if o == nil || o.Version == nil { + var ret int64 + return ret + } + return *o.Version +} + +// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchNotificationRuleParametersDataAttributes) GetVersionOk() (*int64, bool) { + if o == nil || o.Version == nil { + return nil, false + } + return o.Version, true +} + +// HasVersion returns a boolean if a field has been set. +func (o *PatchNotificationRuleParametersDataAttributes) HasVersion() bool { + return o != nil && o.Version != nil +} + +// SetVersion gets a reference to the given int64 and assigns it to the Version field. +func (o *PatchNotificationRuleParametersDataAttributes) SetVersion(v int64) { + o.Version = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchNotificationRuleParametersDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Selectors != nil { + toSerialize["selectors"] = o.Selectors + } + if o.Targets != nil { + toSerialize["targets"] = o.Targets + } + if o.TimeAggregation != nil { + toSerialize["time_aggregation"] = o.TimeAggregation + } + if o.Version != nil { + toSerialize["version"] = o.Version + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchNotificationRuleParametersDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` + Selectors *Selectors `json:"selectors,omitempty"` + Targets []string `json:"targets,omitempty"` + TimeAggregation *int64 `json:"time_aggregation,omitempty"` + Version *int64 `json:"version,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"enabled", "name", "selectors", "targets", "time_aggregation", "version"}) + } else { + return err + } + + hasInvalidField := false + o.Enabled = all.Enabled + o.Name = all.Name + if all.Selectors != nil && all.Selectors.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Selectors = all.Selectors + o.Targets = all.Targets + o.TimeAggregation = all.TimeAggregation + o.Version = all.Version + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rule_severity.go b/api/datadogV2/model_rule_severity.go new file mode 100644 index 00000000000..ce5ef01edc8 --- /dev/null +++ b/api/datadogV2/model_rule_severity.go @@ -0,0 +1,74 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RuleSeverity Severity of a security rule. +type RuleSeverity string + +// List of RuleSeverity. +const ( + RULESEVERITY_CRITICAL RuleSeverity = "critical" + RULESEVERITY_HIGH RuleSeverity = "high" + RULESEVERITY_MEDIUM RuleSeverity = "medium" + RULESEVERITY_LOW RuleSeverity = "low" + RULESEVERITY_UNKNOWN RuleSeverity = "unknown" + RULESEVERITY_INFO RuleSeverity = "info" +) + +var allowedRuleSeverityEnumValues = []RuleSeverity{ + RULESEVERITY_CRITICAL, + RULESEVERITY_HIGH, + RULESEVERITY_MEDIUM, + RULESEVERITY_LOW, + RULESEVERITY_UNKNOWN, + RULESEVERITY_INFO, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RuleSeverity) GetAllowedValues() []RuleSeverity { + return allowedRuleSeverityEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RuleSeverity) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RuleSeverity(value) + return nil +} + +// NewRuleSeverityFromValue returns a pointer to a valid RuleSeverity +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRuleSeverityFromValue(v string) (*RuleSeverity, error) { + ev := RuleSeverity(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RuleSeverity: valid values are %v", v, allowedRuleSeverityEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RuleSeverity) IsValid() bool { + for _, existing := range allowedRuleSeverityEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RuleSeverity value. +func (v RuleSeverity) Ptr() *RuleSeverity { + return &v +} diff --git a/api/datadogV2/model_rule_types_items.go b/api/datadogV2/model_rule_types_items.go new file mode 100644 index 00000000000..f899df19047 --- /dev/null +++ b/api/datadogV2/model_rule_types_items.go @@ -0,0 +1,92 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RuleTypesItems 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. +type RuleTypesItems string + +// List of RuleTypesItems. +const ( + RULETYPESITEMS_APPLICATION_SECURITY RuleTypesItems = "application_security" + RULETYPESITEMS_LOG_DETECTION RuleTypesItems = "log_detection" + RULETYPESITEMS_WORKLOAD_SECURITY RuleTypesItems = "workload_security" + RULETYPESITEMS_SIGNAL_CORRELATION RuleTypesItems = "signal_correlation" + RULETYPESITEMS_CLOUD_CONFIGURATION RuleTypesItems = "cloud_configuration" + RULETYPESITEMS_INFRASTRUCTURE_CONFIGURATION RuleTypesItems = "infrastructure_configuration" + RULETYPESITEMS_APPLICATION_CODE_VULNERABILITY RuleTypesItems = "application_code_vulnerability" + RULETYPESITEMS_APPLICATION_LIBRARY_VULNERABILITY RuleTypesItems = "application_library_vulnerability" + RULETYPESITEMS_ATTACK_PATH RuleTypesItems = "attack_path" + RULETYPESITEMS_CONTAINER_IMAGE_VULNERABILITY RuleTypesItems = "container_image_vulnerability" + RULETYPESITEMS_IDENTITY_RISK RuleTypesItems = "identity_risk" + RULETYPESITEMS_MISCONFIGURATION RuleTypesItems = "misconfiguration" + RULETYPESITEMS_API_SECURITY RuleTypesItems = "api_security" +) + +var allowedRuleTypesItemsEnumValues = []RuleTypesItems{ + RULETYPESITEMS_APPLICATION_SECURITY, + RULETYPESITEMS_LOG_DETECTION, + RULETYPESITEMS_WORKLOAD_SECURITY, + RULETYPESITEMS_SIGNAL_CORRELATION, + RULETYPESITEMS_CLOUD_CONFIGURATION, + RULETYPESITEMS_INFRASTRUCTURE_CONFIGURATION, + RULETYPESITEMS_APPLICATION_CODE_VULNERABILITY, + RULETYPESITEMS_APPLICATION_LIBRARY_VULNERABILITY, + RULETYPESITEMS_ATTACK_PATH, + RULETYPESITEMS_CONTAINER_IMAGE_VULNERABILITY, + RULETYPESITEMS_IDENTITY_RISK, + RULETYPESITEMS_MISCONFIGURATION, + RULETYPESITEMS_API_SECURITY, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RuleTypesItems) GetAllowedValues() []RuleTypesItems { + return allowedRuleTypesItemsEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RuleTypesItems) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RuleTypesItems(value) + return nil +} + +// NewRuleTypesItemsFromValue returns a pointer to a valid RuleTypesItems +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRuleTypesItemsFromValue(v string) (*RuleTypesItems, error) { + ev := RuleTypesItems(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RuleTypesItems: valid values are %v", v, allowedRuleTypesItemsEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RuleTypesItems) IsValid() bool { + for _, existing := range allowedRuleTypesItemsEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RuleTypesItems value. +func (v RuleTypesItems) Ptr() *RuleTypesItems { + return &v +} diff --git a/api/datadogV2/model_rule_user.go b/api/datadogV2/model_rule_user.go new file mode 100644 index 00000000000..f22d7752416 --- /dev/null +++ b/api/datadogV2/model_rule_user.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RuleUser User creating or modifying a rule. +type RuleUser struct { + // The user handle. + Handle *string `json:"handle,omitempty"` + // The user name. + Name *string `json:"name,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewRuleUser instantiates a new RuleUser object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRuleUser() *RuleUser { + this := RuleUser{} + return &this +} + +// NewRuleUserWithDefaults instantiates a new RuleUser object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewRuleUserWithDefaults() *RuleUser { + this := RuleUser{} + return &this +} + +// GetHandle returns the Handle field value if set, zero value otherwise. +func (o *RuleUser) GetHandle() string { + if o == nil || o.Handle == nil { + var ret string + return ret + } + return *o.Handle +} + +// GetHandleOk returns a tuple with the Handle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleUser) GetHandleOk() (*string, bool) { + if o == nil || o.Handle == nil { + return nil, false + } + return o.Handle, true +} + +// HasHandle returns a boolean if a field has been set. +func (o *RuleUser) HasHandle() bool { + return o != nil && o.Handle != nil +} + +// SetHandle gets a reference to the given string and assigns it to the Handle field. +func (o *RuleUser) SetHandle(v string) { + o.Handle = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *RuleUser) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleUser) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *RuleUser) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *RuleUser) SetName(v string) { + o.Name = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RuleUser) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Handle != nil { + toSerialize["handle"] = o.Handle + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RuleUser) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Handle *string `json:"handle,omitempty"` + Name *string `json:"name,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"handle", "name"}) + } else { + return err + } + o.Handle = all.Handle + o.Name = all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_selectors.go b/api/datadogV2/model_selectors.go new file mode 100644 index 00000000000..82368f64e89 --- /dev/null +++ b/api/datadogV2/model_selectors.go @@ -0,0 +1,219 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Selectors 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. +type Selectors struct { + // The query is composed of one or several key:value pairs, which can be used to filter security issues on tags and attributes. + Query *string `json:"query,omitempty"` + // Security rule types used to filter signals and vulnerabilities generating notifications. + RuleTypes []RuleTypesItems `json:"rule_types,omitempty"` + // The security rules severities to consider. + Severities []RuleSeverity `json:"severities,omitempty"` + // 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". + TriggerSource TriggerSource `json:"trigger_source"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSelectors instantiates a new Selectors object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSelectors(triggerSource TriggerSource) *Selectors { + this := Selectors{} + this.TriggerSource = triggerSource + return &this +} + +// NewSelectorsWithDefaults instantiates a new Selectors object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSelectorsWithDefaults() *Selectors { + this := Selectors{} + return &this +} + +// GetQuery returns the Query field value if set, zero value otherwise. +func (o *Selectors) GetQuery() string { + if o == nil || o.Query == nil { + var ret string + return ret + } + return *o.Query +} + +// GetQueryOk returns a tuple with the Query field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Selectors) GetQueryOk() (*string, bool) { + if o == nil || o.Query == nil { + return nil, false + } + return o.Query, true +} + +// HasQuery returns a boolean if a field has been set. +func (o *Selectors) HasQuery() bool { + return o != nil && o.Query != nil +} + +// SetQuery gets a reference to the given string and assigns it to the Query field. +func (o *Selectors) SetQuery(v string) { + o.Query = &v +} + +// GetRuleTypes returns the RuleTypes field value if set, zero value otherwise. +func (o *Selectors) GetRuleTypes() []RuleTypesItems { + if o == nil || o.RuleTypes == nil { + var ret []RuleTypesItems + return ret + } + return o.RuleTypes +} + +// GetRuleTypesOk returns a tuple with the RuleTypes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Selectors) GetRuleTypesOk() (*[]RuleTypesItems, bool) { + if o == nil || o.RuleTypes == nil { + return nil, false + } + return &o.RuleTypes, true +} + +// HasRuleTypes returns a boolean if a field has been set. +func (o *Selectors) HasRuleTypes() bool { + return o != nil && o.RuleTypes != nil +} + +// SetRuleTypes gets a reference to the given []RuleTypesItems and assigns it to the RuleTypes field. +func (o *Selectors) SetRuleTypes(v []RuleTypesItems) { + o.RuleTypes = v +} + +// GetSeverities returns the Severities field value if set, zero value otherwise. +func (o *Selectors) GetSeverities() []RuleSeverity { + if o == nil || o.Severities == nil { + var ret []RuleSeverity + return ret + } + return o.Severities +} + +// GetSeveritiesOk returns a tuple with the Severities field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Selectors) GetSeveritiesOk() (*[]RuleSeverity, bool) { + if o == nil || o.Severities == nil { + return nil, false + } + return &o.Severities, true +} + +// HasSeverities returns a boolean if a field has been set. +func (o *Selectors) HasSeverities() bool { + return o != nil && o.Severities != nil +} + +// SetSeverities gets a reference to the given []RuleSeverity and assigns it to the Severities field. +func (o *Selectors) SetSeverities(v []RuleSeverity) { + o.Severities = v +} + +// GetTriggerSource returns the TriggerSource field value. +func (o *Selectors) GetTriggerSource() TriggerSource { + if o == nil { + var ret TriggerSource + return ret + } + return o.TriggerSource +} + +// GetTriggerSourceOk returns a tuple with the TriggerSource field value +// and a boolean to check if the value has been set. +func (o *Selectors) GetTriggerSourceOk() (*TriggerSource, bool) { + if o == nil { + return nil, false + } + return &o.TriggerSource, true +} + +// SetTriggerSource sets field value. +func (o *Selectors) SetTriggerSource(v TriggerSource) { + o.TriggerSource = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Selectors) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Query != nil { + toSerialize["query"] = o.Query + } + if o.RuleTypes != nil { + toSerialize["rule_types"] = o.RuleTypes + } + if o.Severities != nil { + toSerialize["severities"] = o.Severities + } + toSerialize["trigger_source"] = o.TriggerSource + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Selectors) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Query *string `json:"query,omitempty"` + RuleTypes []RuleTypesItems `json:"rule_types,omitempty"` + Severities []RuleSeverity `json:"severities,omitempty"` + TriggerSource *TriggerSource `json:"trigger_source"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.TriggerSource == nil { + return fmt.Errorf("required field trigger_source missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"query", "rule_types", "severities", "trigger_source"}) + } else { + return err + } + + hasInvalidField := false + o.Query = all.Query + o.RuleTypes = all.RuleTypes + o.Severities = all.Severities + if !all.TriggerSource.IsValid() { + hasInvalidField = true + } else { + o.TriggerSource = *all.TriggerSource + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_trigger_source.go b/api/datadogV2/model_trigger_source.go new file mode 100644 index 00000000000..a443f4fba93 --- /dev/null +++ b/api/datadogV2/model_trigger_source.go @@ -0,0 +1,67 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerSource 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". +type TriggerSource string + +// List of TriggerSource. +const ( + TRIGGERSOURCE_SECURITY_FINDINGS TriggerSource = "security_findings" + TRIGGERSOURCE_SECURITY_SIGNALS TriggerSource = "security_signals" +) + +var allowedTriggerSourceEnumValues = []TriggerSource{ + TRIGGERSOURCE_SECURITY_FINDINGS, + TRIGGERSOURCE_SECURITY_SIGNALS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TriggerSource) GetAllowedValues() []TriggerSource { + return allowedTriggerSourceEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TriggerSource) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TriggerSource(value) + return nil +} + +// NewTriggerSourceFromValue returns a pointer to a valid TriggerSource +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTriggerSourceFromValue(v string) (*TriggerSource, error) { + ev := TriggerSource(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TriggerSource: valid values are %v", v, allowedTriggerSourceEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TriggerSource) IsValid() bool { + for _, existing := range allowedTriggerSourceEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TriggerSource value. +func (v TriggerSource) Ptr() *TriggerSource { + return &v +} diff --git a/examples/v2/security-monitoring/CreateSignalNotificationRule.go b/examples/v2/security-monitoring/CreateSignalNotificationRule.go new file mode 100644 index 00000000000..eb70218e1f2 --- /dev/null +++ b/examples/v2/security-monitoring/CreateSignalNotificationRule.go @@ -0,0 +1,53 @@ +// Create a new signal-based rule returns "Successfully created the notification rule." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.CreateNotificationRuleParameters{ + Data: &datadogV2.CreateNotificationRuleParametersData{ + Attributes: datadogV2.CreateNotificationRuleParametersDataAttributes{ + Enabled: datadog.PtrBool(true), + Name: "Rule 1", + Selectors: datadogV2.Selectors{ + Query: datadog.PtrString("(source:production_service OR env:prod)"), + RuleTypes: []datadogV2.RuleTypesItems{ + datadogV2.RULETYPESITEMS_MISCONFIGURATION, + datadogV2.RULETYPESITEMS_ATTACK_PATH, + }, + Severities: []datadogV2.RuleSeverity{ + datadogV2.RULESEVERITY_CRITICAL, + }, + TriggerSource: datadogV2.TRIGGERSOURCE_SECURITY_FINDINGS, + }, + Targets: []string{ + "@john.doe@email.com", + }, + TimeAggregation: datadog.PtrInt64(86400), + }, + Type: datadogV2.NOTIFICATIONRULESTYPE_NOTIFICATION_RULES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.CreateSignalNotificationRule(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.CreateSignalNotificationRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.CreateSignalNotificationRule`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/CreateVulnerabilityNotificationRule.go b/examples/v2/security-monitoring/CreateVulnerabilityNotificationRule.go new file mode 100644 index 00000000000..fdef354ade4 --- /dev/null +++ b/examples/v2/security-monitoring/CreateVulnerabilityNotificationRule.go @@ -0,0 +1,53 @@ +// Create a new vulnerability-based rule returns "Successfully created the notification rule." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.CreateNotificationRuleParameters{ + Data: &datadogV2.CreateNotificationRuleParametersData{ + Attributes: datadogV2.CreateNotificationRuleParametersDataAttributes{ + Enabled: datadog.PtrBool(true), + Name: "Rule 1", + Selectors: datadogV2.Selectors{ + Query: datadog.PtrString("(source:production_service OR env:prod)"), + RuleTypes: []datadogV2.RuleTypesItems{ + datadogV2.RULETYPESITEMS_MISCONFIGURATION, + datadogV2.RULETYPESITEMS_ATTACK_PATH, + }, + Severities: []datadogV2.RuleSeverity{ + datadogV2.RULESEVERITY_CRITICAL, + }, + TriggerSource: datadogV2.TRIGGERSOURCE_SECURITY_FINDINGS, + }, + Targets: []string{ + "@john.doe@email.com", + }, + TimeAggregation: datadog.PtrInt64(86400), + }, + Type: datadogV2.NOTIFICATIONRULESTYPE_NOTIFICATION_RULES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.CreateVulnerabilityNotificationRule(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.CreateVulnerabilityNotificationRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.CreateVulnerabilityNotificationRule`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/DeleteSignalNotificationRule.go b/examples/v2/security-monitoring/DeleteSignalNotificationRule.go new file mode 100644 index 00000000000..347048c637a --- /dev/null +++ b/examples/v2/security-monitoring/DeleteSignalNotificationRule.go @@ -0,0 +1,28 @@ +// Delete a signal-based rule returns "Rule successfully deleted." response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "valid_signal_notification_rule" in the system + ValidSignalNotificationRuleDataID := os.Getenv("VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + r, err := api.DeleteSignalNotificationRule(ctx, ValidSignalNotificationRuleDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.DeleteSignalNotificationRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/security-monitoring/DeleteVulnerabilityNotificationRule.go b/examples/v2/security-monitoring/DeleteVulnerabilityNotificationRule.go new file mode 100644 index 00000000000..35f56892ec6 --- /dev/null +++ b/examples/v2/security-monitoring/DeleteVulnerabilityNotificationRule.go @@ -0,0 +1,28 @@ +// Delete a vulnerability-based rule returns "Rule successfully deleted." response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "valid_vulnerability_notification_rule" in the system + ValidVulnerabilityNotificationRuleDataID := os.Getenv("VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + r, err := api.DeleteVulnerabilityNotificationRule(ctx, ValidVulnerabilityNotificationRuleDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.DeleteVulnerabilityNotificationRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/security-monitoring/GetSignalNotificationRule.go b/examples/v2/security-monitoring/GetSignalNotificationRule.go new file mode 100644 index 00000000000..5ecf006b3b6 --- /dev/null +++ b/examples/v2/security-monitoring/GetSignalNotificationRule.go @@ -0,0 +1,32 @@ +// Get details of a signal-based rule returns "Notification rule details." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "valid_signal_notification_rule" in the system + ValidSignalNotificationRuleDataID := os.Getenv("VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.GetSignalNotificationRule(ctx, ValidSignalNotificationRuleDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.GetSignalNotificationRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.GetSignalNotificationRule`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/GetSignalNotificationRules.go b/examples/v2/security-monitoring/GetSignalNotificationRules.go new file mode 100644 index 00000000000..0514fe5dc92 --- /dev/null +++ b/examples/v2/security-monitoring/GetSignalNotificationRules.go @@ -0,0 +1,29 @@ +// Get the list of signal-based rules returns "The list of notification rules." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.GetSignalNotificationRules(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.GetSignalNotificationRules`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.GetSignalNotificationRules`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/GetVulnerabilityNotificationRule.go b/examples/v2/security-monitoring/GetVulnerabilityNotificationRule.go new file mode 100644 index 00000000000..e5f667ac27d --- /dev/null +++ b/examples/v2/security-monitoring/GetVulnerabilityNotificationRule.go @@ -0,0 +1,32 @@ +// Get details of a vulnerability-based rule returns "Notification rule details." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "valid_vulnerability_notification_rule" in the system + ValidVulnerabilityNotificationRuleDataID := os.Getenv("VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.GetVulnerabilityNotificationRule(ctx, ValidVulnerabilityNotificationRuleDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.GetVulnerabilityNotificationRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.GetVulnerabilityNotificationRule`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/GetVulnerabilityNotificationRules.go b/examples/v2/security-monitoring/GetVulnerabilityNotificationRules.go new file mode 100644 index 00000000000..5c235e457b8 --- /dev/null +++ b/examples/v2/security-monitoring/GetVulnerabilityNotificationRules.go @@ -0,0 +1,29 @@ +// Get the list of vulnerability-based rules returns "The list of notification rules." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.GetVulnerabilityNotificationRules(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.GetVulnerabilityNotificationRules`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.GetVulnerabilityNotificationRules`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/PatchSignalNotificationRule.go b/examples/v2/security-monitoring/PatchSignalNotificationRule.go new file mode 100644 index 00000000000..25e22929e08 --- /dev/null +++ b/examples/v2/security-monitoring/PatchSignalNotificationRule.go @@ -0,0 +1,58 @@ +// Patch a signal-based rule returns "Notification rule successfully patched." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "valid_signal_notification_rule" in the system + ValidSignalNotificationRuleDataID := os.Getenv("VALID_SIGNAL_NOTIFICATION_RULE_DATA_ID") + + body := datadogV2.PatchNotificationRuleParameters{ + Data: &datadogV2.PatchNotificationRuleParametersData{ + Attributes: datadogV2.PatchNotificationRuleParametersDataAttributes{ + Enabled: datadog.PtrBool(true), + Name: datadog.PtrString("Rule 1"), + Selectors: &datadogV2.Selectors{ + Query: datadog.PtrString("(source:production_service OR env:prod)"), + RuleTypes: []datadogV2.RuleTypesItems{ + datadogV2.RULETYPESITEMS_MISCONFIGURATION, + datadogV2.RULETYPESITEMS_ATTACK_PATH, + }, + Severities: []datadogV2.RuleSeverity{ + datadogV2.RULESEVERITY_CRITICAL, + }, + TriggerSource: datadogV2.TRIGGERSOURCE_SECURITY_FINDINGS, + }, + Targets: []string{ + "@john.doe@email.com", + }, + TimeAggregation: datadog.PtrInt64(86400), + Version: datadog.PtrInt64(1), + }, + Id: ValidSignalNotificationRuleDataID, + Type: datadogV2.NOTIFICATIONRULESTYPE_NOTIFICATION_RULES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.PatchSignalNotificationRule(ctx, ValidSignalNotificationRuleDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.PatchSignalNotificationRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.PatchSignalNotificationRule`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/PatchVulnerabilityNotificationRule.go b/examples/v2/security-monitoring/PatchVulnerabilityNotificationRule.go new file mode 100644 index 00000000000..80f32890609 --- /dev/null +++ b/examples/v2/security-monitoring/PatchVulnerabilityNotificationRule.go @@ -0,0 +1,58 @@ +// Patch a vulnerability-based rule returns "Notification rule successfully patched." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "valid_vulnerability_notification_rule" in the system + ValidVulnerabilityNotificationRuleDataID := os.Getenv("VALID_VULNERABILITY_NOTIFICATION_RULE_DATA_ID") + + body := datadogV2.PatchNotificationRuleParameters{ + Data: &datadogV2.PatchNotificationRuleParametersData{ + Attributes: datadogV2.PatchNotificationRuleParametersDataAttributes{ + Enabled: datadog.PtrBool(true), + Name: datadog.PtrString("Rule 1"), + Selectors: &datadogV2.Selectors{ + Query: datadog.PtrString("(source:production_service OR env:prod)"), + RuleTypes: []datadogV2.RuleTypesItems{ + datadogV2.RULETYPESITEMS_MISCONFIGURATION, + datadogV2.RULETYPESITEMS_ATTACK_PATH, + }, + Severities: []datadogV2.RuleSeverity{ + datadogV2.RULESEVERITY_CRITICAL, + }, + TriggerSource: datadogV2.TRIGGERSOURCE_SECURITY_FINDINGS, + }, + Targets: []string{ + "@john.doe@email.com", + }, + TimeAggregation: datadog.PtrInt64(86400), + Version: datadog.PtrInt64(1), + }, + Id: ValidVulnerabilityNotificationRuleDataID, + Type: datadogV2.NOTIFICATIONRULESTYPE_NOTIFICATION_RULES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.PatchVulnerabilityNotificationRule(ctx, ValidVulnerabilityNotificationRuleDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.PatchVulnerabilityNotificationRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.PatchVulnerabilityNotificationRule`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule._response.freeze new file mode 100644 index 00000000000..b0503404843 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:35:59.157Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule._response.yaml new file mode 100644 index 00000000000..eee67c2c7cd --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule._response.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + body: '{"data":{"id":"xen-2ux-w4q","type":"notification_rules","attributes":{"created_at":1737628559636,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628559636,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/xen-2ux-w4q + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule_response.freeze new file mode 100644 index 00000000000..d013b137455 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule_response.yaml new file mode 100644 index 00000000000..5274c8dae83 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_signal-based_rule_returns_Successfully_created_the_notification_rule_response.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/rko-c7a-mx9 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule._response.freeze new file mode 100644 index 00000000000..4df775f8484 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:35:59.776Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule._response.yaml new file mode 100644 index 00000000000..98f0052824e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule._response.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + body: '{"data":{"id":"757-rvr-pnu","type":"notification_rules","attributes":{"created_at":1737628559864,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628559864,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/757-rvr-pnu + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule_response.freeze new file mode 100644 index 00000000000..4a1ded127d1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule_response.yaml new file mode 100644 index 00000000000..c0aa13b71ec --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_new_vulnerability-based_rule_returns_Successfully_created_the_notification_rule_response.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/1hi-lla-3nx + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..5ed3da99691 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..fcc32dd8b2d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Not_Found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/000-000-000 + response: + body: '{"errors":["not_found(Notification rule with id ''000-000-000'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted._response.freeze new file mode 100644 index 00000000000..c75b28e4575 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:36:00.001Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted._response.yaml new file mode 100644 index 00000000000..708ccd8253d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted._response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":true,"name":"Test-Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response-1737628560","selectors":{"query":"env:test","rule_types":["signal_correlation"],"severities":["critical"],"trigger_source":"security_signals"},"targets":["@email@email.com"]},"type":"notification_rules"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + body: '{"data":{"id":"trc-uxv-vc0","type":"notification_rules","attributes":{"created_at":1737628560083,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628560083,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Delete_a_signal_based_rule_returns_Rule_successfully_deleted_response-1737628560","selectors":{"severities":["critical"],"rule_types":["signal_correlation"],"query":"env:test","trigger_source":"security_signals"},"targets":["@email@email.com"],"time_aggregation":0,"version":1}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/trc-uxv-vc0 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/trc-uxv-vc0 + response: + body: '{"errors":["not_found(Notification rule with id ''trc-uxv-vc0'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted_response.freeze new file mode 100644 index 00000000000..5b9cab2f5f9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted_response.yaml new file mode 100644 index 00000000000..be9ae903d06 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_signal-based_rule_returns_Rule_successfully_deleted_response.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/ukc-0jn-maf + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/ukc-0jn-maf + response: + body: '{"errors":["not_found(Notification rule with id ''ukc-0jn-maf'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..31d1497fde4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..5e36340ec79 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Not_Found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/000-000-000 + response: + body: '{"errors":["not_found(Notification rule with id ''000-000-000'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted._response.freeze new file mode 100644 index 00000000000..a338c2e32c4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:36:00.286Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted._response.yaml new file mode 100644 index 00000000000..03e44c5341d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted._response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":true,"name":"Test-Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response-1737628560","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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + body: '{"data":{"id":"gcs-6rv-fjw","type":"notification_rules","attributes":{"created_at":1737628560356,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628560356,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Delete_a_vulnerability_based_rule_returns_Rule_successfully_deleted_response-1737628560","selectors":{"severities":["critical"],"rule_types":["misconfiguration","attack_path"],"query":"env:test","trigger_source":"security_findings"},"targets":["@email@email.com"],"time_aggregation":86400,"version":1}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/gcs-6rv-fjw + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/gcs-6rv-fjw + response: + body: '{"errors":["not_found(Notification rule with id ''gcs-6rv-fjw'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted_response.freeze new file mode 100644 index 00000000000..f80fa530897 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted_response.yaml new file mode 100644 index 00000000000..93f6a47ff0c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_a_vulnerability-based_rule_returns_Rule_successfully_deleted_response.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/qip-ygy-7ke + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/qip-ygy-7ke + response: + body: '{"errors":["not_found(Notification rule with id ''qip-ygy-7ke'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..6d4de62a52a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..1c75f1df37e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Not_Found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/000-000-000 + response: + body: '{"errors":["not_found(Notification rule with id ''000-000-000'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details._response.freeze new file mode 100644 index 00000000000..1e9763b3e42 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:36:00.694Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details._response.yaml new file mode 100644 index 00000000000..ecfd52214fd --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details._response.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":true,"name":"Test-Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response-1737628560","selectors":{"query":"env:test","rule_types":["signal_correlation"],"severities":["critical"],"trigger_source":"security_signals"},"targets":["@email@email.com"]},"type":"notification_rules"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + body: '{"data":{"id":"fjl-dbj-4lx","type":"notification_rules","attributes":{"created_at":1737628560844,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628560844,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response-1737628560","selectors":{"severities":["critical"],"rule_types":["signal_correlation"],"query":"env:test","trigger_source":"security_signals"},"targets":["@email@email.com"],"time_aggregation":0,"version":1}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/fjl-dbj-4lx + response: + body: '{"data":{"id":"fjl-dbj-4lx","type":"notification_rules","attributes":{"created_at":1737628560844,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628560844,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Get_details_of_a_signal_based_rule_returns_Notification_rule_details_response-1737628560","selectors":{"severities":["critical"],"rule_types":["signal_correlation"],"query":"env:test","trigger_source":"security_signals"},"targets":["@email@email.com"],"time_aggregation":0,"version":1}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/fjl-dbj-4lx + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details_response.freeze new file mode 100644 index 00000000000..fe7b63784cc --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details_response.yaml new file mode 100644 index 00000000000..84110d8c156 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_signal-based_rule_returns_Notification_rule_details_response.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/t8x-amt-d52 + response: + 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}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/t8x-amt-d52 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..d1e8767198e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..ee1484e72f9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Not_Found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/000-000-000 + response: + body: '{"errors":["not_found(Notification rule with id ''000-000-000'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details._response.freeze new file mode 100644 index 00000000000..9f8c0c6866c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:36:01.133Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details._response.yaml new file mode 100644 index 00000000000..4bc0e3651be --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details._response.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":true,"name":"Test-Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response-1737628561","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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + body: '{"data":{"id":"sr4-jjh-rjy","type":"notification_rules","attributes":{"created_at":1737628561210,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628561210,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response-1737628561","selectors":{"severities":["critical"],"rule_types":["misconfiguration","attack_path"],"query":"env:test","trigger_source":"security_findings"},"targets":["@email@email.com"],"time_aggregation":86400,"version":1}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/sr4-jjh-rjy + response: + body: '{"data":{"id":"sr4-jjh-rjy","type":"notification_rules","attributes":{"created_at":1737628561210,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628561210,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Get_details_of_a_vulnerability_based_rule_returns_Notification_rule_details_response-1737628561","selectors":{"severities":["critical"],"rule_types":["misconfiguration","attack_path"],"query":"env:test","trigger_source":"security_findings"},"targets":["@email@email.com"],"time_aggregation":86400,"version":1}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/sr4-jjh-rjy + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details_response.freeze new file mode 100644 index 00000000000..1aed5057f55 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details_response.yaml new file mode 100644 index 00000000000..3bd9690375f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_details_of_a_vulnerability-based_rule_returns_Notification_rule_details_response.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/aqq-x71-k2h + response: + 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}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/aqq-x71-k2h + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules._response.freeze new file mode 100644 index 00000000000..3f0d8fa0766 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:36:01.381Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules._response.yaml new file mode 100644 index 00000000000..6a1544d6146 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules._response.yaml @@ -0,0 +1,67 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":true,"name":"Test-Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response-1737628561","selectors":{"query":"env:test","rule_types":["signal_correlation"],"severities":["critical"],"trigger_source":"security_signals"},"targets":["@email@email.com"]},"type":"notification_rules"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + body: '{"data":{"id":"wt5-y8s-3fa","type":"notification_rules","attributes":{"created_at":1737628561456,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628561456,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response-1737628561","selectors":{"severities":["critical"],"rule_types":["signal_correlation"],"query":"env:test","trigger_source":"security_signals"},"targets":["@email@email.com"],"time_aggregation":0,"version":1}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + 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":"wt5-y8s-3fa","type":"notification_rules","attributes":{"created_at":1737628561456,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628561456,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Get_the_list_of_signal_based_rules_returns_The_list_of_notification_rules_response-1737628561","selectors":{"severities":["critical"],"rule_types":["signal_correlation"],"query":"env:test","trigger_source":"security_signals"},"targets":["@email@email.com"],"time_aggregation":0,"version":1}}]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/wt5-y8s-3fa + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules_response.yaml new file mode 100644 index 00000000000..58d1193e728 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_signal-based_rules_returns_The_list_of_notification_rules_response.yaml @@ -0,0 +1,63 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + 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}}]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/dr3-owt-amk + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules._response.freeze new file mode 100644 index 00000000000..1c559ecb18a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:36:01.893Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules._response.yaml new file mode 100644 index 00000000000..d75c5a4a6e2 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules._response.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":true,"name":"Test-Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response-1737628561","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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + body: '{"data":{"id":"hrp-9cl-j7q","type":"notification_rules","attributes":{"created_at":1737628561955,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628561955,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response-1737628561","selectors":{"severities":["critical"],"rule_types":["misconfiguration","attack_path"],"query":"env:test","trigger_source":"security_findings"},"targets":["@email@email.com"],"time_aggregation":86400,"version":1}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + body: '{"data":[{"id":"hrp-9cl-j7q","type":"notification_rules","attributes":{"created_at":1737628561955,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628561955,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Get_the_list_of_vulnerability_based_rules_returns_The_list_of_notification_rules_response-1737628561","selectors":{"severities":["critical"],"rule_types":["misconfiguration","attack_path"],"query":"env:test","trigger_source":"security_findings"},"targets":["@email@email.com"],"time_aggregation":86400,"version":1}}]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/hrp-9cl-j7q + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules_response.yaml new file mode 100644 index 00000000000..4655e051ff4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_the_list_of_vulnerability-based_rules_returns_The_list_of_notification_rules_response.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + 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}}]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/ua9-ppq-acw + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..50ebef7d381 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..6d151d87817 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Bad_Request_response.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/urx-vcd-58d + response: + body: '{"errors":["input_validation_error(Field ''data.attributes.version'' is + invalid: Specify the notification rule version to update, it cannot be 0.)"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/urx-vcd-58d + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..cbf78aceabd --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..2faf1010edf --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Not_Found_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/000-000-000 + response: + body: '{"errors":["not_found(Notification rule with id ''000-000-000'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched._response.freeze new file mode 100644 index 00000000000..97e974ae6bd --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:36:02.171Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched._response.yaml new file mode 100644 index 00000000000..9bfd68a100a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched._response.yaml @@ -0,0 +1,62 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":true,"name":"Test-Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response-1737628562","selectors":{"query":"env:test","rule_types":["signal_correlation"],"severities":["critical"],"trigger_source":"security_signals"},"targets":["@email@email.com"]},"type":"notification_rules"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + body: '{"data":{"id":"oip-w1n-zpc","type":"notification_rules","attributes":{"created_at":1737628562246,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628562246,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Patch_a_signal_based_rule_returns_Notification_rule_successfully_patched_response-1737628562","selectors":{"severities":["critical"],"rule_types":["signal_correlation"],"query":"env:test","trigger_source":"security_signals"},"targets":["@email@email.com"],"time_aggregation":0,"version":1}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/oip-w1n-zpc + response: + body: '{"data":{"id":"oip-w1n-zpc","type":"notification_rules","attributes":{"created_at":1737628562246,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628562326,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"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}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/oip-w1n-zpc + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched_response.freeze new file mode 100644 index 00000000000..dbfecb7971f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched_response.yaml new file mode 100644 index 00000000000..463feb4266d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_signal-based_rule_returns_Notification_rule_successfully_patched_response.yaml @@ -0,0 +1,59 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/h6x-nyx-fkm + response: + 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}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/signals/notification_rules/h6x-nyx-fkm + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..fcdc31ed0f0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..368bcc2df13 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Bad_Request_response.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/ks5-ywq-grp + response: + body: '{"errors":["input_validation_error(Field ''data.attributes.version'' is + invalid: Specify the notification rule version to update, it cannot be 0.)"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/ks5-ywq-grp + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..f24abb9c921 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..40032e51e53 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Not_Found_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/000-000-000 + response: + body: '{"errors":["not_found(Notification rule with id ''000-000-000'' not found)"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched._response.freeze new file mode 100644 index 00000000000..cfd5bff93e3 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched._response.freeze @@ -0,0 +1 @@ +2025-01-23T10:36:02.436Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched._response.yaml new file mode 100644 index 00000000000..e0615575246 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched._response.yaml @@ -0,0 +1,62 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":true,"name":"Test-Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response-1737628562","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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + body: '{"data":{"id":"sou-9gl-xxm","type":"notification_rules","attributes":{"created_at":1737628562491,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628562491,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"name":"Test-Patch_a_vulnerability_based_rule_returns_Notification_rule_successfully_patched_response-1737628562","selectors":{"severities":["critical"],"rule_types":["misconfiguration","attack_path"],"query":"env:test","trigger_source":"security_findings"},"targets":["@email@email.com"],"time_aggregation":86400,"version":1}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/sou-9gl-xxm + response: + body: '{"data":{"id":"sou-9gl-xxm","type":"notification_rules","attributes":{"created_at":1737628562491,"created_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"enabled":true,"modified_at":1737628562590,"modified_by":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"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}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/sou-9gl-xxm + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched_response.freeze new file mode 100644 index 00000000000..e2e97276a9e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_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/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched_response.yaml new file mode 100644 index 00000000000..732840c0f3d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Patch_a_vulnerability-based_rule_returns_Notification_rule_successfully_patched_response.yaml @@ -0,0 +1,59 @@ +interactions: +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules + response: + 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}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/a40-xl3-95h + response: + 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}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/security/vulnerabilities/notification_rules/a40-xl3-95h + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index e5c2cbcc488..a4729ae0c58 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/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/tests/scenarios/features/v2/security_monitoring.feature b/tests/scenarios/features/v2/security_monitoring.feature index 5a2330a8f35..a82f2a3dcd8 100644 --- a/tests/scenarios/features/v2/security_monitoring.feature +++ b/tests/scenarios/features/v2/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 @@ -599,6 +657,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 @@ -773,6 +889,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/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index a195ddc9e5e..d8ddf129a0e 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2067,12 +2067,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": {