@@ -2938,3 +2938,186 @@ func (d *SecurityDetectionRuleData) updateSeverityMappingFromApi(ctx context.Con
29382938
29392939 return diags
29402940}
2941+
2942+ // Helper function to update index patterns from API response
2943+ func (d * SecurityDetectionRuleData ) updateIndexFromApi (ctx context.Context , index * []string ) diag.Diagnostics {
2944+ var diags diag.Diagnostics
2945+
2946+ if index != nil && len (* index ) > 0 {
2947+ d .Index = utils .ListValueFrom (ctx , * index , types .StringType , path .Root ("index" ), & diags )
2948+ } else {
2949+ d .Index = types .ListValueMust (types .StringType , []attr.Value {})
2950+ }
2951+
2952+ return diags
2953+ }
2954+
2955+ // Helper function to update author from API response
2956+ func (d * SecurityDetectionRuleData ) updateAuthorFromApi (ctx context.Context , author []string ) diag.Diagnostics {
2957+ var diags diag.Diagnostics
2958+
2959+ if len (author ) > 0 {
2960+ d .Author = utils .ListValueFrom (ctx , author , types .StringType , path .Root ("author" ), & diags )
2961+ } else {
2962+ d .Author = types .ListValueMust (types .StringType , []attr.Value {})
2963+ }
2964+
2965+ return diags
2966+ }
2967+
2968+ // Helper function to update tags from API response
2969+ func (d * SecurityDetectionRuleData ) updateTagsFromApi (ctx context.Context , tags []string ) diag.Diagnostics {
2970+ var diags diag.Diagnostics
2971+
2972+ if len (tags ) > 0 {
2973+ d .Tags = utils .ListValueFrom (ctx , tags , types .StringType , path .Root ("tags" ), & diags )
2974+ } else {
2975+ d .Tags = types .ListValueMust (types .StringType , []attr.Value {})
2976+ }
2977+
2978+ return diags
2979+ }
2980+
2981+ // Helper function to update false positives from API response
2982+ func (d * SecurityDetectionRuleData ) updateFalsePositivesFromApi (ctx context.Context , falsePositives []string ) diag.Diagnostics {
2983+ var diags diag.Diagnostics
2984+
2985+ if len (falsePositives ) > 0 {
2986+ d .FalsePositives = utils .ListValueFrom (ctx , falsePositives , types .StringType , path .Root ("false_positives" ), & diags )
2987+ } else {
2988+ d .FalsePositives = types .ListValueMust (types .StringType , []attr.Value {})
2989+ }
2990+
2991+ return diags
2992+ }
2993+
2994+ // Helper function to update references from API response
2995+ func (d * SecurityDetectionRuleData ) updateReferencesFromApi (ctx context.Context , references []string ) diag.Diagnostics {
2996+ var diags diag.Diagnostics
2997+
2998+ if len (references ) > 0 {
2999+ d .References = utils .ListValueFrom (ctx , references , types .StringType , path .Root ("references" ), & diags )
3000+ } else {
3001+ d .References = types .ListValueMust (types .StringType , []attr.Value {})
3002+ }
3003+
3004+ return diags
3005+ }
3006+
3007+ // Helper function to update data view ID from API response
3008+ func (d * SecurityDetectionRuleData ) updateDataViewIdFromApi (ctx context.Context , dataViewId * kbapi.SecurityDetectionsAPIDataViewId ) diag.Diagnostics {
3009+ var diags diag.Diagnostics
3010+
3011+ if dataViewId != nil {
3012+ d .DataViewId = types .StringValue (string (* dataViewId ))
3013+ } else {
3014+ d .DataViewId = types .StringNull ()
3015+ }
3016+
3017+ return diags
3018+ }
3019+
3020+ // Helper function to update namespace from API response
3021+ func (d * SecurityDetectionRuleData ) updateNamespaceFromApi (ctx context.Context , namespace * kbapi.SecurityDetectionsAPIAlertsIndexNamespace ) diag.Diagnostics {
3022+ var diags diag.Diagnostics
3023+
3024+ if namespace != nil {
3025+ d .Namespace = types .StringValue (string (* namespace ))
3026+ } else {
3027+ d .Namespace = types .StringNull ()
3028+ }
3029+
3030+ return diags
3031+ }
3032+
3033+ // Helper function to update rule name override from API response
3034+ func (d * SecurityDetectionRuleData ) updateRuleNameOverrideFromApi (ctx context.Context , ruleNameOverride * kbapi.SecurityDetectionsAPIRuleNameOverride ) diag.Diagnostics {
3035+ var diags diag.Diagnostics
3036+
3037+ if ruleNameOverride != nil {
3038+ d .RuleNameOverride = types .StringValue (string (* ruleNameOverride ))
3039+ } else {
3040+ d .RuleNameOverride = types .StringNull ()
3041+ }
3042+
3043+ return diags
3044+ }
3045+
3046+ // Helper function to update timestamp override from API response
3047+ func (d * SecurityDetectionRuleData ) updateTimestampOverrideFromApi (ctx context.Context , timestampOverride * kbapi.SecurityDetectionsAPITimestampOverride ) diag.Diagnostics {
3048+ var diags diag.Diagnostics
3049+
3050+ if timestampOverride != nil {
3051+ d .TimestampOverride = types .StringValue (string (* timestampOverride ))
3052+ } else {
3053+ d .TimestampOverride = types .StringNull ()
3054+ }
3055+
3056+ return diags
3057+ }
3058+
3059+ // Helper function to update timestamp override fallback disabled from API response
3060+ func (d * SecurityDetectionRuleData ) updateTimestampOverrideFallbackDisabledFromApi (ctx context.Context , timestampOverrideFallbackDisabled * kbapi.SecurityDetectionsAPITimestampOverrideFallbackDisabled ) diag.Diagnostics {
3061+ var diags diag.Diagnostics
3062+
3063+ if timestampOverrideFallbackDisabled != nil {
3064+ d .TimestampOverrideFallbackDisabled = types .BoolValue (bool (* timestampOverrideFallbackDisabled ))
3065+ } else {
3066+ d .TimestampOverrideFallbackDisabled = types .BoolNull ()
3067+ }
3068+
3069+ return diags
3070+ }
3071+
3072+ // Helper function to update building block type from API response
3073+ func (d * SecurityDetectionRuleData ) updateBuildingBlockTypeFromApi (ctx context.Context , buildingBlockType * kbapi.SecurityDetectionsAPIBuildingBlockType ) diag.Diagnostics {
3074+ var diags diag.Diagnostics
3075+
3076+ if buildingBlockType != nil {
3077+ d .BuildingBlockType = types .StringValue (string (* buildingBlockType ))
3078+ } else {
3079+ d .BuildingBlockType = types .StringNull ()
3080+ }
3081+
3082+ return diags
3083+ }
3084+
3085+ // Helper function to update license from API response
3086+ func (d * SecurityDetectionRuleData ) updateLicenseFromApi (ctx context.Context , license * kbapi.SecurityDetectionsAPIRuleLicense ) diag.Diagnostics {
3087+ var diags diag.Diagnostics
3088+
3089+ if license != nil {
3090+ d .License = types .StringValue (string (* license ))
3091+ } else {
3092+ d .License = types .StringNull ()
3093+ }
3094+
3095+ return diags
3096+ }
3097+
3098+ // Helper function to update note from API response
3099+ func (d * SecurityDetectionRuleData ) updateNoteFromApi (ctx context.Context , note * kbapi.SecurityDetectionsAPIInvestigationGuide ) diag.Diagnostics {
3100+ var diags diag.Diagnostics
3101+
3102+ if note != nil {
3103+ d .Note = types .StringValue (string (* note ))
3104+ } else {
3105+ d .Note = types .StringNull ()
3106+ }
3107+
3108+ return diags
3109+ }
3110+
3111+ // Helper function to update setup from API response
3112+ func (d * SecurityDetectionRuleData ) updateSetupFromApi (ctx context.Context , setup kbapi.SecurityDetectionsAPISetupGuide ) diag.Diagnostics {
3113+ var diags diag.Diagnostics
3114+
3115+ // Handle setup field - if empty, set to null to maintain consistency with optional schema
3116+ if string (setup ) != "" {
3117+ d .Setup = types .StringValue (string (setup ))
3118+ } else {
3119+ d .Setup = types .StringNull ()
3120+ }
3121+
3122+ return diags
3123+ }
0 commit comments