From 7da0940ae1c2ff00ba8f47714572a9b9fd13794b Mon Sep 17 00:00:00 2001 From: Vivek Patel Date: Fri, 16 Sep 2022 11:02:33 +0530 Subject: [PATCH] Add IncTotal param support to all resource List API - Updates rdbms.go.tpl to extends store search method to include total in response --- automation/rest.yaml | 2 + automation/rest/request/session.go | 17 + automation/rest/request/workflow.go | 17 + automation/rest/session.go | 2 + automation/rest/workflow.go | 2 + .../templates/gocode/store/rdbms/rdbms.go.tpl | 20 + compose/rest.yaml | 9 + compose/rest/chart.go | 2 + compose/rest/module.go | 2 + compose/rest/namespace.go | 2 + compose/rest/request/chart.go | 17 + compose/rest/request/module.go | 17 + compose/rest/request/namespace.go | 17 + store/adapters/rdbms/rdbms.gen.go | 513 ++++++++++++++++++ system/rest.yaml | 31 +- system/rest/apigw_route.go | 2 + system/rest/application.go | 2 + system/rest/auth_client.go | 2 + system/rest/dal_connection.go | 2 + system/rest/queues.go | 2 + system/rest/report.go | 2 + system/rest/request/apigwRoute.go | 17 + system/rest/request/application.go | 17 + system/rest/request/authClient.go | 17 + system/rest/request/dalConnection.go | 17 + system/rest/request/queues.go | 17 + system/rest/request/report.go | 17 + system/rest/request/role.go | 17 + system/rest/request/template.go | 17 + system/rest/request/user.go | 17 + system/rest/role.go | 3 +- system/rest/template.go | 2 + system/rest/user.go | 2 + 33 files changed, 836 insertions(+), 6 deletions(-) diff --git a/automation/rest.yaml b/automation/rest.yaml index 194e336c1..03b52b631 100644 --- a/automation/rest.yaml +++ b/automation/rest.yaml @@ -27,6 +27,7 @@ endpoints: - { name: disabled, type: "uint", title: "Exclude (0, default), include (1) or return only (2) disabled workflows" } - { name: labels, type: "map[string]string", title: "Labels", parser: "label.ParseStrings" } - { name: limit, type: "uint", title: "Limit" } + - { name: incTotal, type: "bool", title: "Include total rows counter" } - { name: pageCursor, type: "string", title: "Page cursor" } - { name: sort, type: "string", title: "Sort items" } - name: create @@ -199,6 +200,7 @@ endpoints: - { name: eventType, type: "string", title: "Filter event type" } - { name: resourceType, type: "string", title: "Filter resource type" } - { name: limit, type: "uint", title: "Limit" } + - { name: incTotal, type: "bool", title: "Include total rows counter" } - { name: pageCursor, type: "string", title: "Page cursor" } - { name: sort, type: "string", title: "Sort items" } - name: read diff --git a/automation/rest/request/session.go b/automation/rest/request/session.go index eb1706aac..dabdce329 100644 --- a/automation/rest/request/session.go +++ b/automation/rest/request/session.go @@ -76,6 +76,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total rows counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -138,6 +143,7 @@ func (r SessionList) Auditable() map[string]interface{} { "eventType": r.EventType, "resourceType": r.ResourceType, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -183,6 +189,11 @@ func (r SessionList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r SessionList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r SessionList) GetPageCursor() string { return r.PageCursor @@ -268,6 +279,12 @@ func (r *SessionList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/automation/rest/request/workflow.go b/automation/rest/request/workflow.go index bc8109e8a..16525e04e 100644 --- a/automation/rest/request/workflow.go +++ b/automation/rest/request/workflow.go @@ -67,6 +67,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total rows counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -282,6 +287,7 @@ func (r WorkflowList) Auditable() map[string]interface{} { "disabled": r.Disabled, "labels": r.Labels, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -317,6 +323,11 @@ func (r WorkflowList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r WorkflowList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r WorkflowList) GetPageCursor() string { return r.PageCursor @@ -380,6 +391,12 @@ func (r *WorkflowList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/automation/rest/session.go b/automation/rest/session.go index 401d1cd8e..e2b09853f 100644 --- a/automation/rest/session.go +++ b/automation/rest/session.go @@ -67,6 +67,8 @@ func (ctrl Session) List(ctx context.Context, r *request.SessionList) (interface return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/automation/rest/workflow.go b/automation/rest/workflow.go index 423da34b8..7407dcd80 100644 --- a/automation/rest/workflow.go +++ b/automation/rest/workflow.go @@ -95,6 +95,8 @@ func (ctrl Workflow) List(ctx context.Context, r *request.WorkflowList) (interfa return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/codegen/assets/templates/gocode/store/rdbms/rdbms.go.tpl b/codegen/assets/templates/gocode/store/rdbms/rdbms.go.tpl index fa5b27b3b..5fb22e780 100644 --- a/codegen/assets/templates/gocode/store/rdbms/rdbms.go.tpl +++ b/codegen/assets/templates/gocode/store/rdbms/rdbms.go.tpl @@ -162,6 +162,26 @@ func (s *Store) Search{{ .expIdentPlural }}(ctx context.Context, {{ template "ex if err != nil { return nil, f, err } + + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet {{ .goSetType }} + if navSet, _, _, err = s.fetchFullPageOf{{ .expIdentPlural }}(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + {{ else }} set, _, err = s.Query{{ .expIdentPlural }}(ctx, f) if err != nil { diff --git a/compose/rest.yaml b/compose/rest.yaml index e43685ed5..d26214be0 100644 --- a/compose/rest.yaml +++ b/compose/rest.yaml @@ -33,6 +33,9 @@ endpoints: - type: uint name: limit title: Limit + - type: bool + name: incTotal + title: Include total counter - type: map[string]string name: labels title: Labels @@ -532,6 +535,9 @@ endpoints: - type: uint name: limit title: Limit + - type: bool + name: incTotal + title: Include total counter - type: string name: pageCursor title: Page cursor @@ -943,6 +949,9 @@ endpoints: - type: uint name: limit title: Limit + - type: bool + name: incTotal + title: Include total counter - type: string name: pageCursor title: Page cursor diff --git a/compose/rest/chart.go b/compose/rest/chart.go index 3b30c7738..cb5d70170 100644 --- a/compose/rest/chart.go +++ b/compose/rest/chart.go @@ -73,6 +73,8 @@ func (ctrl Chart) List(ctx context.Context, r *request.ChartList) (interface{}, return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/compose/rest/module.go b/compose/rest/module.go index 705989cae..52a6a57d8 100644 --- a/compose/rest/module.go +++ b/compose/rest/module.go @@ -83,6 +83,8 @@ func (ctrl *Module) List(ctx context.Context, r *request.ModuleList) (interface{ return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/compose/rest/namespace.go b/compose/rest/namespace.go index a64ea5d6e..724ee606c 100644 --- a/compose/rest/namespace.go +++ b/compose/rest/namespace.go @@ -106,6 +106,8 @@ func (ctrl Namespace) List(ctx context.Context, r *request.NamespaceList) (inter return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/compose/rest/request/chart.go b/compose/rest/request/chart.go index 6afef7f8b..991209776 100644 --- a/compose/rest/request/chart.go +++ b/compose/rest/request/chart.go @@ -63,6 +63,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -205,6 +210,7 @@ func (r ChartList) Auditable() map[string]interface{} { "handle": r.Handle, "labels": r.Labels, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -235,6 +241,11 @@ func (r ChartList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r ChartList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r ChartList) GetPageCursor() string { return r.PageCursor @@ -281,6 +292,12 @@ func (r *ChartList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/compose/rest/request/module.go b/compose/rest/request/module.go index bb15560f4..df7111b5d 100644 --- a/compose/rest/request/module.go +++ b/compose/rest/request/module.go @@ -64,6 +64,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -253,6 +258,7 @@ func (r ModuleList) Auditable() map[string]interface{} { "name": r.Name, "handle": r.Handle, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "labels": r.Labels, "sort": r.Sort, @@ -284,6 +290,11 @@ func (r ModuleList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r ModuleList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r ModuleList) GetPageCursor() string { return r.PageCursor @@ -330,6 +341,12 @@ func (r *ModuleList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/compose/rest/request/namespace.go b/compose/rest/request/namespace.go index d8d190339..bbcb3aa08 100644 --- a/compose/rest/request/namespace.go +++ b/compose/rest/request/namespace.go @@ -53,6 +53,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // Labels GET parameter // // Labels @@ -260,6 +265,7 @@ func (r NamespaceList) Auditable() map[string]interface{} { "query": r.Query, "slug": r.Slug, "limit": r.Limit, + "incTotal": r.IncTotal, "labels": r.Labels, "pageCursor": r.PageCursor, "sort": r.Sort, @@ -281,6 +287,11 @@ func (r NamespaceList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r NamespaceList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r NamespaceList) GetLabels() map[string]string { return r.Labels @@ -321,6 +332,12 @@ func (r *NamespaceList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["labels[]"]; ok { r.Labels, err = label.ParseStrings(val) if err != nil { diff --git a/store/adapters/rdbms/rdbms.gen.go b/store/adapters/rdbms/rdbms.gen.go index 90fdf11a8..6c8cab874 100644 --- a/store/adapters/rdbms/rdbms.gen.go +++ b/store/adapters/rdbms/rdbms.gen.go @@ -488,6 +488,25 @@ func (s *Store) SearchApigwFilters(ctx context.Context, f systemType.ApigwFilter return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.ApigwFilterSet + if navSet, _, _, err = s.fetchFullPageOfApigwFilters(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -1024,6 +1043,25 @@ func (s *Store) SearchApigwRoutes(ctx context.Context, f systemType.ApigwRouteFi return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.ApigwRouteSet + if navSet, _, _, err = s.fetchFullPageOfApigwRoutes(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -1564,6 +1602,25 @@ func (s *Store) SearchApplications(ctx context.Context, f systemType.Application return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.ApplicationSet + if navSet, _, _, err = s.fetchFullPageOfApplications(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -2059,6 +2116,25 @@ func (s *Store) SearchAttachments(ctx context.Context, f systemType.AttachmentFi return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.AttachmentSet + if navSet, _, _, err = s.fetchFullPageOfAttachments(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -2549,6 +2625,25 @@ func (s *Store) SearchAuthClients(ctx context.Context, f systemType.AuthClientFi return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.AuthClientSet + if navSet, _, _, err = s.fetchFullPageOfAuthClients(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -4109,6 +4204,25 @@ func (s *Store) SearchAutomationSessions(ctx context.Context, f automationType.S return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet automationType.SessionSet + if navSet, _, _, err = s.fetchFullPageOfAutomationSessions(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -4614,6 +4728,25 @@ func (s *Store) SearchAutomationTriggers(ctx context.Context, f automationType.T return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet automationType.TriggerSet + if navSet, _, _, err = s.fetchFullPageOfAutomationTriggers(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -5115,6 +5248,25 @@ func (s *Store) SearchAutomationWorkflows(ctx context.Context, f automationType. return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet automationType.WorkflowSet + if navSet, _, _, err = s.fetchFullPageOfAutomationWorkflows(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -5678,6 +5830,25 @@ func (s *Store) SearchComposeAttachments(ctx context.Context, f composeType.Atta return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet composeType.AttachmentSet + if navSet, _, _, err = s.fetchFullPageOfComposeAttachments(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -6172,6 +6343,25 @@ func (s *Store) SearchComposeCharts(ctx context.Context, f composeType.ChartFilt return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet composeType.ChartSet + if navSet, _, _, err = s.fetchFullPageOfComposeCharts(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -6707,6 +6897,25 @@ func (s *Store) SearchComposeModules(ctx context.Context, f composeType.ModuleFi return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet composeType.ModuleSet + if navSet, _, _, err = s.fetchFullPageOfComposeModules(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -7692,6 +7901,25 @@ func (s *Store) SearchComposeNamespaces(ctx context.Context, f composeType.Names return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet composeType.NamespaceSet + if navSet, _, _, err = s.fetchFullPageOfComposeNamespaces(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -8252,6 +8480,25 @@ func (s *Store) SearchComposePages(ctx context.Context, f composeType.PageFilter return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet composeType.PageSet + if navSet, _, _, err = s.fetchFullPageOfComposePages(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -9828,6 +10075,25 @@ func (s *Store) SearchDataPrivacyRequests(ctx context.Context, f systemType.Data return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.DataPrivacyRequestSet + if navSet, _, _, err = s.fetchFullPageOfDataPrivacyRequests(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -10328,6 +10594,25 @@ func (s *Store) SearchDataPrivacyRequestComments(ctx context.Context, f systemTy return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.DataPrivacyRequestCommentSet + if navSet, _, _, err = s.fetchFullPageOfDataPrivacyRequestComments(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -10772,6 +11057,25 @@ func (s *Store) SearchFederationExposedModules(ctx context.Context, f federation return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet federationType.ExposedModuleSet + if navSet, _, _, err = s.fetchFullPageOfFederationExposedModules(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -11269,6 +11573,25 @@ func (s *Store) SearchFederationModuleMappings(ctx context.Context, f federation return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet federationType.ModuleMappingSet + if navSet, _, _, err = s.fetchFullPageOfFederationModuleMappings(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -12202,6 +12525,25 @@ func (s *Store) SearchFederationNodeSyncs(ctx context.Context, f federationType. return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet federationType.NodeSyncSet + if navSet, _, _, err = s.fetchFullPageOfFederationNodeSyncs(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -12738,6 +13080,25 @@ func (s *Store) SearchFederationSharedModules(ctx context.Context, f federationT return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet federationType.SharedModuleSet + if navSet, _, _, err = s.fetchFullPageOfFederationSharedModules(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -13848,6 +14209,25 @@ func (s *Store) SearchQueues(ctx context.Context, f systemType.QueueFilter) (set return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.QueueSet + if navSet, _, _, err = s.fetchFullPageOfQueues(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -14378,6 +14758,25 @@ func (s *Store) SearchQueueMessages(ctx context.Context, f systemType.QueueMessa return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.QueueMessageSet + if navSet, _, _, err = s.fetchFullPageOfQueueMessages(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -15064,6 +15463,25 @@ func (s *Store) SearchReminders(ctx context.Context, f systemType.ReminderFilter return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.ReminderSet + if navSet, _, _, err = s.fetchFullPageOfReminders(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -15563,6 +15981,25 @@ func (s *Store) SearchReports(ctx context.Context, f systemType.ReportFilter) (s return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.ReportSet + if navSet, _, _, err = s.fetchFullPageOfReports(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -16364,6 +16801,25 @@ func (s *Store) SearchResourceTranslations(ctx context.Context, f systemType.Res return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.ResourceTranslationSet + if navSet, _, _, err = s.fetchFullPageOfResourceTranslations(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -16837,6 +17293,25 @@ func (s *Store) SearchRoles(ctx context.Context, f systemType.RoleFilter) (set s return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.RoleSet + if navSet, _, _, err = s.fetchFullPageOfRoles(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -18016,6 +18491,25 @@ func (s *Store) SearchTemplates(ctx context.Context, f systemType.TemplateFilter return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.TemplateSet + if navSet, _, _, err = s.fetchFullPageOfTemplates(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } @@ -18589,6 +19083,25 @@ func (s *Store) SearchUsers(ctx context.Context, f systemType.UserFilter) (set s return nil, f, err } + if f.IncTotal { + // Calc total from the number of items fetched + // even if we do build the page navigation + f.Total = uint(len(set)) + + if f.Limit > 0 && uint(len(set)) == f.Limit { + // there are fewer items fetched then requested limit + limit := f.Limit + f.Limit = 0 + var navSet systemType.UserSet + if navSet, _, _, err = s.fetchFullPageOfUsers(ctx, f, sort); err != nil { + return + } else { + f.Total = uint(len(navSet)) + f.Limit = limit + } + } + } + return set, f, nil } diff --git a/system/rest.yaml b/system/rest.yaml index 033e73d2c..5c0d00a22 100644 --- a/system/rest.yaml +++ b/system/rest.yaml @@ -51,6 +51,9 @@ endpoints: - type: uint name: limit title: Limit + - type: bool + name: incTotal + title: Include total counter - type: string name: pageCursor title: Page cursor @@ -233,6 +236,7 @@ endpoints: - { type: "uint", name: "archived", title: "Exclude (0, default), include (1) or return only (2) archived roles" } - { type: "map[string]string", name: "labels", title: "Labels", parser: "label.ParseStrings" } - { type: "uint", name: "limit", title: "Limit" } + - { name: "incTotal", type: "bool", title: "Include total counter" } - { type: "string", name: "pageCursor", title: "Page cursor" } - { type: "string", name: "sort", title: "Sort items" } - name: create @@ -478,6 +482,9 @@ endpoints: - type: uint name: limit title: Limit + - type: bool + name: incTotal + title: Include total counter - type: string name: pageCursor title: Page cursor @@ -852,6 +859,9 @@ endpoints: - name: deleted title: Exclude (0, default), include (1) or return only (2) deleted connections type: uint + - type: bool + name: incTotal + title: Include total counter - name: create method: POST title: Create connection @@ -934,6 +944,9 @@ endpoints: - type: uint name: limit title: Limit + - type: bool + name: incTotal + title: Include total counter - type: string name: pageCursor title: Page cursor @@ -1470,6 +1483,9 @@ endpoints: - name: limit type: uint title: Limit + - type: bool + name: incTotal + title: Include total counter - name: pageCursor type: string title: Page cursor @@ -1637,6 +1653,9 @@ endpoints: - type: uint name: limit title: Limit + - type: bool + name: incTotal + title: Include total counter - type: string name: pageCursor title: Page cursor @@ -1845,11 +1864,12 @@ endpoints: path: "/" parameters: get: - - { type: string, name: query, required: false, title: Search query } - - { type: uint, name: limit, required: false, title: Limit } - - { type: string, name: pageCursor, required: false, title: Page cursor } - - { type: string, name: sort, required: false, title: Sort items } - - { type: uint, name: deleted, required: false, title: Exclude (0, default), include (1) or return only (2) deleted queues } + - { type: string, name: query, title: Search query } + - { type: uint, name: limit, title: Limit } + - { type: bool, name: incTotal, title: Include total counter } + - { type: string, name: pageCursor, title: Page cursor } + - { type: string, name: sort, title: Sort items } + - { type: uint, name: deleted, title: Exclude (0, default), include (1) or return only (2) deleted queues } - name: create method: POST title: Create messaging queue @@ -1912,6 +1932,7 @@ endpoints: - { name: disabled, type: "uint64", title: "Exclude (0, default), include (1) or return only (2) disabled routes" } - { name: labels, type: "map[string]string", title: "Labels", parser: "label.ParseStrings" } - { name: limit, type: "uint", title: "Limit" } + - { name: incTotal, type: "bool", title: "Include total counter" } - { name: pageCursor, type: "string", title: "Page cursor" } - { name: sort, type: "string", title: "Sort items" } - name: create diff --git a/system/rest/apigw_route.go b/system/rest/apigw_route.go index 53365b485..0d498393f 100644 --- a/system/rest/apigw_route.go +++ b/system/rest/apigw_route.go @@ -71,6 +71,8 @@ func (ctrl *ApigwRoute) List(ctx context.Context, r *request.ApigwRouteList) (in return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/system/rest/application.go b/system/rest/application.go index f8b3e3a94..e0302f3ab 100644 --- a/system/rest/application.go +++ b/system/rest/application.go @@ -84,6 +84,8 @@ func (ctrl *Application) List(ctx context.Context, r *request.ApplicationList) ( return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/system/rest/auth_client.go b/system/rest/auth_client.go index 8c5b9ef8e..d8f350ac5 100644 --- a/system/rest/auth_client.go +++ b/system/rest/auth_client.go @@ -77,6 +77,8 @@ func (ctrl *AuthClient) List(ctx context.Context, r *request.AuthClientList) (in return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/system/rest/dal_connection.go b/system/rest/dal_connection.go index c166e1ab7..1b5d395b6 100644 --- a/system/rest/dal_connection.go +++ b/system/rest/dal_connection.go @@ -92,6 +92,8 @@ func (ctrl DalConnection) List(ctx context.Context, r *request.DalConnectionList f.Deleted = filter.StateInclusive } + f.IncTotal = r.IncTotal + dalConnections, err = ctrl.collectConnections(ctx, f) if err != nil { return nil, err diff --git a/system/rest/queues.go b/system/rest/queues.go index ee095941d..22059f98a 100644 --- a/system/rest/queues.go +++ b/system/rest/queues.go @@ -67,6 +67,8 @@ func (ctrl *Queue) List(ctx context.Context, r *request.QueuesList) (interface{} return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/system/rest/report.go b/system/rest/report.go index f639b74f1..cca2389e5 100644 --- a/system/rest/report.go +++ b/system/rest/report.go @@ -81,6 +81,8 @@ func (ctrl *Report) List(ctx context.Context, r *request.ReportList) (interface{ return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/system/rest/request/apigwRoute.go b/system/rest/request/apigwRoute.go index d1ce4cbbf..1830abe0e 100644 --- a/system/rest/request/apigwRoute.go +++ b/system/rest/request/apigwRoute.go @@ -66,6 +66,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -172,6 +177,7 @@ func (r ApigwRouteList) Auditable() map[string]interface{} { "disabled": r.Disabled, "labels": r.Labels, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -207,6 +213,11 @@ func (r ApigwRouteList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r ApigwRouteList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r ApigwRouteList) GetPageCursor() string { return r.PageCursor @@ -270,6 +281,12 @@ func (r *ApigwRouteList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/system/rest/request/application.go b/system/rest/request/application.go index 598cde4ee..64d434007 100644 --- a/system/rest/request/application.go +++ b/system/rest/request/application.go @@ -71,6 +71,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -258,6 +263,7 @@ func (r ApplicationList) Auditable() map[string]interface{} { "flags": r.Flags, "incFlags": r.IncFlags, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -298,6 +304,11 @@ func (r ApplicationList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r ApplicationList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r ApplicationList) GetPageCursor() string { return r.PageCursor @@ -367,6 +378,12 @@ func (r *ApplicationList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/system/rest/request/authClient.go b/system/rest/request/authClient.go index 2808794b6..7e80f3598 100644 --- a/system/rest/request/authClient.go +++ b/system/rest/request/authClient.go @@ -57,6 +57,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -235,6 +240,7 @@ func (r AuthClientList) Auditable() map[string]interface{} { "deleted": r.Deleted, "labels": r.Labels, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -260,6 +266,11 @@ func (r AuthClientList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r AuthClientList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r AuthClientList) GetPageCursor() string { return r.PageCursor @@ -306,6 +317,12 @@ func (r *AuthClientList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/system/rest/request/dalConnection.go b/system/rest/request/dalConnection.go index 800b2fb39..1e8e03255 100644 --- a/system/rest/request/dalConnection.go +++ b/system/rest/request/dalConnection.go @@ -54,6 +54,11 @@ type ( // // Exclude (0, default), include (1) or return only (2) deleted connections Deleted uint + + // IncTotal GET parameter + // + // Include total counter + IncTotal bool } DalConnectionCreate struct { @@ -139,6 +144,7 @@ func (r DalConnectionList) Auditable() map[string]interface{} { "handle": r.Handle, "type": r.Type, "deleted": r.Deleted, + "incTotal": r.IncTotal, } } @@ -162,6 +168,11 @@ func (r DalConnectionList) GetDeleted() uint { return r.Deleted } +// Auditable returns all auditable/loggable parameters +func (r DalConnectionList) GetIncTotal() bool { + return r.IncTotal +} + // Fill processes request and fills internal variables func (r *DalConnectionList) Fill(req *http.Request) (err error) { @@ -198,6 +209,12 @@ func (r *DalConnectionList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } } return err diff --git a/system/rest/request/queues.go b/system/rest/request/queues.go index 20a3bcbae..3d5f112e7 100644 --- a/system/rest/request/queues.go +++ b/system/rest/request/queues.go @@ -45,6 +45,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -132,6 +137,7 @@ func (r QueuesList) Auditable() map[string]interface{} { return map[string]interface{}{ "query": r.Query, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, "deleted": r.Deleted, @@ -148,6 +154,11 @@ func (r QueuesList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r QueuesList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r QueuesList) GetPageCursor() string { return r.PageCursor @@ -182,6 +193,12 @@ func (r *QueuesList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/system/rest/request/report.go b/system/rest/request/report.go index e45a0b5fc..fcd63097b 100644 --- a/system/rest/request/report.go +++ b/system/rest/request/report.go @@ -57,6 +57,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -200,6 +205,7 @@ func (r ReportList) Auditable() map[string]interface{} { "deleted": r.Deleted, "labels": r.Labels, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -225,6 +231,11 @@ func (r ReportList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r ReportList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r ReportList) GetPageCursor() string { return r.PageCursor @@ -271,6 +282,12 @@ func (r *ReportList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/system/rest/request/role.go b/system/rest/request/role.go index 05edec3df..9933b8c13 100644 --- a/system/rest/request/role.go +++ b/system/rest/request/role.go @@ -66,6 +66,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -270,6 +275,7 @@ func (r RoleList) Auditable() map[string]interface{} { "archived": r.Archived, "labels": r.Labels, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -305,6 +311,11 @@ func (r RoleList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r RoleList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r RoleList) GetPageCursor() string { return r.PageCursor @@ -363,6 +374,12 @@ func (r *RoleList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/system/rest/request/template.go b/system/rest/request/template.go index 695571e87..bc150c518 100644 --- a/system/rest/request/template.go +++ b/system/rest/request/template.go @@ -76,6 +76,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -244,6 +249,7 @@ func (r TemplateList) Auditable() map[string]interface{} { "deleted": r.Deleted, "labels": r.Labels, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -289,6 +295,11 @@ func (r TemplateList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r TemplateList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r TemplateList) GetPageCursor() string { return r.PageCursor @@ -359,6 +370,12 @@ func (r *TemplateList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/system/rest/request/user.go b/system/rest/request/user.go index 00e2137d5..dbf93d12b 100644 --- a/system/rest/request/user.go +++ b/system/rest/request/user.go @@ -101,6 +101,11 @@ type ( // Limit Limit uint + // IncTotal GET parameter + // + // Include total counter + IncTotal bool + // PageCursor GET parameter // // Page cursor @@ -345,6 +350,7 @@ func (r UserList) Auditable() map[string]interface{} { "suspended": r.Suspended, "labels": r.Labels, "limit": r.Limit, + "incTotal": r.IncTotal, "pageCursor": r.PageCursor, "sort": r.Sort, } @@ -415,6 +421,11 @@ func (r UserList) GetLimit() uint { return r.Limit } +// Auditable returns all auditable/loggable parameters +func (r UserList) GetIncTotal() bool { + return r.IncTotal +} + // Auditable returns all auditable/loggable parameters func (r UserList) GetPageCursor() string { return r.PageCursor @@ -525,6 +536,12 @@ func (r *UserList) Fill(req *http.Request) (err error) { return err } } + if val, ok := tmp["incTotal"]; ok && len(val) > 0 { + r.IncTotal, err = payload.ParseBool(val[0]), nil + if err != nil { + return err + } + } if val, ok := tmp["pageCursor"]; ok && len(val) > 0 { r.PageCursor, err = val[0], nil if err != nil { diff --git a/system/rest/role.go b/system/rest/role.go index 46adad0d2..77874d5e3 100644 --- a/system/rest/role.go +++ b/system/rest/role.go @@ -2,7 +2,6 @@ package rest import ( "context" - "github.com/cortezaproject/corteza-server/pkg/api" "github.com/cortezaproject/corteza-server/pkg/auth" "github.com/cortezaproject/corteza-server/pkg/corredor" @@ -80,6 +79,8 @@ func (ctrl Role) List(ctx context.Context, r *request.RoleList) (interface{}, er return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/system/rest/template.go b/system/rest/template.go index 9907a7e95..284d6cbdc 100644 --- a/system/rest/template.go +++ b/system/rest/template.go @@ -85,6 +85,8 @@ func (ctrl *Template) List(ctx context.Context, r *request.TemplateList) (interf return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err } diff --git a/system/rest/user.go b/system/rest/user.go index b4090bd80..599127749 100644 --- a/system/rest/user.go +++ b/system/rest/user.go @@ -101,6 +101,8 @@ func (ctrl User) List(ctx context.Context, r *request.UserList) (interface{}, er return nil, err } + f.IncTotal = r.IncTotal + if f.Sorting, err = filter.NewSorting(r.Sort); err != nil { return nil, err }