Add GetInstancesBulk

This commit is contained in:
Kienan Stewart 2020-10-24 21:28:54 -04:00
parent 698589ddcc
commit 84e0ad321f
1 changed files with 14 additions and 0 deletions

View File

@ -14,6 +14,7 @@ type RapiClient interface {
GetNetworks() ([]map[string]interface{}, error)
GetNetworksBulk() ([]map[string]interface{}, error)
GetNetworkInfo(name string) (map[string]interface{}, error)
GetInstancesBulk() ([]map[string]interface{}, error)
}
type Client struct {
@ -73,6 +74,19 @@ func (s *Client) GetNetworksBulk() ([]map[string]interface{}, error) {
return data, nil
}
func (s *Client) GetInstancesBulk() ([]map[string]interface{}, error) {
result, err := s.Do("GET", "instances?bulk=1")
if err != nil {
return nil, err
}
data := make([]map[string]interface{}, 0)
err = json.Unmarshal(result, &data)
if err != nil {
return nil, err
}
return data, nil
}
func (s *Client) GetNetworkInformation(name string) (map[string]interface{}, error) {
result, err := s.Do("GET", "networks/" + name)
if err != nil {