forked from cloudfoundry-community/cloudfoundry-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_instance.go
37 lines (32 loc) · 1.01 KB
/
service_instance.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
package ccv3
import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
)
type ServiceInstance struct {
GUID string `json:"guid"`
Name string `json:"name"`
}
// GetServiceInstances lists ServiceInstances with optional filters.
func (client *Client) GetServiceInstances(query ...Query) ([]ServiceInstance, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceInstancesRequest,
Query: query,
})
if err != nil {
return nil, nil, err
}
var fullServiceInstanceList []ServiceInstance
warnings, err := client.paginate(request, ServiceInstance{}, func(item interface{}) error {
if serviceInstance, ok := item.(ServiceInstance); ok {
fullServiceInstanceList = append(fullServiceInstanceList, serviceInstance)
} else {
return ccerror.UnknownObjectInListError{
Expected: ServiceInstance{},
Unexpected: item,
}
}
return nil
})
return fullServiceInstanceList, warnings, err
}