github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/api/cloudcontroller/ccv3/service_instance.go (about) 1 package ccv3 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" 6 ) 7 8 type ServiceInstance struct { 9 GUID string `json:"guid"` 10 Name string `json:"name"` 11 } 12 13 // GetServiceInstances lists ServiceInstances with optional filters. 14 func (client *Client) GetServiceInstances(query ...Query) ([]ServiceInstance, Warnings, error) { 15 request, err := client.newHTTPRequest(requestOptions{ 16 RequestName: internal.GetServiceInstancesRequest, 17 Query: query, 18 }) 19 if err != nil { 20 return nil, nil, err 21 } 22 23 var fullServiceInstanceList []ServiceInstance 24 warnings, err := client.paginate(request, ServiceInstance{}, func(item interface{}) error { 25 if serviceInstance, ok := item.(ServiceInstance); ok { 26 fullServiceInstanceList = append(fullServiceInstanceList, serviceInstance) 27 } else { 28 return ccerror.UnknownObjectInListError{ 29 Expected: ServiceInstance{}, 30 Unexpected: item, 31 } 32 } 33 return nil 34 }) 35 36 return fullServiceInstanceList, warnings, err 37 }