| 433 | } |
| 434 | |
| 435 | func (s *RunService) doPostRunRequest(ctx context.Context, path string, runReq *RunRequest) (TestID, error) { |
| 436 | if !isValidTarget(runReq.Target) { |
| 437 | return "", &argError{"target"} |
| 438 | } |
| 439 | if !isValidLimit(s.client.apiKey, runReq.Limit) { |
| 440 | return "", &argError{"limit"} |
| 441 | } |
| 442 | |
| 443 | body, err := newJSONReader(runReq) |
| 444 | if err != nil { |
| 445 | return "", err |
| 446 | } |
| 447 | u := s.client.BasePath + path |
| 448 | req, _ := http.NewRequest("POST", u, body) |
| 449 | req = req.WithContext(ctx) |
| 450 | var raw struct { |
| 451 | Error string |
| 452 | ID string `json:"id"` |
| 453 | } |
| 454 | if err = s.client.do(req, &raw); err != nil { |
| 455 | return "", err |
| 456 | } |
| 457 | if raw.Error != "" { |
| 458 | return "", errors.New(raw.Error) |
| 459 | } |
| 460 | return TestID(raw.ID), nil |
| 461 | } |
| 462 | |
| 463 | func (s *RunService) doGetRunOutput(ctx context.Context, path string, testID TestID) (*RunOutput, error) { |
| 464 | u := s.client.BasePath + path + string(testID) |