(operatorConfig OperatorConfig, apiName string, keepCache bool, force bool)
| 30 | ) |
| 31 | |
| 32 | func Delete(operatorConfig OperatorConfig, apiName string, keepCache bool, force bool) (schema.DeleteResponse, error) { |
| 33 | if !force { |
| 34 | readyReplicas := getReadyRealtimeAPIReplicasOrNil(operatorConfig, apiName) |
| 35 | if readyReplicas != nil && *readyReplicas > 2 { |
| 36 | prompt.YesOrExit(fmt.Sprintf("are you sure you want to delete %s (which has %d live replicas)?", apiName, *readyReplicas), "", "") |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | params := map[string]string{ |
| 41 | "apiName": apiName, |
| 42 | "keepCache": s.Bool(keepCache), |
| 43 | } |
| 44 | |
| 45 | httpRes, err := HTTPDelete(operatorConfig, "/delete/"+apiName, params) |
| 46 | if err != nil { |
| 47 | return schema.DeleteResponse{}, err |
| 48 | } |
| 49 | |
| 50 | var deleteRes schema.DeleteResponse |
| 51 | err = json.Unmarshal(httpRes, &deleteRes) |
| 52 | if err != nil { |
| 53 | return schema.DeleteResponse{}, errors.Wrap(err, "/delete", string(httpRes)) |
| 54 | } |
| 55 | |
| 56 | return deleteRes, nil |
| 57 | } |
| 58 | |
| 59 | func getReadyRealtimeAPIReplicasOrNil(operatorConfig OperatorConfig, apiName string) *int32 { |
| 60 | httpRes, err := HTTPGet(operatorConfig, "/get/"+apiName) |
no test coverage detected