mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-07 20:38:51 +08:00
Merge pull request #1540 from gravitl/feature_v0.15.2_apidocs
Update swagger docs
This commit is contained in:
commit
9e63c7e3bc
12 changed files with 2061 additions and 70 deletions
|
@ -99,7 +99,7 @@ func HandleAuthCallback(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route GET /api/oauth/login nodes HandleAuthLogin
|
||||
//
|
||||
// Handles OAuth login
|
||||
// Handles OAuth login.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
|
|
|
@ -27,7 +27,7 @@ func dnsHandlers(r *mux.Router) {
|
|||
|
||||
// swagger:route GET /api/dns/adm/{network}/nodes dns getNodeDNS
|
||||
//
|
||||
// Gets node DNS entries associated with a network
|
||||
// Gets node DNS entries associated with a network.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
|
@ -53,12 +53,16 @@ func getNodeDNS(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route GET /api/dns dns getAllDNS
|
||||
//
|
||||
// Gets all DNS entries
|
||||
// Gets all DNS entries.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: dnsResponse
|
||||
//
|
||||
func getAllDNS(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
dns, err := logic.GetAllDNS()
|
||||
|
@ -73,12 +77,16 @@ func getAllDNS(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route GET /api/dns/adm/{network}/custom dns getCustomDNS
|
||||
//
|
||||
// Gets custom DNS entries associated with a network
|
||||
// Gets custom DNS entries associated with a network.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: dnsResponse
|
||||
//
|
||||
func getCustomDNS(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -99,12 +107,16 @@ func getCustomDNS(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route GET /api/dns/adm/{network} dns getDNS
|
||||
//
|
||||
// Gets all DNS entries associated with the network
|
||||
// Gets all DNS entries associated with the network.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: dnsResponse
|
||||
//
|
||||
func getDNS(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -125,12 +137,16 @@ func getDNS(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route POST /api/dns/{network} dns createDNS
|
||||
//
|
||||
// Create a DNS entry
|
||||
// Create a DNS entry.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: dnsResponse
|
||||
//
|
||||
func createDNS(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -184,12 +200,16 @@ func createDNS(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route DELETE /api/dns/{network}/{domain} dns deleteDNS
|
||||
//
|
||||
// Delete a DNS entry
|
||||
// Delete a DNS entry.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: stringJSONResponse
|
||||
// *: stringJSONResponse
|
||||
func deleteDNS(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -248,12 +268,16 @@ func GetDNSEntry(domain string, network string) (models.DNSEntry, error) {
|
|||
|
||||
// swagger:route POST /api/dns/adm/pushdns dns pushDNS
|
||||
//
|
||||
// Push DNS entries to nameserver
|
||||
// Push DNS entries to nameserver.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: dnsStringJSONResponse
|
||||
// *: dnsStringJSONResponse
|
||||
func pushDNS(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
//
|
||||
// Schemes: https
|
||||
// BasePath: /
|
||||
// Version: 0.15.1
|
||||
// Version: 0.15.2
|
||||
// Host: netmaker.io
|
||||
//
|
||||
// Consumes:
|
||||
|
@ -25,3 +25,376 @@
|
|||
//
|
||||
// swagger:meta
|
||||
package controller
|
||||
|
||||
import (
|
||||
serverconfigpkg "github.com/gravitl/netmaker/config"
|
||||
"github.com/gravitl/netmaker/logic/acls"
|
||||
"github.com/gravitl/netmaker/models"
|
||||
"github.com/gravitl/netmaker/netclient/config"
|
||||
)
|
||||
|
||||
var _ = useUnused() // "use" the function to prevent "unused function" errors
|
||||
|
||||
// swagger:parameters getNodeDNS getCustomDNS getDNS
|
||||
type dnsPathParams struct {
|
||||
// Network
|
||||
// in: path
|
||||
Network string `json:"network"`
|
||||
}
|
||||
|
||||
// swagger:parameters createDNS
|
||||
type dnsParams struct {
|
||||
// Network
|
||||
// in: path
|
||||
Network string `json:"network"`
|
||||
|
||||
// DNS Entry
|
||||
// in: body
|
||||
Body []models.DNSEntry `json:"body"`
|
||||
}
|
||||
|
||||
// Success
|
||||
// swagger:response dnsResponse
|
||||
type dnsResponse struct {
|
||||
// in: body
|
||||
Body []models.DNSEntry `json:"body"`
|
||||
}
|
||||
|
||||
// swagger:parameters deleteDNS
|
||||
type dnsDeletePathParams struct {
|
||||
// Network
|
||||
// in: path
|
||||
Network string `json:"network"`
|
||||
|
||||
// Domain
|
||||
// in: path
|
||||
Domain string `json:"domain"`
|
||||
}
|
||||
|
||||
// swagger:response stringJSONResponse
|
||||
type stringJSONResponse struct {
|
||||
// Response
|
||||
// in: body
|
||||
Response string `json:"response"`
|
||||
}
|
||||
|
||||
// swagger:parameters getAllExtClients
|
||||
type getAllClientsRequest struct {
|
||||
// Networks
|
||||
// in:body
|
||||
Networks []string `json:"networks"`
|
||||
}
|
||||
|
||||
// swagger:response extClientSliceResponse
|
||||
type extClientSliceResponse struct {
|
||||
// ExtClients
|
||||
// in: body
|
||||
ExtClients []models.ExtClient `json:"ext_clients"`
|
||||
}
|
||||
|
||||
// swagger:response extClientResponse
|
||||
type extClientResponse struct {
|
||||
// ExtClient
|
||||
// in: body
|
||||
ExtClient models.ExtClient `json:"ext_client"`
|
||||
}
|
||||
|
||||
// swagger:response successResponse
|
||||
type successResponse struct {
|
||||
// Success Response
|
||||
// in: body
|
||||
SuccessResponse models.SuccessResponse `json:"success_response"`
|
||||
}
|
||||
|
||||
// swagger:parameters getExtClient getExtClientConf updateExtClient deleteExtClient
|
||||
type extClientPathParams struct {
|
||||
// Client ID
|
||||
// in: path
|
||||
ClientID string `json:"clientid"`
|
||||
|
||||
// Network
|
||||
// in: path
|
||||
Network string `json:"network"`
|
||||
}
|
||||
|
||||
// swagger:parameters updateExtClient
|
||||
type extClientBodyParam struct {
|
||||
// ExtClient
|
||||
// in: body
|
||||
ExtClient models.ExtClient `json:"ext_client"`
|
||||
}
|
||||
|
||||
// swagger:parameters getNetworkExtClients
|
||||
type extClientNetworkPathParam struct {
|
||||
// Network
|
||||
// in: path
|
||||
Network string `json:"network"`
|
||||
}
|
||||
|
||||
// swagger:parameters createExtClient
|
||||
type createExtClientPathParams struct {
|
||||
// Network
|
||||
// in: path
|
||||
Network string `json:"network"`
|
||||
|
||||
// Node ID
|
||||
// in: path
|
||||
NodeID string `json:"node"`
|
||||
|
||||
// Custom ExtClient
|
||||
// in: body
|
||||
CustomExtClient models.CustomExtClient `json:"custom_ext_client"`
|
||||
}
|
||||
|
||||
// swagger:parameters getNode updateNode deleteNode createRelay deleteRelay createEgressGateway deleteEgressGateway createIngressGateway deleteIngressGateway uncordonNode
|
||||
type networkNodePathParams struct {
|
||||
// Network
|
||||
// in: path
|
||||
Network string `json:"network"`
|
||||
|
||||
// Node ID
|
||||
// in: path
|
||||
NodeID string `json:"nodeid"`
|
||||
}
|
||||
|
||||
// swagger:response byteArrayResponse
|
||||
type byteArrayResponse struct {
|
||||
// in: body
|
||||
ByteArray []byte `json:"byte_array"`
|
||||
}
|
||||
|
||||
// swagger:parameters getNetworks
|
||||
type headerNetworks struct {
|
||||
// name: networks
|
||||
// in: header
|
||||
Networks []string `json:"networks"`
|
||||
}
|
||||
|
||||
// swagger:response getNetworksSliceResponse
|
||||
type getNetworksSliceResponse struct {
|
||||
// Networks
|
||||
// in: body
|
||||
Networks []models.Network `json:"networks"`
|
||||
}
|
||||
|
||||
// swagger:parameters createNetwork updateNetwork
|
||||
type networkBodyParam struct {
|
||||
// Network
|
||||
// in: body
|
||||
Network models.Network `json:"network"`
|
||||
}
|
||||
|
||||
// swagger:parameters updateNetwork getNetwork updateNetwork updateNetworkNodeLimit deleteNetwork keyUpdate createAccessKey getAccessKeys deleteAccessKey updateNetworkACL getNetworkACL
|
||||
type networkPathParam struct {
|
||||
// Network Name
|
||||
// in: path
|
||||
NetworkName string `json:"networkname"`
|
||||
}
|
||||
|
||||
// swagger:parameters deleteAccessKey
|
||||
type networkAccessKeyNamePathParam struct {
|
||||
// Access Key Name
|
||||
// in: path
|
||||
AccessKeyName string `json:"access_key_name"`
|
||||
}
|
||||
|
||||
// swagger:response networkBodyResponse
|
||||
type networkBodyResponse struct {
|
||||
// Network
|
||||
// in: body
|
||||
Network models.Network `json:"network"`
|
||||
}
|
||||
|
||||
// swagger:parameters createAccessKey
|
||||
type accessKeyBodyParam struct {
|
||||
// Access Key
|
||||
// in: body
|
||||
AccessKey models.AccessKey `json:"access_key"`
|
||||
}
|
||||
|
||||
// swagger:response accessKeyBodyResponse
|
||||
type accessKeyBodyResponse struct {
|
||||
// Access Key
|
||||
// in: body
|
||||
AccessKey models.AccessKey `json:"access_key"`
|
||||
}
|
||||
|
||||
// swagger:response accessKeySliceBodyResponse
|
||||
type accessKeySliceBodyResponse struct {
|
||||
// Access Keys
|
||||
// in: body
|
||||
AccessKey []models.AccessKey `json:"access_key"`
|
||||
}
|
||||
|
||||
// swagger:parameters updateNetworkACL getNetworkACL
|
||||
type aclContainerBodyParam struct {
|
||||
// ACL Container
|
||||
// in: body
|
||||
ACLContainer acls.ACLContainer `json:"acl_container"`
|
||||
}
|
||||
|
||||
// swagger:response aclContainerResponse
|
||||
type aclContainerResponse struct {
|
||||
// ACL Container
|
||||
// in: body
|
||||
ACLContainer acls.ACLContainer `json:"acl_container"`
|
||||
}
|
||||
|
||||
// swagger:response nodeSliceResponse
|
||||
type nodeSliceResponse struct {
|
||||
// Nodes
|
||||
// in: body
|
||||
Nodes []models.Node `json:"nodes"`
|
||||
}
|
||||
|
||||
// swagger:response nodeResponse
|
||||
type nodeResponse struct {
|
||||
// Node
|
||||
// in: body
|
||||
Node models.Node `json:"node"`
|
||||
}
|
||||
|
||||
// swagger:parameters updateNode deleteNode
|
||||
type nodeBodyParam struct {
|
||||
// Node
|
||||
// in: body
|
||||
Node models.Node `json:"node"`
|
||||
}
|
||||
|
||||
// swagger:parameters createRelay
|
||||
type relayRequestBodyParam struct {
|
||||
// Relay Request
|
||||
// in: body
|
||||
RelayRequest models.RelayRequest `json:"relay_request"`
|
||||
}
|
||||
|
||||
// swagger:parameters createEgressGateway
|
||||
type egressGatewayBodyParam struct {
|
||||
// Egress Gateway Request
|
||||
// in: body
|
||||
EgressGatewayRequest models.EgressGatewayRequest `json:"egress_gateway_request"`
|
||||
}
|
||||
|
||||
// swagger:parameters authenticate
|
||||
type authParamBodyParam struct {
|
||||
// AuthParams
|
||||
// in: body
|
||||
AuthParams models.AuthParams `json:"auth_params"`
|
||||
}
|
||||
|
||||
// swagger:response serverConfigResponse
|
||||
type serverConfigResponse struct {
|
||||
// Server Config
|
||||
// in: body
|
||||
ServerConfig serverconfigpkg.ServerConfig `json:"server_config"`
|
||||
}
|
||||
|
||||
// swagger:response nodeGetResponse
|
||||
type nodeGetResponse struct {
|
||||
// Node Get
|
||||
// in: body
|
||||
NodeGet models.NodeGet `json:"node_get"`
|
||||
}
|
||||
|
||||
// swagger:response nodeLastModifiedResponse
|
||||
type nodeLastModifiedResponse struct {
|
||||
// Node Last Modified
|
||||
// in: body
|
||||
NodesLastModified int64 `json:"nodes_last_modified"`
|
||||
}
|
||||
|
||||
// swagger:parameters register
|
||||
type registerRequestBodyParam struct {
|
||||
// Register Request
|
||||
// in: body
|
||||
RegisterRequest config.RegisterRequest `json:"register_request"`
|
||||
}
|
||||
|
||||
// swagger:response registerResponse
|
||||
type registerResponse struct {
|
||||
// Register Response
|
||||
// in: body
|
||||
RegisterResponse config.RegisterResponse `json:"register_response"`
|
||||
}
|
||||
|
||||
// swagger:response boolResponse
|
||||
type boolResponse struct {
|
||||
// Boolean Response
|
||||
// in: body
|
||||
BoolResponse bool `json:"bool_response"`
|
||||
}
|
||||
|
||||
// swagger:parameters createAdmin updateUser updateUserNetworks createUser
|
||||
type userBodyParam struct {
|
||||
// User
|
||||
// in: body
|
||||
User models.User `json:"user"`
|
||||
}
|
||||
|
||||
// swagger:response userBodyResponse
|
||||
type userBodyResponse struct {
|
||||
// User
|
||||
// in: body
|
||||
User models.User `json:"user"`
|
||||
}
|
||||
|
||||
// swagger:parameters authenticateUser
|
||||
type userAuthBodyParam struct {
|
||||
// User Auth Params
|
||||
// in: body
|
||||
UserAuthParams models.UserAuthParams `json:"user_auth_params"`
|
||||
}
|
||||
|
||||
// swagger:parameters updateUser updateUserNetworks updateUserAdm createUser deleteUser getUser
|
||||
type usernamePathParam struct {
|
||||
// Username
|
||||
// in: path
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
// prevent issues with integration tests for types just used by Swagger docs.
|
||||
func useUnused() bool {
|
||||
_ = dnsPathParams{}
|
||||
_ = dnsParams{}
|
||||
_ = dnsResponse{}
|
||||
_ = dnsDeletePathParams{}
|
||||
_ = stringJSONResponse{}
|
||||
_ = getAllClientsRequest{}
|
||||
_ = extClientSliceResponse{}
|
||||
_ = extClientResponse{}
|
||||
_ = successResponse{}
|
||||
_ = extClientPathParams{}
|
||||
_ = extClientBodyParam{}
|
||||
_ = extClientNetworkPathParam{}
|
||||
_ = createExtClientPathParams{}
|
||||
_ = networkNodePathParams{}
|
||||
_ = byteArrayResponse{}
|
||||
_ = headerNetworks{}
|
||||
_ = getNetworksSliceResponse{}
|
||||
_ = networkBodyParam{}
|
||||
_ = networkPathParam{}
|
||||
_ = networkAccessKeyNamePathParam{}
|
||||
_ = networkBodyResponse{}
|
||||
_ = accessKeyBodyParam{}
|
||||
_ = accessKeyBodyResponse{}
|
||||
_ = accessKeySliceBodyResponse{}
|
||||
_ = aclContainerBodyParam{}
|
||||
_ = aclContainerResponse{}
|
||||
_ = nodeSliceResponse{}
|
||||
_ = nodeResponse{}
|
||||
_ = nodeBodyParam{}
|
||||
_ = relayRequestBodyParam{}
|
||||
_ = egressGatewayBodyParam{}
|
||||
_ = authParamBodyParam{}
|
||||
_ = serverConfigResponse{}
|
||||
_ = nodeGetResponse{}
|
||||
_ = nodeLastModifiedResponse{}
|
||||
_ = registerRequestBodyParam{}
|
||||
_ = registerResponse{}
|
||||
_ = boolResponse{}
|
||||
_ = userBodyParam{}
|
||||
_ = userBodyResponse{}
|
||||
_ = userAuthBodyParam{}
|
||||
_ = usernamePathParam{}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -38,13 +38,17 @@ func checkIngressExists(nodeID string) bool {
|
|||
|
||||
// swagger:route GET /api/extclients/{network} ext_client getNetworkExtClients
|
||||
//
|
||||
// Get all extclients associated with network
|
||||
// Gets all extclients associated with network, including pending extclients
|
||||
// Get all extclients associated with network.
|
||||
// Gets all extclients associated with network, including pending extclients.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: extClientSliceResponse
|
||||
//
|
||||
func getNetworkExtClients(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -75,6 +79,9 @@ func getNetworkExtClients(w http.ResponseWriter, r *http.Request) {
|
|||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: extClientSliceResponse
|
||||
//
|
||||
// Not quite sure if this is necessary. Probably necessary based on front end but may
|
||||
// want to review after iteration 1 if it's being used or not
|
||||
func getAllExtClients(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -113,7 +120,7 @@ func getAllExtClients(w http.ResponseWriter, r *http.Request) {
|
|||
json.NewEncoder(w).Encode(clients)
|
||||
}
|
||||
|
||||
// swagger:route GET /api/extclients ext_client getExtClient
|
||||
// swagger:route GET /api/extclients/{network}/{clientid} ext_client getExtClient
|
||||
//
|
||||
// Get an individual extclient.
|
||||
//
|
||||
|
@ -122,6 +129,9 @@ func getAllExtClients(w http.ResponseWriter, r *http.Request) {
|
|||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: extClientResponse
|
||||
//
|
||||
func getExtClient(w http.ResponseWriter, r *http.Request) {
|
||||
// set header.
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -151,6 +161,9 @@ func getExtClient(w http.ResponseWriter, r *http.Request) {
|
|||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: extClientResponse
|
||||
//
|
||||
func getExtClientConf(w http.ResponseWriter, r *http.Request) {
|
||||
// set header.
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -289,7 +302,7 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
|
|||
var params = mux.Vars(r)
|
||||
networkName := params["network"]
|
||||
nodeid := params["nodeid"]
|
||||
|
||||
|
||||
ingressExists := checkIngressExists(nodeid)
|
||||
if !ingressExists {
|
||||
err := errors.New("ingress does not exist")
|
||||
|
@ -301,11 +314,13 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var extclient models.ExtClient
|
||||
var CustomExtClient models.CustomExtClient
|
||||
|
||||
err := json.NewDecoder(r.Body).Decode(&CustomExtClient);
|
||||
|
||||
if err == nil { extclient.ClientID = CustomExtClient.ClientID }
|
||||
|
||||
|
||||
err := json.NewDecoder(r.Body).Decode(&CustomExtClient)
|
||||
|
||||
if err == nil {
|
||||
extclient.ClientID = CustomExtClient.ClientID
|
||||
}
|
||||
|
||||
extclient.Network = networkName
|
||||
extclient.IngressGatewayID = nodeid
|
||||
node, err := logic.GetNodeByID(nodeid)
|
||||
|
@ -346,6 +361,9 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
|
|||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: extClientResponse
|
||||
//
|
||||
func updateExtClient(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -414,6 +432,9 @@ func updateExtClient(w http.ResponseWriter, r *http.Request) {
|
|||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: successResponse
|
||||
//
|
||||
func deleteExtClient(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
func fileHandlers(r *mux.Router) {
|
||||
// swagger:route GET /meshclient/files/{filename} meshclient fileServer
|
||||
//
|
||||
// Retrieve a file from the file server
|
||||
// Retrieve a file from the file server.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
|
|
|
@ -16,13 +16,16 @@ func ipHandlers(r *mux.Router) {
|
|||
|
||||
// swagger:route GET /api/getip ipservice getPublicIP
|
||||
//
|
||||
// Get the current public IP address
|
||||
// Get the current public IP address.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: byteArrayResponse
|
||||
//
|
||||
func getPublicIP(w http.ResponseWriter, r *http.Request) {
|
||||
r.Header.Set("Connection", "close")
|
||||
ip, err := parseIP(r)
|
||||
|
|
|
@ -41,12 +41,15 @@ func networkHandlers(r *mux.Router) {
|
|||
|
||||
// swagger:route GET /api/networks networks getNetworks
|
||||
//
|
||||
// Lists all networks
|
||||
// Lists all networks.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: getNetworksSliceResponse
|
||||
func getNetworks(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
headerNetworks := r.Header.Get("networks")
|
||||
|
@ -87,14 +90,17 @@ func getNetworks(w http.ResponseWriter, r *http.Request) {
|
|||
json.NewEncoder(w).Encode(allnetworks)
|
||||
}
|
||||
|
||||
// swagger:route GET /api/networks networks getNetwork
|
||||
// swagger:route GET /api/networks/{networkname} networks getNetwork
|
||||
//
|
||||
// Get a network
|
||||
// Get a network.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: networkBodyResponse
|
||||
func getNetwork(w http.ResponseWriter, r *http.Request) {
|
||||
// set header.
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -123,6 +129,9 @@ func getNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: networkBodyResponse
|
||||
func keyUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -154,12 +163,15 @@ func keyUpdate(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route PUT /api/networks/{networkname} networks updateNetwork
|
||||
//
|
||||
// Update a network
|
||||
// Update a network.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: networkBodyResponse
|
||||
func updateNetwork(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -256,12 +268,15 @@ func updateNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route PUT /api/networks/{networkname}/nodelimit networks updateNetworkNodeLimit
|
||||
//
|
||||
// Update a network's node limit
|
||||
// Update a network's node limit.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: networkBodyResponse
|
||||
func updateNetworkNodeLimit(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -309,6 +324,9 @@ func updateNetworkNodeLimit(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: aclContainerResponse
|
||||
func updateNetworkACL(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -364,6 +382,9 @@ func updateNetworkACL(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: aclContainerResponse
|
||||
func getNetworkACL(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -389,6 +410,9 @@ func getNetworkACL(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: stringJSONResponse
|
||||
func deleteNetwork(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -413,12 +437,15 @@ func deleteNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route POST /api/networks networks createNetwork
|
||||
//
|
||||
// Create a network
|
||||
// Create a network.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: networkBodyResponse
|
||||
func createNetwork(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -478,6 +505,9 @@ func createNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: accessKeyBodyResponse
|
||||
//
|
||||
// BEGIN KEY MANAGEMENT SECTION
|
||||
func createAccessKey(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -519,6 +549,9 @@ func createAccessKey(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: accessKeySliceBodyResponse
|
||||
func getAccessKeys(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -538,7 +571,7 @@ func getAccessKeys(w http.ResponseWriter, r *http.Request) {
|
|||
json.NewEncoder(w).Encode(keys)
|
||||
}
|
||||
|
||||
// swagger:route GET /api/networks/{networkname}/keys/{name} networks deleteAccessKey
|
||||
// swagger:route DELETE /api/networks/{networkname}/keys/{name} networks deleteAccessKey
|
||||
//
|
||||
// Delete a network access key.
|
||||
//
|
||||
|
@ -547,6 +580,10 @@ func getAccessKeys(w http.ResponseWriter, r *http.Request) {
|
|||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200:
|
||||
// *: stringJSONResponse
|
||||
//
|
||||
// delete key. Has to do a little funky logic since it's not a collection item
|
||||
func deleteAccessKey(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
@ -44,6 +44,9 @@ func nodeHandlers(r *mux.Router) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: successResponse
|
||||
func authenticate(response http.ResponseWriter, request *http.Request) {
|
||||
|
||||
var authRequest models.AuthParams
|
||||
|
@ -297,12 +300,15 @@ func authorize(nodesAllowed, networkCheck bool, authNetwork string, next http.Ha
|
|||
|
||||
// swagger:route GET /api/nodes/{network} nodes getNetworkNodes
|
||||
//
|
||||
// Gets all nodes associated with network including pending nodes
|
||||
// Gets all nodes associated with network including pending nodes.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeSliceResponse
|
||||
func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -339,6 +345,9 @@ func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeSliceResponse
|
||||
// Not quite sure if this is necessary. Probably necessary based on front end but may want to review after iteration 1 if it's being used or not
|
||||
func getAllNodes(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -393,6 +402,9 @@ func getUsersNodes(user models.User) ([]models.Node, error) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func getNode(w http.ResponseWriter, r *http.Request) {
|
||||
// set header.
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -438,6 +450,9 @@ func getNode(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeLastModifiedResponse
|
||||
// TODO: This needs to be refactored
|
||||
// Potential way to do this: On UpdateNode, set a new field for "LastModified"
|
||||
// If we go with the existing way, we need to at least set network.NodesLastModified on UpdateNode
|
||||
|
@ -467,6 +482,9 @@ func getLastModified(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeGetResponse
|
||||
func createNode(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -594,6 +612,9 @@ func createNode(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
// Takes node out of pending state
|
||||
// TODO: May want to use cordon/uncordon terminology instead of "ispending".
|
||||
func uncordonNode(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -624,6 +645,9 @@ func uncordonNode(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func createEgressGateway(w http.ResponseWriter, r *http.Request) {
|
||||
var gateway models.EgressGatewayRequest
|
||||
var params = mux.Vars(r)
|
||||
|
@ -660,6 +684,9 @@ func createEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func deleteEgressGateway(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -691,6 +718,9 @@ func deleteEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func createIngressGateway(w http.ResponseWriter, r *http.Request) {
|
||||
var params = mux.Vars(r)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -720,6 +750,9 @@ func createIngressGateway(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func deleteIngressGateway(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -749,6 +782,9 @@ func deleteIngressGateway(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func updateNode(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -851,6 +887,9 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func deleteNode(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
@ -20,6 +20,9 @@ import (
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func createRelay(w http.ResponseWriter, r *http.Request) {
|
||||
var relay models.RelayRequest
|
||||
var params = mux.Vars(r)
|
||||
|
@ -59,6 +62,9 @@ func createRelay(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: nodeResponse
|
||||
func deleteRelay(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
|
|
@ -75,6 +75,9 @@ func securityCheckServer(adminonly bool, next http.Handler) http.HandlerFunc {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: stringJSONResponse
|
||||
func removeNetwork(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -102,6 +105,9 @@ func removeNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: serverConfigResponse
|
||||
func getServerInfo(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -120,6 +126,9 @@ func getServerInfo(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: serverConfigResponse
|
||||
func getConfig(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -133,12 +142,15 @@ func getConfig(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route POST /api/server/register nodes register
|
||||
//
|
||||
// Registers a client with the server and return the Certificate Authority and certificate
|
||||
// Registers a client with the server and return the Certificate Authority and certificate.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: registerResponse
|
||||
func register(w http.ResponseWriter, r *http.Request) {
|
||||
logger.Log(2, "processing registration request")
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
@ -39,6 +39,8 @@ func userHandlers(r *mux.Router) {
|
|||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: successResponse
|
||||
func authenticateUser(response http.ResponseWriter, request *http.Request) {
|
||||
|
||||
// Auth request consists of Mac Address and Password (from node that is authorizing
|
||||
|
@ -103,6 +105,9 @@ func authenticateUser(response http.ResponseWriter, request *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: successResponse
|
||||
func hasAdmin(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -140,6 +145,9 @@ func GetUserInternal(username string) (models.User, error) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: userBodyResponse
|
||||
func getUser(w http.ResponseWriter, r *http.Request) {
|
||||
// set header.
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -159,12 +167,15 @@ func getUser(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route GET /api/users nodes getUsers
|
||||
//
|
||||
// Get all users
|
||||
// Get all users.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: userBodyResponse
|
||||
func getUsers(w http.ResponseWriter, r *http.Request) {
|
||||
// set header.
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -189,6 +200,9 @@ func getUsers(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: userBodyResponse
|
||||
func createAdmin(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -222,6 +236,9 @@ func createAdmin(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: userBodyResponse
|
||||
func createUser(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -246,12 +263,15 @@ func createUser(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route PUT /api/users/networks/{username} nodes updateUserNetworks
|
||||
//
|
||||
// Updates the networks of the given user
|
||||
// Updates the networks of the given user.
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: userBodyResponse
|
||||
func updateUserNetworks(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -293,6 +313,9 @@ func updateUserNetworks(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: userBodyResponse
|
||||
func updateUser(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -335,12 +358,15 @@ func updateUser(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// swagger:route PUT /api/users/{username}/adm nodes updateUserAdm
|
||||
//
|
||||
// Updates the given admin user's info (as long as the user is an admin)
|
||||
// Updates the given admin user's info (as long as the user is an admin).
|
||||
//
|
||||
// Schemes: https
|
||||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: userBodyResponse
|
||||
func updateUserAdm(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
var params = mux.Vars(r)
|
||||
|
@ -390,6 +416,9 @@ func updateUserAdm(w http.ResponseWriter, r *http.Request) {
|
|||
//
|
||||
// Security:
|
||||
// oauth
|
||||
//
|
||||
// Responses:
|
||||
// 200: userBodyResponse
|
||||
func deleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
// Set header
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
1523
swagger.yaml
1523
swagger.yaml
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue