mirror of
https://github.com/spaytac/orbiter.git
synced 2026-01-21 22:04:42 +00:00
Add new API call to get all the autoscalers currently managed by orbiter: ``` curl http://localhost:8000/autoscaler ``` Add command into the CLI to get this list ``` export ORBITER_HOST=http://localhost:8000 orbiter autoscler ls ``` Add command into the CLI to print all the events fired by the daemon: ``` export ORBITER_HOST=http://localhost:8000 orbiter system events ```
30 lines
533 B
Go
30 lines
533 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/gianarb/orbiter/autoscaler"
|
|
)
|
|
|
|
type AutoscalerResponse struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func AutoscalerList(scalers autoscaler.Autoscalers) func(w http.ResponseWriter, r *http.Request) {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
l := []AutoscalerResponse{}
|
|
for n, _ := range scalers {
|
|
c := AutoscalerResponse{
|
|
Name: n,
|
|
}
|
|
l = append(l, c)
|
|
}
|
|
cc := &CollectionResponse{
|
|
Data: l,
|
|
}
|
|
b, _ := json.Marshal(cc)
|
|
w.Write(b)
|
|
}
|
|
}
|