mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 08:47:35 +08:00
add ext_client create, get, delete and list commands
This commit is contained in:
38
cli/functions/ext_client.go
Normal file
38
cli/functions/ext_client.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package functions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gravitl/netmaker/models"
|
||||
)
|
||||
|
||||
func GetAllExtClients() *[]models.ExtClient {
|
||||
return request[[]models.ExtClient](http.MethodGet, "/api/extclients", nil)
|
||||
}
|
||||
|
||||
func GetNetworkExtClients(networkName string) *[]models.ExtClient {
|
||||
return request[[]models.ExtClient](http.MethodGet, "/api/extclients/"+networkName, nil)
|
||||
}
|
||||
|
||||
func GetExtClient(networkName, clientID string) *models.ExtClient {
|
||||
return request[models.ExtClient](http.MethodGet, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), nil)
|
||||
}
|
||||
|
||||
func GetExtClientConfig(networkName, clientID, configType string) *models.ExtClient {
|
||||
return request[models.ExtClient](http.MethodGet, fmt.Sprintf("/api/extclients/%s/%s/%s", networkName, clientID, configType), nil)
|
||||
}
|
||||
|
||||
func CreateExtClient(networkName, nodeID, extClientID string) {
|
||||
if extClientID != "" {
|
||||
request[any](http.MethodPost, fmt.Sprintf("/api/extclients/%s/%s", networkName, nodeID), &models.CustomExtClient{
|
||||
ClientID: extClientID,
|
||||
})
|
||||
} else {
|
||||
request[any](http.MethodPost, fmt.Sprintf("/api/extclients/%s/%s", networkName, nodeID), nil)
|
||||
}
|
||||
}
|
||||
|
||||
func DeleteExtClient(networkName, clientID string) *models.SuccessResponse {
|
||||
return request[models.SuccessResponse](http.MethodDelete, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), nil)
|
||||
}
|
Reference in New Issue
Block a user