forked from cloudfoundry/cli
/
stack.go
41 lines (36 loc) · 1.02 KB
/
stack.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
package ccv3
import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
)
type Stack struct {
// GUID is a unique stack identifier.
GUID string `json:"guid"`
// Name is the name of the stack.
Name string `json:"name"`
// Description is the description for the stack
Description string `json:"description"`
}
// GetStacks lists stacks with optional filters.
func (client *Client) GetStacks(query ...Query) ([]Stack, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetStacksRequest,
Query: query,
})
if err != nil {
return nil, nil, err
}
var fullStacksList []Stack
warnings, err := client.paginate(request, Stack{}, func(item interface{}) error {
if stack, ok := item.(Stack); ok {
fullStacksList = append(fullStacksList, stack)
} else {
return ccerror.UnknownObjectInListError{
Expected: Stack{},
Unexpected: item,
}
}
return nil
})
return fullStacksList, warnings, err
}