Magic-Pod/magicpod-api-client

BatchRun: support GET APIs

gkzz opened this issue · 3 comments

gkzz commented

Describe our problem

We have no ways to call, with magicpod-api-client , GET the following BatchRun APIs;

  • /v1.0/{organization_name}/{project_name}/batch-run/{batch_run_number}/
  • /v1.0/{organization_name}/{project_name}/batch-runs/

src: https://magic-pod.com/api/v1.0/doc/

The only way to get the BatchRun's results is to call the APIs directory with curl command, or something :(

Proposed Solution

  • All we have to do in order to get BatchRun's results and the test-cases' results is to execute it only once.
    • Once we execute it, magicpod-api-client calls /v1.0/{organization_name}/{project_name}/batch-runs/ API and /v1.0/{organization_name}/{project_name}/batch-run/{batch_run_number}/ APIs repeatedly for number of {batch_run_number} s.

Clues to solve the problem

  • We've already have the functions to call these APIs
    • /v1.0/{organization_name}/{project_name}/batch-run/{batch_run_number}/
      • // GetBatchRun retrieves status and number of test cases executed of a specified batch run
        func GetBatchRun(urlBase string, apiToken string, organization string, project string, httpHeadersMap map[string]string, batchRunNumber int) (*BatchRun, *cli.ExitError) {
        res, err := createBaseRequest(urlBase, apiToken, organization, project, httpHeadersMap).
        SetPathParams(map[string]string{
        "batch_run_number": strconv.Itoa(batchRunNumber),
        }).
        SetResult(BatchRun{}).
        Get("/{organization}/{project}/batch-run/{batch_run_number}/")
    • /v1.0/{organization_name}/{project_name}/batch-runs/
      • func LatestBatchRunNo(urlBase string, apiToken string, organization string, project string, httpHeadersMap map[string]string) (int, *cli.ExitError) {
        res, err := createBaseRequest(urlBase, apiToken, organization, project, httpHeadersMap).
        SetQueryParam("count", "1").
        SetResult(BatchRuns{}).
        Get("/{organization}/{project}/batch-runs/")
  • These functions are inner ones
    • func latestBatchRunNoAction(c *cli.Context) error {
      // handle command line arguments
      urlBase, apiToken, organization, project, httpHeadersMap, err := parseCommonFlags(c)
      if err != nil {
      return err
      }
      batchRunNo, exitErr := common.LatestBatchRunNo(urlBase, apiToken, organization, project, httpHeadersMap)
    • func waitForBatchRunAction(c *cli.Context) error {
      urlBase, apiToken, organization, project, httpHeadersMap, err := parseCommonFlags(c)
      if err != nil {
      return err
      }
      batchRunNumber := c.Int("batch_run_number")
      if batchRunNumber == 0 {
      return cli.NewExitError("--batch_run_number option is not specified or 0", 1)
      }
      waitLimit := c.Int("wait_limit")
      batchRunUnderProgress, batchRunError := common.GetBatchRun(urlBase, apiToken, organization, project, httpHeadersMap, batchRunNumber)
yaumu3 commented

Thank you for informative suggestion! As for /v1.0/{organization_name}/{project_name}/batch-run/{batch_run_number}/, it seems that utilizing GetBatchRun is the key. I'm trying to partially resolve it with #8.

gkzz commented

Thx always :)
I'll re-open one, when I'm faced with problems.

Sorry, we've not yet supported /v1.0/{organization_name}/{project_name}/batch-runs/.
Let me reopen now.