mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-07 09:41:37 +08:00
add host endpoints to cli
This commit is contained in:
33
cli/functions/host.go
Normal file
33
cli/functions/host.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package functions
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gravitl/netmaker/models"
|
||||
)
|
||||
|
||||
type hostNetworksUpdatePayload struct {
|
||||
Networks []string `json:"networks"`
|
||||
}
|
||||
|
||||
// GetHosts - fetch all host entries
|
||||
func GetHosts() *[]models.ApiHost {
|
||||
return request[[]models.ApiHost](http.MethodGet, "/api/hosts", nil)
|
||||
}
|
||||
|
||||
// DeleteHost - delete a host
|
||||
func DeleteHost(hostID string) *models.ApiHost {
|
||||
return request[models.ApiHost](http.MethodDelete, "/api/hosts/"+hostID, nil)
|
||||
}
|
||||
|
||||
// UpdateHost - update a host
|
||||
func UpdateHost(hostID string, body *models.ApiHost) *models.ApiHost {
|
||||
return request[models.ApiHost](http.MethodPut, "/api/hosts/"+hostID, body)
|
||||
}
|
||||
|
||||
// UpdateHostNetworks - update a host's networks
|
||||
func UpdateHostNetworks(hostID string, networks []string) *hostNetworksUpdatePayload {
|
||||
return request[hostNetworksUpdatePayload](http.MethodPut, "/api/hosts/"+hostID+"/networks", &hostNetworksUpdatePayload{
|
||||
Networks: networks,
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user