/
resource_visibility_packet_capture_object_templates_aam_auth_relay_hbase_inst_tmpl_trigger_stats_rate.go
131 lines (125 loc) · 6.07 KB
/
resource_visibility_packet_capture_object_templates_aam_auth_relay_hbase_inst_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
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 resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRate() *schema.Resource {
return &schema.Resource{
Description: "`thunder_visibility_packet_capture_object_templates_aam_auth_relay_hbase_inst_tmpl_trigger_stats_rate`: Configure stats to triggers packet capture on increment\n\n__PLACEHOLDER__",
CreateContext: resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateCreate,
UpdateContext: resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateUpdate,
ReadContext: resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateRead,
DeleteContext: resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateDelete,
Schema: map[string]*schema.Schema{
"bad_req": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Bad Request",
},
"duration": {
Type: schema.TypeInt, Optional: true, Default: 60, Description: "Time in seconds to look for the anomaly, default is 60",
},
"forbidden": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Forbidden",
},
"no_creds": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for No Credential",
},
"not_found": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Not Found",
},
"server_error": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Internal Server Error",
},
"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",
},
"unauth": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Unauthorized",
},
"unavailable": {
Type: schema.TypeInt, Optional: true, Default: 0, Description: "Enable automatic packet-capture for Service Unavailable",
},
"uuid": {
Type: schema.TypeString, Optional: true, Computed: true, Description: "uuid of the object",
},
"name": {
Type: schema.TypeString, Required: true, Description: "Name",
},
},
}
}
func resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateCreate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRate(d)
d.SetId(obj.GetId())
err := obj.Post(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateUpdate()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRate(d)
err := obj.Put(client.Token, client.Host, logger)
if err != nil {
return diag.FromErr(err)
}
return resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateRead(ctx, d, meta)
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateDelete()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRate(d)
err := obj.Delete(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRateRead()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRate(d)
err := obj.Get(client.Token, client.Host, d.Id(), logger)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func dataToEndpointVisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRate(d *schema.ResourceData) edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRate {
var ret edpt.VisibilityPacketCaptureObjectTemplatesAamAuthRelayHbaseInstTmplTriggerStatsRate
ret.Inst.BadReq = d.Get("bad_req").(int)
ret.Inst.Duration = d.Get("duration").(int)
ret.Inst.Forbidden = d.Get("forbidden").(int)
ret.Inst.NoCreds = d.Get("no_creds").(int)
ret.Inst.NotFound = d.Get("not_found").(int)
ret.Inst.ServerError = d.Get("server_error").(int)
ret.Inst.ThresholdExceededBy = d.Get("threshold_exceeded_by").(int)
ret.Inst.Unauth = d.Get("unauth").(int)
ret.Inst.Unavailable = d.Get("unavailable").(int)
//omit uuid
ret.Inst.Name = d.Get("name").(string)
return ret
}