@@ -25,12 +25,17 @@ import (
2525 "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store"
2626 "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage"
2727 "github.com/spf13/cobra"
28+ atlasv2 "go.mongodb.org/atlas-sdk/v20241113002/admin"
2829)
2930
3031const describeTemplate = `ID SNAPSHOT TYPE TYPE DESCRIPTION EXPIRES AT
3132{{.Id}} {{.SnapshotType}} {{.Type}} {{.Description}} {{.ExpiresAt}}
3233`
3334
35+ const describeTemplateFlex = `ID STATUS MONGODB VERSION START TIME FINISH TIME EXPIRATION
36+ {{.Id}} {{.Status}} {{.MongoDBVersion}} {{.StartTime}} {{.FinishTime}} {{.Expiration}}
37+ `
38+
3439type DescribeOpts struct {
3540 cli.ProjectOpts
3641 cli.OutputOpts
@@ -48,22 +53,39 @@ func (opts *DescribeOpts) initStore(ctx context.Context) func() error {
4853}
4954
5055func (opts * DescribeOpts ) Run () error {
51- r , err := opts .store .Snapshot (opts .ConfigProjectID (), opts .clusterName , opts .snapshot )
56+ r , err := opts .store .FlexClusterSnapshot (opts .ConfigProjectID (), opts .clusterName , opts .snapshot )
57+ if err == nil {
58+ opts .Template = describeTemplateFlex
59+ return opts .Print (r )
60+ }
61+
62+ apiError , ok := atlasv2 .AsError (err )
63+ if ! ok {
64+ return err
65+ }
66+
67+ if apiError .ErrorCode != cannotUseNotFlexWithFlexApisErrorCode {
68+ return err
69+ }
70+
71+ snapshots , err := opts .store .Snapshot (opts .ConfigProjectID (), opts .clusterName , opts .snapshot )
5272 if err != nil {
5373 return err
5474 }
5575
56- return opts .Print (r )
76+ return opts .Print (snapshots )
5777}
5878
79+ // DescribeBuilder builds a cobra.Command that can run as:
5980// atlas backup snapshots describe snapshotId --clusterName clusterName --projectId projectId.
6081func DescribeBuilder () * cobra.Command {
6182 opts := new (DescribeOpts )
6283 cmd := & cobra.Command {
63- Use : "describe <snapshotId>" ,
64- Short : "Return the details for the specified snapshot for your project." ,
65- Long : fmt .Sprintf (usage .RequiredRole , "Project Read Only" ),
66- Args : require .ExactArgs (1 ),
84+ Use : "describe <snapshotId>" ,
85+ Aliases : []string {"get" },
86+ Short : "Return the details for the specified snapshot for your project." ,
87+ Long : fmt .Sprintf (usage .RequiredRole , "Project Read Only" ),
88+ Args : require .ExactArgs (1 ),
6789 Example : ` # Return the details for the backup snapshot with the ID 5f4007f327a3bd7b6f4103c5 for the cluster named myDemo:
6890 atlas backups snapshots describe 5f4007f327a3bd7b6f4103c5 --clusterName myDemo` ,
6991 Annotations : map [string ]string {
0 commit comments