@@ -100,7 +100,7 @@ func ResourceTransform() *schema.Resource {
100
100
Description : "The pivot method transforms the data by aggregating and grouping it." ,
101
101
Type : schema .TypeString ,
102
102
Optional : true ,
103
- AtLeastOneOf : []string {"pivot" , "latest" },
103
+ ExactlyOneOf : []string {"pivot" , "latest" },
104
104
DiffSuppressFunc : utils .DiffJsonSuppress ,
105
105
ValidateFunc : validation .StringIsJSON ,
106
106
ForceNew : true ,
@@ -109,7 +109,7 @@ func ResourceTransform() *schema.Resource {
109
109
Description : "The latest method transforms the data by finding the latest document for each unique key." ,
110
110
Type : schema .TypeString ,
111
111
Optional : true ,
112
- AtLeastOneOf : []string {"pivot" , "latest" },
112
+ ExactlyOneOf : []string {"pivot" , "latest" },
113
113
DiffSuppressFunc : utils .DiffJsonSuppress ,
114
114
ValidateFunc : validation .StringIsJSON ,
115
115
ForceNew : true ,
@@ -119,7 +119,7 @@ func ResourceTransform() *schema.Resource {
119
119
Description : "The interval between checks for changes in the source indices when the transform is running continuously. Defaults to `1m`." ,
120
120
Optional : true ,
121
121
Default : "1m" ,
122
- ValidateFunc : utils .StringIsDuration ,
122
+ ValidateFunc : utils .StringIsElasticDuration ,
123
123
},
124
124
"metadata" : {
125
125
Description : "Defines optional transform metadata." ,
@@ -151,7 +151,7 @@ func ResourceTransform() *schema.Resource {
151
151
Description : "Specifies the maximum age of a document in the destination index." ,
152
152
Type : schema .TypeString ,
153
153
Required : true ,
154
- ValidateFunc : utils .StringIsDuration ,
154
+ ValidateFunc : utils .StringIsElasticDuration ,
155
155
},
156
156
},
157
157
},
@@ -183,7 +183,7 @@ func ResourceTransform() *schema.Resource {
183
183
Type : schema .TypeString ,
184
184
Optional : true ,
185
185
Default : "60s" ,
186
- ValidateFunc : utils .StringIsDuration ,
186
+ ValidateFunc : utils .StringIsElasticDuration ,
187
187
},
188
188
},
189
189
},
@@ -405,13 +405,12 @@ func getTransformFromResourceData(ctx context.Context, d *schema.ResourceData, n
405
405
if v , ok := d .GetOk ("source" ); ok {
406
406
definedSource := v .([]interface {})[0 ].(map [string ]interface {})
407
407
408
+ transform .Source = new (models.TransformSource )
408
409
indices := make ([]string , 0 )
409
410
for _ , i := range definedSource ["indices" ].([]interface {}) {
410
411
indices = append (indices , i .(string ))
411
412
}
412
- transform .Source = models.TransformSource {
413
- Indices : indices ,
414
- }
413
+ transform .Source .Indices = indices
415
414
416
415
if v , ok := definedSource ["query" ]; ok && len (v .(string )) > 0 {
417
416
var query interface {}
@@ -431,12 +430,13 @@ func getTransformFromResourceData(ctx context.Context, d *schema.ResourceData, n
431
430
}
432
431
433
432
if v , ok := d .GetOk ("destination" ); ok {
433
+
434
434
definedDestination := v .([]interface {})[0 ].(map [string ]interface {})
435
- transform .Destination = models.TransformDestination {
436
- Index : definedDestination ["index" ].(string ),
437
- }
435
+ transform .Destination = new (models.TransformDestination )
438
436
439
- if pipeline , ok := definedDestination ["pipeline" ]; ok {
437
+ transform .Destination .Index = definedDestination ["index" ].(string )
438
+
439
+ if pipeline , ok := definedDestination ["pipeline" ]; ok && len (pipeline .(string )) > 0 {
440
440
transform .Destination .Pipeline = pipeline .(string )
441
441
}
442
442
}
@@ -457,6 +457,10 @@ func getTransformFromResourceData(ctx context.Context, d *schema.ResourceData, n
457
457
transform .Latest = latest
458
458
}
459
459
460
+ if v , ok := d .GetOk ("frequency" ); ok {
461
+ transform .Frequency = v .(string )
462
+ }
463
+
460
464
if v , ok := d .GetOk ("metadata" ); ok {
461
465
metadata := make (map [string ]interface {})
462
466
if err := json .NewDecoder (strings .NewReader (v .(string ))).Decode (& metadata ); err != nil {
@@ -465,5 +469,72 @@ func getTransformFromResourceData(ctx context.Context, d *schema.ResourceData, n
465
469
transform .Meta = metadata
466
470
}
467
471
472
+ if v , ok := d .GetOk ("retention_policy" ); ok && v != nil {
473
+ definedRetentionPolicy := v .([]interface {})[0 ].(map [string ]interface {})
474
+ retentionTime := models.TransformRetentionPolicyTime {}
475
+ if v , ok := definedRetentionPolicy ["time" ]; ok {
476
+ var definedRetentionTime = v .([]interface {})[0 ].(map [string ]interface {})
477
+ if f , ok := definedRetentionTime ["field" ]; ok {
478
+ retentionTime .Field = f .(string )
479
+ }
480
+ if ma , ok := definedRetentionTime ["max_age" ]; ok {
481
+ retentionTime .MaxAge = ma .(string )
482
+ }
483
+ transform .RetentionPolicy = new (models.TransformRetentionPolicy )
484
+ transform .RetentionPolicy .Time = retentionTime
485
+ }
486
+ }
487
+
488
+ if v , ok := d .GetOk ("sync" ); ok {
489
+ definedRetentionPolicy := v .([]interface {})[0 ].(map [string ]interface {})
490
+ syncTime := models.TransformSyncTime {}
491
+ if v , ok := definedRetentionPolicy ["time" ]; ok {
492
+ var definedRetentionTime = v .([]interface {})[0 ].(map [string ]interface {})
493
+ if f , ok := definedRetentionTime ["field" ]; ok {
494
+ syncTime .Field = f .(string )
495
+ }
496
+ if d , ok := definedRetentionTime ["delay" ]; ok {
497
+ syncTime .Delay = d .(string )
498
+ }
499
+ transform .Sync = new (models.TransformSync )
500
+ transform .Sync .Time = syncTime
501
+ }
502
+ }
503
+
504
+ if v , ok := d .GetOk ("settings" ); ok {
505
+ definedSettings := v .([]interface {})[0 ].(map [string ]interface {})
506
+ settings := models.TransformSettings {}
507
+ if v , ok := definedSettings ["align_checkpoints" ]; ok {
508
+ settings .AlignCheckpoints = new (bool )
509
+ * settings .AlignCheckpoints = v .(bool )
510
+ }
511
+ if v , ok := definedSettings ["dates_as_epoch_millis" ]; ok {
512
+ settings .DatesAsEpochMillis = new (bool )
513
+ * settings .DatesAsEpochMillis = v .(bool )
514
+ }
515
+ if v , ok := definedSettings ["deduce_mappings" ]; ok {
516
+ settings .DeduceMappings = new (bool )
517
+ * settings .DeduceMappings = v .(bool )
518
+ }
519
+ if v , ok := definedSettings ["docs_per_second" ]; ok {
520
+ settings .DocsPerSecond = new (float64 )
521
+ * settings .DocsPerSecond = v .(float64 )
522
+ }
523
+ if v , ok := definedSettings ["max_page_search_size" ]; ok {
524
+ settings .MaxPageSearchSize = new (int )
525
+ * settings .MaxPageSearchSize = v .(int )
526
+ }
527
+ if v , ok := definedSettings ["num_failure_retries" ]; ok {
528
+ settings .NumFailureRetries = new (int )
529
+ * settings .NumFailureRetries = v .(int )
530
+ }
531
+ if v , ok := definedSettings ["unattended" ]; ok {
532
+ settings .Unattended = new (bool )
533
+ * settings .Unattended = v .(bool )
534
+ }
535
+
536
+ transform .Settings = & settings
537
+ }
538
+
468
539
return & transform , nil
469
540
}
0 commit comments