/
resource_visibility_packet_capture_object_templates_slb_templ_cache_tmpl.go
265 lines (253 loc) · 12.1 KB
/
resource_visibility_packet_capture_object_templates_slb_templ_cache_tmpl.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
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 resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmpl() *schema.Resource {
return &schema.Resource{
Description: "`thunder_visibility_packet_capture_object_templates_slb_templ_cache_tmpl`: Configure template for slb.template.cache\n\n__PLACEHOLDER__",
CreateContext: resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplCreate,
UpdateContext: resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplUpdate,
ReadContext: resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplRead,
DeleteContext: resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplDelete,
Schema: map[string]*schema.Schema{
"capture_config": {
Type: schema.TypeString, Optional: true, Description: "Specify name of the capture-config to use with this template",
},
"name": {
Type: schema.TypeString, Required: true, Description: "Packet Capture Template Name",
},
"trigger_stats_inc": {
Type: schema.TypeList, MaxItems: 1, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"nc_req_header": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheNcReqHeader, help nc_req_header",
},
"nc_res_header": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheNcResHeader, help nc_res_header",
},
"rv_failure": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheRvFailure, help rv_failure",
},
"content_toobig": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheContentToobig, help content_toobig",
},
"content_toosmall": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheContentToosmall, help content_toosmall",
},
"entry_create_failures": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheEntryCreateFailures, help entry_create_failures",
},
"header_save_error": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for header_save_error",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "uuid of the object",
},
},
},
},
"trigger_stats_rate": {
Type: schema.TypeList, MaxItems: 1, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"threshold_exceeded_by": {
Type: schema.TypeInt, Optional: true, Default: 5, Description: "Set the threshold to the number of times greater than the previous duration to start the capture, default is 5",
},
"duration": {
Type: schema.TypeInt, Optional: true, Default: 60, Description: "Time in seconds to look for the anomaly, default is 60",
},
"nc_req_header": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheNcReqHeader, help nc_req_header",
},
"nc_res_header": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheNcResHeader, help nc_res_header",
},
"rv_failure": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheRvFailure, help rv_failure",
},
"content_toobig": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheContentToobig, help content_toobig",
},
"content_toosmall": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheContentToosmall, help content_toosmall",
},
"entry_create_failures": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for slbTemplateCacheEntryCreateFailures, help entry_create_failures",
},
"header_save_error": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for header_save_error",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "uuid of the object",
},
},
},
},
"trigger_stats_severity": {
Type: schema.TypeList, MaxItems: 1, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"error": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable packet capture on all error counters (Default disabled)",
},
"error_alert": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable packet capture on all alert error counters (Default disabled)",
},
"error_warning": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable packet capture on all warning error counters (Default disabled)",
},
"error_critical": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable packet capture on all critical error counters (Default disabled)",
},
"drop": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable packet capture on all drop counters (Default disabled)",
},
"drop_alert": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable packet capture on all alert drop counters (Default disabled)",
},
"drop_warning": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable packet capture on all warning drop counters (Default disabled)",
},
"drop_critical": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable packet capture on all critical drop counters (Default disabled)",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "uuid of the object",
},
},
},
},
"user_tag": {
Type: schema.TypeString, Optional: true, Description: "Customized tag",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "uuid of the object",
},
},
}
}
func resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplCreate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmpl(d)
d.SetId(obj.GetId())
err := obj.Post(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplUpdate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmpl(d)
err := obj.Put(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplDelete()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmpl(d)
err := obj.Delete(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplRead()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmpl(d)
err := obj.Get(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func getObjectVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsInc2711(d []interface{}) edpt.VisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsInc2711 {
count1 := len(d)
var ret edpt.VisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsInc2711
if count1 > 0 {
in := d[0].(map[string]interface{})
ret.Nc_req_header = in["nc_req_header"].(int)
ret.Nc_res_header = in["nc_res_header"].(int)
ret.Rv_failure = in["rv_failure"].(int)
ret.Content_toobig = in["content_toobig"].(int)
ret.Content_toosmall = in["content_toosmall"].(int)
ret.Entry_create_failures = in["entry_create_failures"].(int)
ret.Header_save_error = in["header_save_error"].(int)
//omit uuid
}
return ret
}
func getObjectVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsRate2712(d []interface{}) edpt.VisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsRate2712 {
count1 := len(d)
var ret edpt.VisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsRate2712
if count1 > 0 {
in := d[0].(map[string]interface{})
ret.ThresholdExceededBy = in["threshold_exceeded_by"].(int)
ret.Duration = in["duration"].(int)
ret.Nc_req_header = in["nc_req_header"].(int)
ret.Nc_res_header = in["nc_res_header"].(int)
ret.Rv_failure = in["rv_failure"].(int)
ret.Content_toobig = in["content_toobig"].(int)
ret.Content_toosmall = in["content_toosmall"].(int)
ret.Entry_create_failures = in["entry_create_failures"].(int)
ret.Header_save_error = in["header_save_error"].(int)
//omit uuid
}
return ret
}
func getObjectVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsSeverity2713(d []interface{}) edpt.VisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsSeverity2713 {
count1 := len(d)
var ret edpt.VisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsSeverity2713
if count1 > 0 {
in := d[0].(map[string]interface{})
ret.Error = in["error"].(int)
ret.ErrorAlert = in["error_alert"].(int)
ret.ErrorWarning = in["error_warning"].(int)
ret.ErrorCritical = in["error_critical"].(int)
ret.Drop = in["drop"].(int)
ret.DropAlert = in["drop_alert"].(int)
ret.DropWarning = in["drop_warning"].(int)
ret.DropCritical = in["drop_critical"].(int)
//omit uuid
}
return ret
}
func dataToEndpointVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmpl(d *schema.ResourceData) edpt.VisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmpl {
var ret edpt.VisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmpl
ret.Inst.CaptureConfig = d.Get("capture_config").(string)
ret.Inst.Name = d.Get("name").(string)
ret.Inst.TriggerStatsInc = getObjectVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsInc2711(d.Get("trigger_stats_inc").([]interface{}))
ret.Inst.TriggerStatsRate = getObjectVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsRate2712(d.Get("trigger_stats_rate").([]interface{}))
ret.Inst.TriggerStatsSeverity = getObjectVisibilityPacketCaptureObjectTemplatesSlbTemplCacheTmplTriggerStatsSeverity2713(d.Get("trigger_stats_severity").([]interface{}))
ret.Inst.UserTag = d.Get("user_tag").(string)
//omit uuid
return ret
}