From 06c37c64e2c26a58a7abc79eafbe227f9c79b0e3 Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Fri, 28 Apr 2023 15:22:20 +0100 Subject: [PATCH 1/4] CLOUDP-171854 Add commands atlas datalakepipelines availablesnaphosts and availableschedules --- ...aLakePipelines-availableSchedules-list.txt | 80 ++++++++++++ ...s-dataLakePipelines-availableSchedules.txt | 59 +++++++++ ...aLakePipelines-availableSnapshots-list.txt | 92 ++++++++++++++ ...s-dataLakePipelines-availableSnapshots.txt | 59 +++++++++ .../command/atlas-dataLakePipelines.txt | 4 + .../availableschedules/available_schedules.go | 37 ++++++ .../available_schedules_test.go | 34 +++++ .../availableschedules/list.go | 93 ++++++++++++++ .../availableschedules/list_test.go | 81 ++++++++++++ .../availablesnapshots/available_snapshots.go | 37 ++++++ .../available_snapshots_test.go | 34 +++++ .../availablesnapshots/list.go | 120 ++++++++++++++++++ .../availablesnapshots/list_test.go | 95 ++++++++++++++ .../datalakepipelines/data_lake_pipelines.go | 4 + .../data_lake_pipelines_test.go | 2 +- internal/flag/flags.go | 1 + internal/mocks/mock_data_lake_pipelines.go | 80 +++++++++++- internal/store/data_lake_pipelines.go | 43 ++++++- internal/usage/usage.go | 1 + tools/cli-generator/spec.yaml | 35 ++++- 20 files changed, 987 insertions(+), 4 deletions(-) create mode 100644 docs/atlascli/command/atlas-dataLakePipelines-availableSchedules-list.txt create mode 100644 docs/atlascli/command/atlas-dataLakePipelines-availableSchedules.txt create mode 100644 docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots-list.txt create mode 100644 docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots.txt create mode 100644 internal/cli/atlas/datalakepipelines/availableschedules/available_schedules.go create mode 100644 internal/cli/atlas/datalakepipelines/availableschedules/available_schedules_test.go create mode 100644 internal/cli/atlas/datalakepipelines/availableschedules/list.go create mode 100644 internal/cli/atlas/datalakepipelines/availableschedules/list_test.go create mode 100644 internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots.go create mode 100644 internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots_test.go create mode 100644 internal/cli/atlas/datalakepipelines/availablesnapshots/list.go create mode 100644 internal/cli/atlas/datalakepipelines/availablesnapshots/list_test.go diff --git a/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules-list.txt b/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules-list.txt new file mode 100644 index 0000000000..4471eac420 --- /dev/null +++ b/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules-list.txt @@ -0,0 +1,80 @@ +.. _atlas-dataLakePipelines-availableSchedules-list: + +=============================================== +atlas dataLakePipelines availableSchedules list +=============================================== + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Returns all available schedules for the data lake pipelines for your project. + +To use this command, you must authenticate with a user account or an API key that has the Project Read Only role. + +Syntax +------ + +.. code-block:: + :caption: Command Syntax + + atlas dataLakePipelines availableSchedules list [options] + +.. Code end marker, please don't delete this comment + +Options +------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -h, --help + - + - false + - help for list + * - -o, --output + - string + - false + - Output format. Valid values are json, json-path, go-template, or go-template-file. + * - --pipeline + - string + - true + - Name of the Data lake pipeline. + * - --projectId + - string + - false + - Hexadecimal string that identifies the project to use. This option overrides the settings in the configuration file or environment variable. + +Inherited Options +----------------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -P, --profile + - string + - false + - Human-readable label that identifies the profile to use from your configuration file. To learn about profiles for the Atlas CLI, see https://dochub.mongodb.org/core/atlas-cli-save-connection-settings. To learn about profiles for MongoCLI, see https://dochub.mongodb.org/core/atlas-cli-configuration-file. + +Examples +-------- + +.. code-block:: + + # list available schedules for data lake pipeline called 'Pipeline1': + atlas dataLakePipelines availableSchedules list Pipeline1 + diff --git a/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules.txt b/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules.txt new file mode 100644 index 0000000000..1ac5e6377f --- /dev/null +++ b/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules.txt @@ -0,0 +1,59 @@ +.. _atlas-dataLakePipelines-availableSchedules: + +========================================== +atlas dataLakePipelines availableSchedules +========================================== + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Available Schedules for data lake pipelines. + +Options +------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -h, --help + - + - false + - help for availableSchedules + +Inherited Options +----------------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -P, --profile + - string + - false + - Human-readable label that identifies the profile to use from your configuration file. To learn about profiles for the Atlas CLI, see https://dochub.mongodb.org/core/atlas-cli-save-connection-settings. To learn about profiles for MongoCLI, see https://dochub.mongodb.org/core/atlas-cli-configuration-file. + +Related Commands +---------------- + +* :ref:`atlas-dataLakePipelines-availableSchedules-list` - Returns all available schedules for the data lake pipelines for your project. + + +.. toctree:: + :titlesonly: + + list + diff --git a/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots-list.txt b/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots-list.txt new file mode 100644 index 0000000000..23e731aaf7 --- /dev/null +++ b/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots-list.txt @@ -0,0 +1,92 @@ +.. _atlas-dataLakePipelines-availableSnapshots-list: + +=============================================== +atlas dataLakePipelines availableSnapshots list +=============================================== + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Returns all available backup snaphots for the data lake pipelines for your project. + +To use this command, you must authenticate with a user account or an API key that has the Project Read Only role. + +Syntax +------ + +.. code-block:: + :caption: Command Syntax + + atlas dataLakePipelines availableSnapshots list [options] + +.. Code end marker, please don't delete this comment + +Options +------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - --completedAfter + - string + - false + - Date filter of which the backup snapshots where completed. Format must be YYYY-MM-DD + * - -h, --help + - + - false + - help for list + * - --limit + - int + - false + - Number of items per results page. This value defaults to 100. + * - -o, --output + - string + - false + - Output format. Valid values are json, json-path, go-template, or go-template-file. + * - --page + - int + - false + - Page number that specifies a page of results. This value defaults to 1. + * - --pipeline + - string + - true + - Name of the Data lake pipeline. + * - --projectId + - string + - false + - Hexadecimal string that identifies the project to use. This option overrides the settings in the configuration file or environment variable. + +Inherited Options +----------------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -P, --profile + - string + - false + - Human-readable label that identifies the profile to use from your configuration file. To learn about profiles for the Atlas CLI, see https://dochub.mongodb.org/core/atlas-cli-save-connection-settings. To learn about profiles for MongoCLI, see https://dochub.mongodb.org/core/atlas-cli-configuration-file. + +Examples +-------- + +.. code-block:: + + # list available backup schedules for data lake pipeline called 'Pipeline1': + atlas dataLakePipelines availableSnapshots list Pipeline1 + diff --git a/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots.txt b/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots.txt new file mode 100644 index 0000000000..e09fccb17e --- /dev/null +++ b/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots.txt @@ -0,0 +1,59 @@ +.. _atlas-dataLakePipelines-availableSnapshots: + +========================================== +atlas dataLakePipelines availableSnapshots +========================================== + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Available backup snapshots for data lake pipelines. + +Options +------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -h, --help + - + - false + - help for availableSnapshots + +Inherited Options +----------------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -P, --profile + - string + - false + - Human-readable label that identifies the profile to use from your configuration file. To learn about profiles for the Atlas CLI, see https://dochub.mongodb.org/core/atlas-cli-save-connection-settings. To learn about profiles for MongoCLI, see https://dochub.mongodb.org/core/atlas-cli-configuration-file. + +Related Commands +---------------- + +* :ref:`atlas-dataLakePipelines-availableSnapshots-list` - Returns all available backup snaphots for the data lake pipelines for your project. + + +.. toctree:: + :titlesonly: + + list + diff --git a/docs/atlascli/command/atlas-dataLakePipelines.txt b/docs/atlascli/command/atlas-dataLakePipelines.txt index 7f38a025e1..d915ab1901 100644 --- a/docs/atlascli/command/atlas-dataLakePipelines.txt +++ b/docs/atlascli/command/atlas-dataLakePipelines.txt @@ -49,6 +49,8 @@ Inherited Options Related Commands ---------------- +* :ref:`atlas-dataLakePipelines-availableSchedules` - Available Schedules for data lake pipelines. +* :ref:`atlas-dataLakePipelines-availableSnapshots` - Available backup snapshots for data lake pipelines. * :ref:`atlas-dataLakePipelines-create` - Creates a new Data Lake Pipeline. * :ref:`atlas-dataLakePipelines-delete` - Remove the specified data lake pipeline from your project. * :ref:`atlas-dataLakePipelines-describe` - Return the details for the specified data lake pipeline for your project. @@ -60,6 +62,8 @@ Related Commands .. toctree:: :titlesonly: + availableSchedules + availableSnapshots create delete describe diff --git a/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules.go b/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules.go new file mode 100644 index 0000000000..66bb5fb684 --- /dev/null +++ b/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules.go @@ -0,0 +1,37 @@ +// Copyright 2023 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was autogenerated at 2023-04-27T17:56:11+01:00. Note: Manual updates are allowed, but may be overwritten. + +package availableschedules + +import ( + "github.com/mongodb/mongodb-atlas-cli/internal/cli" + "github.com/spf13/cobra" +) + +func Builder() *cobra.Command { + const use = "availableSchedules" + cmd := &cobra.Command{ + Use: use, + Aliases: cli.GenerateAliases(use), + Short: "Available Schedules for data lake pipelines.", + } + + cmd.AddCommand( + ListBuilder(), + ) + + return cmd +} diff --git a/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules_test.go b/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules_test.go new file mode 100644 index 0000000000..4779fb0b3f --- /dev/null +++ b/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules_test.go @@ -0,0 +1,34 @@ +// Copyright 2023 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build unit + +// This code was autogenerated at 2023-04-27T17:56:11+01:00. Note: Manual updates are allowed, but may be overwritten. + +package availableschedules + +import ( + "testing" + + "github.com/mongodb/mongodb-atlas-cli/internal/test" +) + +func TestBuilder(t *testing.T) { + test.CmdValidator( + t, + Builder(), + 1, + []string{}, + ) +} diff --git a/internal/cli/atlas/datalakepipelines/availableschedules/list.go b/internal/cli/atlas/datalakepipelines/availableschedules/list.go new file mode 100644 index 0000000000..0dddd9b2e1 --- /dev/null +++ b/internal/cli/atlas/datalakepipelines/availableschedules/list.go @@ -0,0 +1,93 @@ +// Copyright 2023 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was autogenerated at 2023-04-27T17:56:11+01:00. Note: Manual updates are allowed, but may be overwritten. + +package availableschedules + +import ( + "context" + "fmt" + + "github.com/mongodb/mongodb-atlas-cli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/internal/cli/require" + "github.com/mongodb/mongodb-atlas-cli/internal/config" + "github.com/mongodb/mongodb-atlas-cli/internal/flag" + "github.com/mongodb/mongodb-atlas-cli/internal/store" + "github.com/mongodb/mongodb-atlas-cli/internal/usage" + + "github.com/spf13/cobra" +) + +var listTemplate = `ID FREQUENCY INTERVAL FREQUENCY TYPE RETENTION UNIT RETENTION VALUE{{range .}} +{{ .Id }} {{ .FrequencyInterval }} {{ .FrequencyType }} {{ .RetentionUnit }} {{ .RetentionValue }}{{end}}` + +type ListOpts struct { + cli.GlobalOpts + cli.OutputOpts + store store.PipelineAvailableSchedulesLister + + pipelineName string +} + +func (opts *ListOpts) initStore(ctx context.Context) func() error { + return func() error { + var err error + opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx)) + return err + } +} + +func (opts *ListOpts) Run() error { + r, err := opts.store.PipelineAvailableSchedules(opts.ConfigProjectID(), opts.pipelineName) + if err != nil { + return err + } + + return opts.Print(r) +} + +// atlas dataLakePipelines availableSchedules list [--projectId projectId]. +func ListBuilder() *cobra.Command { + opts := &ListOpts{} + cmd := &cobra.Command{ + Use: "list", + Short: "Returns all available schedules for the data lake pipelines for your project.", + Long: fmt.Sprintf(usage.RequiredRole, "Project Read Only"), + Aliases: []string{"ls"}, + Args: require.NoArgs, + Example: `# list available schedules for data lake pipeline called 'Pipeline1': + atlas dataLakePipelines availableSchedules list Pipeline1 +`, + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.PreRunE( + opts.ValidateProjectID, + opts.initStore(cmd.Context()), + opts.InitOutput(cmd.OutOrStdout(), listTemplate), + ) + }, + RunE: func(cmd *cobra.Command, args []string) error { + return opts.Run() + }, + } + + cmd.Flags().StringVar(&opts.pipelineName, flag.Pipeline, "", usage.Pipeline) + cmd.MarkFlagRequired(flag.Pipeline) + + 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()) + + return cmd +} diff --git a/internal/cli/atlas/datalakepipelines/availableschedules/list_test.go b/internal/cli/atlas/datalakepipelines/availableschedules/list_test.go new file mode 100644 index 0000000000..e2ff9dc3f5 --- /dev/null +++ b/internal/cli/atlas/datalakepipelines/availableschedules/list_test.go @@ -0,0 +1,81 @@ +// Copyright 2023 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build unit + +// This code was autogenerated at 2023-04-27T17:56:12+01:00. Note: Manual updates are allowed, but may be overwritten. + +package availableschedules + +import ( + "bytes" + "testing" + + "github.com/golang/mock/gomock" + "github.com/mongodb/mongodb-atlas-cli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/internal/flag" + "github.com/mongodb/mongodb-atlas-cli/internal/mocks" + "github.com/mongodb/mongodb-atlas-cli/internal/pointer" + "github.com/mongodb/mongodb-atlas-cli/internal/test" + "github.com/stretchr/testify/assert" + atlasv2 "go.mongodb.org/atlas/mongodbatlasv2" +) + +func TestListOpts_Run(t *testing.T) { + ctrl := gomock.NewController(t) + mockStore := mocks.NewMockPipelineAvailableSchedulesLister(ctrl) + + expected := []atlasv2.PolicyItem{ + { + Id: pointer.Get("5e4e593f70dfbf1010295836"), + FrequencyInterval: 1, + FrequencyType: "daily", + RetentionUnit: "months", + RetentionValue: int32(1), + }, + } + + buf := new(bytes.Buffer) + listOpts := &ListOpts{ + store: mockStore, + pipelineName: "Pipeline1", + OutputOpts: cli.OutputOpts{ + Template: listTemplate, + OutWriter: buf, + }, + } + + mockStore. + EXPECT(). + PipelineAvailableSchedules(listOpts.ProjectID, listOpts.pipelineName). + Return(expected, nil). + Times(1) + + if err := listOpts.Run(); err != nil { + t.Fatalf("Run() unexpected error: %v", err) + } + + assert.Equal(t, `ID FREQUENCY INTERVAL FREQUENCY TYPE RETENTION UNIT RETENTION VALUE +5e4e593f70dfbf1010295836 1 daily months 1`, buf.String()) + t.Log(buf.String()) +} + +func TestListBuilder(t *testing.T) { + test.CmdValidator( + t, + ListBuilder(), + 0, + []string{flag.ProjectID, flag.Output}, + ) +} diff --git a/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots.go new file mode 100644 index 0000000000..08e5a4ff14 --- /dev/null +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots.go @@ -0,0 +1,37 @@ +// Copyright 2023 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was autogenerated at 2023-04-27T17:56:12+01:00. Note: Manual updates are allowed, but may be overwritten. + +package availablesnapshots + +import ( + "github.com/mongodb/mongodb-atlas-cli/internal/cli" + "github.com/spf13/cobra" +) + +func Builder() *cobra.Command { + const use = "availableSnapshots" + cmd := &cobra.Command{ + Use: use, + Aliases: cli.GenerateAliases(use), + Short: "Available backup snapshots for data lake pipelines.", + } + + cmd.AddCommand( + ListBuilder(), + ) + + return cmd +} diff --git a/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots_test.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots_test.go new file mode 100644 index 0000000000..f26fc284d2 --- /dev/null +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots_test.go @@ -0,0 +1,34 @@ +// Copyright 2023 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build unit + +// This code was autogenerated at 2023-04-27T17:56:12+01:00. Note: Manual updates are allowed, but may be overwritten. + +package availablesnapshots + +import ( + "testing" + + "github.com/mongodb/mongodb-atlas-cli/internal/test" +) + +func TestBuilder(t *testing.T) { + test.CmdValidator( + t, + Builder(), + 1, + []string{}, + ) +} diff --git a/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go new file mode 100644 index 0000000000..96624ef106 --- /dev/null +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go @@ -0,0 +1,120 @@ +// Copyright 2023 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was autogenerated at 2023-04-27T17:56:12+01:00. Note: Manual updates are allowed, but may be overwritten. + +package availablesnapshots + +import ( + "context" + "errors" + "fmt" + "time" + + "github.com/mongodb/mongodb-atlas-cli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/internal/cli/require" + "github.com/mongodb/mongodb-atlas-cli/internal/config" + "github.com/mongodb/mongodb-atlas-cli/internal/flag" + "github.com/mongodb/mongodb-atlas-cli/internal/store" + "github.com/mongodb/mongodb-atlas-cli/internal/usage" + + "github.com/spf13/cobra" +) + +var listTemplate = `ID STATUS{{range .Results}} +{{if .DiskBackupReplicaSet}}{{.DiskBackupReplicaSet.Id}} {{.DiskBackupReplicaSet.Status}}{{else}}{{.DiskBackupShardedClusterSnapshot.Id}} {{.DiskBackupShardedClusterSnapshot.Status}}{{end}}{{end}}` + +type ListOpts struct { + cli.GlobalOpts + cli.OutputOpts + cli.ListOpts + store store.PipelineAvailableSnapshotsLister + + pipelineName string + completedAfter string +} + +var ErrCompletedAfterInvalidFormat = errors.New("--completedAfter flag is in an invalid format") + +func (opts *ListOpts) initStore(ctx context.Context) func() error { + return func() error { + var err error + opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx)) + return err + } +} + +func convertTime(value string) *time.Time { + var result *time.Time + if completedAfter, err := time.Parse(time.RFC3339, value); err == nil { + result = &completedAfter + } + return result +} + +func (opts *ListOpts) validate() error { + if _, err := time.Parse(time.RFC3339, opts.completedAfter); opts.completedAfter != "" && err != nil { + return fmt.Errorf("%w: expected format 'YYYY-MM-DD' got '%s'", ErrCompletedAfterInvalidFormat, opts.completedAfter) + } + return nil +} + +func (opts *ListOpts) Run() error { + r, err := opts.store.PipelineAvailableSnapshots(opts.ConfigProjectID(), opts.pipelineName, convertTime(opts.completedAfter), opts.NewListOptions()) + if err != nil { + return err + } + + return opts.Print(r) +} + +// atlas dataLakePipelines availableSnapshots list [--projectId projectId]. +func ListBuilder() *cobra.Command { + opts := &ListOpts{} + cmd := &cobra.Command{ + Use: "list", + Short: "Returns all available backup snaphots for the data lake pipelines for your project.", + Long: fmt.Sprintf(usage.RequiredRole, "Project Read Only"), + Aliases: []string{"ls"}, + Args: require.NoArgs, + Example: `# list available backup schedules for data lake pipeline called 'Pipeline1': + atlas dataLakePipelines availableSnapshots list Pipeline1 +`, + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.PreRunE( + opts.ValidateProjectID, + opts.initStore(cmd.Context()), + opts.InitOutput(cmd.OutOrStdout(), listTemplate), + opts.validate, + ) + }, + RunE: func(cmd *cobra.Command, args []string) error { + return opts.Run() + }, + } + + cmd.Flags().StringVar(&opts.pipelineName, flag.Pipeline, "", usage.Pipeline) + cmd.MarkFlagRequired(flag.Pipeline) + + cmd.Flags().StringVar(&opts.completedAfter, flag.CompletedAfter, "", usage.CompletedAfter) + + cmd.Flags().IntVar(&opts.PageNum, flag.Page, cli.DefaultPage, usage.Page) + cmd.Flags().IntVar(&opts.ItemsPerPage, flag.Limit, cli.DefaultPageLimit, usage.Limit) + + 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()) + + return cmd +} diff --git a/internal/cli/atlas/datalakepipelines/availablesnapshots/list_test.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/list_test.go new file mode 100644 index 0000000000..bac6a053ab --- /dev/null +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/list_test.go @@ -0,0 +1,95 @@ +// Copyright 2023 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build unit + +// This code was autogenerated at 2023-04-27T17:56:13+01:00. Note: Manual updates are allowed, but may be overwritten. + +package availablesnapshots + +import ( + "bytes" + "testing" + + "github.com/golang/mock/gomock" + "github.com/mongodb/mongodb-atlas-cli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/internal/flag" + "github.com/mongodb/mongodb-atlas-cli/internal/mocks" + "github.com/mongodb/mongodb-atlas-cli/internal/pointer" + "github.com/mongodb/mongodb-atlas-cli/internal/test" + "github.com/stretchr/testify/assert" + atlasv2 "go.mongodb.org/atlas/mongodbatlasv2" +) + +func TestListOpts_Run(t *testing.T) { + ctrl := gomock.NewController(t) + mockStore := mocks.NewMockPipelineAvailableSnapshotsLister(ctrl) + + expected := &atlasv2.PaginatedBackupSnapshot{ + Results: []atlasv2.DiskBackupSnapshot{ + { + DiskBackupReplicaSet: &atlasv2.DiskBackupReplicaSet{ + Id: pointer.Get("5e4e593f70dfbf1010295836"), + Status: pointer.Get("IDLE"), + }, + }, + { + DiskBackupShardedClusterSnapshot: &atlasv2.DiskBackupShardedClusterSnapshot{ + Id: pointer.Get("5e4e593f70dfbf1010295638"), + Status: pointer.Get("IDLE"), + }, + }, + }, + TotalCount: pointer.Get(int32(2)), + } + + buf := new(bytes.Buffer) + listOpts := &ListOpts{ + store: mockStore, + pipelineName: "Pipeline1", + completedAfter: "2022-05-01", + ListOpts: cli.ListOpts{ + PageNum: 1, + ItemsPerPage: 20, + }, + OutputOpts: cli.OutputOpts{ + Template: listTemplate, + OutWriter: buf, + }, + } + + mockStore. + EXPECT(). + PipelineAvailableSnapshots(listOpts.ProjectID, listOpts.pipelineName, convertTime(listOpts.completedAfter), listOpts.NewListOptions()). + Return(expected, nil). + Times(1) + + if err := listOpts.Run(); err != nil { + t.Fatalf("Run() unexpected error: %v", err) + } + + assert.Equal(t, `ID STATUS +5e4e593f70dfbf1010295836 IDLE +5e4e593f70dfbf1010295638 IDLE`, buf.String()) + t.Log(buf.String()) +} + +func TestListBuilder(t *testing.T) { + test.CmdValidator( + t, + ListBuilder(), + 0, + []string{flag.ProjectID, flag.Output}, + ) +} diff --git a/internal/cli/atlas/datalakepipelines/data_lake_pipelines.go b/internal/cli/atlas/datalakepipelines/data_lake_pipelines.go index defbc656a1..f70d30ec91 100644 --- a/internal/cli/atlas/datalakepipelines/data_lake_pipelines.go +++ b/internal/cli/atlas/datalakepipelines/data_lake_pipelines.go @@ -18,6 +18,8 @@ package datalakepipelines import ( "github.com/mongodb/mongodb-atlas-cli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/internal/cli/atlas/datalakepipelines/availableschedules" + "github.com/mongodb/mongodb-atlas-cli/internal/cli/atlas/datalakepipelines/availablesnapshots" "github.com/mongodb/mongodb-atlas-cli/internal/cli/atlas/datalakepipelines/runs" "github.com/spf13/cobra" ) @@ -44,6 +46,8 @@ func Builder() *cobra.Command { DeleteBuilder(), UpdateBuilder(), runs.Builder(), + availableschedules.Builder(), + availablesnapshots.Builder(), ) return cmd diff --git a/internal/cli/atlas/datalakepipelines/data_lake_pipelines_test.go b/internal/cli/atlas/datalakepipelines/data_lake_pipelines_test.go index c14fbb996f..9b5640ce28 100644 --- a/internal/cli/atlas/datalakepipelines/data_lake_pipelines_test.go +++ b/internal/cli/atlas/datalakepipelines/data_lake_pipelines_test.go @@ -28,7 +28,7 @@ func TestBuilder(t *testing.T) { test.CmdValidator( t, Builder(), - 6, + 8, []string{}, ) } diff --git a/internal/flag/flags.go b/internal/flag/flags.go index 0be8d9c3a0..840df277c5 100644 --- a/internal/flag/flags.go +++ b/internal/flag/flags.go @@ -342,4 +342,5 @@ const ( SourcePolicyItemID = "sourcePolicyItemId" // SourcePolicyItemID flag Transform = "transform" // Transform flag Pipeline = "pipeline" // Pipeline flag + CompletedAfter = "completedAfter" // CompletedAfter flag ) diff --git a/internal/mocks/mock_data_lake_pipelines.go b/internal/mocks/mock_data_lake_pipelines.go index e9c3fa9543..7386073b84 100644 --- a/internal/mocks/mock_data_lake_pipelines.go +++ b/internal/mocks/mock_data_lake_pipelines.go @@ -1,13 +1,15 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/mongodb/mongodb-atlas-cli/internal/store (interfaces: PipelinesLister,PipelinesDescriber,PipelinesCreator,PipelinesUpdater,PipelinesDeleter) +// Source: github.com/mongodb/mongodb-atlas-cli/internal/store (interfaces: PipelinesLister,PipelinesDescriber,PipelinesCreator,PipelinesUpdater,PipelinesDeleter,PipelineAvailableSnapshotsLister,PipelineAvailableSchedulesLister) // Package mocks is a generated GoMock package. package mocks import ( reflect "reflect" + time "time" gomock "github.com/golang/mock/gomock" + mongodbatlas "go.mongodb.org/atlas/mongodbatlas" mongodbatlasv2 "go.mongodb.org/atlas/mongodbatlasv2" ) @@ -199,3 +201,79 @@ func (mr *MockPipelinesDeleterMockRecorder) DeletePipeline(arg0, arg1 interface{ mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePipeline", reflect.TypeOf((*MockPipelinesDeleter)(nil).DeletePipeline), arg0, arg1) } + +// MockPipelineAvailableSnapshotsLister is a mock of PipelineAvailableSnapshotsLister interface. +type MockPipelineAvailableSnapshotsLister struct { + ctrl *gomock.Controller + recorder *MockPipelineAvailableSnapshotsListerMockRecorder +} + +// MockPipelineAvailableSnapshotsListerMockRecorder is the mock recorder for MockPipelineAvailableSnapshotsLister. +type MockPipelineAvailableSnapshotsListerMockRecorder struct { + mock *MockPipelineAvailableSnapshotsLister +} + +// NewMockPipelineAvailableSnapshotsLister creates a new mock instance. +func NewMockPipelineAvailableSnapshotsLister(ctrl *gomock.Controller) *MockPipelineAvailableSnapshotsLister { + mock := &MockPipelineAvailableSnapshotsLister{ctrl: ctrl} + mock.recorder = &MockPipelineAvailableSnapshotsListerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPipelineAvailableSnapshotsLister) EXPECT() *MockPipelineAvailableSnapshotsListerMockRecorder { + return m.recorder +} + +// PipelineAvailableSnapshots mocks base method. +func (m *MockPipelineAvailableSnapshotsLister) PipelineAvailableSnapshots(arg0, arg1 string, arg2 *time.Time, arg3 *mongodbatlas.ListOptions) (*mongodbatlasv2.PaginatedBackupSnapshot, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PipelineAvailableSnapshots", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*mongodbatlasv2.PaginatedBackupSnapshot) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PipelineAvailableSnapshots indicates an expected call of PipelineAvailableSnapshots. +func (mr *MockPipelineAvailableSnapshotsListerMockRecorder) PipelineAvailableSnapshots(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PipelineAvailableSnapshots", reflect.TypeOf((*MockPipelineAvailableSnapshotsLister)(nil).PipelineAvailableSnapshots), arg0, arg1, arg2, arg3) +} + +// MockPipelineAvailableSchedulesLister is a mock of PipelineAvailableSchedulesLister interface. +type MockPipelineAvailableSchedulesLister struct { + ctrl *gomock.Controller + recorder *MockPipelineAvailableSchedulesListerMockRecorder +} + +// MockPipelineAvailableSchedulesListerMockRecorder is the mock recorder for MockPipelineAvailableSchedulesLister. +type MockPipelineAvailableSchedulesListerMockRecorder struct { + mock *MockPipelineAvailableSchedulesLister +} + +// NewMockPipelineAvailableSchedulesLister creates a new mock instance. +func NewMockPipelineAvailableSchedulesLister(ctrl *gomock.Controller) *MockPipelineAvailableSchedulesLister { + mock := &MockPipelineAvailableSchedulesLister{ctrl: ctrl} + mock.recorder = &MockPipelineAvailableSchedulesListerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPipelineAvailableSchedulesLister) EXPECT() *MockPipelineAvailableSchedulesListerMockRecorder { + return m.recorder +} + +// PipelineAvailableSchedules mocks base method. +func (m *MockPipelineAvailableSchedulesLister) PipelineAvailableSchedules(arg0, arg1 string) ([]mongodbatlasv2.PolicyItem, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PipelineAvailableSchedules", arg0, arg1) + ret0, _ := ret[0].([]mongodbatlasv2.PolicyItem) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PipelineAvailableSchedules indicates an expected call of PipelineAvailableSchedules. +func (mr *MockPipelineAvailableSchedulesListerMockRecorder) PipelineAvailableSchedules(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PipelineAvailableSchedules", reflect.TypeOf((*MockPipelineAvailableSchedulesLister)(nil).PipelineAvailableSchedules), arg0, arg1) +} diff --git a/internal/store/data_lake_pipelines.go b/internal/store/data_lake_pipelines.go index 00ca06325b..3f73088da4 100644 --- a/internal/store/data_lake_pipelines.go +++ b/internal/store/data_lake_pipelines.go @@ -18,12 +18,14 @@ package store import ( "fmt" + "time" "github.com/mongodb/mongodb-atlas-cli/internal/config" + atlas "go.mongodb.org/atlas/mongodbatlas" atlasv2 "go.mongodb.org/atlas/mongodbatlasv2" ) -//go:generate mockgen -destination=../mocks/mock_data_lake_pipelines.go -package=mocks github.com/mongodb/mongodb-atlas-cli/internal/store PipelinesLister,PipelinesDescriber,PipelinesCreator,PipelinesUpdater,PipelinesDeleter +//go:generate mockgen -destination=../mocks/mock_data_lake_pipelines.go -package=mocks github.com/mongodb/mongodb-atlas-cli/internal/store PipelinesLister,PipelinesDescriber,PipelinesCreator,PipelinesUpdater,PipelinesDeleter,PipelineAvailableSnapshotsLister,PipelineAvailableSchedulesLister type PipelinesLister interface { Pipelines(string) ([]atlasv2.IngestionPipeline, error) @@ -45,6 +47,14 @@ type PipelinesUpdater interface { UpdatePipeline(string, string, atlasv2.IngestionPipeline) (*atlasv2.IngestionPipeline, error) } +type PipelineAvailableSnapshotsLister interface { + PipelineAvailableSnapshots(string, string, *time.Time, *atlas.ListOptions) (*atlasv2.PaginatedBackupSnapshot, error) +} + +type PipelineAvailableSchedulesLister interface { + PipelineAvailableSchedules(string, string) ([]atlasv2.PolicyItem, error) +} + // Pipelines encapsulates the logic to manage different cloud providers. func (s *Store) Pipelines(projectID string) ([]atlasv2.IngestionPipeline, error) { switch s.service { @@ -99,3 +109,34 @@ func (s *Store) DeletePipeline(projectID, id string) error { return fmt.Errorf("%w: %s", errUnsupportedService, s.service) } } + +// PipelineAvailableSchedules encapsulates the logic to manage different cloud providers. +func (s *Store) PipelineAvailableSchedules(projectID, pipelineName string) ([]atlasv2.PolicyItem, error) { + switch s.service { + case config.CloudService, config.CloudGovService: + result, _, err := s.clientv2.DataLakePipelinesApi.ListPipelineSchedules(s.ctx, projectID, pipelineName).Execute() + return result, err + default: + return nil, fmt.Errorf("%w: %s", errUnsupportedService, s.service) + } +} + +// PipelineAvailableSnapshots encapsulates the logic to manage different cloud providers. +func (s *Store) PipelineAvailableSnapshots(projectID, pipelineName string, completedAfter *time.Time, listOps *atlas.ListOptions) (*atlasv2.PaginatedBackupSnapshot, error) { + switch s.service { + case config.CloudService, config.CloudGovService: + request := s.clientv2.DataLakePipelinesApi.ListPipelineSnapshots(s.ctx, projectID, pipelineName) + if completedAfter != nil { + request = request.CompletedAfter(*completedAfter) + } + if listOps != nil { + request = request.IncludeCount(listOps.IncludeCount) + request = request.ItemsPerPage(int32(listOps.ItemsPerPage)) + request = request.PageNum(int32(listOps.PageNum)) + } + result, _, err := request.Execute() + return result, err + default: + return nil, fmt.Errorf("%w: %s", errUnsupportedService, s.service) + } +} diff --git a/internal/usage/usage.go b/internal/usage/usage.go index 993e8f83c0..17aac55b8f 100644 --- a/internal/usage/usage.go +++ b/internal/usage/usage.go @@ -418,4 +418,5 @@ dbName and collection are required only for built-in roles.` Transform = "Fields to be excluded for this data lake pipeline." PipelineFilename = "Name of the JSON data lake pipeline configuration file to use." Pipeline = "Name of the Data lake pipeline." + CompletedAfter = "Date filter of which the backup snapshots where completed. Format must be YYYY-MM-DD" ) diff --git a/tools/cli-generator/spec.yaml b/tools/cli-generator/spec.yaml index 0c7e437a9c..adba3df5a9 100644 --- a/tools/cli-generator/spec.yaml +++ b/tools/cli-generator/spec.yaml @@ -100,7 +100,40 @@ commands: example: | # retrieves pipeline run '507f1f77bcf86cd799439011': atlas dataLakePipelines runs describe 507f1f77bcf86cd799439011 - + - command_path: atlas dataLakePipelines availableSchedules + package_name: availableschedules + description: Available Schedules for data lake pipelines. + template: parent + sub_commands: + - command_path: atlas dataLakePipelines availableSchedules list + package_name: availableschedules + store_name: PipelineAvailableSchedulesLister + store_method: PipelineAvailableSchedules + description: Returns all available schedules for the data lake pipelines for your project. + template: list + output_template: | + ID FREQUENCY INTERVAL FREQUENCY TYPE RETENTION UNIT RETENTION VALUE{{range .}} + {{ .Id }} {{ .FrequencyInterval }} {{ .FrequencyType }} {{ .RetentionUnit }} {{ .RetentionValue }}{{end}} + example: | + # list available schedules for data lake pipeline called 'Pipeline1': + atlas dataLakePipelines availableSchedules list Pipeline1 + - command_path: atlas dataLakePipelines availableSnapshots + package_name: availablesnapshots + description: Available backup snapshots for data lake pipelines. + template: parent + sub_commands: + - command_path: atlas dataLakePipelines availableSnapshots list + package_name: availablesnapshots + store_name: PipelineAvailableSnapshotsLister + store_method: PipelineAvailableSnapshots + description: Returns all available backup snaphots for the data lake pipelines for your project. + template: list + output_template: | + ID STATUS{{range .Results}} + {{if .DiskBackupReplicaSet}}{{.DiskBackupReplicaSet.Id}} {{.DiskBackupReplicaSet.Status}}{{else}}{{.DiskBackupShardedClusterSnapshot.Id}} {{.DiskBackupShardedClusterSnapshot.Status}}{{end}}{{end}} + example: | + # list available backup schedules for data lake pipeline called 'Pipeline1': + atlas dataLakePipelines availableSnapshots list Pipeline1 stores: - base_file_name: data_lake_pipelines template: store From e27854bc3cf6d59290c29e76d3becc0daea093f9 Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Fri, 28 Apr 2023 15:26:02 +0100 Subject: [PATCH 2/4] Fix lint --- .../cli/atlas/datalakepipelines/availableschedules/list.go | 3 +-- .../cli/atlas/datalakepipelines/availablesnapshots/list.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/cli/atlas/datalakepipelines/availableschedules/list.go b/internal/cli/atlas/datalakepipelines/availableschedules/list.go index 0dddd9b2e1..5df95191c5 100644 --- a/internal/cli/atlas/datalakepipelines/availableschedules/list.go +++ b/internal/cli/atlas/datalakepipelines/availableschedules/list.go @@ -26,7 +26,6 @@ import ( "github.com/mongodb/mongodb-atlas-cli/internal/flag" "github.com/mongodb/mongodb-atlas-cli/internal/store" "github.com/mongodb/mongodb-atlas-cli/internal/usage" - "github.com/spf13/cobra" ) @@ -83,7 +82,7 @@ func ListBuilder() *cobra.Command { } cmd.Flags().StringVar(&opts.pipelineName, flag.Pipeline, "", usage.Pipeline) - cmd.MarkFlagRequired(flag.Pipeline) + _ = cmd.MarkFlagRequired(flag.Pipeline) 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.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go index 96624ef106..85daccfbe6 100644 --- a/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go @@ -28,7 +28,6 @@ import ( "github.com/mongodb/mongodb-atlas-cli/internal/flag" "github.com/mongodb/mongodb-atlas-cli/internal/store" "github.com/mongodb/mongodb-atlas-cli/internal/usage" - "github.com/spf13/cobra" ) @@ -105,7 +104,7 @@ func ListBuilder() *cobra.Command { } cmd.Flags().StringVar(&opts.pipelineName, flag.Pipeline, "", usage.Pipeline) - cmd.MarkFlagRequired(flag.Pipeline) + _ = cmd.MarkFlagRequired(flag.Pipeline) cmd.Flags().StringVar(&opts.completedAfter, flag.CompletedAfter, "", usage.CompletedAfter) From c14f5aedf9aac38bfabc92a9d7474501d639ad29 Mon Sep 17 00:00:00 2001 From: Filipe Constantinov Menezes Date: Fri, 28 Apr 2023 16:00:29 +0100 Subject: [PATCH 3/4] Update internal/store/data_lake_pipelines.go Co-authored-by: Gustavo Bazan --- internal/store/data_lake_pipelines.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/store/data_lake_pipelines.go b/internal/store/data_lake_pipelines.go index 3f73088da4..1db950ca6a 100644 --- a/internal/store/data_lake_pipelines.go +++ b/internal/store/data_lake_pipelines.go @@ -130,7 +130,6 @@ func (s *Store) PipelineAvailableSnapshots(projectID, pipelineName string, compl request = request.CompletedAfter(*completedAfter) } if listOps != nil { - request = request.IncludeCount(listOps.IncludeCount) request = request.ItemsPerPage(int32(listOps.ItemsPerPage)) request = request.PageNum(int32(listOps.PageNum)) } From 69f1873767ddfb15de8095580c919f902fecf69a Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Thu, 4 May 2023 11:11:15 +0100 Subject: [PATCH 4/4] address feedback --- .../atlas-dataLakePipelines-availableSchedules-list.txt | 2 +- .../atlas-dataLakePipelines-availableSchedules.txt | 4 ++-- .../atlas-dataLakePipelines-availableSnapshots-list.txt | 2 +- .../atlas-dataLakePipelines-availableSnapshots.txt | 4 ++-- docs/atlascli/command/atlas-dataLakePipelines.txt | 4 ++-- .../availableschedules/available_schedules.go | 2 +- .../atlas/datalakepipelines/availableschedules/list.go | 2 +- .../availablesnapshots/available_snapshots.go | 2 +- .../atlas/datalakepipelines/availablesnapshots/list.go | 2 +- tools/cli-generator/spec.yaml | 8 ++++---- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules-list.txt b/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules-list.txt index 4471eac420..9e49b6da88 100644 --- a/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules-list.txt +++ b/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules-list.txt @@ -12,7 +12,7 @@ atlas dataLakePipelines availableSchedules list :depth: 1 :class: singlecol -Returns all available schedules for the data lake pipelines for your project. +Return all available schedules for the specified data lake pipeline. To use this command, you must authenticate with a user account or an API key that has the Project Read Only role. diff --git a/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules.txt b/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules.txt index 1ac5e6377f..47a87322bc 100644 --- a/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules.txt +++ b/docs/atlascli/command/atlas-dataLakePipelines-availableSchedules.txt @@ -12,7 +12,7 @@ atlas dataLakePipelines availableSchedules :depth: 1 :class: singlecol -Available Schedules for data lake pipelines. +Manage available schedules for the specified data lake pipeline. Options ------- @@ -49,7 +49,7 @@ Inherited Options Related Commands ---------------- -* :ref:`atlas-dataLakePipelines-availableSchedules-list` - Returns all available schedules for the data lake pipelines for your project. +* :ref:`atlas-dataLakePipelines-availableSchedules-list` - Return all available schedules for the specified data lake pipeline. .. toctree:: diff --git a/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots-list.txt b/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots-list.txt index 23e731aaf7..333747a5f3 100644 --- a/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots-list.txt +++ b/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots-list.txt @@ -12,7 +12,7 @@ atlas dataLakePipelines availableSnapshots list :depth: 1 :class: singlecol -Returns all available backup snaphots for the data lake pipelines for your project. +Return all available backup snapshots for the specified data lake pipeline. To use this command, you must authenticate with a user account or an API key that has the Project Read Only role. diff --git a/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots.txt b/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots.txt index e09fccb17e..01a0c5e298 100644 --- a/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots.txt +++ b/docs/atlascli/command/atlas-dataLakePipelines-availableSnapshots.txt @@ -12,7 +12,7 @@ atlas dataLakePipelines availableSnapshots :depth: 1 :class: singlecol -Available backup snapshots for data lake pipelines. + Manage available backup snapshots for data lake pipelines. Options ------- @@ -49,7 +49,7 @@ Inherited Options Related Commands ---------------- -* :ref:`atlas-dataLakePipelines-availableSnapshots-list` - Returns all available backup snaphots for the data lake pipelines for your project. +* :ref:`atlas-dataLakePipelines-availableSnapshots-list` - Return all available backup snapshots for the specified data lake pipeline. .. toctree:: diff --git a/docs/atlascli/command/atlas-dataLakePipelines.txt b/docs/atlascli/command/atlas-dataLakePipelines.txt index d915ab1901..dd5291db66 100644 --- a/docs/atlascli/command/atlas-dataLakePipelines.txt +++ b/docs/atlascli/command/atlas-dataLakePipelines.txt @@ -49,8 +49,8 @@ Inherited Options Related Commands ---------------- -* :ref:`atlas-dataLakePipelines-availableSchedules` - Available Schedules for data lake pipelines. -* :ref:`atlas-dataLakePipelines-availableSnapshots` - Available backup snapshots for data lake pipelines. +* :ref:`atlas-dataLakePipelines-availableSchedules` - Manage available schedules for the specified data lake pipeline. +* :ref:`atlas-dataLakePipelines-availableSnapshots` - Manage available backup snapshots for data lake pipelines. * :ref:`atlas-dataLakePipelines-create` - Creates a new Data Lake Pipeline. * :ref:`atlas-dataLakePipelines-delete` - Remove the specified data lake pipeline from your project. * :ref:`atlas-dataLakePipelines-describe` - Return the details for the specified data lake pipeline for your project. diff --git a/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules.go b/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules.go index 66bb5fb684..1ffa9f1fcb 100644 --- a/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules.go +++ b/internal/cli/atlas/datalakepipelines/availableschedules/available_schedules.go @@ -26,7 +26,7 @@ func Builder() *cobra.Command { cmd := &cobra.Command{ Use: use, Aliases: cli.GenerateAliases(use), - Short: "Available Schedules for data lake pipelines.", + Short: "Manage available schedules for the specified data lake pipeline.", } cmd.AddCommand( diff --git a/internal/cli/atlas/datalakepipelines/availableschedules/list.go b/internal/cli/atlas/datalakepipelines/availableschedules/list.go index 5df95191c5..25888cde75 100644 --- a/internal/cli/atlas/datalakepipelines/availableschedules/list.go +++ b/internal/cli/atlas/datalakepipelines/availableschedules/list.go @@ -62,7 +62,7 @@ func ListBuilder() *cobra.Command { opts := &ListOpts{} cmd := &cobra.Command{ Use: "list", - Short: "Returns all available schedules for the data lake pipelines for your project.", + Short: "Return all available schedules for the specified data lake pipeline.", Long: fmt.Sprintf(usage.RequiredRole, "Project Read Only"), Aliases: []string{"ls"}, Args: require.NoArgs, diff --git a/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots.go index 08e5a4ff14..b664f31f98 100644 --- a/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots.go +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/available_snapshots.go @@ -26,7 +26,7 @@ func Builder() *cobra.Command { cmd := &cobra.Command{ Use: use, Aliases: cli.GenerateAliases(use), - Short: "Available backup snapshots for data lake pipelines.", + Short: " Manage available backup snapshots for data lake pipelines.", } cmd.AddCommand( diff --git a/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go b/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go index 85daccfbe6..0b2f753ed8 100644 --- a/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go +++ b/internal/cli/atlas/datalakepipelines/availablesnapshots/list.go @@ -83,7 +83,7 @@ func ListBuilder() *cobra.Command { opts := &ListOpts{} cmd := &cobra.Command{ Use: "list", - Short: "Returns all available backup snaphots for the data lake pipelines for your project.", + Short: "Return all available backup snapshots for the specified data lake pipeline.", Long: fmt.Sprintf(usage.RequiredRole, "Project Read Only"), Aliases: []string{"ls"}, Args: require.NoArgs, diff --git a/tools/cli-generator/spec.yaml b/tools/cli-generator/spec.yaml index adba3df5a9..83ffa80697 100644 --- a/tools/cli-generator/spec.yaml +++ b/tools/cli-generator/spec.yaml @@ -102,14 +102,14 @@ commands: atlas dataLakePipelines runs describe 507f1f77bcf86cd799439011 - command_path: atlas dataLakePipelines availableSchedules package_name: availableschedules - description: Available Schedules for data lake pipelines. + description: Manage available schedules for the specified data lake pipeline. template: parent sub_commands: - command_path: atlas dataLakePipelines availableSchedules list package_name: availableschedules store_name: PipelineAvailableSchedulesLister store_method: PipelineAvailableSchedules - description: Returns all available schedules for the data lake pipelines for your project. + description: Return all available schedules for the specified data lake pipeline. template: list output_template: | ID FREQUENCY INTERVAL FREQUENCY TYPE RETENTION UNIT RETENTION VALUE{{range .}} @@ -119,14 +119,14 @@ commands: atlas dataLakePipelines availableSchedules list Pipeline1 - command_path: atlas dataLakePipelines availableSnapshots package_name: availablesnapshots - description: Available backup snapshots for data lake pipelines. + description: Manage available backup snapshots for data lake pipelines. template: parent sub_commands: - command_path: atlas dataLakePipelines availableSnapshots list package_name: availablesnapshots store_name: PipelineAvailableSnapshotsLister store_method: PipelineAvailableSnapshots - description: Returns all available backup snaphots for the data lake pipelines for your project. + description: Return all available backup snapshots for the specified data lake pipeline. template: list output_template: | ID STATUS{{range .Results}}