From 633f745f226e9bfea02928bd7f129a7a9f8022d7 Mon Sep 17 00:00:00 2001 From: Aditya Kajla Date: Fri, 5 Jan 2024 13:28:57 -0800 Subject: [PATCH] Change objecttype list cmd back to returning array of types + add pagination for objecttypes --- internal/cmd/objecttype.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/cmd/objecttype.go b/internal/cmd/objecttype.go index 1aa1659..1cf30cd 100644 --- a/internal/cmd/objecttype.go +++ b/internal/cmd/objecttype.go @@ -64,9 +64,21 @@ warrant objecttype list`, WarrantToken: listObjecttypeWarrantToken, } } - types, err := objecttype.ListObjectTypes(listParams) - if err != nil { - return err + + // Fetch all objecttypes (paginate if necessary) + var types []warrant.ObjectType + for { + typesResp, err := objecttype.ListObjectTypes(listParams) + if err != nil { + return err + } + types = append(types, typesResp.Results...) + + if typesResp.NextCursor == "" { + break + } else { + listParams.NextCursor = typesResp.NextCursor + } } printer.PrintJson(types)