/
resource_vrrp_a_partition_vrid_all_status_oper.go
143 lines (131 loc) · 4.99 KB
/
resource_vrrp_a_partition_vrid_all_status_oper.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
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 resourceVrrpAPartitionVridAllStatusOper() *schema.Resource {
return &schema.Resource{
Description: "`thunder_vrrp_a_partition_vrid_all_status_oper`: Operational Status for the object partition-vrid-all-status\n\n__PLACEHOLDER__",
ReadContext: resourceVrrpAPartitionVridAllStatusOperRead,
Schema: map[string]*schema.Schema{
"oper": {
Type: schema.TypeList, MaxItems: 1, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"all_partition_list": {
Type: schema.TypeList, Optional: true, Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"local_device_id": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"partition_name": {
Type: schema.TypeString, Optional: true, Description: "",
},
"vrid": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"active_device_id": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"active_priority": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"active_weight": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"standby_device_id": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"standby_priority": {
Type: schema.TypeInt, Optional: true, Description: "",
},
"standby_weight": {
Type: schema.TypeInt, Optional: true, Description: "",
},
},
},
},
},
},
},
},
}
}
func resourceVrrpAPartitionVridAllStatusOperRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(Thunder)
logger := client.log
logger.Println("resourceVrrpAPartitionVridAllStatusOperRead()")
var diags diag.Diagnostics
if client.Host != "" {
obj := dataToEndpointVrrpAPartitionVridAllStatusOper(d)
res, err := obj.Get(client.Token, client.Host, d.Id(), logger)
d.SetId(obj.GetId())
logger.Println(res)
VrrpAPartitionVridAllStatusOperOper := setObjectVrrpAPartitionVridAllStatusOperOper(res)
d.Set("oper", VrrpAPartitionVridAllStatusOperOper)
if err != nil {
return diag.FromErr(err)
}
}
return diags
}
func setObjectVrrpAPartitionVridAllStatusOperOper(ret edpt.DataVrrpAPartitionVridAllStatusOper) []interface{} {
return []interface{}{
map[string]interface{}{
"all_partition_list": setSliceVrrpAPartitionVridAllStatusOperOperAllPartitionList(ret.DtVrrpAPartitionVridAllStatusOper.Oper.AllPartitionList),
},
}
}
func setSliceVrrpAPartitionVridAllStatusOperOperAllPartitionList(d []edpt.VrrpAPartitionVridAllStatusOperOperAllPartitionList) []map[string]interface{} {
result := []map[string]interface{}{}
for _, item := range d {
in := make(map[string]interface{})
in["local_device_id"] = item.Local_device_id
in["partition_name"] = item.PartitionName
in["vrid"] = item.Vrid
in["active_device_id"] = item.Active_device_id
in["active_priority"] = item.Active_priority
in["active_weight"] = item.Active_weight
in["standby_device_id"] = item.Standby_device_id
in["standby_priority"] = item.Standby_priority
in["standby_weight"] = item.Standby_weight
result = append(result, in)
}
return result
}
func getObjectVrrpAPartitionVridAllStatusOperOper(d []interface{}) edpt.VrrpAPartitionVridAllStatusOperOper {
count1 := len(d)
var ret edpt.VrrpAPartitionVridAllStatusOperOper
if count1 > 0 {
in := d[0].(map[string]interface{})
ret.AllPartitionList = getSliceVrrpAPartitionVridAllStatusOperOperAllPartitionList(in["all_partition_list"].([]interface{}))
}
return ret
}
func getSliceVrrpAPartitionVridAllStatusOperOperAllPartitionList(d []interface{}) []edpt.VrrpAPartitionVridAllStatusOperOperAllPartitionList {
count1 := len(d)
ret := make([]edpt.VrrpAPartitionVridAllStatusOperOperAllPartitionList, 0, count1)
for _, item := range d {
in := item.(map[string]interface{})
var oi edpt.VrrpAPartitionVridAllStatusOperOperAllPartitionList
oi.Local_device_id = in["local_device_id"].(int)
oi.PartitionName = in["partition_name"].(string)
oi.Vrid = in["vrid"].(int)
oi.Active_device_id = in["active_device_id"].(int)
oi.Active_priority = in["active_priority"].(int)
oi.Active_weight = in["active_weight"].(int)
oi.Standby_device_id = in["standby_device_id"].(int)
oi.Standby_priority = in["standby_priority"].(int)
oi.Standby_weight = in["standby_weight"].(int)
ret = append(ret, oi)
}
return ret
}
func dataToEndpointVrrpAPartitionVridAllStatusOper(d *schema.ResourceData) edpt.VrrpAPartitionVridAllStatusOper {
var ret edpt.VrrpAPartitionVridAllStatusOper
ret.Oper = getObjectVrrpAPartitionVridAllStatusOperOper(d.Get("oper").([]interface{}))
return ret
}