(name, planGUID string, params map[string]interface{}, tags []string)
| 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" |
| 143 | request := models.ServiceInstanceCreateRequest{ |
| 144 | Name: name, |
| 145 | PlanGUID: planGUID, |
| 146 | SpaceGUID: repo.config.SpaceFields().GUID, |
| 147 | Params: params, |
| 148 | Tags: tags, |
| 149 | } |
| 150 | |
| 151 | jsonBytes, err := json.Marshal(request) |
| 152 | if err != nil { |
| 153 | return err |
| 154 | } |
| 155 | |
| 156 | err = repo.gateway.CreateResource(repo.config.APIEndpoint(), path, bytes.NewReader(jsonBytes)) |
| 157 | |
| 158 | if httpErr, ok := err.(errors.HTTPError); ok && httpErr.ErrorCode() == errors.ServiceInstanceNameTaken { |
| 159 | serviceInstance, findInstanceErr := repo.FindInstanceByName(name) |
| 160 | |
| 161 | if findInstanceErr == nil && serviceInstance.ServicePlan.GUID == planGUID { |
| 162 | return errors.NewModelAlreadyExistsError("Service", name) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | return |
| 167 | } |
| 168 | |
| 169 | func (repo CloudControllerServiceRepository) UpdateServiceInstance(instanceGUID, planGUID string, params map[string]interface{}, tags *[]string) (err error) { |
| 170 | path := fmt.Sprintf("/v2/service_instances/%s?accepts_incomplete=true", instanceGUID) |
nothing calls this directly
no test coverage detected