-
Notifications
You must be signed in to change notification settings - Fork 0
/
space.go
42 lines (37 loc) · 1.09 KB
/
space.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
package ccv3
import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
)
// Space represents a Cloud Controller V3 Space.
type Space struct {
// GUID is a unique space identifier.
GUID string `json:"guid"`
// Name is the name of the space.
Name string `json:"name"`
// Relationships list the relationships to the space.
Relationships Relationships `json:"relationships"`
}
// GetSpaces lists spaces with optional filters.
func (client *Client) GetSpaces(query ...Query) ([]Space, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetSpacesRequest,
Query: query,
})
if err != nil {
return nil, nil, err
}
var fullSpacesList []Space
warnings, err := client.paginate(request, Space{}, func(item interface{}) error {
if space, ok := item.(Space); ok {
fullSpacesList = append(fullSpacesList, space)
} else {
return ccerror.UnknownObjectInListError{
Expected: Space{},
Unexpected: item,
}
}
return nil
})
return fullSpacesList, warnings, err
}