/
resource_visibility_monitored_entity_detail_debug_oper.go
368 lines (347 loc) · 13.8 KB
/
resource_visibility_monitored_entity_detail_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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
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 resourceVisibilityMonitoredEntityDetailDebugOper() *schema.Resource {
return &schema.Resource{
Description: "`thunder_visibility_monitored_entity_detail_debug_oper`: Operational Status for the object debug\n\n__PLACEHOLDER__",
ReadContext: resourceVisibilityMonitoredEntityDetailDebugOperRead,
Schema: map[string]*schema.Schema{
"oper": {
Type: schema.TypeList, MaxItems: 1, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"primary_keys": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"all_keys": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"mon_entity_list": {
Type: schema.TypeList, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"entity_key": {
Type: schema.TypeString, Optional: true, Description: "",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "",
},
"flat_oid": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"ipv4_addr": {
Type: schema.TypeString, Optional: true, Description: "",
},
"ipv6_addr": {
Type: schema.TypeString, Optional: true, Description: "",
},
"l4_proto": {
Type: schema.TypeString, Optional: true, Description: "",
},
"l4_port": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"mode": {
Type: schema.TypeString, Optional: true, Description: "",
},
"ha_state": {
Type: schema.TypeString, Optional: true, Description: "",
},
"entity_metric_list": {
Type: schema.TypeList, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"metric_name": {
Type: schema.TypeString, Optional: true, Description: "",
},
"current": {
Type: schema.TypeString, Optional: true, Description: "",
},
"min": {
Type: schema.TypeString, Optional: true, Description: "",
},
"max": {
Type: schema.TypeString, Optional: true, Description: "",
},
"mean": {
Type: schema.TypeString, Optional: true, Description: "",
},
"threshold": {
Type: schema.TypeString, Optional: true, Description: "",
},
"std_dev": {
Type: schema.TypeString, Optional: true, Description: "",
},
"anomaly": {
Type: schema.TypeString, Optional: true, Description: "",
},
},
},
},
"sec_entity_list": {
Type: schema.TypeList, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"entity_key": {
Type: schema.TypeString, Optional: true, Description: "",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "",
},
"flat_oid": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"ipv4_addr": {
Type: schema.TypeString, Optional: true, Description: "",
},
"ipv6_addr": {
Type: schema.TypeString, Optional: true, Description: "",
},
"l4_proto": {
Type: schema.TypeString, Optional: true, Description: "",
},
"l4_port": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"mode": {
Type: schema.TypeString, Optional: true, Description: "",
},
"ha_state": {
Type: schema.TypeString, Optional: true, Description: "",
},
"entity_metric_list": {
Type: schema.TypeList, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"metric_name": {
Type: schema.TypeString, Optional: true, Description: "",
},
"current": {
Type: schema.TypeString, Optional: true, Description: "",
},
"min": {
Type: schema.TypeString, Optional: true, Description: "",
},
"max": {
Type: schema.TypeString, Optional: true, Description: "",
},
"mean": {
Type: schema.TypeString, Optional: true, Description: "",
},
"threshold": {
Type: schema.TypeString, Optional: true, Description: "",
},
"std_dev": {
Type: schema.TypeString, Optional: true, Description: "",
},
"anomaly": {
Type: schema.TypeString, Optional: true, Description: "",
},
},
},
},
},
},
},
},
},
},
},
},
},
},
}
}
func resourceVisibilityMonitoredEntityDetailDebugOperRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityMonitoredEntityDetailDebugOperRead()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityMonitoredEntityDetailDebugOper(d)
res, err := obj.Get(client.Token, client.Host, d.Id(), logger)
d.SetId(obj.GetId())
logger.Println(res)
VisibilityMonitoredEntityDetailDebugOperOper := setObjectVisibilityMonitoredEntityDetailDebugOperOper(res)
d.Set("oper", VisibilityMonitoredEntityDetailDebugOperOper)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func setObjectVisibilityMonitoredEntityDetailDebugOperOper(ret edpt.DataVisibilityMonitoredEntityDetailDebugOper) []interface{} {
return []interface{}{
map[string]interface{}{
"primary_keys": ret.DtVisibilityMonitoredEntityDetailDebugOper.Oper.PrimaryKeys,
"all_keys": ret.DtVisibilityMonitoredEntityDetailDebugOper.Oper.AllKeys,
"mon_entity_list": setSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityList(ret.DtVisibilityMonitoredEntityDetailDebugOper.Oper.MonEntityList),
},
}
}
func setSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityList(d []edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityList) []map[string]interface{} {
result := []map[string]interface{}{}
for _, item := range d {
in := make(map[string]interface{})
in["entity_key"] = item.EntityKey
//omit uuid
in["flat_oid"] = item.FlatOid
in["ipv4_addr"] = item.Ipv4Addr
in["ipv6_addr"] = item.Ipv6Addr
in["l4_proto"] = item.L4Proto
in["l4_port"] = item.L4Port
in["mode"] = item.Mode
in["ha_state"] = item.HaState
in["entity_metric_list"] = setSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListEntityMetricList(item.EntityMetricList)
in["sec_entity_list"] = setSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityList(item.SecEntityList)
result = append(result, in)
}
return result
}
func setSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListEntityMetricList(d []edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListEntityMetricList) []map[string]interface{} {
result := []map[string]interface{}{}
for _, item := range d {
in := make(map[string]interface{})
in["metric_name"] = item.MetricName
in["current"] = item.Current
in["min"] = item.Min
in["max"] = item.Max
in["mean"] = item.Mean
in["threshold"] = item.Threshold
in["std_dev"] = item.StdDev
in["anomaly"] = item.Anomaly
result = append(result, in)
}
return result
}
func setSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityList(d []edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityList) []map[string]interface{} {
result := []map[string]interface{}{}
for _, item := range d {
in := make(map[string]interface{})
in["entity_key"] = item.EntityKey
//omit uuid
in["flat_oid"] = item.FlatOid
in["ipv4_addr"] = item.Ipv4Addr
in["ipv6_addr"] = item.Ipv6Addr
in["l4_proto"] = item.L4Proto
in["l4_port"] = item.L4Port
in["mode"] = item.Mode
in["ha_state"] = item.HaState
in["entity_metric_list"] = setSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityListEntityMetricList(item.EntityMetricList)
result = append(result, in)
}
return result
}
func setSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityListEntityMetricList(d []edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityListEntityMetricList) []map[string]interface{} {
result := []map[string]interface{}{}
for _, item := range d {
in := make(map[string]interface{})
in["metric_name"] = item.MetricName
in["current"] = item.Current
in["min"] = item.Min
in["max"] = item.Max
in["mean"] = item.Mean
in["threshold"] = item.Threshold
in["std_dev"] = item.StdDev
in["anomaly"] = item.Anomaly
result = append(result, in)
}
return result
}
func getObjectVisibilityMonitoredEntityDetailDebugOperOper(d []interface{}) edpt.VisibilityMonitoredEntityDetailDebugOperOper {
count1 := len(d)
var ret edpt.VisibilityMonitoredEntityDetailDebugOperOper
if count1 > 0 {
in := d[0].(map[string]interface{})
ret.PrimaryKeys = in["primary_keys"].(int)
ret.AllKeys = in["all_keys"].(int)
ret.MonEntityList = getSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityList(in["mon_entity_list"].([]interface{}))
}
return ret
}
func getSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityList(d []interface{}) []edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityList {
count1 := len(d)
ret := make([]edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityList, 0, count1)
for _, item := range d {
in := item.(map[string]interface{})
var oi edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityList
oi.EntityKey = in["entity_key"].(string)
//omit uuid
oi.FlatOid = in["flat_oid"].(int)
oi.Ipv4Addr = in["ipv4_addr"].(string)
oi.Ipv6Addr = in["ipv6_addr"].(string)
oi.L4Proto = in["l4_proto"].(string)
oi.L4Port = in["l4_port"].(int)
oi.Mode = in["mode"].(string)
oi.HaState = in["ha_state"].(string)
oi.EntityMetricList = getSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListEntityMetricList(in["entity_metric_list"].([]interface{}))
oi.SecEntityList = getSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityList(in["sec_entity_list"].([]interface{}))
ret = append(ret, oi)
}
return ret
}
func getSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListEntityMetricList(d []interface{}) []edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListEntityMetricList {
count1 := len(d)
ret := make([]edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListEntityMetricList, 0, count1)
for _, item := range d {
in := item.(map[string]interface{})
var oi edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListEntityMetricList
oi.MetricName = in["metric_name"].(string)
oi.Current = in["current"].(string)
oi.Min = in["min"].(string)
oi.Max = in["max"].(string)
oi.Mean = in["mean"].(string)
oi.Threshold = in["threshold"].(string)
oi.StdDev = in["std_dev"].(string)
oi.Anomaly = in["anomaly"].(string)
ret = append(ret, oi)
}
return ret
}
func getSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityList(d []interface{}) []edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityList {
count1 := len(d)
ret := make([]edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityList, 0, count1)
for _, item := range d {
in := item.(map[string]interface{})
var oi edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityList
oi.EntityKey = in["entity_key"].(string)
//omit uuid
oi.FlatOid = in["flat_oid"].(int)
oi.Ipv4Addr = in["ipv4_addr"].(string)
oi.Ipv6Addr = in["ipv6_addr"].(string)
oi.L4Proto = in["l4_proto"].(string)
oi.L4Port = in["l4_port"].(int)
oi.Mode = in["mode"].(string)
oi.HaState = in["ha_state"].(string)
oi.EntityMetricList = getSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityListEntityMetricList(in["entity_metric_list"].([]interface{}))
ret = append(ret, oi)
}
return ret
}
func getSliceVisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityListEntityMetricList(d []interface{}) []edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityListEntityMetricList {
count1 := len(d)
ret := make([]edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityListEntityMetricList, 0, count1)
for _, item := range d {
in := item.(map[string]interface{})
var oi edpt.VisibilityMonitoredEntityDetailDebugOperOperMonEntityListSecEntityListEntityMetricList
oi.MetricName = in["metric_name"].(string)
oi.Current = in["current"].(string)
oi.Min = in["min"].(string)
oi.Max = in["max"].(string)
oi.Mean = in["mean"].(string)
oi.Threshold = in["threshold"].(string)
oi.StdDev = in["std_dev"].(string)
oi.Anomaly = in["anomaly"].(string)
ret = append(ret, oi)
}
return ret
}
func dataToEndpointVisibilityMonitoredEntityDetailDebugOper(d *schema.ResourceData) edpt.VisibilityMonitoredEntityDetailDebugOper {
var ret edpt.VisibilityMonitoredEntityDetailDebugOper
ret.Oper = getObjectVisibilityMonitoredEntityDetailDebugOperOper(d.Get("oper").([]interface{}))
return ret
}