MCPcopy Create free account
hub / github.com/algolia/cli / fetchAccountApplications

Method fetchAccountApplications

pkg/cmd/open/open.go:349–377  ·  view source on GitHub ↗
(
	client *dashboard.Client,
	accessToken string,
)

Source from the content-addressed store, hash-verified

347}
348
349func (opts *OpenOptions) fetchAccountApplications(
350 client *dashboard.Client,
351 accessToken string,
352) ([]dashboard.Application, error) {
353 listFn := opts.ListApplications
354 if listFn == nil {
355 listFn = func(c *dashboard.Client, token string) ([]dashboard.Application, error) {
356 return c.ListApplications(token)
357 }
358 }
359
360 opts.IO.StartProgressIndicatorWithLabel("Fetching applications")
361 apps, err := listFn(client, accessToken)
362 opts.IO.StopProgressIndicator()
363 if err != nil {
364 newToken, reAuthErr := auth.ReauthenticateIfExpired(opts.IO, client, err)
365 if reAuthErr != nil {
366 return nil, reAuthErr
367 }
368 opts.IO.StartProgressIndicatorWithLabel("Fetching applications")
369 apps, err = listFn(client, newToken)
370 opts.IO.StopProgressIndicator()
371 if err != nil {
372 return nil, err
373 }
374 }
375
376 return apps, nil
377}
378
379// resolveApplicationForAccount returns an application ID that belongs to the
380// signed-in account. The configured profile application is used only when it

Callers 1

Calls 4

ReauthenticateIfExpiredFunction · 0.92
ListApplicationsMethod · 0.80
StopProgressIndicatorMethod · 0.80

Tested by

no test coverage detected