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

Function GetAPIByName

pkg/operator/resources/realtimeapi/api.go:206–243  ·  view source on GitHub ↗
(deployedResource *operator.DeployedResource)

Source from the content-addressed store, hash-verified

204}
205
206func GetAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
207 deployment, err := config.K8s.GetDeployment(workloads.K8sName(deployedResource.Name))
208 if err != nil {
209 return nil, err
210 }
211
212 if deployment == nil {
213 return nil, errors.ErrorUnexpected("unable to find deployment", deployedResource.Name)
214 }
215
216 apiStatus := status.FromDeployment(deployment)
217 apiMetadata, err := spec.MetadataFromDeployment(deployment)
218 if err != nil {
219 return nil, errors.ErrorUnexpected("unable to obtain metadata", deployedResource.Name)
220 }
221
222 api, err := operator.DownloadAPISpec(apiMetadata.Name, apiMetadata.APIID)
223 if err != nil {
224 return nil, err
225 }
226
227 apiEndpoint, err := operator.APIEndpoint(api)
228 if err != nil {
229 return nil, err
230 }
231
232 dashboardURL := pointer.String(getDashboardURL(api.Name))
233
234 return []schema.APIResponse{
235 {
236 Spec: api,
237 Metadata: apiMetadata,
238 Status: apiStatus,
239 Endpoint: &apiEndpoint,
240 DashboardURL: dashboardURL,
241 },
242 }, nil
243}
244
245func DescribeAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
246 deployment, err := config.K8s.GetDeployment(workloads.K8sName(deployedResource.Name))

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