(env cliconfig.Environment, apiName string)
| 460 | } |
| 461 | |
| 462 | func getAPI(env cliconfig.Environment, apiName string) (string, error) { |
| 463 | apisRes, err := cluster.GetAPI(MustGetOperatorConfig(env.Name), apiName) |
| 464 | if err != nil { |
| 465 | return "", err |
| 466 | } |
| 467 | |
| 468 | var bytes []byte |
| 469 | if _flagOutput == flags.JSONOutputType { |
| 470 | bytes, err = libjson.Marshal(apisRes) |
| 471 | } else if _flagOutput == flags.YAMLOutputType { |
| 472 | bytes, err = yaml.Marshal(apisRes) |
| 473 | } |
| 474 | if err != nil { |
| 475 | return "", err |
| 476 | } |
| 477 | if _flagOutput == flags.JSONOutputType || _flagOutput == flags.YAMLOutputType { |
| 478 | return string(bytes), nil |
| 479 | } |
| 480 | |
| 481 | if len(apisRes) == 0 { |
| 482 | exit.Error(errors.ErrorUnexpected(fmt.Sprintf("unable to find api %s", apiName))) |
| 483 | } |
| 484 | |
| 485 | apiRes := apisRes[0] |
| 486 | |
| 487 | switch apiRes.Metadata.Kind { |
| 488 | case userconfig.RealtimeAPIKind: |
| 489 | return realtimeAPITable(apiRes, env) |
| 490 | case userconfig.AsyncAPIKind: |
| 491 | return asyncAPITable(apiRes, env) |
| 492 | case userconfig.TrafficSplitterKind: |
| 493 | return trafficSplitterTable(apiRes, env) |
| 494 | case userconfig.BatchAPIKind: |
| 495 | return batchAPITable(apiRes), nil |
| 496 | case userconfig.TaskAPIKind: |
| 497 | return taskAPITable(apiRes), nil |
| 498 | default: |
| 499 | return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Metadata.Kind, apiRes.Metadata.Name)) |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | func apiHistoryTable(apiVersions []schema.APIVersion) string { |
| 504 | t := table.Table{ |
no test coverage detected