Documentation
¶
Index ¶
- Constants
- Variables
- type API
- func (api *API) CreateUser(w http.ResponseWriter, r *http.Request)
- func (api *API) DeleteProject(w http.ResponseWriter, r *http.Request)
- func (api *API) GetAlgorithm(w http.ResponseWriter, r *http.Request)
- func (api *API) GetDomain(w http.ResponseWriter, r *http.Request)
- func (api *API) GetDomains(w http.ResponseWriter, r *http.Request)
- func (api *API) GetIPsByProjectName(w http.ResponseWriter, r *http.Request)
- func (api *API) GetIndex(w http.ResponseWriter, r *http.Request)
- func (api *API) GetNode(w http.ResponseWriter, r *http.Request)
- func (api *API) GetNodes(w http.ResponseWriter, r *http.Request)
- func (api *API) GetPortByIP(w http.ResponseWriter, r *http.Request)
- func (api *API) GetPortsByIP(w http.ResponseWriter, r *http.Request)
- func (api *API) GetProject(w http.ResponseWriter, r *http.Request)
- func (api *API) GetProjects(w http.ResponseWriter, r *http.Request)
- func (api *API) GetRawsByModule(w http.ResponseWriter, r *http.Request)
- func (api *API) GetRawsByProject(w http.ResponseWriter, r *http.Request)
- func (api *API) GetRoutesByIP(w http.ResponseWriter, r *http.Request)
- func (api *API) GetURIByPort(w http.ResponseWriter, r *http.Request)
- func (api *API) GetURIsByPort(w http.ResponseWriter, r *http.Request)
- func (api *API) GetUser(w http.ResponseWriter, r *http.Request)
- func (api *API) NotFound(w http.ResponseWriter, r *http.Request)
- func (api *API) PostAlgorithm(w http.ResponseWriter, r *http.Request)
- func (api *API) PostDomain(w http.ResponseWriter, r *http.Request)
- func (api *API) PostIP(w http.ResponseWriter, r *http.Request)
- func (api *API) PostPortsByIP(w http.ResponseWriter, r *http.Request)
- func (api *API) PostProject(w http.ResponseWriter, r *http.Request)
- func (api *API) Routes()
- func (api *API) RunModule(w http.ResponseWriter, r *http.Request)
- func (api *API) RunModules(w http.ResponseWriter, r *http.Request)
- func (api *API) Shutdown()
- func (api *API) Start()
- func (api *API) UserLogin(w http.ResponseWriter, r *http.Request)
- func (api *API) UserLogout(w http.ResponseWriter, r *http.Request)
- type Code
- type Info
- type Metadata
- type Result
Constants ¶
const (
//Version represents the API version
Version = "v1"
)
Variables ¶
var CodeToResult map[Code]Result
CodeToResult defines a simple way to get predefined and coherents results from an error code.
var UnauthentificatedWhiteList = []string{
"/",
"/users/create",
"/users/login",
}
UnauthentificatedWhiteList contains all of the allowed ressources without MAC, unprefixed
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// Session defines the global session for the API.
Session *session.Session
Server *server.Server
Prefix string
Router *mux.Router
IPPort string
Version string
// contains filtered or unexported fields
}
API is the constructor for this package
func (*API) CreateUser ¶
func (api *API) CreateUser(w http.ResponseWriter, r *http.Request)
CreateUser handle the requests for creating users.
func (*API) DeleteProject ¶
func (api *API) DeleteProject(w http.ResponseWriter, r *http.Request)
DeleteProject return this template after deleting the project
"data": "ProjectName"
func (*API) GetAlgorithm ¶
func (api *API) GetAlgorithm(w http.ResponseWriter, r *http.Request)
GetAlgorithm return the current algorithm used by the server
func (*API) GetDomains ¶
func (api *API) GetDomains(w http.ResponseWriter, r *http.Request)
func (*API) GetIPsByProjectName ¶
func (api *API) GetIPsByProjectName(w http.ResponseWriter, r *http.Request)
GetIPsByProjectName return this template
"data": [ "10.0.0.1", "10.0.0.12", "10.20.3.4" ]
func (*API) GetIndex ¶
func (api *API) GetIndex(w http.ResponseWriter, r *http.Request)
GetIndex returns a link to the documentation on the root path
func (*API) GetNodes ¶
func (api *API) GetNodes(w http.ResponseWriter, r *http.Request)
GetNodes returns informations about all the connected (client) nodes for this server
func (*API) GetPortByIP ¶
func (api *API) GetPortByIP(w http.ResponseWriter, r *http.Request)
GetPortByIP return informations about a given port. It requires port number, ip address, and project name It has an optionnal "protocol" query (form) to specify the tcp/upd/... protocol If multiple ports are found with the same number and the protocol isn't specified, the function return an error : CodeAmbiguousRequest
func (*API) GetPortsByIP ¶
func (api *API) GetPortsByIP(w http.ResponseWriter, r *http.Request)
GetPortsByIP return all the ports for a given IP (and project)
func (*API) GetProject ¶
func (api *API) GetProject(w http.ResponseWriter, r *http.Request)
GetProject return this template
"data": {
"name": "FirstProject",
"updated_at": 1520122127
}
func (*API) GetProjects ¶
func (api *API) GetProjects(w http.ResponseWriter, r *http.Request)
GetProjects return this template
"data": [
{
"name": "FirstProject",
"description": "Some description",
"updated_at": 12345678
}
]
func (*API) GetRawsByModule ¶
func (api *API) GetRawsByModule(w http.ResponseWriter, r *http.Request)
GetRawsByModule returns all the raws output from the requested module and project
func (*API) GetRawsByProject ¶
func (api *API) GetRawsByProject(w http.ResponseWriter, r *http.Request)
GetRawsByProject returns all the raws output from a module for a specified project
func (*API) GetRoutesByIP ¶
func (api *API) GetRoutesByIP(w http.ResponseWriter, r *http.Request)
GetRoutesByIP returns all the routes informations
func (*API) GetURIByPort ¶
func (api *API) GetURIByPort(w http.ResponseWriter, r *http.Request)
GetURIByPort returns the specified URI information. The URI provided MUST be base64 encoded (and then urlEncoded) We are using standard base64 (and not the url-base64 for simplicity with frontend and other languages)
func (*API) GetURIsByPort ¶
func (api *API) GetURIsByPort(w http.ResponseWriter, r *http.Request)
func (*API) GetUser ¶
func (api *API) GetUser(w http.ResponseWriter, r *http.Request)
GetUser will return basic information on the user
func (*API) NotFound ¶
func (api *API) NotFound(w http.ResponseWriter, r *http.Request)
NotFound returns a simple 404 json error messages
func (*API) PostAlgorithm ¶
func (api *API) PostAlgorithm(w http.ResponseWriter, r *http.Request)
PostAlgorithm is the api endpoint handler for changing the loadbalancing algorithm
func (*API) PostDomain ¶
func (api *API) PostDomain(w http.ResponseWriter, r *http.Request)
func (*API) PostPortsByIP ¶
func (api *API) PostPortsByIP(w http.ResponseWriter, r *http.Request)
func (*API) PostProject ¶
func (api *API) PostProject(w http.ResponseWriter, r *http.Request)
func (*API) Routes ¶
func (api *API) Routes()
Routes is responsible for seting up all the handler function for the API
func (*API) RunModule ¶
func (api *API) RunModule(w http.ResponseWriter, r *http.Request)
RunModule return this template after starting the modules
"data": {
nodes: [
"1.2.3.4",
"4.3.2.1"
]
}
func (*API) RunModules ¶
func (api *API) RunModules(w http.ResponseWriter, r *http.Request)
RunModules runs every enabled modules
func (*API) Shutdown ¶
func (api *API) Shutdown()
Shutdown is responsible for graceful shutdown of the API.
func (*API) UserLogin ¶
func (api *API) UserLogin(w http.ResponseWriter, r *http.Request)
UserLogin will return a new token if the provided user match an existing one You must send the following json with correct user/password : ```
{
"name":"someusername",
"password":"somepassword"
}
```
func (*API) UserLogout ¶
func (api *API) UserLogout(w http.ResponseWriter, r *http.Request)
UserLogout disable the provided token
type Code ¶
type Code int
Code represents the internal status errors for the API. This is distinct from the HTTP error code. All the code are sets below
const ( //CodeOK : Successful operation CodeOK Code = iota //CodeNotFound : Ressource not found on the server CodeNotFound //CodeCouldNotDecodeJSON : Invalid json CodeCouldNotDecodeJSON //CodeDatabaseError : Something unexepected has happened with the database CodeDatabaseError //CodeNotImplementedYet : This function is not implemented yet. CodeNotImplementedYet //CodeInvalidInput : Unexepected inputs where provided CodeInvalidInput //CodeServerError : A server error occured CodeServerError //CodeForbidden : Access to this ressource forbidden CodeForbidden //CodeAmbiguousRequest : The server needs more information to perform the action CodeAmbiguousRequest )
type Metadata ¶
type Metadata struct {
Nodes []communication.Node `json:"nodes,omitempty"`
Info Info `json:"api"`
}
Metadata of the current system (node, api, database)