add api default values + rename host to url
This commit is contained in:
parent
4425e3323f
commit
2b504289ea
|
@ -4,14 +4,16 @@ import "encoding/base64"
|
|||
|
||||
// A Client for the API
|
||||
type Client struct {
|
||||
Token string `toml:"token"`
|
||||
Host string `toml:"host"`
|
||||
Token string `toml:"token"`
|
||||
URL string `toml:"url"`
|
||||
DefaultVHost string `toml:"default_vhost"`
|
||||
DefaultApp string `toml:"default_app"`
|
||||
}
|
||||
|
||||
// New Client from host and token
|
||||
func New(host, token string) *Client {
|
||||
func New(url, token string) *Client {
|
||||
c := &Client{
|
||||
Host: host,
|
||||
URL: url,
|
||||
}
|
||||
c.SetToken(token)
|
||||
return c
|
||||
|
|
|
@ -12,7 +12,7 @@ func (c *Client) Request(url string, value interface{}) error {
|
|||
netClient := &http.Client{
|
||||
Timeout: time.Second * 20,
|
||||
}
|
||||
req, err := http.NewRequest(http.MethodGet, c.Host+url, nil)
|
||||
req, err := http.NewRequest(http.MethodGet, c.URL+url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ type ResponseList struct {
|
|||
Data []string `json:"response,omitempty"`
|
||||
}
|
||||
|
||||
// RequestListVHosts to get list of vhosts
|
||||
func (c *Client) RequestListVHosts() (*ResponseList, error) {
|
||||
req := ResponseList{}
|
||||
url := fmt.Sprintf(URLRequestListVHost)
|
||||
|
@ -25,6 +26,7 @@ func (c *Client) RequestListVHosts() (*ResponseList, error) {
|
|||
return &req, nil
|
||||
}
|
||||
|
||||
// RequestListApps to get list of apps on given vhost
|
||||
func (c *Client) RequestListApps(vhost string) (*ResponseList, error) {
|
||||
req := ResponseList{}
|
||||
url := fmt.Sprintf(URLRequestListApp, vhost)
|
||||
|
@ -34,6 +36,12 @@ func (c *Client) RequestListApps(vhost string) (*ResponseList, error) {
|
|||
return &req, nil
|
||||
}
|
||||
|
||||
// RequestDefaultListApps to get list of apps on default vhost
|
||||
func (c *Client) RequestDefaultListApps() (*ResponseList, error) {
|
||||
return c.RequestListApps(c.DefaultVHost)
|
||||
}
|
||||
|
||||
// RequestDefaultListStreams to get list of streams on given vhost and app
|
||||
func (c *Client) RequestListStreams(vhost, app string) (*ResponseList, error) {
|
||||
req := ResponseList{}
|
||||
url := fmt.Sprintf(URLRequestListStream, vhost, app)
|
||||
|
@ -42,3 +50,8 @@ func (c *Client) RequestListStreams(vhost, app string) (*ResponseList, error) {
|
|||
}
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
// RequestDefaultListStreams to get list of streams on default vhost and app
|
||||
func (c *Client) RequestDefaultListStreams() (*ResponseList, error) {
|
||||
return c.RequestListStreams(c.DefaultVHost, c.DefaultApp)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
listen = ":8080"
|
||||
|
||||
[api]
|
||||
host = "http://1.2.3.4:8081"
|
||||
url = "http://1.2.3.4:8081"
|
||||
token = "ome-access-token"
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description = Prometheus exporter for OvenMediaEngine
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/oven-exporter -c /etc/ovenmediaengine/exporter.conf
|
||||
Restart=always
|
||||
RestartSec=5s
|
||||
Environment=PATH=/usr/bin:/usr/local/bin
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue