/
resource_visibility_packet_capture_object_templates_aam_auth_relay_ws_fed_tmpl.go
217 lines (205 loc) · 9.31 KB
/
resource_visibility_packet_capture_object_templates_aam_auth_relay_ws_fed_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
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 resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmpl() *schema.Resource {
return &schema.Resource{
Description: "`thunder_visibility_packet_capture_object_templates_aam_auth_relay_ws_fed_tmpl`: Configure template for aam.authentication.relay.ws-federation\n\n__PLACEHOLDER__",
CreateContext: resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplCreate,
UpdateContext: resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplUpdate,
ReadContext: resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplRead,
DeleteContext: resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplDelete,
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{
"failure": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Failure",
},
"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",
},
"failure": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Failure",
},
"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 resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplCreate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmpl(d)
d.SetId(obj.GetId())
err := obj.Post(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplUpdate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmpl(d)
err := obj.Put(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplDelete()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmpl(d)
err := obj.Delete(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplRead()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmpl(d)
err := obj.Get(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func getObjectVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsInc2636(d []interface{}) edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsInc2636 {
count1 := len(d)
var ret edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsInc2636
if count1 > 0 {
in := d[0].(map[string]interface{})
ret.Failure = in["failure"].(int)
//omit uuid
}
return ret
}
func getObjectVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsRate2637(d []interface{}) edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsRate2637 {
count1 := len(d)
var ret edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsRate2637
if count1 > 0 {
in := d[0].(map[string]interface{})
ret.ThresholdExceededBy = in["threshold_exceeded_by"].(int)
ret.Duration = in["duration"].(int)
ret.Failure = in["failure"].(int)
//omit uuid
}
return ret
}
func getObjectVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsSeverity2638(d []interface{}) edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsSeverity2638 {
count1 := len(d)
var ret edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsSeverity2638
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 dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmpl(d *schema.ResourceData) edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmpl {
var ret edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmpl
ret.Inst.CaptureConfig = d.Get("capture_config").(string)
ret.Inst.Name = d.Get("name").(string)
ret.Inst.TriggerStatsInc = getObjectVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsInc2636(d.Get("trigger_stats_inc").([]interface{}))
ret.Inst.TriggerStatsRate = getObjectVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsRate2637(d.Get("trigger_stats_rate").([]interface{}))
ret.Inst.TriggerStatsSeverity = getObjectVisibilityPacketCaptureObjectTemplatesAamAuthRelayWsFedTmplTriggerStatsSeverity2638(d.Get("trigger_stats_severity").([]interface{}))
ret.Inst.UserTag = d.Get("user_tag").(string)
//omit uuid
return ret
}