(name string)
| 112 | } |
| 113 | |
| 114 | func (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 | |
| 141 | func (repo CloudControllerServiceRepository) CreateServiceInstance(name, planGUID string, params map[string]interface{}, tags []string) (err error) { |
| 142 | path := "/v2/service_instances?accepts_incomplete=true" |
no test coverage detected