-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfleets.go
54 lines (44 loc) · 1.24 KB
/
fleets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package valyent
import (
"fmt"
stdHTTP "net/http"
"github.com/valyentdev/ravel/api"
)
func (client *Client) CreateFleet(opts api.CreateFleetPayload) (*api.Fleet, error) {
fleet := &api.Fleet{}
err := client.PerformRequest(
"POST",
"/v1/fleets",
opts,
fleet,
)
if err != nil {
return nil, fmt.Errorf("failed to create fleet: %v", err)
}
return fleet, nil
}
func (client *Client) GetFleets() (fleets []api.Fleet, err error) {
// Fetch existing fleets matching the user's namespace.
fleets = []api.Fleet{}
err = client.PerformRequest(stdHTTP.MethodGet, "/v1/fleets", nil, &fleets)
if err != nil {
return fleets, fmt.Errorf("failed to retrieve fleets: %v", err)
}
return
}
func (client *Client) GetFleet(fleetID string) (fleet api.Fleet, err error) {
// Fetch existing fleets matching the user's namespace.
fleet = api.Fleet{}
err = client.PerformRequest(stdHTTP.MethodGet, "/v1/fleets/"+fleetID, nil, &fleet)
if err != nil {
return fleet, fmt.Errorf("failed to retrieve fleet: %v", err)
}
return
}
func (client *Client) DeleteFleet(fleetID string) error {
err := client.PerformRequest(stdHTTP.MethodDelete, "/v1/fleets/"+fleetID, nil, nil)
if err != nil {
return fmt.Errorf("failed to delete fleet: %v", err)
}
return nil
}