2021-07-21 00:15:57 +02:00
|
|
|
package api
|
2021-07-20 12:18:00 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-07-20 12:25:05 +02:00
|
|
|
URLRequestListVHost = "/v1/vhosts"
|
|
|
|
URLRequestListApp = "/v1/vhosts/%s/apps"
|
2021-07-20 12:18:00 +02:00
|
|
|
URLRequestListStream = "/v1/vhosts/%s/apps/%s/streams"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ResponseList struct {
|
2021-07-20 12:25:05 +02:00
|
|
|
Message string `json:"message"`
|
|
|
|
StatusCode int `json:"statusCode"`
|
|
|
|
Data []string `json:"response,omitempty"`
|
2021-07-20 12:18:00 +02:00
|
|
|
}
|
|
|
|
|
2021-07-21 00:15:57 +02:00
|
|
|
func (c *Client) RequestListVHosts() (*ResponseList, error) {
|
2021-07-20 12:18:00 +02:00
|
|
|
req := ResponseList{}
|
|
|
|
url := fmt.Sprintf(URLRequestListVHost)
|
2021-07-20 12:25:05 +02:00
|
|
|
if err := c.Request(url, &req); err != nil {
|
2021-07-20 12:18:00 +02:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &req, nil
|
|
|
|
}
|
|
|
|
|
2021-07-21 00:15:57 +02:00
|
|
|
func (c *Client) RequestListApps(vhost string) (*ResponseList, error) {
|
2021-07-20 12:18:00 +02:00
|
|
|
req := ResponseList{}
|
|
|
|
url := fmt.Sprintf(URLRequestListApp, vhost)
|
2021-07-20 12:25:05 +02:00
|
|
|
if err := c.Request(url, &req); err != nil {
|
2021-07-20 12:18:00 +02:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &req, nil
|
|
|
|
}
|
|
|
|
|
2021-07-21 00:15:57 +02:00
|
|
|
func (c *Client) RequestListStreams(vhost, app string) (*ResponseList, error) {
|
2021-07-20 12:18:00 +02:00
|
|
|
req := ResponseList{}
|
|
|
|
url := fmt.Sprintf(URLRequestListStream, vhost, app)
|
2021-07-20 12:25:05 +02:00
|
|
|
if err := c.Request(url, &req); err != nil {
|
2021-07-20 12:18:00 +02:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &req, nil
|
|
|
|
}
|