github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/api/cloudcontroller/ccv2/service_instance_shared_to.go (about) 1 package ccv2 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2/internal" 6 ) 7 8 type ServiceInstanceSharedTo struct { 9 SpaceGUID string `json:"space_guid"` 10 SpaceName string `json:"space_name"` 11 OrganizationName string `json:"organization_name"` 12 BoundAppCount int `json:"bound_app_count"` 13 } 14 15 func (client *Client) GetServiceInstanceSharedTos(serviceInstanceGUID string) ([]ServiceInstanceSharedTo, Warnings, error) { 16 request, err := client.newHTTPRequest(requestOptions{ 17 RequestName: internal.GetServiceInstanceSharedToRequest, 18 URIParams: Params{"service_instance_guid": serviceInstanceGUID}, 19 }) 20 21 if err != nil { 22 return nil, nil, err 23 } 24 25 var fullSharedToList []ServiceInstanceSharedTo 26 warnings, err := client.paginate(request, ServiceInstanceSharedTo{}, func(item interface{}) error { 27 if instance, ok := item.(ServiceInstanceSharedTo); ok { 28 fullSharedToList = append(fullSharedToList, instance) 29 } else { 30 return ccerror.UnknownObjectInListError{ 31 Expected: ServiceInstanceSharedTo{}, 32 Unexpected: item, 33 } 34 } 35 return nil 36 }) 37 38 return fullSharedToList, warnings, err 39 }