MCPcopy Index your code
hub / github.com/cloudfoundry/cli / FindInstanceByName

Method FindInstanceByName

cf/api/services.go:114–139  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

112}
113
114func (repo CloudControllerServiceRepository) FindInstanceByName(name string) (instance models.ServiceInstance, apiErr error) {
115 path := fmt.Sprintf("%s/v2/spaces/%s/service_instances?return_user_provided_service_instances=true&q=%s&inline-relations-depth=1", repo.config.APIEndpoint(), repo.config.SpaceFields().GUID, url.QueryEscape("name:"+name))
116
117 responseJSON := new(resources.PaginatedServiceInstanceResources)
118 apiErr = repo.gateway.GetResource(path, responseJSON)
119 if apiErr != nil {
120 return
121 }
122
123 if len(responseJSON.Resources) == 0 {
124 apiErr = errors.NewModelNotFoundError("Service instance", name)
125 return
126 }
127
128 instanceResource := responseJSON.Resources[0]
129 instance = instanceResource.ToModel()
130
131 if instanceResource.Entity.ServicePlan.Metadata.GUID != "" {
132 resource := &resources.ServiceOfferingResource{}
133 path = fmt.Sprintf("%s/v2/services/%s", repo.config.APIEndpoint(), instanceResource.Entity.ServicePlan.Entity.ServiceOfferingGUID)
134 apiErr = repo.gateway.GetResource(path, resource)
135 instance.ServiceOffering = resource.ToFields()
136 }
137
138 return
139}
140
141func (repo CloudControllerServiceRepository) CreateServiceInstance(name, planGUID string, params map[string]interface{}, tags []string) (err error) {
142 path := "/v2/service_instances?accepts_incomplete=true"

Callers 1

CreateServiceInstanceMethod · 0.95

Calls 6

ToFieldsMethod · 0.95
NewModelNotFoundErrorFunction · 0.92
GetResourceMethod · 0.80
APIEndpointMethod · 0.65
SpaceFieldsMethod · 0.65
ToModelMethod · 0.45

Tested by

no test coverage detected