flores/lib/http/network/inspect.go
2025-04-15 19:57:11 +08:00

51 lines
1.2 KiB
Go

package network
import (
"encoding/json"
"floares/config"
"floares/lib/model"
"log"
"net/http"
"time"
)
type Inspect struct {
Name string `json:"Name"`
Id string `json:"Id"`
Created time.Time `json:"Created"`
Scope string `json:"Scope"`
Driver string `json:"Driver"`
EnableIPv6 bool `json:"EnableIPv6"`
IPAM model.IPAM `json:"IPAM"`
Internal bool `json:"Internal"`
Attachable bool `json:"Attachable"`
Ingress bool `json:"Ingress"`
ConfigFrom struct {
Network string `json:"Network"`
} `json:"ConfigFrom"`
ConfigOnly bool `json:"ConfigOnly"`
Containers map[string]struct {
Name string `json:"Name"`
EndpointID string `json:"EndpointID"`
MacAddress string `json:"MacAddress"`
IPv4Address string `json:"IPv4Address"`
IPv6Address string `json:"IPv6Address"`
} `json:"Containers"`
Options struct {
} `json:"Options"`
Labels struct {
} `json:"Labels"`
}
func GetInspect(ns string) (net Inspect) {
req, _ := http.NewRequest("GET", config.Entrypoint+"/networks/"+ns, nil)
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Println("request for network list error:", err)
return
}
err = json.NewDecoder(res.Body).Decode(&net)
return
}