-
Notifications
You must be signed in to change notification settings - Fork 2
/
zones_default.go
37 lines (30 loc) · 976 Bytes
/
zones_default.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
// Code generated by go generate; DO NOT EDIT.
package brightbox
import "context"
import "path"
import "fmt"
const (
// zoneAPIPath returns the relative URL path to the Zone endpoint
zoneAPIPath = "zones"
)
// Zones returns the collection view for Zone
func (c *Client) Zones(ctx context.Context) ([]Zone, error) {
return apiGetCollection[[]Zone](ctx, c, zoneAPIPath)
}
// Zone retrieves a detailed view of one resource
func (c *Client) Zone(ctx context.Context, identifier string) (*Zone, error) {
return apiGet[Zone](ctx, c, path.Join(zoneAPIPath, identifier))
}
// Zone retrieves a detailed view of one resource using a handle
func (c *Client) ZoneByHandle(ctx context.Context, handle string) (*Zone, error) {
collection, err := c.Zones(ctx)
if err != nil {
return nil, err
}
for _, instance := range collection {
if instance.Handle == handle {
return &instance, nil
}
}
return nil, fmt.Errorf("Resource with handle '%s' doesn't exist", handle)
}