diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4c46f3c596f..9041f8a0039 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -45082,6 +45082,125 @@ components: meta: $ref: "#/components/schemas/MonthlyCostAttributionMeta" type: object + MuteDataType: + default: mute + description: Mute resource type. + enum: + - mute + example: mute + type: string + x-enum-varnames: + - MUTE + MuteFindingsMuteAttributes: + description: Mute properties to apply to the findings. + properties: + description: + description: Additional information about the reason why the findings are muted or unmuted. This field has a limit of 280 characters. + example: "To be resolved later." + type: string + expire_at: + description: >- + The expiration date of the mute action (Unix ms). It must be set to a value greater than the current timestamp. If this field is not provided, the findings remain muted indefinitely. + example: 1778721573794 + format: int64 + type: integer + is_muted: + description: Whether the findings should be muted or unmuted. + example: true + type: boolean + reason: + $ref: "#/components/schemas/MuteFindingsReason" + description: The reason why the findings are muted or unmuted. + required: + - is_muted + - reason + type: object + MuteFindingsReason: + description: The reason why the findings are muted or unmuted. + enum: + - PENDING_FIX + - FALSE_POSITIVE + - OTHER + - NO_FIX + - DUPLICATE + - RISK_ACCEPTED + - NO_PENDING_FIX + - HUMAN_ERROR + - NO_LONGER_ACCEPTED_RISK + example: PENDING_FIX + type: string + x-enum-varnames: + - PENDING_FIX + - FALSE_POSITIVE + - OTHER + - NO_FIX + - DUPLICATE + - RISK_ACCEPTED + - NO_PENDING_FIX + - HUMAN_ERROR + - NO_LONGER_ACCEPTED_RISK + MuteFindingsRequest: + description: Request to mute or unmute security findings. + properties: + data: + $ref: "#/components/schemas/MuteFindingsRequestData" + required: + - data + type: object + MuteFindingsRequestData: + description: Data of the mute request. + properties: + attributes: + $ref: "#/components/schemas/MuteFindingsRequestDataAttributes" + id: + description: Unique identifier of the mute request. + example: "93bfeb70-af47-424d-908a-948d3f08e37f" + type: string + relationships: + $ref: "#/components/schemas/MuteFindingsRequestDataRelationships" + type: + $ref: "#/components/schemas/MuteDataType" + required: + - attributes + - relationships + - type + type: object + MuteFindingsRequestDataAttributes: + description: Attributes of the mute request. + properties: + mute: + $ref: "#/components/schemas/MuteFindingsMuteAttributes" + required: + - mute + type: object + MuteFindingsRequestDataRelationships: + description: Relationships of the mute request. + properties: + findings: + $ref: "#/components/schemas/Findings" + description: Security findings to mute or unmute. + required: + - findings + type: object + MuteFindingsResponse: + description: Response for the mute or unmute request. + properties: + data: + $ref: "#/components/schemas/MuteFindingsResponseData" + type: object + MuteFindingsResponseData: + description: Data of the mute response. + properties: + id: + description: Unique identifier of the mute request. + example: "93bfeb70-af47-424d-908a-948d3f08e37f" + type: string + type: + $ref: "#/components/schemas/MuteDataType" + required: + - type + - id + type: object NotebookCreateData: description: Notebook creation data properties: @@ -119237,6 +119356,74 @@ paths: permissions: - security_monitoring_findings_write - appsec_vm_write + /api/v2/security/findings/mute: + patch: + description: >- + Mute or unmute security findings. + + You can mute or unmute up to 100 security findings per request. The request body must include `is_muted` and `reason` attributes. The allowed reasons depend on whether the finding is being muted or unmuted: + - To mute a finding: `PENDING_FIX`, `FALSE_POSITIVE`, `OTHER`, `NO_FIX`, `DUPLICATE`, `RISK_ACCEPTED`. + - To unmute a finding: `NO_PENDING_FIX`, `HUMAN_ERROR`, `NO_LONGER_ACCEPTED_RISK`, `OTHER`. + operationId: MuteSecurityFindings + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + mute: + description: "To be resolved later." + expire_at: 1778721573794 + is_muted: true + reason: "RISK_ACCEPTED" + relationships: + findings: + data: + - id: "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==" + type: "findings" + type: "mute" + schema: + $ref: "#/components/schemas/MuteFindingsRequest" + required: true + responses: + "202": + content: + application/json: + schema: + $ref: "#/components/schemas/MuteFindingsResponse" + description: Accepted + "400": + $ref: "#/components/responses/BadRequestResponse" + "401": + $ref: "#/components/responses/UnauthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "422": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: "Unprocessable Entity" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Mute or unmute security findings + tags: + - "Security Monitoring" + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - security_monitoring_findings_write + - appsec_vm_write + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/security/findings/search: post: description: |- diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index f25b6ecb84a..ee3b734d974 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -757,6 +757,7 @@ func NewConfiguration() *Configuration { "v2.ListVulnerabilities": false, "v2.ListVulnerableAssets": false, "v2.MuteFindings": false, + "v2.MuteSecurityFindings": false, "v2.RunHistoricalJob": false, "v2.SearchSecurityMonitoringHistsignals": false, "v2.GetCodeCoverageBranchSummary": false, diff --git a/api/datadogV2/api_security_monitoring.go b/api/datadogV2/api_security_monitoring.go index d0fcf5e6674..81168fb7064 100644 --- a/api/datadogV2/api_security_monitoring.go +++ b/api/datadogV2/api_security_monitoring.go @@ -8561,6 +8561,107 @@ func (a *SecurityMonitoringApi) MuteFindings(ctx _context.Context, body BulkMute return localVarReturnValue, localVarHTTPResponse, nil } +// MuteSecurityFindings Mute or unmute security findings. +// Mute or unmute security findings. +// You can mute or unmute up to 100 security findings per request. The request body must include `is_muted` and `reason` attributes. The allowed reasons depend on whether the finding is being muted or unmuted: +// - To mute a finding: `PENDING_FIX`, `FALSE_POSITIVE`, `OTHER`, `NO_FIX`, `DUPLICATE`, `RISK_ACCEPTED`. +// - To unmute a finding: `NO_PENDING_FIX`, `HUMAN_ERROR`, `NO_LONGER_ACCEPTED_RISK`, `OTHER`. +func (a *SecurityMonitoringApi) MuteSecurityFindings(ctx _context.Context, body MuteFindingsRequest) (MuteFindingsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue MuteFindingsResponse + ) + + operationId := "v2.MuteSecurityFindings" + 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.MuteSecurityFindings") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/findings/mute" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 401 || 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 +} + // PatchSignalNotificationRule Patch a signal-based notification 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) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 603812f6338..6fdecb55509 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -813,6 +813,7 @@ // - [SecurityMonitoringApi.ListVulnerabilities] // - [SecurityMonitoringApi.ListVulnerableAssets] // - [SecurityMonitoringApi.MuteFindings] +// - [SecurityMonitoringApi.MuteSecurityFindings] // - [SecurityMonitoringApi.PatchSignalNotificationRule] // - [SecurityMonitoringApi.PatchVulnerabilityNotificationRule] // - [SecurityMonitoringApi.RunHistoricalJob] diff --git a/api/datadogV2/model_mute_data_type.go b/api/datadogV2/model_mute_data_type.go new file mode 100644 index 00000000000..c289c5b21e6 --- /dev/null +++ b/api/datadogV2/model_mute_data_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" +) + +// MuteDataType Mute resource type. +type MuteDataType string + +// List of MuteDataType. +const ( + MUTEDATATYPE_MUTE MuteDataType = "mute" +) + +var allowedMuteDataTypeEnumValues = []MuteDataType{ + MUTEDATATYPE_MUTE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *MuteDataType) GetAllowedValues() []MuteDataType { + return allowedMuteDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *MuteDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = MuteDataType(value) + return nil +} + +// NewMuteDataTypeFromValue returns a pointer to a valid MuteDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewMuteDataTypeFromValue(v string) (*MuteDataType, error) { + ev := MuteDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for MuteDataType: valid values are %v", v, allowedMuteDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v MuteDataType) IsValid() bool { + for _, existing := range allowedMuteDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to MuteDataType value. +func (v MuteDataType) Ptr() *MuteDataType { + return &v +} diff --git a/api/datadogV2/model_mute_findings_mute_attributes.go b/api/datadogV2/model_mute_findings_mute_attributes.go new file mode 100644 index 00000000000..fb560c2dcb1 --- /dev/null +++ b/api/datadogV2/model_mute_findings_mute_attributes.go @@ -0,0 +1,213 @@ +// 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" +) + +// MuteFindingsMuteAttributes Mute properties to apply to the findings. +type MuteFindingsMuteAttributes struct { + // Additional information about the reason why the findings are muted or unmuted. This field has a limit of 280 characters. + Description *string `json:"description,omitempty"` + // The expiration date of the mute action (Unix ms). It must be set to a value greater than the current timestamp. If this field is not provided, the findings remain muted indefinitely. + ExpireAt *int64 `json:"expire_at,omitempty"` + // Whether the findings should be muted or unmuted. + IsMuted bool `json:"is_muted"` + // The reason why the findings are muted or unmuted. + Reason MuteFindingsReason `json:"reason"` + // 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:"-"` +} + +// NewMuteFindingsMuteAttributes instantiates a new MuteFindingsMuteAttributes 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 NewMuteFindingsMuteAttributes(isMuted bool, reason MuteFindingsReason) *MuteFindingsMuteAttributes { + this := MuteFindingsMuteAttributes{} + this.IsMuted = isMuted + this.Reason = reason + return &this +} + +// NewMuteFindingsMuteAttributesWithDefaults instantiates a new MuteFindingsMuteAttributes 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 NewMuteFindingsMuteAttributesWithDefaults() *MuteFindingsMuteAttributes { + this := MuteFindingsMuteAttributes{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *MuteFindingsMuteAttributes) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MuteFindingsMuteAttributes) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *MuteFindingsMuteAttributes) HasDescription() bool { + return o != nil && o.Description != nil +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *MuteFindingsMuteAttributes) SetDescription(v string) { + o.Description = &v +} + +// GetExpireAt returns the ExpireAt field value if set, zero value otherwise. +func (o *MuteFindingsMuteAttributes) GetExpireAt() int64 { + if o == nil || o.ExpireAt == nil { + var ret int64 + return ret + } + return *o.ExpireAt +} + +// GetExpireAtOk returns a tuple with the ExpireAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MuteFindingsMuteAttributes) GetExpireAtOk() (*int64, bool) { + if o == nil || o.ExpireAt == nil { + return nil, false + } + return o.ExpireAt, true +} + +// HasExpireAt returns a boolean if a field has been set. +func (o *MuteFindingsMuteAttributes) HasExpireAt() bool { + return o != nil && o.ExpireAt != nil +} + +// SetExpireAt gets a reference to the given int64 and assigns it to the ExpireAt field. +func (o *MuteFindingsMuteAttributes) SetExpireAt(v int64) { + o.ExpireAt = &v +} + +// GetIsMuted returns the IsMuted field value. +func (o *MuteFindingsMuteAttributes) GetIsMuted() bool { + if o == nil { + var ret bool + return ret + } + return o.IsMuted +} + +// GetIsMutedOk returns a tuple with the IsMuted field value +// and a boolean to check if the value has been set. +func (o *MuteFindingsMuteAttributes) GetIsMutedOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.IsMuted, true +} + +// SetIsMuted sets field value. +func (o *MuteFindingsMuteAttributes) SetIsMuted(v bool) { + o.IsMuted = v +} + +// GetReason returns the Reason field value. +func (o *MuteFindingsMuteAttributes) GetReason() MuteFindingsReason { + if o == nil { + var ret MuteFindingsReason + return ret + } + return o.Reason +} + +// GetReasonOk returns a tuple with the Reason field value +// and a boolean to check if the value has been set. +func (o *MuteFindingsMuteAttributes) GetReasonOk() (*MuteFindingsReason, bool) { + if o == nil { + return nil, false + } + return &o.Reason, true +} + +// SetReason sets field value. +func (o *MuteFindingsMuteAttributes) SetReason(v MuteFindingsReason) { + o.Reason = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MuteFindingsMuteAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if o.ExpireAt != nil { + toSerialize["expire_at"] = o.ExpireAt + } + toSerialize["is_muted"] = o.IsMuted + toSerialize["reason"] = o.Reason + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MuteFindingsMuteAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description,omitempty"` + ExpireAt *int64 `json:"expire_at,omitempty"` + IsMuted *bool `json:"is_muted"` + Reason *MuteFindingsReason `json:"reason"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.IsMuted == nil { + return fmt.Errorf("required field is_muted missing") + } + if all.Reason == nil { + return fmt.Errorf("required field reason missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "expire_at", "is_muted", "reason"}) + } else { + return err + } + + hasInvalidField := false + o.Description = all.Description + o.ExpireAt = all.ExpireAt + o.IsMuted = *all.IsMuted + if !all.Reason.IsValid() { + hasInvalidField = true + } else { + o.Reason = *all.Reason + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_mute_findings_reason.go b/api/datadogV2/model_mute_findings_reason.go new file mode 100644 index 00000000000..f1475f3c4de --- /dev/null +++ b/api/datadogV2/model_mute_findings_reason.go @@ -0,0 +1,80 @@ +// 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" +) + +// MuteFindingsReason The reason why the findings are muted or unmuted. +type MuteFindingsReason string + +// List of MuteFindingsReason. +const ( + MUTEFINDINGSREASON_PENDING_FIX MuteFindingsReason = "PENDING_FIX" + MUTEFINDINGSREASON_FALSE_POSITIVE MuteFindingsReason = "FALSE_POSITIVE" + MUTEFINDINGSREASON_OTHER MuteFindingsReason = "OTHER" + MUTEFINDINGSREASON_NO_FIX MuteFindingsReason = "NO_FIX" + MUTEFINDINGSREASON_DUPLICATE MuteFindingsReason = "DUPLICATE" + MUTEFINDINGSREASON_RISK_ACCEPTED MuteFindingsReason = "RISK_ACCEPTED" + MUTEFINDINGSREASON_NO_PENDING_FIX MuteFindingsReason = "NO_PENDING_FIX" + MUTEFINDINGSREASON_HUMAN_ERROR MuteFindingsReason = "HUMAN_ERROR" + MUTEFINDINGSREASON_NO_LONGER_ACCEPTED_RISK MuteFindingsReason = "NO_LONGER_ACCEPTED_RISK" +) + +var allowedMuteFindingsReasonEnumValues = []MuteFindingsReason{ + MUTEFINDINGSREASON_PENDING_FIX, + MUTEFINDINGSREASON_FALSE_POSITIVE, + MUTEFINDINGSREASON_OTHER, + MUTEFINDINGSREASON_NO_FIX, + MUTEFINDINGSREASON_DUPLICATE, + MUTEFINDINGSREASON_RISK_ACCEPTED, + MUTEFINDINGSREASON_NO_PENDING_FIX, + MUTEFINDINGSREASON_HUMAN_ERROR, + MUTEFINDINGSREASON_NO_LONGER_ACCEPTED_RISK, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *MuteFindingsReason) GetAllowedValues() []MuteFindingsReason { + return allowedMuteFindingsReasonEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *MuteFindingsReason) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = MuteFindingsReason(value) + return nil +} + +// NewMuteFindingsReasonFromValue returns a pointer to a valid MuteFindingsReason +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewMuteFindingsReasonFromValue(v string) (*MuteFindingsReason, error) { + ev := MuteFindingsReason(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for MuteFindingsReason: valid values are %v", v, allowedMuteFindingsReasonEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v MuteFindingsReason) IsValid() bool { + for _, existing := range allowedMuteFindingsReasonEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to MuteFindingsReason value. +func (v MuteFindingsReason) Ptr() *MuteFindingsReason { + return &v +} diff --git a/api/datadogV2/model_mute_findings_request.go b/api/datadogV2/model_mute_findings_request.go new file mode 100644 index 00000000000..509ff43d1df --- /dev/null +++ b/api/datadogV2/model_mute_findings_request.go @@ -0,0 +1,110 @@ +// 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" +) + +// MuteFindingsRequest Request to mute or unmute security findings. +type MuteFindingsRequest struct { + // Data of the mute request. + Data MuteFindingsRequestData `json:"data"` + // 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:"-"` +} + +// NewMuteFindingsRequest instantiates a new MuteFindingsRequest 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 NewMuteFindingsRequest(data MuteFindingsRequestData) *MuteFindingsRequest { + this := MuteFindingsRequest{} + this.Data = data + return &this +} + +// NewMuteFindingsRequestWithDefaults instantiates a new MuteFindingsRequest 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 NewMuteFindingsRequestWithDefaults() *MuteFindingsRequest { + this := MuteFindingsRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *MuteFindingsRequest) GetData() MuteFindingsRequestData { + if o == nil { + var ret MuteFindingsRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *MuteFindingsRequest) GetDataOk() (*MuteFindingsRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *MuteFindingsRequest) SetData(v MuteFindingsRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MuteFindingsRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MuteFindingsRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *MuteFindingsRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + 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.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_mute_findings_request_data.go b/api/datadogV2/model_mute_findings_request_data.go new file mode 100644 index 00000000000..7a3cff3c494 --- /dev/null +++ b/api/datadogV2/model_mute_findings_request_data.go @@ -0,0 +1,218 @@ +// 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" +) + +// MuteFindingsRequestData Data of the mute request. +type MuteFindingsRequestData struct { + // Attributes of the mute request. + Attributes MuteFindingsRequestDataAttributes `json:"attributes"` + // Unique identifier of the mute request. + Id *string `json:"id,omitempty"` + // Relationships of the mute request. + Relationships MuteFindingsRequestDataRelationships `json:"relationships"` + // Mute resource type. + Type MuteDataType `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:"-"` +} + +// NewMuteFindingsRequestData instantiates a new MuteFindingsRequestData 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 NewMuteFindingsRequestData(attributes MuteFindingsRequestDataAttributes, relationships MuteFindingsRequestDataRelationships, typeVar MuteDataType) *MuteFindingsRequestData { + this := MuteFindingsRequestData{} + this.Attributes = attributes + this.Relationships = relationships + this.Type = typeVar + return &this +} + +// NewMuteFindingsRequestDataWithDefaults instantiates a new MuteFindingsRequestData 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 NewMuteFindingsRequestDataWithDefaults() *MuteFindingsRequestData { + this := MuteFindingsRequestData{} + var typeVar MuteDataType = MUTEDATATYPE_MUTE + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *MuteFindingsRequestData) GetAttributes() MuteFindingsRequestDataAttributes { + if o == nil { + var ret MuteFindingsRequestDataAttributes + 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 *MuteFindingsRequestData) GetAttributesOk() (*MuteFindingsRequestDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *MuteFindingsRequestData) SetAttributes(v MuteFindingsRequestDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *MuteFindingsRequestData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MuteFindingsRequestData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *MuteFindingsRequestData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *MuteFindingsRequestData) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value. +func (o *MuteFindingsRequestData) GetRelationships() MuteFindingsRequestDataRelationships { + if o == nil { + var ret MuteFindingsRequestDataRelationships + return ret + } + return o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value +// and a boolean to check if the value has been set. +func (o *MuteFindingsRequestData) GetRelationshipsOk() (*MuteFindingsRequestDataRelationships, bool) { + if o == nil { + return nil, false + } + return &o.Relationships, true +} + +// SetRelationships sets field value. +func (o *MuteFindingsRequestData) SetRelationships(v MuteFindingsRequestDataRelationships) { + o.Relationships = v +} + +// GetType returns the Type field value. +func (o *MuteFindingsRequestData) GetType() MuteDataType { + if o == nil { + var ret MuteDataType + 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 *MuteFindingsRequestData) GetTypeOk() (*MuteDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *MuteFindingsRequestData) SetType(v MuteDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MuteFindingsRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["relationships"] = o.Relationships + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MuteFindingsRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *MuteFindingsRequestDataAttributes `json:"attributes"` + Id *string `json:"id,omitempty"` + Relationships *MuteFindingsRequestDataRelationships `json:"relationships"` + Type *MuteDataType `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.Relationships == nil { + return fmt.Errorf("required field relationships 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", "relationships", "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.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = *all.Relationships + 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_mute_findings_request_data_attributes.go b/api/datadogV2/model_mute_findings_request_data_attributes.go new file mode 100644 index 00000000000..b6eb2027740 --- /dev/null +++ b/api/datadogV2/model_mute_findings_request_data_attributes.go @@ -0,0 +1,110 @@ +// 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" +) + +// MuteFindingsRequestDataAttributes Attributes of the mute request. +type MuteFindingsRequestDataAttributes struct { + // Mute properties to apply to the findings. + Mute MuteFindingsMuteAttributes `json:"mute"` + // 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:"-"` +} + +// NewMuteFindingsRequestDataAttributes instantiates a new MuteFindingsRequestDataAttributes 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 NewMuteFindingsRequestDataAttributes(mute MuteFindingsMuteAttributes) *MuteFindingsRequestDataAttributes { + this := MuteFindingsRequestDataAttributes{} + this.Mute = mute + return &this +} + +// NewMuteFindingsRequestDataAttributesWithDefaults instantiates a new MuteFindingsRequestDataAttributes 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 NewMuteFindingsRequestDataAttributesWithDefaults() *MuteFindingsRequestDataAttributes { + this := MuteFindingsRequestDataAttributes{} + return &this +} + +// GetMute returns the Mute field value. +func (o *MuteFindingsRequestDataAttributes) GetMute() MuteFindingsMuteAttributes { + if o == nil { + var ret MuteFindingsMuteAttributes + return ret + } + return o.Mute +} + +// GetMuteOk returns a tuple with the Mute field value +// and a boolean to check if the value has been set. +func (o *MuteFindingsRequestDataAttributes) GetMuteOk() (*MuteFindingsMuteAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Mute, true +} + +// SetMute sets field value. +func (o *MuteFindingsRequestDataAttributes) SetMute(v MuteFindingsMuteAttributes) { + o.Mute = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MuteFindingsRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["mute"] = o.Mute + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MuteFindingsRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Mute *MuteFindingsMuteAttributes `json:"mute"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Mute == nil { + return fmt.Errorf("required field mute missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"mute"}) + } else { + return err + } + + hasInvalidField := false + if all.Mute.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Mute = *all.Mute + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_mute_findings_request_data_relationships.go b/api/datadogV2/model_mute_findings_request_data_relationships.go new file mode 100644 index 00000000000..c1e8c6a6735 --- /dev/null +++ b/api/datadogV2/model_mute_findings_request_data_relationships.go @@ -0,0 +1,110 @@ +// 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" +) + +// MuteFindingsRequestDataRelationships Relationships of the mute request. +type MuteFindingsRequestDataRelationships struct { + // A list of security findings. + Findings Findings `json:"findings"` + // 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:"-"` +} + +// NewMuteFindingsRequestDataRelationships instantiates a new MuteFindingsRequestDataRelationships 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 NewMuteFindingsRequestDataRelationships(findings Findings) *MuteFindingsRequestDataRelationships { + this := MuteFindingsRequestDataRelationships{} + this.Findings = findings + return &this +} + +// NewMuteFindingsRequestDataRelationshipsWithDefaults instantiates a new MuteFindingsRequestDataRelationships 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 NewMuteFindingsRequestDataRelationshipsWithDefaults() *MuteFindingsRequestDataRelationships { + this := MuteFindingsRequestDataRelationships{} + return &this +} + +// GetFindings returns the Findings field value. +func (o *MuteFindingsRequestDataRelationships) GetFindings() Findings { + if o == nil { + var ret Findings + return ret + } + return o.Findings +} + +// GetFindingsOk returns a tuple with the Findings field value +// and a boolean to check if the value has been set. +func (o *MuteFindingsRequestDataRelationships) GetFindingsOk() (*Findings, bool) { + if o == nil { + return nil, false + } + return &o.Findings, true +} + +// SetFindings sets field value. +func (o *MuteFindingsRequestDataRelationships) SetFindings(v Findings) { + o.Findings = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MuteFindingsRequestDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["findings"] = o.Findings + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MuteFindingsRequestDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Findings *Findings `json:"findings"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Findings == nil { + return fmt.Errorf("required field findings missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"findings"}) + } else { + return err + } + + hasInvalidField := false + if all.Findings.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Findings = *all.Findings + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_mute_findings_response.go b/api/datadogV2/model_mute_findings_response.go new file mode 100644 index 00000000000..05d6aba86f9 --- /dev/null +++ b/api/datadogV2/model_mute_findings_response.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" +) + +// MuteFindingsResponse Response for the mute or unmute request. +type MuteFindingsResponse struct { + // Data of the mute response. + Data *MuteFindingsResponseData `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:"-"` +} + +// NewMuteFindingsResponse instantiates a new MuteFindingsResponse 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 NewMuteFindingsResponse() *MuteFindingsResponse { + this := MuteFindingsResponse{} + return &this +} + +// NewMuteFindingsResponseWithDefaults instantiates a new MuteFindingsResponse 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 NewMuteFindingsResponseWithDefaults() *MuteFindingsResponse { + this := MuteFindingsResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *MuteFindingsResponse) GetData() MuteFindingsResponseData { + if o == nil || o.Data == nil { + var ret MuteFindingsResponseData + 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 *MuteFindingsResponse) GetDataOk() (*MuteFindingsResponseData, 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 *MuteFindingsResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given MuteFindingsResponseData and assigns it to the Data field. +func (o *MuteFindingsResponse) SetData(v MuteFindingsResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MuteFindingsResponse) 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 *MuteFindingsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *MuteFindingsResponseData `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_mute_findings_response_data.go b/api/datadogV2/model_mute_findings_response_data.go new file mode 100644 index 00000000000..42eb4c000cb --- /dev/null +++ b/api/datadogV2/model_mute_findings_response_data.go @@ -0,0 +1,145 @@ +// 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" +) + +// MuteFindingsResponseData Data of the mute response. +type MuteFindingsResponseData struct { + // Unique identifier of the mute request. + Id string `json:"id"` + // Mute resource type. + Type MuteDataType `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:"-"` +} + +// NewMuteFindingsResponseData instantiates a new MuteFindingsResponseData 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 NewMuteFindingsResponseData(id string, typeVar MuteDataType) *MuteFindingsResponseData { + this := MuteFindingsResponseData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewMuteFindingsResponseDataWithDefaults instantiates a new MuteFindingsResponseData 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 NewMuteFindingsResponseDataWithDefaults() *MuteFindingsResponseData { + this := MuteFindingsResponseData{} + var typeVar MuteDataType = MUTEDATATYPE_MUTE + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *MuteFindingsResponseData) 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 *MuteFindingsResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *MuteFindingsResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *MuteFindingsResponseData) GetType() MuteDataType { + if o == nil { + var ret MuteDataType + 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 *MuteFindingsResponseData) GetTypeOk() (*MuteDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *MuteFindingsResponseData) SetType(v MuteDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MuteFindingsResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + 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 *MuteFindingsResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *MuteDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + 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/examples/v2/security-monitoring/MuteSecurityFindings.go b/examples/v2/security-monitoring/MuteSecurityFindings.go new file mode 100644 index 00000000000..ac0e69bb9e5 --- /dev/null +++ b/examples/v2/security-monitoring/MuteSecurityFindings.go @@ -0,0 +1,54 @@ +// Mute or unmute security findings returns "Accepted" 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.MuteFindingsRequest{ + Data: datadogV2.MuteFindingsRequestData{ + Attributes: datadogV2.MuteFindingsRequestDataAttributes{ + Mute: datadogV2.MuteFindingsMuteAttributes{ + Description: datadog.PtrString("To be resolved later."), + ExpireAt: datadog.PtrInt64(1778721573794), + IsMuted: true, + Reason: datadogV2.MUTEFINDINGSREASON_PENDING_FIX, + }, + }, + Id: datadog.PtrString("93bfeb70-af47-424d-908a-948d3f08e37f"), + Relationships: datadogV2.MuteFindingsRequestDataRelationships{ + Findings: datadogV2.Findings{ + Data: []datadogV2.FindingData{ + { + Id: "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", + Type: datadogV2.FINDINGDATATYPE_FINDINGS, + }, + }, + }, + }, + Type: datadogV2.MUTEDATATYPE_MUTE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.MuteSecurityFindings", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.MuteSecurityFindings(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.MuteSecurityFindings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.MuteSecurityFindings`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/MuteSecurityFindings_298521544.go b/examples/v2/security-monitoring/MuteSecurityFindings_298521544.go new file mode 100644 index 00000000000..16ddad61ac4 --- /dev/null +++ b/examples/v2/security-monitoring/MuteSecurityFindings_298521544.go @@ -0,0 +1,52 @@ +// Unmute security findings returns "Accepted" 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.MuteFindingsRequest{ + Data: datadogV2.MuteFindingsRequestData{ + Attributes: datadogV2.MuteFindingsRequestDataAttributes{ + Mute: datadogV2.MuteFindingsMuteAttributes{ + Description: datadog.PtrString("Resolved."), + IsMuted: false, + Reason: datadogV2.MUTEFINDINGSREASON_NO_PENDING_FIX, + }, + }, + Relationships: datadogV2.MuteFindingsRequestDataRelationships{ + Findings: datadogV2.Findings{ + Data: []datadogV2.FindingData{ + { + Id: "ZGVmLTAwMC0wYmd-MDE4NjcyMDJkMzE4MDE5ODY5MGE4ZmQ2MmFlMjg0Y2M=", + Type: datadogV2.FINDINGDATATYPE_FINDINGS, + }, + }, + }, + }, + Type: datadogV2.MUTEDATATYPE_MUTE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.MuteSecurityFindings", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.MuteSecurityFindings(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.MuteSecurityFindings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.MuteSecurityFindings`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/MuteSecurityFindings_3830190821.go b/examples/v2/security-monitoring/MuteSecurityFindings_3830190821.go new file mode 100644 index 00000000000..85fdca26b28 --- /dev/null +++ b/examples/v2/security-monitoring/MuteSecurityFindings_3830190821.go @@ -0,0 +1,53 @@ +// Mute security findings returns "Accepted" 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.MuteFindingsRequest{ + Data: datadogV2.MuteFindingsRequestData{ + Attributes: datadogV2.MuteFindingsRequestDataAttributes{ + Mute: datadogV2.MuteFindingsMuteAttributes{ + Description: datadog.PtrString("To be resolved later."), + ExpireAt: datadog.PtrInt64(1778721573794), + IsMuted: true, + Reason: datadogV2.MUTEFINDINGSREASON_RISK_ACCEPTED, + }, + }, + Relationships: datadogV2.MuteFindingsRequestDataRelationships{ + Findings: datadogV2.Findings{ + Data: []datadogV2.FindingData{ + { + Id: "ZGVmLTAwMC0wYmd-MDE4NjcyMDJkMzE4MDE5ODY5MGE4ZmQ2MmFlMjg0Y2M=", + Type: datadogV2.FINDINGDATATYPE_FINDINGS, + }, + }, + }, + }, + Type: datadogV2.MUTEDATATYPE_MUTE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.MuteSecurityFindings", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.MuteSecurityFindings(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.MuteSecurityFindings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.MuteSecurityFindings`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Accepted_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Accepted_response.freeze new file mode 100644 index 00000000000..c70fc98419e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Accepted_response.freeze @@ -0,0 +1 @@ +2026-04-27T16:46:59.369Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Accepted_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Accepted_response.yaml new file mode 100644 index 00000000000..535615f44d7 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Accepted_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"mute":{"description":"To be resolved later.","expire_at":1778721573794,"is_muted":true,"reason":"RISK_ACCEPTED"}},"relationships":{"findings":{"data":[{"id":"ZGVmLTAwMC0wYmd-MDE4NjcyMDJkMzE4MDE5ODY5MGE4ZmQ2MmFlMjg0Y2M=","type":"findings"}]}},"type":"mute"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/findings/mute + response: + body: '{"data":{"id":"7a0bd082-5c8a-4ea3-a8a5-c5036e083ddb","type":"mute"}}' + code: 202 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 202 Accepted +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..2343aeed263 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2026-04-27T16:13:25.084Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..bf5a2c246d2 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Not_Found_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"mute":{"description":"To be resolved later.","expire_at":1778721573794,"is_muted":true,"reason":"RISK_ACCEPTED"}},"relationships":{"findings":{"data":[{"id":"ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==","type":"findings"}]}},"type":"mute"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/findings/mute + response: + body: '{"errors":[{"status":"404","title":"Not Found","detail":"finding not found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Unprocessable_Entity_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Unprocessable_Entity_response.freeze new file mode 100644 index 00000000000..4217cf20b9c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Unprocessable_Entity_response.freeze @@ -0,0 +1 @@ +2026-04-27T16:19:46.205Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Unprocessable_Entity_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Unprocessable_Entity_response.yaml new file mode 100644 index 00000000000..1366536d523 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Mute_security_findings_returns_Unprocessable_Entity_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"mute":{"description":"To be resolved later.","expire_at":1,"is_muted":true,"reason":"RISK_ACCEPTED"}},"relationships":{"findings":{"data":[{"id":"ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==","type":"findings"}]}},"type":"mute"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/findings/mute + response: + body: '{"errors":[{"status":"422","title":"Invalid Request","detail":"Invalid + expiration date. Please provide an expiration date in the future"}]}' + code: 422 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 422 Unprocessable Entity +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Accepted_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Accepted_response.freeze new file mode 100644 index 00000000000..aeddfe329e9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Accepted_response.freeze @@ -0,0 +1 @@ +2026-04-27T16:48:26.948Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Accepted_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Accepted_response.yaml new file mode 100644 index 00000000000..1d95033771b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Accepted_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"mute":{"description":"Resolved.","is_muted":false,"reason":"NO_PENDING_FIX"}},"relationships":{"findings":{"data":[{"id":"ZGVmLTAwMC0wYmd-MDE4NjcyMDJkMzE4MDE5ODY5MGE4ZmQ2MmFlMjg0Y2M=","type":"findings"}]}},"type":"mute"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/findings/mute + response: + body: '{"data":{"id":"4ae87c1e-099b-4f63-af21-3568cf226263","type":"mute"}}' + code: 202 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 202 Accepted +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..2e3bb3a33a6 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2026-04-27T16:23:28.911Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..fc03240c97d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Not_Found_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"mute":{"description":"Resolved.","is_muted":false,"reason":"NO_PENDING_FIX"}},"relationships":{"findings":{"data":[{"id":"ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==","type":"findings"}]}},"type":"mute"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/findings/mute + response: + body: '{"errors":[{"status":"404","title":"Not Found","detail":"finding not found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Unprocessable_Entity_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Unprocessable_Entity_response.freeze new file mode 100644 index 00000000000..1c328239af8 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Unprocessable_Entity_response.freeze @@ -0,0 +1 @@ +2026-04-27T16:23:50.077Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Unprocessable_Entity_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Unprocessable_Entity_response.yaml new file mode 100644 index 00000000000..0e06ed06358 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Unmute_security_findings_returns_Unprocessable_Entity_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"mute":{"description":"Resolved.","is_muted":false,"reason":"RISK_ACCEPTED"}},"relationships":{"findings":{"data":[{"id":"ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==","type":"findings"}]}},"type":"mute"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/security/findings/mute + response: + body: '{"errors":[{"status":"422","title":"Invalid Request","detail":"The provided + reason is not valid for the specified mute action. Possible values: [NO_PENDING_FIX + HUMAN_ERROR NO_LONGER_ACCEPTED_RISK OTHER]"}]}' + code: 422 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 422 Unprocessable Entity +version: 2 diff --git a/tests/scenarios/features/v2/security_monitoring.feature b/tests/scenarios/features/v2/security_monitoring.feature index 9c65c8a95bd..820747b79b7 100644 --- a/tests/scenarios/features/v2/security_monitoring.feature +++ b/tests/scenarios/features/v2/security_monitoring.feature @@ -1864,6 +1864,62 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/k9-investigation + Scenario: Mute or unmute security findings returns "Accepted" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later.", "expire_at": 1778721573794, "is_muted": true, "reason": "PENDING_FIX"}}, "id": "93bfeb70-af47-424d-908a-948d3f08e37f", "relationships": {"findings": {"data": [{"id": "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 202 Accepted + + @generated @skip @team:DataDog/k9-investigation + Scenario: Mute or unmute security findings returns "Bad Request" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later.", "expire_at": 1778721573794, "is_muted": true, "reason": "PENDING_FIX"}}, "id": "93bfeb70-af47-424d-908a-948d3f08e37f", "relationships": {"findings": {"data": [{"id": "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-investigation + Scenario: Mute or unmute security findings returns "Not Found" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later.", "expire_at": 1778721573794, "is_muted": true, "reason": "PENDING_FIX"}}, "id": "93bfeb70-af47-424d-908a-948d3f08e37f", "relationships": {"findings": {"data": [{"id": "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-investigation + Scenario: Mute or unmute security findings returns "Unprocessable Entity" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later.", "expire_at": 1778721573794, "is_muted": true, "reason": "PENDING_FIX"}}, "id": "93bfeb70-af47-424d-908a-948d3f08e37f", "relationships": {"findings": {"data": [{"id": "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 422 Unprocessable Entity + + @team:DataDog/k9-investigation + Scenario: Mute security findings returns "Accepted" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later.", "expire_at": 1778721573794, "is_muted": true, "reason": "RISK_ACCEPTED"}}, "relationships": {"findings": {"data": [{"id": "ZGVmLTAwMC0wYmd-MDE4NjcyMDJkMzE4MDE5ODY5MGE4ZmQ2MmFlMjg0Y2M=", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 202 Accepted + + @team:DataDog/k9-investigation + Scenario: Mute security findings returns "Not Found" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later.", "expire_at": 1778721573794, "is_muted": true, "reason": "RISK_ACCEPTED"}}, "relationships": {"findings": {"data": [{"id": "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-investigation + Scenario: Mute security findings returns "Unprocessable Entity" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later.", "expire_at": 1, "is_muted": true, "reason": "RISK_ACCEPTED"}}, "relationships": {"findings": {"data": [{"id": "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 422 Unprocessable Entity + @team:DataDog/cloud-security-posture-management Scenario: Patch a signal-based notification rule returns "Bad Request" response Given new "PatchSignalNotificationRule" request @@ -2065,6 +2121,30 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @team:DataDog/k9-investigation + Scenario: Unmute security findings returns "Accepted" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "Resolved.", "is_muted": false, "reason": "NO_PENDING_FIX"}}, "relationships": {"findings": {"data": [{"id": "ZGVmLTAwMC0wYmd-MDE4NjcyMDJkMzE4MDE5ODY5MGE4ZmQ2MmFlMjg0Y2M=", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 202 Accepted + + @team:DataDog/k9-investigation + Scenario: Unmute security findings returns "Not Found" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "Resolved.", "is_muted": false, "reason": "NO_PENDING_FIX"}}, "relationships": {"findings": {"data": [{"id": "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-investigation + Scenario: Unmute security findings returns "Unprocessable Entity" response + Given operation "MuteSecurityFindings" enabled + And new "MuteSecurityFindings" request + And body with value {"data": {"attributes": {"mute": {"description": "Resolved.", "is_muted": false, "reason": "RISK_ACCEPTED"}}, "relationships": {"findings": {"data": [{"id": "ZGVmLTAwcC1pZXJ-aS0wZjhjNjMyZDNmMzRlZTgzNw==", "type": "findings"}]}}, "type": "mute"}} + When the request is sent + Then the response status is 422 Unprocessable Entity + @skip-validation @team:DataDog/k9-cloud-siem Scenario: Update a cloud configuration rule's details returns "OK" response Given new "UpdateSecurityMonitoringRule" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 36d1cdbe4c0..8c591eca8c2 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -5308,6 +5308,12 @@ "type": "unsafe" } }, + "MuteSecurityFindings": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, "SearchSecurityFindings": { "tag": "Security Monitoring", "undo": {