/
resource_visibility_packet_capture_global_templates_template_trigger_sys_obj_stats_change_slb_persist_trigger_stats_rate.go
195 lines (189 loc) · 10.3 KB
/
resource_visibility_packet_capture_global_templates_template_trigger_sys_obj_stats_change_slb_persist_trigger_stats_rate.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
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 resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRate() *schema.Resource {
return &schema.Resource{
Description: "`thunder_visibility_packet_capture_global_templates_template_trigger_sys_obj_stats_change_slb_persist_trigger_stats_rate`: Configure stats to trigger packet capture on increment rate\n\n__PLACEHOLDER__",
CreateContext: resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateCreate,
UpdateContext: resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateUpdate,
ReadContext: resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateRead,
DeleteContext: resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateDelete,
Schema: map[string]*schema.Schema{
"cookie_invalid": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Invalid persist cookie",
},
"cookie_not_found": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Persist cookie not found",
},
"cookie_persist_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Cookie persist fail",
},
"cssl_sid_not_found": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Client SSL SID not found",
},
"cssl_sid_not_match": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Client SSL SID not match",
},
"dst_ip_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for DST IP persist fail",
},
"dst_ip_hash_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for DST IP hash persist fail",
},
"dst_ip_new_sess_cache_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for DST IP new sess fail (c)",
},
"dst_ip_new_sess_sel_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for DST IP new sess fail (s)",
},
"duration": {
Type: schema.TypeInt, Optional: true, Default: 60, Description: "Time in seconds to look for the anomaly, default is 60",
},
"hash_tbl_create_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Hash tbl create fail",
},
"hash_tbl_rst_adddel": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Hash tbl reset (add/del)",
},
"hash_tbl_rst_updown": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Hash tbl reset (up/down)",
},
"hash_tbl_trylock_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Hash tbl lock fail",
},
"header_hash_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Header hash persist fail",
},
"src_ip_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for SRC IP persist fail",
},
"src_ip_hash_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for SRC IP hash persist fail",
},
"src_ip_new_sess_cache_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for SRC IP new sess fail (c)",
},
"src_ip_new_sess_sel_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for SRC IP new sess fail (s)",
},
"ssl_sid_persist_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for SSL SID persist fail",
},
"ssl_sid_session_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Create SSL SID fail",
},
"sssl_sid_not_found": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Server SSL SID not found",
},
"sssl_sid_not_match": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Server SSL SID not match",
},
"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",
},
"url_hash_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for URL hash persist fail",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "uuid of the object",
},
"name": {
Type: schema.TypeString, Required: true, Description: "Name",
},
},
}
}
func resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateCreate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRate(d)
d.SetId(obj.GetId())
err := obj.Post(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateUpdate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRate(d)
err := obj.Put(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateDelete()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRate(d)
err := obj.Delete(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRateRead()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRate(d)
err := obj.Get(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func dataToEndpointVisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRate(d *schema.ResourceData) edpt.VisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRate {
var ret edpt.VisibilityPacketCaptureGlobalTemplatesTemplateTriggerSysObjStatsChangeSlbPersistTriggerStatsRate
ret.Inst.Cookie_invalid = d.Get("cookie_invalid").(int)
ret.Inst.Cookie_not_found = d.Get("cookie_not_found").(int)
ret.Inst.Cookie_persist_fail = d.Get("cookie_persist_fail").(int)
ret.Inst.Cssl_sid_not_found = d.Get("cssl_sid_not_found").(int)
ret.Inst.Cssl_sid_not_match = d.Get("cssl_sid_not_match").(int)
ret.Inst.Dst_ip_fail = d.Get("dst_ip_fail").(int)
ret.Inst.Dst_ip_hash_fail = d.Get("dst_ip_hash_fail").(int)
ret.Inst.Dst_ip_new_sess_cache_fail = d.Get("dst_ip_new_sess_cache_fail").(int)
ret.Inst.Dst_ip_new_sess_sel_fail = d.Get("dst_ip_new_sess_sel_fail").(int)
ret.Inst.Duration = d.Get("duration").(int)
ret.Inst.Hash_tbl_create_fail = d.Get("hash_tbl_create_fail").(int)
ret.Inst.Hash_tbl_rst_adddel = d.Get("hash_tbl_rst_adddel").(int)
ret.Inst.Hash_tbl_rst_updown = d.Get("hash_tbl_rst_updown").(int)
ret.Inst.Hash_tbl_trylock_fail = d.Get("hash_tbl_trylock_fail").(int)
ret.Inst.Header_hash_fail = d.Get("header_hash_fail").(int)
ret.Inst.Src_ip_fail = d.Get("src_ip_fail").(int)
ret.Inst.Src_ip_hash_fail = d.Get("src_ip_hash_fail").(int)
ret.Inst.Src_ip_new_sess_cache_fail = d.Get("src_ip_new_sess_cache_fail").(int)
ret.Inst.Src_ip_new_sess_sel_fail = d.Get("src_ip_new_sess_sel_fail").(int)
ret.Inst.Ssl_sid_persist_fail = d.Get("ssl_sid_persist_fail").(int)
ret.Inst.Ssl_sid_session_fail = d.Get("ssl_sid_session_fail").(int)
ret.Inst.Sssl_sid_not_found = d.Get("sssl_sid_not_found").(int)
ret.Inst.Sssl_sid_not_match = d.Get("sssl_sid_not_match").(int)
ret.Inst.ThresholdExceededBy = d.Get("threshold_exceeded_by").(int)
ret.Inst.Url_hash_fail = d.Get("url_hash_fail").(int)
//omit uuid
ret.Inst.Name = d.Get("name").(string)
return ret
}