-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver_types_default.go
37 lines (30 loc) · 1.07 KB
/
server_types_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 (
// servertypeAPIPath returns the relative URL path to the ServerType endpoint
servertypeAPIPath = "server_types"
)
// ServerTypes returns the collection view for ServerType
func (c *Client) ServerTypes(ctx context.Context) ([]ServerType, error) {
return apiGetCollection[[]ServerType](ctx, c, servertypeAPIPath)
}
// ServerType retrieves a detailed view of one resource
func (c *Client) ServerType(ctx context.Context, identifier string) (*ServerType, error) {
return apiGet[ServerType](ctx, c, path.Join(servertypeAPIPath, identifier))
}
// ServerType retrieves a detailed view of one resource using a handle
func (c *Client) ServerTypeByHandle(ctx context.Context, handle string) (*ServerType, error) {
collection, err := c.ServerTypes(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)
}