Skip to content

Commit 9fb135b

Browse files
authored
add data_stream parameter (#11)
1 parent 1164c14 commit 9fb135b

File tree

3 files changed

+358
-26
lines changed

3 files changed

+358
-26
lines changed

provider/resource_elkaliases_index.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ func resourceelkAliasesIndex() *schema.Resource {
2929
Elem: &schema.Schema{Type: schema.TypeString},
3030
Required: true,
3131
},
32+
"data_stream": {
33+
Type: schema.TypeList,
34+
MaxItems: 1,
35+
Optional: true,
36+
Elem: &schema.Resource{
37+
Schema: map[string]*schema.Schema{
38+
"allow_custom_routing": {
39+
Type: schema.TypeBool,
40+
Optional: true,
41+
Default: false,
42+
},
43+
"hidden": {
44+
Type: schema.TypeBool,
45+
Optional: true,
46+
Default: false,
47+
},
48+
},
49+
},
50+
},
3251
"template": {
3352
Type: schema.TypeList,
3453
MaxItems: 1,
@@ -109,6 +128,15 @@ func resourceelkAliasesIndexCreate(d *schema.ResourceData, m interface{}) error
109128
"composed_of": composedOf,
110129
}
111130

131+
// Convert data_stream
132+
if value, ok := d.GetOk("data_stream"); ok {
133+
content := value.([]any)[0].(map[string]any)
134+
templateBody["data_stream"] = map[string]any{
135+
"allow_custom_routing": content["allow_custom_routing"],
136+
"hidden": content["hidden"],
137+
}
138+
}
139+
112140
// Convert templateBody to JSON
113141
body, err := json.Marshal(templateBody)
114142
if err != nil {
@@ -182,6 +210,22 @@ func resourceelkAliasesIndexRead(d *schema.ResourceData, m interface{}) error {
182210
d.Set("composed_of", composedOf)
183211
}
184212

213+
// Handle data_stream
214+
if dataStream, ok := templateDetails["data_stream"].(map[string]any); ok {
215+
dataSteamTemplate := make(map[string]any)
216+
if routing, ok := dataStream["allow_custom_routing"]; ok {
217+
dataSteamTemplate["allow_custom_routing"] = routing
218+
}
219+
220+
if hidden, ok := dataStream["hidden"]; ok {
221+
dataSteamTemplate["hidden"] = hidden
222+
}
223+
224+
d.Set("data_stream", []any{dataSteamTemplate})
225+
} else {
226+
d.Set("data_stream", nil)
227+
}
228+
185229
// Extract and handle template components
186230
if templateContent, ok := templateDetails["template"].(map[string]interface{}); ok {
187231
// Handle mappings

0 commit comments

Comments
 (0)