MCPcopy
hub / github.com/cortexlabs/cortex / GetAPI

Function GetAPI

pkg/operator/resources/resources.go:363–415  ·  view source on GitHub ↗
(apiName string)

Source from the content-addressed store, hash-verified

361}
362
363func GetAPI(apiName string) ([]schema.APIResponse, error) {
364 deployedResource, err := GetDeployedResourceByName(apiName)
365 if err != nil {
366 return nil, err
367 }
368
369 var apiResponse []schema.APIResponse
370
371 switch deployedResource.Kind {
372 case userconfig.RealtimeAPIKind:
373 apiResponse, err = realtimeapi.GetAPIByName(deployedResource)
374 if err != nil {
375 return nil, err
376 }
377 case userconfig.BatchAPIKind:
378 apiResponse, err = batchapi.GetAPIByName(deployedResource)
379 if err != nil {
380 return nil, err
381 }
382 case userconfig.TaskAPIKind:
383 apiResponse, err = taskapi.GetAPIByName(deployedResource)
384 if err != nil {
385 return nil, err
386 }
387 case userconfig.AsyncAPIKind:
388 apiResponse, err = asyncapi.GetAPIByName(deployedResource)
389 if err != nil {
390 return nil, err
391 }
392 case userconfig.TrafficSplitterKind:
393 apiResponse, err = trafficsplitter.GetAPIByName(deployedResource)
394 if err != nil {
395 return nil, err
396 }
397 default:
398 return nil, ErrorOperationIsOnlySupportedForKind(
399 *deployedResource,
400 userconfig.RealtimeAPIKind, userconfig.BatchAPIKind,
401 userconfig.TaskAPIKind, userconfig.TrafficSplitterKind,
402 userconfig.AsyncAPIKind,
403 ) // unexpected
404 }
405
406 // Get past API deploy times
407 if len(apiResponse) > 0 {
408 apiResponse[0].APIVersions, err = getPastAPIDeploys(deployedResource.Name)
409 if err != nil {
410 return nil, err
411 }
412 }
413
414 return apiResponse, nil
415}
416
417func GetAPIByID(apiName string, apiID string) ([]schema.APIResponse, error) {
418 // check if the API is currently running, so that additional information can be returned

Callers 2

GetAPIFunction · 0.92
GetAPIByIDFunction · 0.70

Calls 8

GetAPIByNameFunction · 0.92
GetAPIByNameFunction · 0.92
GetAPIByNameFunction · 0.92
GetAPIByNameFunction · 0.92
GetAPIByNameFunction · 0.92
getPastAPIDeploysFunction · 0.85

Tested by

no test coverage detected