Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions internal/commands/fastedge/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func outputMap(m *map[string]string, title string) {
}

func getAppIdByName(appName string) (int64, error) {
idRsp, err := client.GetAppIdByNameWithResponse(context.Background(), appName)
idRsp, err := client.ListAppsWithResponse(context.Background(), &sdk.ListAppsParams{Name: &appName})
if err != nil {
return 0, fmt.Errorf("api response: %w", err)
}
Expand All @@ -457,5 +457,25 @@ func getAppIdByName(appName string) (int64, error) {
if idRsp.JSON200 == nil {
return 0, fmt.Errorf("app '%s' not found", appName)
}
return *idRsp.JSON200, nil
if len(idRsp.JSON200.Apps) != 1 {
return 0, fmt.Errorf("app '%s' not found", appName)
}
return idRsp.JSON200.Apps[0].Id, nil
}

func getAppByName(appName string) (sdk.AppShort, error) {
idRsp, err := client.ListAppsWithResponse(context.Background(), &sdk.ListAppsParams{Name: &appName})
if err != nil {
return sdk.AppShort{}, fmt.Errorf("api response: %w", err)
}
if idRsp.StatusCode() != http.StatusOK {
return sdk.AppShort{}, fmt.Errorf("%s", string(idRsp.Body))
}
if idRsp.JSON200 == nil {
return sdk.AppShort{}, fmt.Errorf("app '%s' not found", appName)
}
if len(idRsp.JSON200.Apps) != 1 {
return sdk.AppShort{}, fmt.Errorf("app '%s' not found", appName)
}
return idRsp.JSON200.Apps[0], nil
}
22 changes: 13 additions & 9 deletions internal/commands/fastedge/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ This command allows you filtering by edge name, client ip and time range.`,

if rsp.JSON200.Logs != nil {
printLogs(rsp.JSON200.Logs)
for *rsp.JSON200.CurrentPage < *rsp.JSON200.TotalPages {
fmt.Printf("Displaying %d/%d logs, load next page? (Y/n) ", *rsp.JSON200.CurrentPage**rsp.JSON200.PageSize, *rsp.JSON200.TotalPages**rsp.JSON200.PageSize)
for *rsp.JSON200.Offset < *rsp.JSON200.TotalCount {
fmt.Printf("Displaying %d/%d logs, load next page? (Y/n) ", *rsp.JSON200.Offset, *rsp.JSON200.TotalCount)
text, _ := reader.ReadString('\n')
text = strings.ToLower(strings.TrimSpace(text))

Expand All @@ -139,19 +139,23 @@ This command allows you filtering by edge name, client ip and time range.`,
fmt.Print("\033[2K\033[1A\033[2K\033[1A\n")

// Increment the page number
page := int64(*rsp.JSON200.CurrentPage + 1)
var (
offset = int32(*rsp.JSON200.Offset + 25)
limit = int32(25)
)

// Call the API again with the new page number
rsp, err = client.GetV1AppsIdLogsWithResponse(
context.Background(),
id,
&sdk.GetV1AppsIdLogsParams{
From: &from,
To: &to,
Edge: edge,
Sort: sort,
ClientIp: clientIp,
CurrentPage: &page,
From: &from,
To: &to,
Edge: edge,
Sort: sort,
ClientIp: clientIp,
Offset: &offset,
Limit: &limit,
},
)
if err != nil {
Expand Down