f-21: code: change from ip to interface type

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-04-21 21:28:20 +02:00
commit 9ec6e64327
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
8 changed files with 41 additions and 40 deletions

View file

@ -13,19 +13,19 @@ type SubnetCreateRequest struct {
Name string `json:"name"`
VPC string `json:"vpc"`
VxlanID int `json:"vxlan_id"`
LocalIP string `json:"local_ip"`
IfaceType string `json:"iface_type"`
GatewayIP string `json:"gateway_ip"`
CIDR string `json:"cidr"`
}
type Subnet struct {
Name string `json:"name"`
State string `json:"state"`
VPC string `json:"vpc"`
VxlanID int `json:"vxlan_id"`
LocalIP string `json:"local_ip"`
GatewayIP string `json:"gateway_ip"`
CIDR string `json:"cidr"`
Name string `json:"name"`
State string `json:"state"`
VPC string `json:"vpc"`
VxlanID int `json:"vxlan_id"`
LocalIface string `json:"local_iface"`
GatewayIP string `json:"gateway_ip"`
CIDR string `json:"cidr"`
}
type ErrorResponse struct {

View file

@ -31,16 +31,16 @@ func (s *Server) postSubnet(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(ErrorResponse{Error: "invalid request body"})
return
}
if req.Name == "" || req.VPC == "" || req.LocalIP == "" || req.GatewayIP == "" || req.CIDR == "" {
if req.Name == "" || req.VPC == "" || req.IfaceType == "" || req.GatewayIP == "" || req.CIDR == "" {
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(ErrorResponse{Error: "name, vpc, local_ip, gateway_ip and cidr are required"})
json.NewEncoder(w).Encode(ErrorResponse{Error: "name, vpc, iface_type, gateway_ip and cidr are required"})
return
}
s.dispatcher.Dispatch(dispatcher.CreateSubnetCommand{
Name: req.Name,
VPC: req.VPC,
VxlanID: req.VxlanID,
LocalIP: req.LocalIP,
IfaceType: req.IfaceType,
GatewayIP: req.GatewayIP,
CIDR: req.CIDR,
})
@ -50,9 +50,7 @@ func (s *Server) postSubnet(w http.ResponseWriter, r *http.Request) {
State: "creating",
VPC: req.VPC,
VxlanID: req.VxlanID,
LocalIP: req.LocalIP,
GatewayIP: req.GatewayIP,
CIDR: req.CIDR,
})
}