API endpoint and associated RPC changes to resolve VMs IP's (#188)

* API endpoint and associated RPC changes to resolve VMs IP's

* Fix "Missing expected argument '<name>'" error when doing "tart set"

* Implement TestIPEndpoint() and IP() method in controller HTTP client
This commit is contained in:
Nikolay Edigaryev
2024-07-03 22:56:43 +04:00
committed by GitHub
parent 8119b22817
commit 76f192bdb0
18 changed files with 603 additions and 124 deletions
+16
View File
@@ -101,6 +101,22 @@ func (service *VMsService) PortForward(
})
}
func (service *VMsService) IP(ctx context.Context, name string, waitSeconds uint16) (string, error) {
result := struct {
IP string `json:"ip"`
}{}
err := service.client.request(ctx, http.MethodGet, fmt.Sprintf("vms/%s/ip", url.PathEscape(name)),
nil, &result, map[string]string{
"wait": strconv.FormatUint(uint64(waitSeconds), 10),
})
if err != nil {
return "", err
}
return result.IP, nil
}
func (service *VMsService) StreamEvents(name string) *EventStreamer {
return NewEventStreamer(service.client, fmt.Sprintf("vms/%s/events", url.PathEscape(name)))
}