|
@@ -7,14 +7,14 @@ import (
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/gorilla/mux"
|
|
- "github.com/gravitl/netmaker/database"
|
|
|
|
- "github.com/gravitl/netmaker/logger"
|
|
|
|
- "github.com/gravitl/netmaker/logic"
|
|
|
|
- "github.com/gravitl/netmaker/logic/pro"
|
|
|
|
- "github.com/gravitl/netmaker/models"
|
|
|
|
- "github.com/gravitl/netmaker/models/promodels"
|
|
|
|
- "github.com/gravitl/netmaker/mq"
|
|
|
|
- "github.com/gravitl/netmaker/servercfg"
|
|
|
|
|
|
+ "github.com/netmakerio/netmaker/database"
|
|
|
|
+ "github.com/netmakerio/netmaker/logger"
|
|
|
|
+ "github.com/netmakerio/netmaker/logic"
|
|
|
|
+ "github.com/netmakerio/netmaker/logic/pro"
|
|
|
|
+ "github.com/netmakerio/netmaker/models"
|
|
|
|
+ "github.com/netmakerio/netmaker/models/promodels"
|
|
|
|
+ "github.com/netmakerio/netmaker/mq"
|
|
|
|
+ "github.com/netmakerio/netmaker/servercfg"
|
|
"golang.org/x/crypto/bcrypt"
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -41,13 +41,13 @@ func nodeHandlers(r *mux.Router) {
|
|
//
|
|
//
|
|
// Authenticate to make further API calls related to a network.
|
|
// Authenticate to make further API calls related to a network.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: successResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: successResponse
|
|
func authenticate(response http.ResponseWriter, request *http.Request) {
|
|
func authenticate(response http.ResponseWriter, request *http.Request) {
|
|
|
|
|
|
var authRequest models.AuthParams
|
|
var authRequest models.AuthParams
|
|
@@ -304,13 +304,13 @@ func authorize(nodesAllowed, networkCheck bool, authNetwork string, next http.Ha
|
|
//
|
|
//
|
|
// Gets all nodes associated with network including pending nodes.
|
|
// Gets all nodes associated with network including pending nodes.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeSliceResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeSliceResponse
|
|
func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
|
|
func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
@@ -343,13 +343,14 @@ func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Get all nodes across all networks.
|
|
// Get all nodes across all networks.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
|
|
+//
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeSliceResponse
|
|
//
|
|
//
|
|
-// 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
|
|
// 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) {
|
|
func getAllNodes(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
@@ -400,13 +401,13 @@ func getUsersNodes(user models.User) ([]models.Node, error) {
|
|
//
|
|
//
|
|
// Get an individual node.
|
|
// Get an individual node.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeResponse
|
|
func getNode(w http.ResponseWriter, r *http.Request) {
|
|
func getNode(w http.ResponseWriter, r *http.Request) {
|
|
// set header.
|
|
// set header.
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
@@ -449,13 +450,14 @@ func getNode(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Get the time that a network of nodes was last modified.
|
|
// Get the time that a network of nodes was last modified.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
|
|
+//
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeLastModifiedResponse
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeLastModifiedResponse
|
|
|
|
// TODO: This needs to be refactored
|
|
// TODO: This needs to be refactored
|
|
// Potential way to do this: On UpdateNode, set a new field for "LastModified"
|
|
// 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
|
|
// If we go with the existing way, we need to at least set network.NodesLastModified on UpdateNode
|
|
@@ -481,13 +483,13 @@ func getLastModified(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Create a node on a network.
|
|
// Create a node on a network.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeGetResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeGetResponse
|
|
func createNode(w http.ResponseWriter, r *http.Request) {
|
|
func createNode(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
|
|
@@ -638,13 +640,14 @@ func createNode(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Takes a node out of pending state.
|
|
// Takes a node out of pending state.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
|
|
+//
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeResponse
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeResponse
|
|
|
|
// Takes node out of pending state
|
|
// Takes node out of pending state
|
|
// TODO: May want to use cordon/uncordon terminology instead of "ispending".
|
|
// TODO: May want to use cordon/uncordon terminology instead of "ispending".
|
|
func uncordonNode(w http.ResponseWriter, r *http.Request) {
|
|
func uncordonNode(w http.ResponseWriter, r *http.Request) {
|
|
@@ -671,13 +674,13 @@ func uncordonNode(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Create an egress gateway.
|
|
// Create an egress gateway.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeResponse
|
|
func createEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|
func createEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|
var gateway models.EgressGatewayRequest
|
|
var gateway models.EgressGatewayRequest
|
|
var params = mux.Vars(r)
|
|
var params = mux.Vars(r)
|
|
@@ -710,13 +713,13 @@ func createEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Delete an egress gateway.
|
|
// Delete an egress gateway.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeResponse
|
|
func deleteEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|
func deleteEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
var params = mux.Vars(r)
|
|
var params = mux.Vars(r)
|
|
@@ -744,13 +747,13 @@ func deleteEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Create an ingress gateway.
|
|
// Create an ingress gateway.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeResponse
|
|
func createIngressGateway(w http.ResponseWriter, r *http.Request) {
|
|
func createIngressGateway(w http.ResponseWriter, r *http.Request) {
|
|
var params = mux.Vars(r)
|
|
var params = mux.Vars(r)
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
@@ -776,13 +779,13 @@ func createIngressGateway(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Delete an ingress gateway.
|
|
// Delete an ingress gateway.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeResponse
|
|
func deleteIngressGateway(w http.ResponseWriter, r *http.Request) {
|
|
func deleteIngressGateway(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
var params = mux.Vars(r)
|
|
var params = mux.Vars(r)
|
|
@@ -808,13 +811,13 @@ func deleteIngressGateway(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Update an individual node.
|
|
// Update an individual node.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeResponse
|
|
func updateNode(w http.ResponseWriter, r *http.Request) {
|
|
func updateNode(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
|
|
@@ -913,13 +916,13 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
|
|
//
|
|
//
|
|
// Delete an individual node.
|
|
// Delete an individual node.
|
|
//
|
|
//
|
|
-// Schemes: https
|
|
|
|
|
|
+// Schemes: https
|
|
//
|
|
//
|
|
-// Security:
|
|
|
|
-// oauth
|
|
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
//
|
|
//
|
|
-// Responses:
|
|
|
|
-// 200: nodeResponse
|
|
|
|
|
|
+// Responses:
|
|
|
|
+// 200: nodeResponse
|
|
func deleteNode(w http.ResponseWriter, r *http.Request) {
|
|
func deleteNode(w http.ResponseWriter, r *http.Request) {
|
|
// Set header
|
|
// Set header
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Content-Type", "application/json")
|