/
resource_visibility_packet_capture_object_templates_smtp_vport_tmpl_trigger_stats_rate.go
179 lines (173 loc) · 8.76 KB
/
resource_visibility_packet_capture_object_templates_smtp_vport_tmpl_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
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 resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRate() *schema.Resource {
return &schema.Resource{
Description: "`thunder_visibility_packet_capture_object_templates_smtp_vport_tmpl_trigger_stats_rate`: Configure stats to triggers packet capture on increment\n\n__PLACEHOLDER__",
CreateContext: resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateCreate,
UpdateContext: resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateUpdate,
ReadContext: resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateRead,
DeleteContext: resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateDelete,
Schema: map[string]*schema.Schema{
"duration": {
Type: schema.TypeInt, Optional: true, Default: 60, Description: "Time in seconds to look for the anomaly, default is 60",
},
"forward_req_data_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Forward REQ data failure",
},
"forward_req_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Forward request failure",
},
"get_all_headers_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Get all headers fail",
},
"insert_resonse_line_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Ins response line fail",
},
"line_extend_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Line extend fail",
},
"line_table_extend_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Table extend fail",
},
"line_too_long": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Line too long",
},
"no_proxy": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for No proxy error",
},
"parse_req_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Parse request failure",
},
"parse_request_line_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Parse request line fail",
},
"parse_resonse_line_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Parse response line fail",
},
"read_request_line_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Read request line fail",
},
"recv_server_unknow_reply_code": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Recv server unknown-code",
},
"remove_resonse_line_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Del response line fail",
},
"send_client_service_not_ready": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Sent client serv-not-rdy",
},
"server_select_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Server selection failure",
},
"server_starttls_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Server side STARTTLS fail",
},
"snat_fail": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Source NAT failure",
},
"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",
},
"too_many_headers": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Too many headers",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "uuid of the object",
},
"name": {
Type: schema.TypeString, Required: true, Description: "Name",
},
},
}
}
func resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateCreate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRate(d)
d.SetId(obj.GetId())
err := obj.Post(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateUpdate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRate(d)
err := obj.Put(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateDelete()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRate(d)
err := obj.Delete(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRateRead()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRate(d)
err := obj.Get(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func dataToEndpointVisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRate(d *schema.ResourceData) edpt.VisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRate {
var ret edpt.VisibilityPacketCaptureObjectTemplatesSmtpVportTmplTriggerStatsRate
ret.Inst.Duration = d.Get("duration").(int)
ret.Inst.Forward_req_data_fail = d.Get("forward_req_data_fail").(int)
ret.Inst.Forward_req_fail = d.Get("forward_req_fail").(int)
ret.Inst.Get_all_headers_fail = d.Get("get_all_headers_fail").(int)
ret.Inst.Insert_resonse_line_fail = d.Get("insert_resonse_line_fail").(int)
ret.Inst.Line_extend_fail = d.Get("line_extend_fail").(int)
ret.Inst.Line_table_extend_fail = d.Get("line_table_extend_fail").(int)
ret.Inst.Line_too_long = d.Get("line_too_long").(int)
ret.Inst.No_proxy = d.Get("no_proxy").(int)
ret.Inst.Parse_req_fail = d.Get("parse_req_fail").(int)
ret.Inst.Parse_request_line_fail = d.Get("parse_request_line_fail").(int)
ret.Inst.Parse_resonse_line_fail = d.Get("parse_resonse_line_fail").(int)
ret.Inst.Read_request_line_fail = d.Get("read_request_line_fail").(int)
ret.Inst.Recv_server_unknow_reply_code = d.Get("recv_server_unknow_reply_code").(int)
ret.Inst.Remove_resonse_line_fail = d.Get("remove_resonse_line_fail").(int)
ret.Inst.Send_client_service_not_ready = d.Get("send_client_service_not_ready").(int)
ret.Inst.Server_select_fail = d.Get("server_select_fail").(int)
ret.Inst.Server_starttls_fail = d.Get("server_starttls_fail").(int)
ret.Inst.Snat_fail = d.Get("snat_fail").(int)
ret.Inst.ThresholdExceededBy = d.Get("threshold_exceeded_by").(int)
ret.Inst.Too_many_headers = d.Get("too_many_headers").(int)
//omit uuid
ret.Inst.Name = d.Get("name").(string)
return ret
}