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

Function GetAPIByName

pkg/operator/resources/asyncapi/api.go:273–310  ·  view source on GitHub ↗
(deployedResource *operator.DeployedResource)

Source from the content-addressed store, hash-verified

271}
272
273func GetAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
274 apiDeployment, err := config.K8s.GetDeployment(workloads.K8sName(deployedResource.Name))
275 if err != nil {
276 return nil, err
277 }
278
279 if apiDeployment == nil {
280 return nil, errors.ErrorUnexpected("unable to find api deployment", deployedResource.Name)
281 }
282
283 apiStatus := status.FromDeployment(apiDeployment)
284 apiMetadata, err := spec.MetadataFromDeployment(apiDeployment)
285 if err != nil {
286 return nil, errors.ErrorUnexpected("unable to obtain metadata", deployedResource.Name)
287 }
288
289 api, err := operator.DownloadAPISpec(apiMetadata.Name, apiMetadata.APIID)
290 if err != nil {
291 return nil, err
292 }
293
294 apiEndpoint, err := operator.APIEndpoint(api)
295 if err != nil {
296 return nil, err
297 }
298
299 dashboardURL := pointer.String(getDashboardURL(api.Name))
300
301 return []schema.APIResponse{
302 {
303 Spec: api,
304 Metadata: apiMetadata,
305 Status: apiStatus,
306 Endpoint: &apiEndpoint,
307 DashboardURL: dashboardURL,
308 },
309 }, nil
310}
311
312func DescribeAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
313 var apiDeployment *kapps.Deployment

Callers 2

GetAPIFunction · 0.92
GetLogURLFunction · 0.92

Calls 9

K8sNameFunction · 0.92
ErrorUnexpectedFunction · 0.92
FromDeploymentFunction · 0.92
MetadataFromDeploymentFunction · 0.92
DownloadAPISpecFunction · 0.92
APIEndpointFunction · 0.92
StringFunction · 0.92
GetDeploymentMethod · 0.80
getDashboardURLFunction · 0.70

Tested by

no test coverage detected