• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb / mongodb-atlas-cli / 26228926989

21 May 2026 01:27PM UTC coverage: 22.63% (-41.6%) from 64.198%
26228926989

push

github

apix-bot[bot]
Update compliance report for v1.55.0

8987 of 39713 relevant lines covered (22.63%)

0.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.0
/internal/cli/datafederation/querylimits/list.go
1
// Copyright 2023 MongoDB Inc
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
// This code was autogenerated at 2023-06-23T15:50:54+01:00. Note: Manual updates are allowed, but may be overwritten.
16

17
package querylimits
18

19
import (
20
        "context"
21
        "fmt"
22

23
        "github.com/mongodb/atlas-cli-core/config"
24
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
25
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require"
26
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag"
27
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store"
28
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage"
29
        "github.com/spf13/cobra"
30
        atlasv2 "go.mongodb.org/atlas-sdk/v20250312018/admin"
31
)
32

33
var listTemplate = `TENANT NAME        NAME        VALUE{{range valueOrEmptySlice .}}
34
{{.TenantName}}        {{.Name}}        {{.Value}}
35
{{end}}
36
`
37

38
//go:generate go tool go.uber.org/mock/mockgen -typed -destination=list_mock_test.go -package=querylimits -source=list.go
39

40
type DataFederationQueryLimitLister interface {
41
        DataFederationQueryLimits(string, string) ([]atlasv2.DataFederationTenantQueryLimit, error)
42
}
43

44
type ListOpts struct {
45
        cli.ProjectOpts
46
        cli.OutputOpts
47
        store      DataFederationQueryLimitLister
48
        tenantName string
49
}
50

51
func (opts *ListOpts) initStore(ctx context.Context) func() error {
×
52
        return func() error {
×
53
                var err error
×
54
                opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx))
×
55
                return err
×
56
        }
×
57
}
58

59
func (opts *ListOpts) Run() error {
1✔
60
        r, err := opts.store.DataFederationQueryLimits(opts.ConfigProjectID(), opts.tenantName)
1✔
61
        if err != nil {
1✔
62
                return err
×
63
        }
×
64

65
        return opts.Print(r)
1✔
66
}
67

68
// ListBuilder represents atlas dataFederation queryLimits list [--projectId projectId].
69
func ListBuilder() *cobra.Command {
×
70
        opts := &ListOpts{}
×
71
        cmd := &cobra.Command{
×
72
                Use:     "list",
×
73
                Short:   "Returns all data federation query limits for your project.",
×
74
                Long:    fmt.Sprintf(usage.RequiredRole, "Project Read Only"),
×
75
                Aliases: []string{"ls"},
×
76
                Args:    require.NoArgs,
×
77
                Example: `# list all data federation query limits for the database federated instance "myInstance":
×
78
  atlas dataFederation queryLimits list --dataFederation myInstance
×
79
`,
×
80
                PreRunE: func(cmd *cobra.Command, _ []string) error {
×
81
                        return opts.PreRunE(
×
82
                                opts.ValidateProjectID,
×
83
                                opts.initStore(cmd.Context()),
×
84
                                opts.InitOutput(cmd.OutOrStdout(), listTemplate),
×
85
                        )
×
86
                },
×
87
                RunE: func(_ *cobra.Command, _ []string) error {
×
88
                        return opts.Run()
×
89
                },
×
90
        }
91

92
        cmd.Flags().StringVar(&opts.tenantName, flag.DataFederation, "", usage.DataFederation)
×
93
        opts.AddProjectOptsFlags(cmd)
×
94
        opts.AddOutputOptFlags(cmd)
×
95

×
96
        _ = cmd.MarkFlagRequired(flag.DataFederation)
×
97

×
98
        return cmd
×
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc