/
resource_visibility_reporting_template_notification_debug_oper.go
108 lines (96 loc) · 3.94 KB
/
resource_visibility_reporting_template_notification_debug_oper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package thunder
import (
"context"
edpt "github.com/a10networks/terraform-provider-thunder/thunder/axapi/endpoint"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func resourceVisibilityReportingTemplateNotificationDebugOper() *schema.Resource {
return &schema.Resource{
Description: "`thunder_visibility_reporting_template_notification_debug_oper`: Operational Status for the object debug\n\n__PLACEHOLDER__",
ReadContext: resourceVisibilityReportingTemplateNotificationDebugOperRead,
Schema: map[string]*schema.Schema{
"oper": {
Type: schema.TypeList, MaxItems: 1, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"debug_list": {
Type: schema.TypeList, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"debug_log": {
Type: schema.TypeString, Optional: true, Description: "",
},
},
},
},
"log": {
Type: schema.TypeInt, Optional: true, Description: "",
},
},
},
},
},
}
}
func resourceVisibilityReportingTemplateNotificationDebugOperRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityReportingTemplateNotificationDebugOperRead()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityReportingTemplateNotificationDebugOper(d)
res, err := obj.Get(client.Token, client.Host, d.Id(), logger)
d.SetId(obj.GetId())
logger.Println(res)
VisibilityReportingTemplateNotificationDebugOperOper := setObjectVisibilityReportingTemplateNotificationDebugOperOper(res)
d.Set("oper", VisibilityReportingTemplateNotificationDebugOperOper)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func setObjectVisibilityReportingTemplateNotificationDebugOperOper(ret edpt.DataVisibilityReportingTemplateNotificationDebugOper) []interface{} {
return []interface{}{
map[string]interface{}{
"debug_list": setSliceVisibilityReportingTemplateNotificationDebugOperOperDebugList(ret.DtVisibilityReportingTemplateNotificationDebugOper.Oper.DebugList),
"log": ret.DtVisibilityReportingTemplateNotificationDebugOper.Oper.Log,
},
}
}
func setSliceVisibilityReportingTemplateNotificationDebugOperOperDebugList(d []edpt.VisibilityReportingTemplateNotificationDebugOperOperDebugList) []map[string]interface{} {
result := []map[string]interface{}{}
for _, item := range d {
in := make(map[string]interface{})
in["debug_log"] = item.DebugLog
result = append(result, in)
}
return result
}
func getObjectVisibilityReportingTemplateNotificationDebugOperOper(d []interface{}) edpt.VisibilityReportingTemplateNotificationDebugOperOper {
count1 := len(d)
var ret edpt.VisibilityReportingTemplateNotificationDebugOperOper
if count1 > 0 {
in := d[0].(map[string]interface{})
ret.DebugList = getSliceVisibilityReportingTemplateNotificationDebugOperOperDebugList(in["debug_list"].([]interface{}))
ret.Log = in["log"].(int)
}
return ret
}
func getSliceVisibilityReportingTemplateNotificationDebugOperOperDebugList(d []interface{}) []edpt.VisibilityReportingTemplateNotificationDebugOperOperDebugList {
count1 := len(d)
ret := make([]edpt.VisibilityReportingTemplateNotificationDebugOperOperDebugList, 0, count1)
for _, item := range d {
in := item.(map[string]interface{})
var oi edpt.VisibilityReportingTemplateNotificationDebugOperOperDebugList
oi.DebugLog = in["debug_log"].(string)
ret = append(ret, oi)
}
return ret
}
func dataToEndpointVisibilityReportingTemplateNotificationDebugOper(d *schema.ResourceData) edpt.VisibilityReportingTemplateNotificationDebugOper {
var ret edpt.VisibilityReportingTemplateNotificationDebugOper
ret.Oper = getObjectVisibilityReportingTemplateNotificationDebugOperOper(d.Get("oper").([]interface{}))
return ret
}