@@ -30,24 +30,12 @@ func (d SecurityDetectionRuleData) toMachineLearningRuleCreateProps(ctx context.
3030 if utils .IsKnown (d .MachineLearningJobId ) {
3131 jobIds := utils .ListTypeAs [string ](ctx , d .MachineLearningJobId , path .Root ("machine_learning_job_id" ), & diags )
3232 if ! diags .HasError () {
33- if len (jobIds ) == 1 {
34- // Single job ID
35- var mlJobId kbapi.SecurityDetectionsAPIMachineLearningJobId
36- err := mlJobId .FromSecurityDetectionsAPIMachineLearningJobId0 (jobIds [0 ])
37- if err != nil {
38- diags .AddError ("Error setting ML job ID" , err .Error ())
39- } else {
40- mlRule .MachineLearningJobId = mlJobId
41- }
42- } else if len (jobIds ) > 1 {
43- // Multiple job IDs
44- var mlJobId kbapi.SecurityDetectionsAPIMachineLearningJobId
45- err := mlJobId .FromSecurityDetectionsAPIMachineLearningJobId1 (jobIds )
46- if err != nil {
47- diags .AddError ("Error setting ML job IDs" , err .Error ())
48- } else {
49- mlRule .MachineLearningJobId = mlJobId
50- }
33+ var mlJobId kbapi.SecurityDetectionsAPIMachineLearningJobId
34+ err := mlJobId .FromSecurityDetectionsAPIMachineLearningJobId1 (jobIds )
35+ if err != nil {
36+ diags .AddError ("Error setting ML job IDs" , err .Error ())
37+ } else {
38+ mlRule .MachineLearningJobId = mlJobId
5139 }
5240 }
5341 }
@@ -135,24 +123,12 @@ func (d SecurityDetectionRuleData) toMachineLearningRuleUpdateProps(ctx context.
135123 if utils .IsKnown (d .MachineLearningJobId ) {
136124 jobIds := utils .ListTypeAs [string ](ctx , d .MachineLearningJobId , path .Root ("machine_learning_job_id" ), & diags )
137125 if ! diags .HasError () {
138- if len (jobIds ) == 1 {
139- // Single job ID
140- var mlJobId kbapi.SecurityDetectionsAPIMachineLearningJobId
141- err := mlJobId .FromSecurityDetectionsAPIMachineLearningJobId0 (jobIds [0 ])
142- if err != nil {
143- diags .AddError ("Error setting ML job ID" , err .Error ())
144- } else {
145- mlRule .MachineLearningJobId = mlJobId
146- }
147- } else if len (jobIds ) > 1 {
148- // Multiple job IDs
149- var mlJobId kbapi.SecurityDetectionsAPIMachineLearningJobId
150- err := mlJobId .FromSecurityDetectionsAPIMachineLearningJobId1 (jobIds )
151- if err != nil {
152- diags .AddError ("Error setting ML job IDs" , err .Error ())
153- } else {
154- mlRule .MachineLearningJobId = mlJobId
155- }
126+ var mlJobId kbapi.SecurityDetectionsAPIMachineLearningJobId
127+ err := mlJobId .FromSecurityDetectionsAPIMachineLearningJobId1 (jobIds )
128+ if err != nil {
129+ diags .AddError ("Error setting ML job IDs" , err .Error ())
130+ } else {
131+ mlRule .MachineLearningJobId = mlJobId
156132 }
157133 }
158134 }
@@ -254,13 +230,8 @@ func (d *SecurityDetectionRuleData) updateFromMachineLearningRule(ctx context.Co
254230 // ML-specific fields
255231 d .AnomalyThreshold = types .Int64Value (int64 (rule .AnomalyThreshold ))
256232
257- // Handle ML job ID(s) - can be single string or array
258- // Try to extract as single job ID first, then as array
259- if singleJobId , err := rule .MachineLearningJobId .AsSecurityDetectionsAPIMachineLearningJobId0 (); err == nil {
260- // Single job ID
261- d .MachineLearningJobId = utils .ListValueFrom (ctx , []string {string (singleJobId )}, types .StringType , path .Root ("machine_learning_job_id" ), & diags )
262- } else if multipleJobIds , err := rule .MachineLearningJobId .AsSecurityDetectionsAPIMachineLearningJobId1 (); err == nil {
263- // Multiple job IDs
233+ // Handle ML job ID(s)
234+ if multipleJobIds , err := rule .MachineLearningJobId .AsSecurityDetectionsAPIMachineLearningJobId1 (); err == nil {
264235 jobIdStrings := make ([]string , len (multipleJobIds ))
265236 for i , jobId := range multipleJobIds {
266237 jobIdStrings [i ] = string (jobId )
0 commit comments