forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_instance_shared_to.go
53 lines (44 loc) · 1.74 KB
/
service_instance_shared_to.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
43
44
45
46
47
48
49
50
51
52
53
package ccv2
import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv2/internal"
)
// ServiceInstanceSharedTo represents a Cloud Controller relationship object
// that describes a service instance in another space (and possibly org) that
// this service is **shared to**.
type ServiceInstanceSharedTo struct {
// SpaceGUID is the unique identifier of the space that this service is
// shared to.
SpaceGUID string `json:"space_guid"`
// SpaceName is the name of the space that this service is shared to.
SpaceName string `json:"space_name"`
// OrganizationName is the name of the organization that this service is
// shared to.
OrganizationName string `json:"organization_name"`
// BoundAppCount is the number of apps that are bound to the shared to
// service instance.
BoundAppCount int `json:"bound_app_count"`
}
// GetServiceInstanceSharedTos returns a list of ServiceInstanceSharedTo objects.
func (client *Client) GetServiceInstanceSharedTos(serviceInstanceGUID string) ([]ServiceInstanceSharedTo, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceInstanceSharedToRequest,
URIParams: Params{"service_instance_guid": serviceInstanceGUID},
})
if err != nil {
return nil, nil, err
}
var fullSharedToList []ServiceInstanceSharedTo
warnings, err := client.paginate(request, ServiceInstanceSharedTo{}, func(item interface{}) error {
if instance, ok := item.(ServiceInstanceSharedTo); ok {
fullSharedToList = append(fullSharedToList, instance)
} else {
return ccerror.UnknownObjectInListError{
Expected: ServiceInstanceSharedTo{},
Unexpected: item,
}
}
return nil
})
return fullSharedToList, warnings, err
}