-
Notifications
You must be signed in to change notification settings - Fork 927
/
service_instance.go
31 lines (24 loc) · 1.22 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
package v7action
import (
"code.cloudfoundry.org/cli/actor/actionerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
)
type ServiceInstance ccv3.ServiceInstance
func (actor Actor) GetServiceInstanceByNameAndSpace(serviceInstanceName string, spaceGUID string) (ServiceInstance, Warnings, error) {
serviceInstances, warnings, err := actor.CloudControllerClient.GetServiceInstances(
ccv3.Query{Key: ccv3.NameFilter, Values: []string{serviceInstanceName}},
ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}},
)
if err != nil {
return ServiceInstance{}, Warnings(warnings), err
}
if len(serviceInstances) == 0 {
return ServiceInstance{}, Warnings(warnings), actionerror.ServiceInstanceNotFoundError{Name: serviceInstanceName}
}
//Handle multiple serviceInstances being returned as GetServiceInstances arnt filtered by space
return ServiceInstance(serviceInstances[0]), Warnings(warnings), nil
}
func (actor Actor) UnshareServiceInstanceByServiceInstanceAndSpace(serviceInstanceGUID string, sharedToSpaceGUID string) (Warnings, error) {
warnings, err := actor.CloudControllerClient.DeleteServiceInstanceRelationshipsSharedSpace(serviceInstanceGUID, sharedToSpaceGUID)
return Warnings(warnings), err
}