diff --git a/docs/atlascli/command/atlas-events-projects-list.txt b/docs/atlascli/command/atlas-events-projects-list.txt index a124288471..34e4aa5cd0 100644 --- a/docs/atlascli/command/atlas-events-projects-list.txt +++ b/docs/atlascli/command/atlas-events-projects-list.txt @@ -51,6 +51,10 @@ Options - string - false - Minimum created date. This option returns events whose created date is greater than or equal to the specified value. + * - --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/events/list.go b/internal/cli/atlas/events/list.go index 2ba93d033b..2e5d618315 100644 --- a/internal/cli/atlas/events/list.go +++ b/internal/cli/atlas/events/list.go @@ -111,6 +111,11 @@ func (opts *ListOpts) NewProjectListOptions() admin.ListProjectEventsApiParams { if opts.PageNum > 0 { p.PageNum = &opts.PageNum } + + if opts.OmitCount { + p.IncludeCount = pointer.Get(false) + } + return p } @@ -157,6 +162,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().StringSliceVar(&opts.EventType, flag.TypeFlag, nil, usage.Event) cmd.Flags().StringVar(&opts.MaxDate, flag.MaxDate, "", usage.MaxDate) diff --git a/internal/cli/atlas/events/list_test.go b/internal/cli/atlas/events/list_test.go index fa7917cf66..627ad60d4a 100644 --- a/internal/cli/atlas/events/list_test.go +++ b/internal/cli/atlas/events/list_test.go @@ -73,6 +73,7 @@ func TestListBuilder(t *testing.T) { []string{ flag.Limit, flag.Page, + flag.OmitCount, flag.Output, flag.ProjectID, flag.OrgID, diff --git a/internal/cli/atlas/events/projects_list.go b/internal/cli/atlas/events/projects_list.go index 1917cba425..b65cded394 100644 --- a/internal/cli/atlas/events/projects_list.go +++ b/internal/cli/atlas/events/projects_list.go @@ -78,6 +78,11 @@ func (opts *projectListOpts) NewProjectListOptions() admin.ListProjectEventsApiP if opts.PageNum > 0 { p.PageNum = &opts.PageNum } + + if opts.OmitCount { + p.IncludeCount = pointer.Get(false) + } + return p } @@ -112,6 +117,7 @@ func ProjectListBuilder() *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().StringSliceVar(&opts.EventType, flag.TypeFlag, nil, usage.Event) cmd.Flags().StringVar(&opts.MaxDate, flag.MaxDate, "", usage.MaxDate) diff --git a/internal/cli/atlas/events/projects_list_test.go b/internal/cli/atlas/events/projects_list_test.go index e1cfc2615e..f69210eb62 100644 --- a/internal/cli/atlas/events/projects_list_test.go +++ b/internal/cli/atlas/events/projects_list_test.go @@ -53,6 +53,7 @@ func TestProjectListBuilder(t *testing.T) { flag.Limit, flag.Page, flag.Output, + flag.OmitCount, flag.ProjectID, flag.TypeFlag, flag.MaxDate, diff --git a/internal/cli/list_opts.go b/internal/cli/list_opts.go index d199900edd..8713fa5537 100644 --- a/internal/cli/list_opts.go +++ b/internal/cli/list_opts.go @@ -27,6 +27,7 @@ const ( type ListOpts struct { PageNum int ItemsPerPage int + OmitCount bool } func (opts *ListOpts) NewListOptions() *mongodbatlas.ListOptions { diff --git a/internal/flag/flags.go b/internal/flag/flags.go index 4e7ce3f329..356b69959b 100644 --- a/internal/flag/flags.go +++ b/internal/flag/flags.go @@ -113,6 +113,7 @@ const ( Until = "until" // Until flag Page = "page" // Page flag Limit = "limit" // Limit flag + OmitCount = "omitCount" // OmitCount flag File = "file" // File flag FileShort = "f" // File flag Force = "force" // Force flag diff --git a/internal/usage/usage.go b/internal/usage/usage.go index db04cae075..d58e01e416 100644 --- a/internal/usage/usage.go +++ b/internal/usage/usage.go @@ -50,6 +50,7 @@ const ( Until = "ISO 8601-formatted time until which the alert is acknowledged. This command returns this value if a MongoDB user previously acknowledged the alert. After this date, the alert becomes unacknowledged." ConnectionStringType = "Type of connection string. If you specify 'private', this option retrieves the connection string for the network peering endpoint. This value defaults to 'standard'." Limit = "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." + OmitCount = "Flag that indicates whether the JSON response returns the total number of items (totalCount) in the JSON response." Username = "Name that identifies the user. You must specify a valid email address." BackupStatus = "Status of the backup configuration." StorageEngine = "Storage engine for the backup."