diff --git a/docs/command/atlas-accessLists-list.txt b/docs/command/atlas-accessLists-list.txt index 0072343cfa..b9202c2303 100644 --- a/docs/command/atlas-accessLists-list.txt +++ b/docs/command/atlas-accessLists-list.txt @@ -45,6 +45,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-alerts-list.txt b/docs/command/atlas-alerts-list.txt index 585b6aaccc..35eaf42e42 100644 --- a/docs/command/atlas-alerts-list.txt +++ b/docs/command/atlas-alerts-list.txt @@ -45,6 +45,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-backups-exports-buckets-list.txt b/docs/command/atlas-backups-exports-buckets-list.txt index 994db5d976..390f75bcec 100644 --- a/docs/command/atlas-backups-exports-buckets-list.txt +++ b/docs/command/atlas-backups-exports-buckets-list.txt @@ -45,6 +45,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-backups-exports-jobs-list.txt b/docs/command/atlas-backups-exports-jobs-list.txt index aa7a6ae7c7..e96cada08e 100644 --- a/docs/command/atlas-backups-exports-jobs-list.txt +++ b/docs/command/atlas-backups-exports-jobs-list.txt @@ -61,6 +61,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-backups-restores-list.txt b/docs/command/atlas-backups-restores-list.txt index 4c6da9eee0..a65b122132 100644 --- a/docs/command/atlas-backups-restores-list.txt +++ b/docs/command/atlas-backups-restores-list.txt @@ -61,6 +61,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-backups-snapshots-list.txt b/docs/command/atlas-backups-snapshots-list.txt index 8cd1c17cf3..8e680ae743 100644 --- a/docs/command/atlas-backups-snapshots-list.txt +++ b/docs/command/atlas-backups-snapshots-list.txt @@ -61,6 +61,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-clusters-list.txt b/docs/command/atlas-clusters-list.txt index c796b18b51..a3aef6930d 100644 --- a/docs/command/atlas-clusters-list.txt +++ b/docs/command/atlas-clusters-list.txt @@ -45,6 +45,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-clusters-onlineArchives-list.txt b/docs/command/atlas-clusters-onlineArchives-list.txt index ed874f9d5e..4b072e882b 100644 --- a/docs/command/atlas-clusters-onlineArchives-list.txt +++ b/docs/command/atlas-clusters-onlineArchives-list.txt @@ -49,6 +49,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-dataLakePipelines-availableSnapshots-list.txt b/docs/command/atlas-dataLakePipelines-availableSnapshots-list.txt index f8d50f73df..2feb27a830 100644 --- a/docs/command/atlas-dataLakePipelines-availableSnapshots-list.txt +++ b/docs/command/atlas-dataLakePipelines-availableSnapshots-list.txt @@ -49,6 +49,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-dbusers-list.txt b/docs/command/atlas-dbusers-list.txt index d04cfa0041..622772d5e7 100644 --- a/docs/command/atlas-dbusers-list.txt +++ b/docs/command/atlas-dbusers-list.txt @@ -49,6 +49,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-metrics-databases-list.txt b/docs/command/atlas-metrics-databases-list.txt index 0699eee508..c71da7d191 100644 --- a/docs/command/atlas-metrics-databases-list.txt +++ b/docs/command/atlas-metrics-databases-list.txt @@ -64,6 +64,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-metrics-disks-list.txt b/docs/command/atlas-metrics-disks-list.txt index d402cea68e..5b10f812a5 100644 --- a/docs/command/atlas-metrics-disks-list.txt +++ b/docs/command/atlas-metrics-disks-list.txt @@ -64,6 +64,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-networking-containers-list.txt b/docs/command/atlas-networking-containers-list.txt index 648eff5637..56d5cda8f6 100644 --- a/docs/command/atlas-networking-containers-list.txt +++ b/docs/command/atlas-networking-containers-list.txt @@ -45,6 +45,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/docs/command/atlas-networking-peering-list.txt b/docs/command/atlas-networking-peering-list.txt index c79b48196b..284c302eae 100644 --- a/docs/command/atlas-networking-peering-list.txt +++ b/docs/command/atlas-networking-peering-list.txt @@ -45,6 +45,10 @@ Options - int - false - Number of items per results page, up to a maximum of 500. If you have more than 500 results, specify the --page option to change the results page. This value defaults to 100. + * - --omitCount + - + - false + - Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response. * - -o, --output - string - false diff --git a/internal/cli/atlas/accesslists/list.go b/internal/cli/atlas/accesslists/list.go index b3ce9afaf3..78271f18cb 100644 --- a/internal/cli/atlas/accesslists/list.go +++ b/internal/cli/atlas/accesslists/list.go @@ -82,6 +82,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/accesslists/list_test.go b/internal/cli/atlas/accesslists/list_test.go index 6ade9945fc..d62cf6b2e8 100644 --- a/internal/cli/atlas/accesslists/list_test.go +++ b/internal/cli/atlas/accesslists/list_test.go @@ -82,6 +82,6 @@ func TestListBuilder(t *testing.T) { t, ListBuilder(), 0, - []string{flag.ProjectID, flag.Output, flag.Page, flag.Limit}, + []string{flag.ProjectID, flag.Output, flag.Page, flag.Limit, flag.OmitCount}, ) } diff --git a/internal/cli/atlas/alerts/list.go b/internal/cli/atlas/alerts/list.go index ef8405444e..5a4465d155 100644 --- a/internal/cli/atlas/alerts/list.go +++ b/internal/cli/atlas/alerts/list.go @@ -22,6 +22,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/config" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage" "github.com/spf13/cobra" @@ -54,6 +55,11 @@ func (opts *ListOpts) Run() error { ItemsPerPage: &opts.ItemsPerPage, PageNum: &opts.PageNum, } + + if opts.OmitCount { + params.IncludeCount = pointer.Get(false) + } + if opts.status != "" { params.Status = &opts.status } @@ -94,6 +100,8 @@ func ListBuilder() *cobra.Command { } cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) + cmd.Flags().StringVar(&opts.status, flag.Status, "", usage.Status) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/alerts/list_test.go b/internal/cli/atlas/alerts/list_test.go index d35ebb8743..f9a1f98618 100644 --- a/internal/cli/atlas/alerts/list_test.go +++ b/internal/cli/atlas/alerts/list_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -22,6 +22,7 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/test" @@ -75,3 +76,12 @@ func TestList_Run(t *testing.T) { t.Log(buf.String()) test.VerifyOutputTemplate(t, listTemplate, expected) } + +func TestListBuilder(t *testing.T) { + test.CmdValidator( + t, + ListBuilder(), + 0, + []string{flag.ProjectID, flag.Output, flag.Page, flag.Limit, flag.OmitCount, flag.Status}, + ) +} diff --git a/internal/cli/atlas/backup/exports/buckets/list.go b/internal/cli/atlas/backup/exports/buckets/list.go index 7ab020e62f..3f149dbc4d 100644 --- a/internal/cli/atlas/backup/exports/buckets/list.go +++ b/internal/cli/atlas/backup/exports/buckets/list.go @@ -84,6 +84,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/backup/exports/buckets/list_test.go b/internal/cli/atlas/backup/exports/buckets/list_test.go index 48b3652b75..3fb992945b 100644 --- a/internal/cli/atlas/backup/exports/buckets/list_test.go +++ b/internal/cli/atlas/backup/exports/buckets/list_test.go @@ -72,6 +72,7 @@ func TestListBuilder(t *testing.T) { flag.Limit, flag.ProjectID, flag.Output, + flag.OmitCount, }, ) } diff --git a/internal/cli/atlas/backup/exports/jobs/list.go b/internal/cli/atlas/backup/exports/jobs/list.go index 706fedb5c5..4f10effb9e 100644 --- a/internal/cli/atlas/backup/exports/jobs/list.go +++ b/internal/cli/atlas/backup/exports/jobs/list.go @@ -88,6 +88,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/backup/exports/jobs/list_test.go b/internal/cli/atlas/backup/exports/jobs/list_test.go index f0729a14a8..bdc08e9567 100644 --- a/internal/cli/atlas/backup/exports/jobs/list_test.go +++ b/internal/cli/atlas/backup/exports/jobs/list_test.go @@ -57,6 +57,7 @@ func TestListBuilder(t *testing.T) { flag.Limit, flag.ProjectID, flag.Output, + flag.OmitCount, }, ) } diff --git a/internal/cli/atlas/backup/restores/list.go b/internal/cli/atlas/backup/restores/list.go index 127e155a54..1b85b09e2b 100644 --- a/internal/cli/atlas/backup/restores/list.go +++ b/internal/cli/atlas/backup/restores/list.go @@ -88,6 +88,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/backup/restores/list_test.go b/internal/cli/atlas/backup/restores/list_test.go index 47f21d1d91..e5dfd7fcff 100644 --- a/internal/cli/atlas/backup/restores/list_test.go +++ b/internal/cli/atlas/backup/restores/list_test.go @@ -60,6 +60,7 @@ func TestListBuilder(t *testing.T) { flag.Limit, flag.ProjectID, flag.Output, + flag.OmitCount, }, ) } diff --git a/internal/cli/atlas/backup/snapshots/list.go b/internal/cli/atlas/backup/snapshots/list.go index 4622fc67e0..051ece5d15 100644 --- a/internal/cli/atlas/backup/snapshots/list.go +++ b/internal/cli/atlas/backup/snapshots/list.go @@ -88,6 +88,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/backup/snapshots/list_test.go b/internal/cli/atlas/backup/snapshots/list_test.go index 8c2b572e56..61d8844b8f 100644 --- a/internal/cli/atlas/backup/snapshots/list_test.go +++ b/internal/cli/atlas/backup/snapshots/list_test.go @@ -22,6 +22,7 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/test" @@ -63,3 +64,18 @@ func TestList_Run(t *testing.T) { } test.VerifyOutputTemplate(t, listTemplate, expected) } + +func TestListBuilder(t *testing.T) { + test.CmdValidator( + t, + ListBuilder(), + 0, + []string{ + flag.Page, + flag.Limit, + flag.OmitCount, + flag.ProjectID, + flag.Output, + }, + ) +} diff --git a/internal/cli/atlas/clusters/list.go b/internal/cli/atlas/clusters/list.go index 176117a05f..7c1477f5c1 100644 --- a/internal/cli/atlas/clusters/list.go +++ b/internal/cli/atlas/clusters/list.go @@ -84,6 +84,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/clusters/list_test.go b/internal/cli/atlas/clusters/list_test.go index 07a70896e9..5f4297972e 100644 --- a/internal/cli/atlas/clusters/list_test.go +++ b/internal/cli/atlas/clusters/list_test.go @@ -64,6 +64,6 @@ func TestListBuilder(t *testing.T) { t, ListBuilder(), 0, - []string{flag.Limit, flag.Page, flag.Output, flag.ProjectID}, + []string{flag.Limit, flag.Page, flag.Output, flag.ProjectID, flag.OmitCount}, ) } diff --git a/internal/cli/atlas/clusters/onlinearchive/list.go b/internal/cli/atlas/clusters/onlinearchive/list.go index 9d50fc6847..8116fdb3fb 100644 --- a/internal/cli/atlas/clusters/onlinearchive/list.go +++ b/internal/cli/atlas/clusters/onlinearchive/list.go @@ -83,10 +83,11 @@ func ListBuilder() *cobra.Command { }, } - cmd.Flags().StringVar(&opts.clusterName, flag.ClusterName, "", usage.ClusterName) cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) + cmd.Flags().StringVar(&opts.clusterName, flag.ClusterName, "", usage.ClusterName) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) _ = cmd.RegisterFlagCompletionFunc(flag.Output, opts.AutoCompleteOutputFlag()) diff --git a/internal/cli/atlas/clusters/onlinearchive/list_test.go b/internal/cli/atlas/clusters/onlinearchive/list_test.go index 2a4221b57f..8dc1637b64 100644 --- a/internal/cli/atlas/clusters/onlinearchive/list_test.go +++ b/internal/cli/atlas/clusters/onlinearchive/list_test.go @@ -38,6 +38,7 @@ func TestListBuilder(t *testing.T) { flag.Limit, flag.Output, flag.ProjectID, + flag.OmitCount, }, ) } diff --git a/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go index f3a22db31e..f7dd160443 100644 --- a/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go @@ -111,6 +111,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/datalakepipelines/availablesnapshots/list_test.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/list_test.go index 568fc458a9..e004645224 100644 --- a/internal/cli/atlas/datalakepipelines/availablesnapshots/list_test.go +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/list_test.go @@ -88,6 +88,6 @@ func TestListBuilder(t *testing.T) { t, ListBuilder(), 0, - []string{flag.ProjectID, flag.Output}, + []string{flag.ProjectID, flag.Output, flag.OmitCount, flag.Page, flag.Limit, flag.CompletedAfter, flag.Pipeline}, ) } diff --git a/internal/cli/atlas/dbusers/list.go b/internal/cli/atlas/dbusers/list.go index c203e6caa3..f0450ee73e 100644 --- a/internal/cli/atlas/dbusers/list.go +++ b/internal/cli/atlas/dbusers/list.go @@ -86,6 +86,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/dbusers/list_test.go b/internal/cli/atlas/dbusers/list_test.go index f37927a314..b6ca1e91ec 100644 --- a/internal/cli/atlas/dbusers/list_test.go +++ b/internal/cli/atlas/dbusers/list_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/golang/mock/gomock" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/test" atlasv2 "go.mongodb.org/atlas-sdk/v20231115007/admin" @@ -52,3 +53,12 @@ func TestDBUserList_Run(t *testing.T) { } test.VerifyOutputTemplate(t, listTemplate, expected) } + +func TestListBuilder(t *testing.T) { + test.CmdValidator( + t, + ListBuilder(), + 0, + []string{flag.ProjectID, flag.Output, flag.OmitCount, flag.Page, flag.Limit, flag.CompactResponse}, + ) +} diff --git a/internal/cli/atlas/metrics/databases/list.go b/internal/cli/atlas/metrics/databases/list.go index fecbc45373..5a81982658 100644 --- a/internal/cli/atlas/metrics/databases/list.go +++ b/internal/cli/atlas/metrics/databases/list.go @@ -96,6 +96,8 @@ atlas processes list cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) + cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) _ = cmd.RegisterFlagCompletionFunc(flag.Output, opts.AutoCompleteOutputFlag()) diff --git a/internal/cli/atlas/metrics/databases/list_test.go b/internal/cli/atlas/metrics/databases/list_test.go index bdc1905905..7c7957c261 100644 --- a/internal/cli/atlas/metrics/databases/list_test.go +++ b/internal/cli/atlas/metrics/databases/list_test.go @@ -62,6 +62,6 @@ func TestListBuilder(t *testing.T) { t, ListBuilder(), 0, - []string{flag.Page, flag.Limit, flag.ProjectID, flag.Output}, + []string{flag.Page, flag.Limit, flag.OmitCount, flag.ProjectID, flag.Output}, ) } diff --git a/internal/cli/atlas/metrics/disks/list.go b/internal/cli/atlas/metrics/disks/list.go index 5045e0dab5..9ef994b873 100644 --- a/internal/cli/atlas/metrics/disks/list.go +++ b/internal/cli/atlas/metrics/disks/list.go @@ -97,6 +97,8 @@ $ atlas processes list cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) + cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) _ = cmd.RegisterFlagCompletionFunc(flag.Output, opts.AutoCompleteOutputFlag()) diff --git a/internal/cli/atlas/metrics/disks/list_test.go b/internal/cli/atlas/metrics/disks/list_test.go index d27279c544..04945debfd 100644 --- a/internal/cli/atlas/metrics/disks/list_test.go +++ b/internal/cli/atlas/metrics/disks/list_test.go @@ -62,6 +62,6 @@ func TestListBuilder(t *testing.T) { t, ListBuilder(), 0, - []string{flag.Page, flag.Limit, flag.ProjectID, flag.Output}, + []string{flag.Page, flag.Limit, flag.OmitCount, flag.ProjectID, flag.Output}, ) } diff --git a/internal/cli/atlas/networking/containers/list.go b/internal/cli/atlas/networking/containers/list.go index c4ab4cfd03..2c85268509 100644 --- a/internal/cli/atlas/networking/containers/list.go +++ b/internal/cli/atlas/networking/containers/list.go @@ -97,6 +97,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().StringVar(&opts.provider, flag.Provider, "", usage.Provider) cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/networking/containers/list_test.go b/internal/cli/atlas/networking/containers/list_test.go index 38502a5529..8e32688779 100644 --- a/internal/cli/atlas/networking/containers/list_test.go +++ b/internal/cli/atlas/networking/containers/list_test.go @@ -22,6 +22,7 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/test" @@ -80,3 +81,12 @@ func TestList_Run(t *testing.T) { } }) } + +func TestListBuilder(t *testing.T) { + test.CmdValidator( + t, + ListBuilder(), + 0, + []string{flag.Page, flag.Limit, flag.OmitCount, flag.ProjectID, flag.Output, flag.Provider}, + ) +} diff --git a/internal/cli/atlas/networking/peering/list.go b/internal/cli/atlas/networking/peering/list.go index 53ae43d6dd..9998bbb579 100644 --- a/internal/cli/atlas/networking/peering/list.go +++ b/internal/cli/atlas/networking/peering/list.go @@ -89,6 +89,7 @@ func ListBuilder() *cobra.Command { cmd.Flags().StringVar(&opts.provider, flag.Provider, "AWS", usage.Provider) cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + cmd.Flags().BoolVar(&opts.OmitCount, flag.OmitCount, false, usage.OmitCount) cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) diff --git a/internal/cli/atlas/networking/peering/list_test.go b/internal/cli/atlas/networking/peering/list_test.go index b044a65039..e2211da6e0 100644 --- a/internal/cli/atlas/networking/peering/list_test.go +++ b/internal/cli/atlas/networking/peering/list_test.go @@ -22,6 +22,7 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/test" @@ -63,3 +64,12 @@ func TestList_Run(t *testing.T) { test.VerifyOutputTemplate(t, listTemplate, expected) }) } + +func TestListBuilder(t *testing.T) { + test.CmdValidator( + t, + ListBuilder(), + 0, + []string{flag.Page, flag.Limit, flag.OmitCount, flag.ProjectID, flag.Output, flag.Provider}, + ) +} diff --git a/internal/cli/list_opts.go b/internal/cli/list_opts.go index 0dc5876684..fd7af611ec 100644 --- a/internal/cli/list_opts.go +++ b/internal/cli/list_opts.go @@ -34,6 +34,7 @@ func (opts *ListOpts) NewListOptions() *mongodbatlas.ListOptions { return &mongodbatlas.ListOptions{ PageNum: opts.PageNum, ItemsPerPage: opts.ItemsPerPage, + IncludeCount: !opts.OmitCount, } } @@ -41,5 +42,6 @@ func (opts *ListOpts) NewAtlasListOptions() *store.ListOptions { return &store.ListOptions{ PageNum: opts.PageNum, ItemsPerPage: opts.ItemsPerPage, + IncludeCount: !opts.OmitCount, } } diff --git a/internal/store/cloud_provider_backup.go b/internal/store/cloud_provider_backup.go index f59a21336b..b9bdb947fb 100644 --- a/internal/store/cloud_provider_backup.go +++ b/internal/store/cloud_provider_backup.go @@ -94,7 +94,7 @@ type ScheduleDeleter interface { func (s *Store) RestoreJobs(projectID, clusterName string, opts *atlas.ListOptions) (*atlasv2.PaginatedCloudBackupRestoreJob, error) { res := s.clientv2.CloudBackupsApi.ListBackupRestoreJobs(s.ctx, projectID, clusterName) if opts != nil { - res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage) + res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).IncludeCount(opts.IncludeCount) } result, _, err := res.Execute() return result, err @@ -122,7 +122,7 @@ func (s *Store) CreateSnapshot(projectID, clusterName string, request *atlasv2.D func (s *Store) Snapshots(projectID, clusterName string, opts *atlas.ListOptions) (*atlasv2.PaginatedCloudBackupReplicaSet, error) { res := s.clientv2.CloudBackupsApi.ListReplicaSetBackups(s.ctx, projectID, clusterName) if opts != nil { - res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage) + res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).IncludeCount(opts.IncludeCount) } result, _, err := res.Execute() return result, err @@ -166,7 +166,7 @@ func (s *Store) CreateExportJob(projectID, clusterName string, job *atlasv2.Disk func (s *Store) ExportBuckets(projectID string, opts *atlas.ListOptions) (*atlasv2.PaginatedBackupSnapshotExportBucket, error) { res := s.clientv2.CloudBackupsApi.ListExportBuckets(s.ctx, projectID) if opts != nil { - res = res.ItemsPerPage(opts.ItemsPerPage).PageNum(opts.PageNum) + res = res.ItemsPerPage(opts.ItemsPerPage).PageNum(opts.PageNum).IncludeCount(opts.IncludeCount) } result, _, err := res.Execute() return result, err diff --git a/internal/store/clusters.go b/internal/store/clusters.go index e45f563b92..e7815bd026 100644 --- a/internal/store/clusters.go +++ b/internal/store/clusters.go @@ -163,7 +163,7 @@ func (s *Store) UpgradeCluster(projectID string, cluster *atlas.Cluster) (*atlas func (s *Store) ProjectClusters(projectID string, opts *ListOptions) (*admin.PaginatedAdvancedClusterDescription, error) { res := s.clientv2.ClustersApi.ListClusters(s.ctx, projectID) if opts != nil { - res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage) + res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).IncludeCount(opts.IncludeCount) } result, _, err := res.Execute() return result, err diff --git a/internal/store/data_lake_pipelines.go b/internal/store/data_lake_pipelines.go index 0735d04949..372f14599a 100644 --- a/internal/store/data_lake_pipelines.go +++ b/internal/store/data_lake_pipelines.go @@ -108,8 +108,7 @@ func (s *Store) PipelineAvailableSnapshots(projectID, pipelineName string, compl request = request.CompletedAfter(*completedAfter) } if listOps != nil { - request = request.ItemsPerPage(listOps.ItemsPerPage) - request = request.PageNum(listOps.PageNum) + request = request.ItemsPerPage(listOps.ItemsPerPage).PageNum(listOps.PageNum).IncludeCount(listOps.IncludeCount) } result, _, err := request.Execute() return result, err diff --git a/internal/store/database_users.go b/internal/store/database_users.go index 8d7055be0b..25f7ca6c2c 100644 --- a/internal/store/database_users.go +++ b/internal/store/database_users.go @@ -64,7 +64,7 @@ func (s *Store) DeleteDatabaseUser(authDB, groupID, username string) error { func (s *Store) DatabaseUsers(projectID string, opts *ListOptions) (*atlasv2.PaginatedApiAtlasDatabaseUser, error) { res := s.clientv2.DatabaseUsersApi.ListDatabaseUsers(s.ctx, projectID) if opts != nil { - res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage) + res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).IncludeCount(opts.IncludeCount) } result, _, err := res.Execute() return result, err diff --git a/internal/store/online_archives.go b/internal/store/online_archives.go index 53e57433dd..6acb06719a 100644 --- a/internal/store/online_archives.go +++ b/internal/store/online_archives.go @@ -50,7 +50,7 @@ func (s *Store) OnlineArchives(projectID, clusterName string, lstOpt *atlas.List return nil, fmt.Errorf("%w: %s", errUnsupportedService, s.service) } result, _, err := s.clientv2.OnlineArchiveApi.ListOnlineArchives(s.ctx, projectID, clusterName). - PageNum(lstOpt.PageNum).ItemsPerPage(lstOpt.ItemsPerPage).Execute() + PageNum(lstOpt.PageNum).ItemsPerPage(lstOpt.ItemsPerPage).IncludeCount(lstOpt.IncludeCount).Execute() return result, err } diff --git a/internal/store/operator.go b/internal/store/operator.go index 745118aba9..feac0d8755 100644 --- a/internal/store/operator.go +++ b/internal/store/operator.go @@ -27,6 +27,7 @@ import ( type ListOptions struct { PageNum int ItemsPerPage int + IncludeCount bool } type ContainersListOptions struct { diff --git a/internal/store/peering_connections.go b/internal/store/peering_connections.go index 3656f5c14f..bf01c7c8bf 100644 --- a/internal/store/peering_connections.go +++ b/internal/store/peering_connections.go @@ -96,7 +96,7 @@ func (s *Store) CreatePeeringConnection(projectID string, peer *atlasv2.BaseNetw func (s *Store) ContainersByProvider(projectID string, opts *atlas.ContainersListOptions) ([]atlasv2.CloudProviderContainer, error) { res := s.clientv2.NetworkPeeringApi.ListPeeringContainerByCloudProvider(s.ctx, projectID) if opts != nil { - res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).ProviderName(opts.ProviderName) + res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).IncludeCount(opts.IncludeCount).ProviderName(opts.ProviderName) } result, _, err := res.Execute() if err != nil { diff --git a/internal/store/process_databases.go b/internal/store/process_databases.go index c14e77580f..6edc70b8ae 100644 --- a/internal/store/process_databases.go +++ b/internal/store/process_databases.go @@ -31,6 +31,6 @@ type ProcessDatabaseLister interface { func (s *Store) ProcessDatabases(groupID, host string, port int, opts *atlas.ListOptions) (*atlasv2.PaginatedDatabase, error) { process := host + ":" + strconv.Itoa(port) result, _, err := s.clientv2.MonitoringAndLogsApi.ListDatabases(s.ctx, groupID, process). - PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).Execute() + PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).IncludeCount(opts.IncludeCount).Execute() return result, err } diff --git a/internal/store/process_disks.go b/internal/store/process_disks.go index 1c570164b9..bb67af2629 100644 --- a/internal/store/process_disks.go +++ b/internal/store/process_disks.go @@ -31,6 +31,6 @@ type ProcessDisksLister interface { func (s *Store) ProcessDisks(groupID, host string, port int, opts *atlas.ListOptions) (*atlasv2.PaginatedDiskPartition, error) { processID := host + ":" + strconv.Itoa(port) result, _, err := s.clientv2.MonitoringAndLogsApi.ListDiskPartitions(s.ctx, groupID, processID). - ItemsPerPage(opts.ItemsPerPage).PageNum(opts.PageNum).Execute() + ItemsPerPage(opts.ItemsPerPage).PageNum(opts.PageNum).IncludeCount(opts.IncludeCount).Execute() return result, err } diff --git a/internal/store/project_ip_access_lists.go b/internal/store/project_ip_access_lists.go index 4d96030b7f..aebe6f95e9 100644 --- a/internal/store/project_ip_access_lists.go +++ b/internal/store/project_ip_access_lists.go @@ -62,7 +62,7 @@ func (s *Store) DeleteProjectIPAccessList(projectID, entry string) error { func (s *Store) ProjectIPAccessLists(projectID string, opts *ListOptions) (*atlasv2.PaginatedNetworkAccess, error) { res := s.clientv2.ProjectIPAccessListApi.ListProjectIpAccessLists(s.ctx, projectID) if opts != nil { - res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage) + res = res.PageNum(opts.PageNum).ItemsPerPage(opts.ItemsPerPage).IncludeCount(opts.IncludeCount) } result, _, err := res.Execute() return result, err