diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9bceb715496..526df34c713 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -23526,6 +23526,30 @@ components: required: - data type: object + GetSuppressionVersionHistoryData: + description: Data for the suppression version history. + properties: + attributes: + $ref: '#/components/schemas/SuppressionVersionHistory' + id: + description: ID of the suppression. + type: string + type: + $ref: '#/components/schemas/GetSuppressionVersionHistoryDataType' + type: object + GetSuppressionVersionHistoryDataType: + description: Type of data. + enum: + - suppression_version_history + type: string + x-enum-varnames: + - SUPPRESSIONVERSIONHISTORY + GetSuppressionVersionHistoryResponse: + description: Response for getting the suppression version history. + properties: + data: + $ref: '#/components/schemas/GetSuppressionVersionHistoryData' + type: object GetTeamMembershipsSort: description: Specifies the order of returned team memberships enum: @@ -42745,38 +42769,13 @@ components: description: The `RuleVersionHistory` `data`. type: object type: object - RuleVersionUpdate: - description: A change in a rule version. - properties: - change: - description: The new value of the field. - example: cloud_provider:aws - type: string - field: - description: The field that was changed. - example: Tags - type: string - type: - $ref: '#/components/schemas/RuleVersionUpdateType' - type: object - RuleVersionUpdateType: - description: The type of change. - enum: - - create - - update - - delete - type: string - x-enum-varnames: - - CREATE - - UPDATE - - DELETE RuleVersions: description: A rule version with a list of updates. properties: changes: description: A list of changes. items: - $ref: '#/components/schemas/RuleVersionUpdate' + $ref: '#/components/schemas/VersionHistoryUpdate' type: array rule: $ref: '#/components/schemas/SecurityMonitoringRuleResponse' @@ -51322,6 +51321,32 @@ components: format: double type: number type: object + SuppressionVersionHistory: + description: Response object containing the version history of a suppression. + properties: + count: + description: The number of suppression versions. + format: int32 + maximum: 2147483647 + type: integer + data: + additionalProperties: + $ref: '#/components/schemas/SuppressionVersions' + description: A suppression version with a list of updates. + description: The version history of a suppression. + type: object + type: object + SuppressionVersions: + description: A suppression version with a list of updates. + properties: + changes: + description: A list of changes. + items: + $ref: '#/components/schemas/VersionHistoryUpdate' + type: array + suppression: + $ref: '#/components/schemas/SecurityMonitoringSuppressionAttributes' + type: object TableResultV2: description: A reference table resource containing its full configuration and state. @@ -55372,6 +55397,31 @@ components: example: 1 format: int64 type: integer + VersionHistoryUpdate: + description: A change in a rule version. + properties: + change: + description: The new value of the field. + example: cloud_provider:aws + type: string + field: + description: The field that was changed. + example: Tags + type: string + type: + $ref: '#/components/schemas/VersionHistoryUpdateType' + type: object + VersionHistoryUpdateType: + description: The type of change. + enum: + - create + - update + - delete + type: string + x-enum-varnames: + - CREATE + - UPDATE + - DELETE VirusTotalAPIKey: description: The definition of the `VirusTotalAPIKey` object. properties: @@ -79065,6 +79115,35 @@ paths: summary: Update a suppression rule tags: - Security Monitoring + /api/v2/security_monitoring/configuration/suppressions/{suppression_id}/version_history: + get: + description: Get a suppression's version history. + operationId: GetSuppressionVersionHistory + parameters: + - $ref: '#/components/parameters/SecurityMonitoringSuppressionID' + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GetSuppressionVersionHistoryResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_suppressions_read + summary: Get a suppression's version history + tags: + - Security Monitoring /api/v2/security_monitoring/rules: get: description: List rules. diff --git a/api/datadogV2/api_security_monitoring.go b/api/datadogV2/api_security_monitoring.go index fd8cacacc17..be5d491422a 100644 --- a/api/datadogV2/api_security_monitoring.go +++ b/api/datadogV2/api_security_monitoring.go @@ -2954,6 +2954,122 @@ func (a *SecurityMonitoringApi) GetSignalNotificationRules(ctx _context.Context) return localVarReturnValue, localVarHTTPResponse, nil } +// GetSuppressionVersionHistoryOptionalParameters holds optional parameters for GetSuppressionVersionHistory. +type GetSuppressionVersionHistoryOptionalParameters struct { + PageSize *int64 + PageNumber *int64 +} + +// NewGetSuppressionVersionHistoryOptionalParameters creates an empty struct for parameters. +func NewGetSuppressionVersionHistoryOptionalParameters() *GetSuppressionVersionHistoryOptionalParameters { + this := GetSuppressionVersionHistoryOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *GetSuppressionVersionHistoryOptionalParameters) WithPageSize(pageSize int64) *GetSuppressionVersionHistoryOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *GetSuppressionVersionHistoryOptionalParameters) WithPageNumber(pageNumber int64) *GetSuppressionVersionHistoryOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// GetSuppressionVersionHistory Get a suppression's version history. +// Get a suppression's version history. +func (a *SecurityMonitoringApi) GetSuppressionVersionHistory(ctx _context.Context, suppressionId string, o ...GetSuppressionVersionHistoryOptionalParameters) (GetSuppressionVersionHistoryResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GetSuppressionVersionHistoryResponse + optionalParams GetSuppressionVersionHistoryOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetSuppressionVersionHistoryOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetSuppressionVersionHistory") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security_monitoring/configuration/suppressions/{suppression_id}/version_history" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{suppression_id}", _neturl.PathEscape(datadog.ParameterToString(suppressionId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageSize != nil { + localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, "")) + } + if optionalParams.PageNumber != nil { + localVarQueryParams.Add("page[number]", datadog.ParameterToString(*optionalParams.PageNumber, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + 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 == 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 +} + // GetSuppressionsAffectingFutureRule Get suppressions affecting future rule. // Get the list of suppressions that would affect a rule. func (a *SecurityMonitoringApi) GetSuppressionsAffectingFutureRule(ctx _context.Context, body SecurityMonitoringRuleCreatePayload) (SecurityMonitoringSuppressionsResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index c5cf4723b97..2d96fa9ce3b 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -542,6 +542,7 @@ // - [SecurityMonitoringApi.GetSecurityMonitoringSuppression] // - [SecurityMonitoringApi.GetSignalNotificationRule] // - [SecurityMonitoringApi.GetSignalNotificationRules] +// - [SecurityMonitoringApi.GetSuppressionVersionHistory] // - [SecurityMonitoringApi.GetSuppressionsAffectingFutureRule] // - [SecurityMonitoringApi.GetSuppressionsAffectingRule] // - [SecurityMonitoringApi.GetThreatHuntingJob] diff --git a/api/datadogV2/model_get_suppression_version_history_data.go b/api/datadogV2/model_get_suppression_version_history_data.go new file mode 100644 index 00000000000..6d2802525f1 --- /dev/null +++ b/api/datadogV2/model_get_suppression_version_history_data.go @@ -0,0 +1,185 @@ +// 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" +) + +// GetSuppressionVersionHistoryData Data for the suppression version history. +type GetSuppressionVersionHistoryData struct { + // Response object containing the version history of a suppression. + Attributes *SuppressionVersionHistory `json:"attributes,omitempty"` + // ID of the suppression. + Id *string `json:"id,omitempty"` + // Type of data. + Type *GetSuppressionVersionHistoryDataType `json:"type,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:"-"` +} + +// NewGetSuppressionVersionHistoryData instantiates a new GetSuppressionVersionHistoryData 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 NewGetSuppressionVersionHistoryData() *GetSuppressionVersionHistoryData { + this := GetSuppressionVersionHistoryData{} + return &this +} + +// NewGetSuppressionVersionHistoryDataWithDefaults instantiates a new GetSuppressionVersionHistoryData 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 NewGetSuppressionVersionHistoryDataWithDefaults() *GetSuppressionVersionHistoryData { + this := GetSuppressionVersionHistoryData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GetSuppressionVersionHistoryData) GetAttributes() SuppressionVersionHistory { + if o == nil || o.Attributes == nil { + var ret SuppressionVersionHistory + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetSuppressionVersionHistoryData) GetAttributesOk() (*SuppressionVersionHistory, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *GetSuppressionVersionHistoryData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given SuppressionVersionHistory and assigns it to the Attributes field. +func (o *GetSuppressionVersionHistoryData) SetAttributes(v SuppressionVersionHistory) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GetSuppressionVersionHistoryData) 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 *GetSuppressionVersionHistoryData) 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 *GetSuppressionVersionHistoryData) 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 *GetSuppressionVersionHistoryData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GetSuppressionVersionHistoryData) GetType() GetSuppressionVersionHistoryDataType { + if o == nil || o.Type == nil { + var ret GetSuppressionVersionHistoryDataType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetSuppressionVersionHistoryData) GetTypeOk() (*GetSuppressionVersionHistoryDataType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GetSuppressionVersionHistoryData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GetSuppressionVersionHistoryDataType and assigns it to the Type field. +func (o *GetSuppressionVersionHistoryData) SetType(v GetSuppressionVersionHistoryDataType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GetSuppressionVersionHistoryData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GetSuppressionVersionHistoryData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SuppressionVersionHistory `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *GetSuppressionVersionHistoryDataType `json:"type,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{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !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_get_suppression_version_history_data_type.go b/api/datadogV2/model_get_suppression_version_history_data_type.go new file mode 100644 index 00000000000..a5f8b20862d --- /dev/null +++ b/api/datadogV2/model_get_suppression_version_history_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" +) + +// GetSuppressionVersionHistoryDataType Type of data. +type GetSuppressionVersionHistoryDataType string + +// List of GetSuppressionVersionHistoryDataType. +const ( + GETSUPPRESSIONVERSIONHISTORYDATATYPE_SUPPRESSIONVERSIONHISTORY GetSuppressionVersionHistoryDataType = "suppression_version_history" +) + +var allowedGetSuppressionVersionHistoryDataTypeEnumValues = []GetSuppressionVersionHistoryDataType{ + GETSUPPRESSIONVERSIONHISTORYDATATYPE_SUPPRESSIONVERSIONHISTORY, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GetSuppressionVersionHistoryDataType) GetAllowedValues() []GetSuppressionVersionHistoryDataType { + return allowedGetSuppressionVersionHistoryDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GetSuppressionVersionHistoryDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GetSuppressionVersionHistoryDataType(value) + return nil +} + +// NewGetSuppressionVersionHistoryDataTypeFromValue returns a pointer to a valid GetSuppressionVersionHistoryDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGetSuppressionVersionHistoryDataTypeFromValue(v string) (*GetSuppressionVersionHistoryDataType, error) { + ev := GetSuppressionVersionHistoryDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GetSuppressionVersionHistoryDataType: valid values are %v", v, allowedGetSuppressionVersionHistoryDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GetSuppressionVersionHistoryDataType) IsValid() bool { + for _, existing := range allowedGetSuppressionVersionHistoryDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GetSuppressionVersionHistoryDataType value. +func (v GetSuppressionVersionHistoryDataType) Ptr() *GetSuppressionVersionHistoryDataType { + return &v +} diff --git a/api/datadogV2/model_get_suppression_version_history_response.go b/api/datadogV2/model_get_suppression_version_history_response.go new file mode 100644 index 00000000000..55faaed5ab5 --- /dev/null +++ b/api/datadogV2/model_get_suppression_version_history_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" +) + +// GetSuppressionVersionHistoryResponse Response for getting the suppression version history. +type GetSuppressionVersionHistoryResponse struct { + // Data for the suppression version history. + Data *GetSuppressionVersionHistoryData `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:"-"` +} + +// NewGetSuppressionVersionHistoryResponse instantiates a new GetSuppressionVersionHistoryResponse 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 NewGetSuppressionVersionHistoryResponse() *GetSuppressionVersionHistoryResponse { + this := GetSuppressionVersionHistoryResponse{} + return &this +} + +// NewGetSuppressionVersionHistoryResponseWithDefaults instantiates a new GetSuppressionVersionHistoryResponse 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 NewGetSuppressionVersionHistoryResponseWithDefaults() *GetSuppressionVersionHistoryResponse { + this := GetSuppressionVersionHistoryResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GetSuppressionVersionHistoryResponse) GetData() GetSuppressionVersionHistoryData { + if o == nil || o.Data == nil { + var ret GetSuppressionVersionHistoryData + 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 *GetSuppressionVersionHistoryResponse) GetDataOk() (*GetSuppressionVersionHistoryData, 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 *GetSuppressionVersionHistoryResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given GetSuppressionVersionHistoryData and assigns it to the Data field. +func (o *GetSuppressionVersionHistoryResponse) SetData(v GetSuppressionVersionHistoryData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GetSuppressionVersionHistoryResponse) 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 *GetSuppressionVersionHistoryResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GetSuppressionVersionHistoryData `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_rule_version_update_type.go b/api/datadogV2/model_rule_version_update_type.go deleted file mode 100644 index 24674c8efbe..00000000000 --- a/api/datadogV2/model_rule_version_update_type.go +++ /dev/null @@ -1,68 +0,0 @@ -// 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" -) - -// RuleVersionUpdateType The type of change. -type RuleVersionUpdateType string - -// List of RuleVersionUpdateType. -const ( - RULEVERSIONUPDATETYPE_CREATE RuleVersionUpdateType = "create" - RULEVERSIONUPDATETYPE_UPDATE RuleVersionUpdateType = "update" - RULEVERSIONUPDATETYPE_DELETE RuleVersionUpdateType = "delete" -) - -var allowedRuleVersionUpdateTypeEnumValues = []RuleVersionUpdateType{ - RULEVERSIONUPDATETYPE_CREATE, - RULEVERSIONUPDATETYPE_UPDATE, - RULEVERSIONUPDATETYPE_DELETE, -} - -// GetAllowedValues reeturns the list of possible values. -func (v *RuleVersionUpdateType) GetAllowedValues() []RuleVersionUpdateType { - return allowedRuleVersionUpdateTypeEnumValues -} - -// UnmarshalJSON deserializes the given payload. -func (v *RuleVersionUpdateType) UnmarshalJSON(src []byte) error { - var value string - err := datadog.Unmarshal(src, &value) - if err != nil { - return err - } - *v = RuleVersionUpdateType(value) - return nil -} - -// NewRuleVersionUpdateTypeFromValue returns a pointer to a valid RuleVersionUpdateType -// for the value passed as argument, or an error if the value passed is not allowed by the enum. -func NewRuleVersionUpdateTypeFromValue(v string) (*RuleVersionUpdateType, error) { - ev := RuleVersionUpdateType(v) - if ev.IsValid() { - return &ev, nil - } - return nil, fmt.Errorf("invalid value '%v' for RuleVersionUpdateType: valid values are %v", v, allowedRuleVersionUpdateTypeEnumValues) -} - -// IsValid return true if the value is valid for the enum, false otherwise. -func (v RuleVersionUpdateType) IsValid() bool { - for _, existing := range allowedRuleVersionUpdateTypeEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to RuleVersionUpdateType value. -func (v RuleVersionUpdateType) Ptr() *RuleVersionUpdateType { - return &v -} diff --git a/api/datadogV2/model_rule_versions.go b/api/datadogV2/model_rule_versions.go index 301e53d3a00..4285204b4dd 100644 --- a/api/datadogV2/model_rule_versions.go +++ b/api/datadogV2/model_rule_versions.go @@ -11,7 +11,7 @@ import ( // RuleVersions A rule version with a list of updates. type RuleVersions struct { // A list of changes. - Changes []RuleVersionUpdate `json:"changes,omitempty"` + Changes []VersionHistoryUpdate `json:"changes,omitempty"` // Create a new rule. Rule *SecurityMonitoringRuleResponse `json:"rule,omitempty"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -37,9 +37,9 @@ func NewRuleVersionsWithDefaults() *RuleVersions { } // GetChanges returns the Changes field value if set, zero value otherwise. -func (o *RuleVersions) GetChanges() []RuleVersionUpdate { +func (o *RuleVersions) GetChanges() []VersionHistoryUpdate { if o == nil || o.Changes == nil { - var ret []RuleVersionUpdate + var ret []VersionHistoryUpdate return ret } return o.Changes @@ -47,7 +47,7 @@ func (o *RuleVersions) GetChanges() []RuleVersionUpdate { // GetChangesOk returns a tuple with the Changes field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *RuleVersions) GetChangesOk() (*[]RuleVersionUpdate, bool) { +func (o *RuleVersions) GetChangesOk() (*[]VersionHistoryUpdate, bool) { if o == nil || o.Changes == nil { return nil, false } @@ -59,8 +59,8 @@ func (o *RuleVersions) HasChanges() bool { return o != nil && o.Changes != nil } -// SetChanges gets a reference to the given []RuleVersionUpdate and assigns it to the Changes field. -func (o *RuleVersions) SetChanges(v []RuleVersionUpdate) { +// SetChanges gets a reference to the given []VersionHistoryUpdate and assigns it to the Changes field. +func (o *RuleVersions) SetChanges(v []VersionHistoryUpdate) { o.Changes = v } @@ -114,7 +114,7 @@ func (o RuleVersions) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *RuleVersions) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Changes []RuleVersionUpdate `json:"changes,omitempty"` + Changes []VersionHistoryUpdate `json:"changes,omitempty"` Rule *SecurityMonitoringRuleResponse `json:"rule,omitempty"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { diff --git a/api/datadogV2/model_suppression_version_history.go b/api/datadogV2/model_suppression_version_history.go new file mode 100644 index 00000000000..189b10743de --- /dev/null +++ b/api/datadogV2/model_suppression_version_history.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" +) + +// SuppressionVersionHistory Response object containing the version history of a suppression. +type SuppressionVersionHistory struct { + // The number of suppression versions. + Count *int32 `json:"count,omitempty"` + // The version history of a suppression. + Data map[string]SuppressionVersions `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:"-"` +} + +// NewSuppressionVersionHistory instantiates a new SuppressionVersionHistory 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 NewSuppressionVersionHistory() *SuppressionVersionHistory { + this := SuppressionVersionHistory{} + return &this +} + +// NewSuppressionVersionHistoryWithDefaults instantiates a new SuppressionVersionHistory 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 NewSuppressionVersionHistoryWithDefaults() *SuppressionVersionHistory { + this := SuppressionVersionHistory{} + return &this +} + +// GetCount returns the Count field value if set, zero value otherwise. +func (o *SuppressionVersionHistory) GetCount() int32 { + if o == nil || o.Count == nil { + var ret int32 + return ret + } + return *o.Count +} + +// GetCountOk returns a tuple with the Count field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SuppressionVersionHistory) GetCountOk() (*int32, bool) { + if o == nil || o.Count == nil { + return nil, false + } + return o.Count, true +} + +// HasCount returns a boolean if a field has been set. +func (o *SuppressionVersionHistory) HasCount() bool { + return o != nil && o.Count != nil +} + +// SetCount gets a reference to the given int32 and assigns it to the Count field. +func (o *SuppressionVersionHistory) SetCount(v int32) { + o.Count = &v +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *SuppressionVersionHistory) GetData() map[string]SuppressionVersions { + if o == nil || o.Data == nil { + var ret map[string]SuppressionVersions + 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 *SuppressionVersionHistory) GetDataOk() (*map[string]SuppressionVersions, 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 *SuppressionVersionHistory) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given map[string]SuppressionVersions and assigns it to the Data field. +func (o *SuppressionVersionHistory) SetData(v map[string]SuppressionVersions) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SuppressionVersionHistory) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Count != nil { + toSerialize["count"] = o.Count + } + 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 *SuppressionVersionHistory) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Count *int32 `json:"count,omitempty"` + Data map[string]SuppressionVersions `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{"count", "data"}) + } else { + return err + } + o.Count = all.Count + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_suppression_versions.go b/api/datadogV2/model_suppression_versions.go new file mode 100644 index 00000000000..bdfe09489ec --- /dev/null +++ b/api/datadogV2/model_suppression_versions.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SuppressionVersions A suppression version with a list of updates. +type SuppressionVersions struct { + // A list of changes. + Changes []VersionHistoryUpdate `json:"changes,omitempty"` + // The attributes of the suppression rule. + Suppression *SecurityMonitoringSuppressionAttributes `json:"suppression,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:"-"` +} + +// NewSuppressionVersions instantiates a new SuppressionVersions 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 NewSuppressionVersions() *SuppressionVersions { + this := SuppressionVersions{} + return &this +} + +// NewSuppressionVersionsWithDefaults instantiates a new SuppressionVersions 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 NewSuppressionVersionsWithDefaults() *SuppressionVersions { + this := SuppressionVersions{} + return &this +} + +// GetChanges returns the Changes field value if set, zero value otherwise. +func (o *SuppressionVersions) GetChanges() []VersionHistoryUpdate { + if o == nil || o.Changes == nil { + var ret []VersionHistoryUpdate + return ret + } + return o.Changes +} + +// GetChangesOk returns a tuple with the Changes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SuppressionVersions) GetChangesOk() (*[]VersionHistoryUpdate, bool) { + if o == nil || o.Changes == nil { + return nil, false + } + return &o.Changes, true +} + +// HasChanges returns a boolean if a field has been set. +func (o *SuppressionVersions) HasChanges() bool { + return o != nil && o.Changes != nil +} + +// SetChanges gets a reference to the given []VersionHistoryUpdate and assigns it to the Changes field. +func (o *SuppressionVersions) SetChanges(v []VersionHistoryUpdate) { + o.Changes = v +} + +// GetSuppression returns the Suppression field value if set, zero value otherwise. +func (o *SuppressionVersions) GetSuppression() SecurityMonitoringSuppressionAttributes { + if o == nil || o.Suppression == nil { + var ret SecurityMonitoringSuppressionAttributes + return ret + } + return *o.Suppression +} + +// GetSuppressionOk returns a tuple with the Suppression field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SuppressionVersions) GetSuppressionOk() (*SecurityMonitoringSuppressionAttributes, bool) { + if o == nil || o.Suppression == nil { + return nil, false + } + return o.Suppression, true +} + +// HasSuppression returns a boolean if a field has been set. +func (o *SuppressionVersions) HasSuppression() bool { + return o != nil && o.Suppression != nil +} + +// SetSuppression gets a reference to the given SecurityMonitoringSuppressionAttributes and assigns it to the Suppression field. +func (o *SuppressionVersions) SetSuppression(v SecurityMonitoringSuppressionAttributes) { + o.Suppression = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SuppressionVersions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Changes != nil { + toSerialize["changes"] = o.Changes + } + if o.Suppression != nil { + toSerialize["suppression"] = o.Suppression + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SuppressionVersions) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Changes []VersionHistoryUpdate `json:"changes,omitempty"` + Suppression *SecurityMonitoringSuppressionAttributes `json:"suppression,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{"changes", "suppression"}) + } else { + return err + } + + hasInvalidField := false + o.Changes = all.Changes + if all.Suppression != nil && all.Suppression.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Suppression = all.Suppression + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rule_version_update.go b/api/datadogV2/model_version_history_update.go similarity index 70% rename from api/datadogV2/model_rule_version_update.go rename to api/datadogV2/model_version_history_update.go index f86259e35db..1d7c356fee2 100644 --- a/api/datadogV2/model_rule_version_update.go +++ b/api/datadogV2/model_version_history_update.go @@ -8,38 +8,38 @@ import ( "github.com/DataDog/datadog-api-client-go/v2/api/datadog" ) -// RuleVersionUpdate A change in a rule version. -type RuleVersionUpdate struct { +// VersionHistoryUpdate A change in a rule version. +type VersionHistoryUpdate struct { // The new value of the field. Change *string `json:"change,omitempty"` // The field that was changed. Field *string `json:"field,omitempty"` // The type of change. - Type *RuleVersionUpdateType `json:"type,omitempty"` + Type *VersionHistoryUpdateType `json:"type,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:"-"` } -// NewRuleVersionUpdate instantiates a new RuleVersionUpdate object. +// NewVersionHistoryUpdate instantiates a new VersionHistoryUpdate 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 NewRuleVersionUpdate() *RuleVersionUpdate { - this := RuleVersionUpdate{} +func NewVersionHistoryUpdate() *VersionHistoryUpdate { + this := VersionHistoryUpdate{} return &this } -// NewRuleVersionUpdateWithDefaults instantiates a new RuleVersionUpdate object. +// NewVersionHistoryUpdateWithDefaults instantiates a new VersionHistoryUpdate 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 NewRuleVersionUpdateWithDefaults() *RuleVersionUpdate { - this := RuleVersionUpdate{} +func NewVersionHistoryUpdateWithDefaults() *VersionHistoryUpdate { + this := VersionHistoryUpdate{} return &this } // GetChange returns the Change field value if set, zero value otherwise. -func (o *RuleVersionUpdate) GetChange() string { +func (o *VersionHistoryUpdate) GetChange() string { if o == nil || o.Change == nil { var ret string return ret @@ -49,7 +49,7 @@ func (o *RuleVersionUpdate) GetChange() string { // GetChangeOk returns a tuple with the Change field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *RuleVersionUpdate) GetChangeOk() (*string, bool) { +func (o *VersionHistoryUpdate) GetChangeOk() (*string, bool) { if o == nil || o.Change == nil { return nil, false } @@ -57,17 +57,17 @@ func (o *RuleVersionUpdate) GetChangeOk() (*string, bool) { } // HasChange returns a boolean if a field has been set. -func (o *RuleVersionUpdate) HasChange() bool { +func (o *VersionHistoryUpdate) HasChange() bool { return o != nil && o.Change != nil } // SetChange gets a reference to the given string and assigns it to the Change field. -func (o *RuleVersionUpdate) SetChange(v string) { +func (o *VersionHistoryUpdate) SetChange(v string) { o.Change = &v } // GetField returns the Field field value if set, zero value otherwise. -func (o *RuleVersionUpdate) GetField() string { +func (o *VersionHistoryUpdate) GetField() string { if o == nil || o.Field == nil { var ret string return ret @@ -77,7 +77,7 @@ func (o *RuleVersionUpdate) GetField() string { // GetFieldOk returns a tuple with the Field field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *RuleVersionUpdate) GetFieldOk() (*string, bool) { +func (o *VersionHistoryUpdate) GetFieldOk() (*string, bool) { if o == nil || o.Field == nil { return nil, false } @@ -85,19 +85,19 @@ func (o *RuleVersionUpdate) GetFieldOk() (*string, bool) { } // HasField returns a boolean if a field has been set. -func (o *RuleVersionUpdate) HasField() bool { +func (o *VersionHistoryUpdate) HasField() bool { return o != nil && o.Field != nil } // SetField gets a reference to the given string and assigns it to the Field field. -func (o *RuleVersionUpdate) SetField(v string) { +func (o *VersionHistoryUpdate) SetField(v string) { o.Field = &v } // GetType returns the Type field value if set, zero value otherwise. -func (o *RuleVersionUpdate) GetType() RuleVersionUpdateType { +func (o *VersionHistoryUpdate) GetType() VersionHistoryUpdateType { if o == nil || o.Type == nil { - var ret RuleVersionUpdateType + var ret VersionHistoryUpdateType return ret } return *o.Type @@ -105,7 +105,7 @@ func (o *RuleVersionUpdate) GetType() RuleVersionUpdateType { // GetTypeOk returns a tuple with the Type field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *RuleVersionUpdate) GetTypeOk() (*RuleVersionUpdateType, bool) { +func (o *VersionHistoryUpdate) GetTypeOk() (*VersionHistoryUpdateType, bool) { if o == nil || o.Type == nil { return nil, false } @@ -113,17 +113,17 @@ func (o *RuleVersionUpdate) GetTypeOk() (*RuleVersionUpdateType, bool) { } // HasType returns a boolean if a field has been set. -func (o *RuleVersionUpdate) HasType() bool { +func (o *VersionHistoryUpdate) HasType() bool { return o != nil && o.Type != nil } -// SetType gets a reference to the given RuleVersionUpdateType and assigns it to the Type field. -func (o *RuleVersionUpdate) SetType(v RuleVersionUpdateType) { +// SetType gets a reference to the given VersionHistoryUpdateType and assigns it to the Type field. +func (o *VersionHistoryUpdate) SetType(v VersionHistoryUpdateType) { o.Type = &v } // MarshalJSON serializes the struct using spec logic. -func (o RuleVersionUpdate) MarshalJSON() ([]byte, error) { +func (o VersionHistoryUpdate) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if o.UnparsedObject != nil { return datadog.Marshal(o.UnparsedObject) @@ -145,11 +145,11 @@ func (o RuleVersionUpdate) MarshalJSON() ([]byte, error) { } // UnmarshalJSON deserializes the given payload. -func (o *RuleVersionUpdate) UnmarshalJSON(bytes []byte) (err error) { +func (o *VersionHistoryUpdate) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Change *string `json:"change,omitempty"` - Field *string `json:"field,omitempty"` - Type *RuleVersionUpdateType `json:"type,omitempty"` + Change *string `json:"change,omitempty"` + Field *string `json:"field,omitempty"` + Type *VersionHistoryUpdateType `json:"type,omitempty"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) diff --git a/api/datadogV2/model_version_history_update_type.go b/api/datadogV2/model_version_history_update_type.go new file mode 100644 index 00000000000..a1d8747d85c --- /dev/null +++ b/api/datadogV2/model_version_history_update_type.go @@ -0,0 +1,68 @@ +// 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" +) + +// VersionHistoryUpdateType The type of change. +type VersionHistoryUpdateType string + +// List of VersionHistoryUpdateType. +const ( + VERSIONHISTORYUPDATETYPE_CREATE VersionHistoryUpdateType = "create" + VERSIONHISTORYUPDATETYPE_UPDATE VersionHistoryUpdateType = "update" + VERSIONHISTORYUPDATETYPE_DELETE VersionHistoryUpdateType = "delete" +) + +var allowedVersionHistoryUpdateTypeEnumValues = []VersionHistoryUpdateType{ + VERSIONHISTORYUPDATETYPE_CREATE, + VERSIONHISTORYUPDATETYPE_UPDATE, + VERSIONHISTORYUPDATETYPE_DELETE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *VersionHistoryUpdateType) GetAllowedValues() []VersionHistoryUpdateType { + return allowedVersionHistoryUpdateTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *VersionHistoryUpdateType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = VersionHistoryUpdateType(value) + return nil +} + +// NewVersionHistoryUpdateTypeFromValue returns a pointer to a valid VersionHistoryUpdateType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewVersionHistoryUpdateTypeFromValue(v string) (*VersionHistoryUpdateType, error) { + ev := VersionHistoryUpdateType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for VersionHistoryUpdateType: valid values are %v", v, allowedVersionHistoryUpdateTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v VersionHistoryUpdateType) IsValid() bool { + for _, existing := range allowedVersionHistoryUpdateTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to VersionHistoryUpdateType value. +func (v VersionHistoryUpdateType) Ptr() *VersionHistoryUpdateType { + return &v +} diff --git a/examples/v2/security-monitoring/GetSuppressionVersionHistory.go b/examples/v2/security-monitoring/GetSuppressionVersionHistory.go new file mode 100644 index 00000000000..492a6845ce2 --- /dev/null +++ b/examples/v2/security-monitoring/GetSuppressionVersionHistory.go @@ -0,0 +1,32 @@ +// Get a suppression's version history returns "OK" 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 "suppression" in the system + SuppressionDataID := os.Getenv("SUPPRESSION_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.GetSuppressionVersionHistory(ctx, SuppressionDataID, *datadogV2.NewGetSuppressionVersionHistoryOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.GetSuppressionVersionHistory`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.GetSuppressionVersionHistory`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..24bfeae8d40 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-11-26T13:33:06.081Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..55ea4546e48 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_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_monitoring/configuration/suppressions/this-does-not-exist/version_history + response: + body: '{"errors":["not_found(Suppression with ID this-does-not-exist 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_a_suppressions_version_history_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_OK_response.freeze new file mode 100644 index 00000000000..d0d5ccec313 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-26T13:33:06.482Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_OK_response.yaml new file mode 100644 index 00000000000..dcbc3d2c62e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_suppressions_version_history_returns_OK_response.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"Test-Get_a_suppression_s_version_history_returns_OK_response-1764163986","enabled":true,"name":"Test-Get_a_suppression_s_version_history_returns_OK_response-1764163986","rule_query":"source:cloudtrail","suppression_query":"env:test","tags":["technique:T1110-brute-force","source:cloudtrail"]},"type":"suppressions"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/security_monitoring/configuration/suppressions + response: + body: '{"data":{"id":"456-piv-74h","type":"suppressions","attributes":{"creation_date":1764163986851,"creator":{"handle":"frog@datadoghq.com","name":"frog"},"data_exclusion_query":"","description":"Test-Get_a_suppression_s_version_history_returns_OK_response-1764163986","editable":true,"enabled":true,"name":"Test-Get_a_suppression_s_version_history_returns_OK_response-1764163986","rule_query":"source:cloudtrail","suppression_query":"env:test","tags":["source:cloudtrail","technique:T1110-brute-force"],"update_date":1764163986851,"updater":{"handle":"frog@datadoghq.com","name":"frog"},"version":1}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/security_monitoring/configuration/suppressions/456-piv-74h/version_history + response: + body: '{"data":{"id":"456-piv-74h","type":"suppression_version_history","attributes":{"count":1,"data":{"1":{"suppression":{"id":"456-piv-74h","name":"Test-Get_a_suppression_s_version_history_returns_OK_response-1764163986","enabled":true,"description":"Test-Get_a_suppression_s_version_history_returns_OK_response-1764163986","rule_query":"source:cloudtrail","suppression_query":"env:test","data_exclusion_query":"","version":1,"creator":{"handle":"frog@datadoghq.com","name":"frog"},"updater":{"handle":"frog@datadoghq.com","name":"frog"},"creation_date":1764163986851,"update_date":1764163986851,"editable":true,"tags":["source:cloudtrail","technique:T1110-brute-force"]},"changes":[]}}}}}' + 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_monitoring/configuration/suppressions/456-piv-74h + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/features/v2/security_monitoring.feature b/tests/scenarios/features/v2/security_monitoring.feature index 531c84c19c1..578e8d28e54 100644 --- a/tests/scenarios/features/v2/security_monitoring.feature +++ b/tests/scenarios/features/v2/security_monitoring.feature @@ -833,6 +833,21 @@ Feature: Security Monitoring And the response "data.attributes.rule_query" has the same value as "suppression.data.attributes.rule_query" And the response "data.attributes.suppression_query" is equal to "env:test" + @team:DataDog/k9-cloud-security-platform + Scenario: Get a suppression's version history returns "Not Found" response + Given new "GetSuppressionVersionHistory" request + And request contains "suppression_id" parameter with value "this-does-not-exist" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-cloud-security-platform + Scenario: Get a suppression's version history returns "OK" response + Given new "GetSuppressionVersionHistory" request + And there is a valid "suppression" in the system + And request contains "suppression_id" parameter from "suppression.data.id" + When the request is sent + Then the response status is 200 OK + @team:DataDog/k9-cloud-security-platform Scenario: Get all security filters returns "OK" response Given new "ListSecurityFilters" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 3799e64e630..67b48870c47 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3830,6 +3830,12 @@ "type": "idempotent" } }, + "GetSuppressionVersionHistory": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListSecurityMonitoringRules": { "tag": "Security Monitoring", "undo": {