Skip to content

Commit db04052

Browse files
committed
adding missing properties for transform
1 parent de26951 commit db04052

File tree

2 files changed

+151
-9
lines changed

2 files changed

+151
-9
lines changed

internal/elasticsearch/transform/transform.go

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,118 @@ func ResourceTransform() *schema.Resource {
128128
ValidateFunc: validation.StringIsJSON,
129129
DiffSuppressFunc: utils.DiffJsonSuppress,
130130
},
131+
"retention_policy": {
132+
Description: "Defines a retention policy for the transform.",
133+
Type: schema.TypeList,
134+
Optional: true,
135+
MaxItems: 1,
136+
Elem: &schema.Resource{
137+
Schema: map[string]*schema.Schema{
138+
"time": {
139+
Description: "Specifies that the transform uses a time field to set the retention policy.",
140+
Type: schema.TypeList,
141+
Required: true,
142+
MaxItems: 1,
143+
Elem: &schema.Resource{
144+
Schema: map[string]*schema.Schema{
145+
"field": {
146+
Description: "The date field that is used to calculate the age of the document.",
147+
Type: schema.TypeString,
148+
Required: true,
149+
},
150+
"max_age": {
151+
Description: "Specifies the maximum age of a document in the destination index.",
152+
Type: schema.TypeString,
153+
Required: true,
154+
ValidateFunc: utils.StringIsDuration,
155+
},
156+
},
157+
},
158+
},
159+
},
160+
},
161+
},
162+
"sync": {
163+
Description: "Defines the properties transforms require to run continuously.",
164+
Type: schema.TypeList,
165+
Optional: true,
166+
MaxItems: 1,
167+
Elem: &schema.Resource{
168+
Schema: map[string]*schema.Schema{
169+
"time": {
170+
Description: "Specifies that the transform uses a time field to synchronize the source and destination indices.",
171+
Type: schema.TypeList,
172+
Required: true,
173+
MaxItems: 1,
174+
Elem: &schema.Resource{
175+
Schema: map[string]*schema.Schema{
176+
"field": {
177+
Description: "The date field that is used to identify new documents in the source.",
178+
Type: schema.TypeString,
179+
Required: true,
180+
},
181+
"delay": {
182+
Description: "The time delay between the current time and the latest input data time. The default value is 60s.",
183+
Type: schema.TypeString,
184+
Optional: true,
185+
Default: "60s",
186+
ValidateFunc: utils.StringIsDuration,
187+
},
188+
},
189+
},
190+
},
191+
},
192+
},
193+
},
194+
"settings": {
195+
Description: "Defines optional transform settings.",
196+
Type: schema.TypeList,
197+
Optional: true,
198+
MaxItems: 1,
199+
Elem: &schema.Resource{
200+
Schema: map[string]*schema.Schema{
201+
"align_checkpoints": {
202+
Description: "Specifies whether the transform checkpoint ranges should be optimized for performance. Default value is true.",
203+
Type: schema.TypeBool,
204+
Optional: true,
205+
Default: true,
206+
},
207+
"dates_as_epoch_millis": {
208+
Description: "Defines if dates in the output should be written as ISO formatted string (default) or as millis since epoch.",
209+
Type: schema.TypeBool,
210+
Optional: true,
211+
Default: false,
212+
},
213+
"deduce_mappings": {
214+
Description: "Specifies whether the transform should deduce the destination index mappings from the transform config. The default value is true",
215+
Type: schema.TypeBool,
216+
Optional: true,
217+
Default: true,
218+
},
219+
"docs_per_second": {
220+
Description: "Specifies a limit on the number of input documents per second. Default value is null, which disables throttling.",
221+
Type: schema.TypeFloat,
222+
Optional: true,
223+
},
224+
"max_page_search_size": {
225+
Description: "Defines the initial page size to use for the composite aggregation for each checkpoint. The default value is 500.",
226+
Type: schema.TypeInt,
227+
Optional: true,
228+
},
229+
"num_failure_retries": {
230+
Description: "Defines the number of retries on a recoverable failure before the transform task is marked as failed. The default value is the cluster-level setting num_transform_failure_retries.",
231+
Type: schema.TypeInt,
232+
Optional: true,
233+
},
234+
"unattended": {
235+
Description: "In unattended mode, the transform retries indefinitely in case of an error which means the transform never fails. Defaults to false.",
236+
Type: schema.TypeBool,
237+
Optional: true,
238+
Default: false,
239+
},
240+
},
241+
},
242+
},
131243
"defer_validation": {
132244
Type: schema.TypeBool,
133245
Description: "When true, deferrable validations are not run upon creation, but rather when the transform is started. This behavior may be desired if the source index does not exist until after the transform is created.",

internal/models/transform.go

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ import (
66
)
77

88
type Transform struct {
9-
Id string `json:"id,omitempty"`
10-
Name string `json:"-"`
11-
Description string `json:"description,omitempty"`
12-
Source TransformSource `json:"source"`
13-
Destination TransformDestination `json:"dest"`
14-
Pivot interface{} `json:"pivot,omitempty"`
15-
Latest interface{} `json:"latest,omitempty"`
16-
Frequency string `json:"frequency,omitempty"`
17-
Meta map[string]interface{} `json:"_meta,omitempty"`
9+
Id string `json:"id,omitempty"`
10+
Name string `json:"-"`
11+
Description string `json:"description,omitempty"`
12+
Source TransformSource `json:"source"`
13+
Destination TransformDestination `json:"dest"`
14+
Pivot interface{} `json:"pivot,omitempty"`
15+
Latest interface{} `json:"latest,omitempty"`
16+
Frequency string `json:"frequency,omitempty"`
17+
RetentionPolicy TransformRetentionPolicy `json:"retention_policy,omitempty"`
18+
Sync TransformSync `json:"sync,omitempty"`
19+
Meta map[string]interface{} `json:"_meta,omitempty"`
1820
}
1921

2022
type TransformSource struct {
@@ -28,6 +30,34 @@ type TransformDestination struct {
2830
Pipeline string `json:"pipeline,omitempty"`
2931
}
3032

33+
type TransformRetentionPolicy struct {
34+
Time TransformRetentionPolicyTime `json:"time"`
35+
}
36+
37+
type TransformRetentionPolicyTime struct {
38+
Field string `json:"field"`
39+
MaxAge string `json:"max_age"`
40+
}
41+
42+
type TransformSync struct {
43+
Time TransformSyncTime `json:"time"`
44+
}
45+
46+
type TransformSyncTime struct {
47+
Field string `json:"field"`
48+
Delay string `json:"delay,omitempty"`
49+
}
50+
51+
type TransformSettings struct {
52+
AlignCheckpoints *bool `json:"align_checkpoints,omitempty"`
53+
DatesAsEpochMillis *bool `json:"dates_as_epoch_millis,omitempty"`
54+
DeduceMappings *bool `json:"deduce_mappings,omitempty"`
55+
DocsPerSecond *float64 `json:"docs_per_second,omitempty"`
56+
MaxPageSearchSize *int `json:"max_page_search_size,omitempty"`
57+
NumFailureRetries *int `json:"num_failure_retries,omitempty"`
58+
Unattended *bool `json:"unattended,omitempty"`
59+
}
60+
3161
type PutTransformParams struct {
3262
DeferValidation bool
3363
Timeout time.Duration

0 commit comments

Comments
 (0)