diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 42b12a3fb05..a18017d3516 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -8650,6 +8650,11 @@ components: CloudWorkloadSecurityAgentRuleActionHash: additionalProperties: {} description: An empty object indicating the hash action + properties: + field: + description: Event field to use for the hash computation. + example: process.file + type: string type: object CloudWorkloadSecurityAgentRuleActionMetadata: description: The metadata action applied on the scope matching the rule diff --git a/api/datadogV2/model_cloud_workload_security_agent_rule_action.go b/api/datadogV2/model_cloud_workload_security_agent_rule_action.go index dd58479aadc..592582691be 100644 --- a/api/datadogV2/model_cloud_workload_security_agent_rule_action.go +++ b/api/datadogV2/model_cloud_workload_security_agent_rule_action.go @@ -13,7 +13,7 @@ type CloudWorkloadSecurityAgentRuleAction struct { // SECL expression used to target the container to apply the action on Filter *string `json:"filter,omitempty"` // An empty object indicating the hash action - Hash map[string]interface{} `json:"hash,omitempty"` + Hash *CloudWorkloadSecurityAgentRuleActionHash `json:"hash,omitempty"` // Kill system call applied on the container matching the rule Kill *CloudWorkloadSecurityAgentRuleKill `json:"kill,omitempty"` // The metadata action applied on the scope matching the rule @@ -71,21 +71,21 @@ func (o *CloudWorkloadSecurityAgentRuleAction) SetFilter(v string) { } // GetHash returns the Hash field value if set, zero value otherwise. -func (o *CloudWorkloadSecurityAgentRuleAction) GetHash() map[string]interface{} { +func (o *CloudWorkloadSecurityAgentRuleAction) GetHash() CloudWorkloadSecurityAgentRuleActionHash { if o == nil || o.Hash == nil { - var ret map[string]interface{} + var ret CloudWorkloadSecurityAgentRuleActionHash return ret } - return o.Hash + return *o.Hash } // GetHashOk returns a tuple with the Hash field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *CloudWorkloadSecurityAgentRuleAction) GetHashOk() (*map[string]interface{}, bool) { +func (o *CloudWorkloadSecurityAgentRuleAction) GetHashOk() (*CloudWorkloadSecurityAgentRuleActionHash, bool) { if o == nil || o.Hash == nil { return nil, false } - return &o.Hash, true + return o.Hash, true } // HasHash returns a boolean if a field has been set. @@ -93,9 +93,9 @@ func (o *CloudWorkloadSecurityAgentRuleAction) HasHash() bool { return o != nil && o.Hash != nil } -// SetHash gets a reference to the given map[string]interface{} and assigns it to the Hash field. -func (o *CloudWorkloadSecurityAgentRuleAction) SetHash(v map[string]interface{}) { - o.Hash = v +// SetHash gets a reference to the given CloudWorkloadSecurityAgentRuleActionHash and assigns it to the Hash field. +func (o *CloudWorkloadSecurityAgentRuleAction) SetHash(v CloudWorkloadSecurityAgentRuleActionHash) { + o.Hash = &v } // GetKill returns the Kill field value if set, zero value otherwise. @@ -214,7 +214,7 @@ func (o CloudWorkloadSecurityAgentRuleAction) MarshalJSON() ([]byte, error) { func (o *CloudWorkloadSecurityAgentRuleAction) UnmarshalJSON(bytes []byte) (err error) { all := struct { Filter *string `json:"filter,omitempty"` - Hash map[string]interface{} `json:"hash,omitempty"` + Hash *CloudWorkloadSecurityAgentRuleActionHash `json:"hash,omitempty"` Kill *CloudWorkloadSecurityAgentRuleKill `json:"kill,omitempty"` Metadata *CloudWorkloadSecurityAgentRuleActionMetadata `json:"metadata,omitempty"` Set *CloudWorkloadSecurityAgentRuleActionSet `json:"set,omitempty"` @@ -231,6 +231,9 @@ func (o *CloudWorkloadSecurityAgentRuleAction) UnmarshalJSON(bytes []byte) (err hasInvalidField := false o.Filter = all.Filter + if all.Hash != nil && all.Hash.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } o.Hash = all.Hash if all.Kill != nil && all.Kill.UnparsedObject != nil && o.UnparsedObject == nil { hasInvalidField = true diff --git a/api/datadogV2/model_cloud_workload_security_agent_rule_action_hash.go b/api/datadogV2/model_cloud_workload_security_agent_rule_action_hash.go new file mode 100644 index 00000000000..a9c3d7683a1 --- /dev/null +++ b/api/datadogV2/model_cloud_workload_security_agent_rule_action_hash.go @@ -0,0 +1,102 @@ +// 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" +) + +// CloudWorkloadSecurityAgentRuleActionHash An empty object indicating the hash action +type CloudWorkloadSecurityAgentRuleActionHash struct { + // Event field to use for the hash computation. + Field *string `json:"field,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:"-"` +} + +// NewCloudWorkloadSecurityAgentRuleActionHash instantiates a new CloudWorkloadSecurityAgentRuleActionHash 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 NewCloudWorkloadSecurityAgentRuleActionHash() *CloudWorkloadSecurityAgentRuleActionHash { + this := CloudWorkloadSecurityAgentRuleActionHash{} + return &this +} + +// NewCloudWorkloadSecurityAgentRuleActionHashWithDefaults instantiates a new CloudWorkloadSecurityAgentRuleActionHash 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 NewCloudWorkloadSecurityAgentRuleActionHashWithDefaults() *CloudWorkloadSecurityAgentRuleActionHash { + this := CloudWorkloadSecurityAgentRuleActionHash{} + return &this +} + +// GetField returns the Field field value if set, zero value otherwise. +func (o *CloudWorkloadSecurityAgentRuleActionHash) GetField() string { + if o == nil || o.Field == nil { + var ret string + return ret + } + return *o.Field +} + +// 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 *CloudWorkloadSecurityAgentRuleActionHash) GetFieldOk() (*string, bool) { + if o == nil || o.Field == nil { + return nil, false + } + return o.Field, true +} + +// HasField returns a boolean if a field has been set. +func (o *CloudWorkloadSecurityAgentRuleActionHash) 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 *CloudWorkloadSecurityAgentRuleActionHash) SetField(v string) { + o.Field = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CloudWorkloadSecurityAgentRuleActionHash) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Field != nil { + toSerialize["field"] = o.Field + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CloudWorkloadSecurityAgentRuleActionHash) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Field *string `json:"field,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{"field"}) + } else { + return err + } + o.Field = all.Field + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/csm-threats/CreateCSMThreatsAgentRule_1295653933.go b/examples/v2/csm-threats/CreateCSMThreatsAgentRule_1295653933.go index 97ee2c02ba6..709bbd5b58b 100644 --- a/examples/v2/csm-threats/CreateCSMThreatsAgentRule_1295653933.go +++ b/examples/v2/csm-threats/CreateCSMThreatsAgentRule_1295653933.go @@ -35,7 +35,7 @@ func main() { }, }, { - Hash: map[string]interface{}{}, + Hash: &datadogV2.CloudWorkloadSecurityAgentRuleActionHash{}, }, }, },