From 53b6e8d9332244c0e1186f361dff843986cddb32 Mon Sep 17 00:00:00 2001 From: Andrea Angiolillo Date: Thu, 13 Jan 2022 14:41:26 +0000 Subject: [PATCH] CLOUDP-108667: Get all the private endpoints for the Data Lake in the specified project. (#917) --- ...as-privateEndpoints-dataLakes-aws-list.txt | 63 +++++++++++++++ ...i-atlas-privateEndpoints-dataLakes-aws.txt | 59 ++++++++++++++ ...gocli-atlas-privateEndpoints-dataLakes.txt | 59 ++++++++++++++ .../mongocli-atlas-privateEndpoints.txt | 2 + go.mod | 2 +- go.sum | 3 +- .../privateendpoints/datalake/aws/aws.go | 30 +++++++ .../privateendpoints/datalake/aws/aws_test.go | 33 ++++++++ .../privateendpoints/datalake/aws/list.go | 81 +++++++++++++++++++ .../datalake/aws/list_test.go | 59 ++++++++++++++ .../privateendpoints/datalake/data_lake.go | 34 ++++++++ .../datalake/data_lake_test.go | 33 ++++++++ .../privateendpoints/private_endpoint_test.go | 2 +- .../privateendpoints/private_endpoints.go | 2 + internal/mocks/mock_private_endpoints.go | 40 ++++++++- internal/store/private_endpoints.go | 17 +++- 16 files changed, 514 insertions(+), 5 deletions(-) create mode 100644 docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws-list.txt create mode 100644 docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws.txt create mode 100644 docs/command/mongocli-atlas-privateEndpoints-dataLakes.txt create mode 100644 internal/cli/atlas/privateendpoints/datalake/aws/aws.go create mode 100644 internal/cli/atlas/privateendpoints/datalake/aws/aws_test.go create mode 100644 internal/cli/atlas/privateendpoints/datalake/aws/list.go create mode 100644 internal/cli/atlas/privateendpoints/datalake/aws/list_test.go create mode 100644 internal/cli/atlas/privateendpoints/datalake/data_lake.go create mode 100644 internal/cli/atlas/privateendpoints/datalake/data_lake_test.go diff --git a/docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws-list.txt b/docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws-list.txt new file mode 100644 index 0000000000..be63fa5b91 --- /dev/null +++ b/docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws-list.txt @@ -0,0 +1,63 @@ +.. _mongocli-atlas-privateEndpoints-dataLakes-aws-list: + +================================================== +mongocli atlas privateEndpoints dataLakes aws list +================================================== + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +List Data Lake private endpoints for your project. + +Syntax +------ + +.. code-block:: + + mongocli atlas privateEndpoints dataLakes aws list [options] + +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. + * - --projectId + - string + - false + - Project ID to use. 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 + - Profile to use from your configuration file. + diff --git a/docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws.txt b/docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws.txt new file mode 100644 index 0000000000..b418881e55 --- /dev/null +++ b/docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws.txt @@ -0,0 +1,59 @@ +.. _mongocli-atlas-privateEndpoints-dataLakes-aws: + +============================================= +mongocli atlas privateEndpoints dataLakes aws +============================================= + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Manage AWS private endpoints. + +Options +------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -h, --help + - + - false + - help for aws + +Inherited Options +----------------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -P, --profile + - string + - false + - Profile to use from your configuration file. + +Related Commands +---------------- + +* :ref:`mongocli-atlas-privateEndpoints-dataLakes-aws-list` - List Data Lake private endpoints for your project. + + +.. toctree:: + :titlesonly: + + list + diff --git a/docs/command/mongocli-atlas-privateEndpoints-dataLakes.txt b/docs/command/mongocli-atlas-privateEndpoints-dataLakes.txt new file mode 100644 index 0000000000..e916c6939a --- /dev/null +++ b/docs/command/mongocli-atlas-privateEndpoints-dataLakes.txt @@ -0,0 +1,59 @@ +.. _mongocli-atlas-privateEndpoints-dataLakes: + +========================================= +mongocli atlas privateEndpoints dataLakes +========================================= + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Manage Data Lake private endpoints. + +Options +------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -h, --help + - + - false + - help for dataLakes + +Inherited Options +----------------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -P, --profile + - string + - false + - Profile to use from your configuration file. + +Related Commands +---------------- + +* :ref:`mongocli-atlas-privateEndpoints-dataLakes-aws` - Manage AWS private endpoints. + + +.. toctree:: + :titlesonly: + + aws + diff --git a/docs/command/mongocli-atlas-privateEndpoints.txt b/docs/command/mongocli-atlas-privateEndpoints.txt index eeff88f67c..9a35e4e33e 100644 --- a/docs/command/mongocli-atlas-privateEndpoints.txt +++ b/docs/command/mongocli-atlas-privateEndpoints.txt @@ -51,6 +51,7 @@ Related Commands * :ref:`mongocli-atlas-privateEndpoints-aws` - Manage AWS Private Endpoints. * :ref:`mongocli-atlas-privateEndpoints-azure` - Manage Azure Private Endpoints. +* :ref:`mongocli-atlas-privateEndpoints-dataLakes` - Manage Data Lake private endpoints. * :ref:`mongocli-atlas-privateEndpoints-regionalModes` - Manage regionalized private endpoint setting for your Atlas project. @@ -59,5 +60,6 @@ Related Commands aws azure + dataLakes regionalModes diff --git a/go.mod b/go.mod index b0a12527ca..9ee366fa22 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/spf13/viper v1.10.1 github.com/stretchr/testify v1.7.0 github.com/tangzero/inflector v1.0.0 - go.mongodb.org/atlas v0.14.0 + go.mongodb.org/atlas v0.14.1-0.20220104180936-6afea6036494 go.mongodb.org/ops-manager v0.33.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index d0060cc6a9..4f87ad485d 100644 --- a/go.sum +++ b/go.sum @@ -400,8 +400,9 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= -go.mongodb.org/atlas v0.14.0 h1:g5y/ZbM+eg++qJtpjG/oxoEicf3MTx7o7JaTpoKfyYw= go.mongodb.org/atlas v0.14.0/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8= +go.mongodb.org/atlas v0.14.1-0.20220104180936-6afea6036494 h1:nRJ7gjh1nNLKdQ1cCgppSoYZl1rAhwrLOzv4tNHYrQc= +go.mongodb.org/atlas v0.14.1-0.20220104180936-6afea6036494/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8= go.mongodb.org/ops-manager v0.33.0 h1:PdsMn4U2yAJiuSEw9DRz+Rx6KGmSCsPrnX52O/9b9n8= go.mongodb.org/ops-manager v0.33.0/go.mod h1:85LPPdME1TFJ/Eau/IgOmy37YWGw1p/S8PBSME8ukXs= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= diff --git a/internal/cli/atlas/privateendpoints/datalake/aws/aws.go b/internal/cli/atlas/privateendpoints/datalake/aws/aws.go new file mode 100644 index 0000000000..4ac2848b94 --- /dev/null +++ b/internal/cli/atlas/privateendpoints/datalake/aws/aws.go @@ -0,0 +1,30 @@ +// Copyright 2022 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. + +package aws + +import ( + "github.com/spf13/cobra" +) + +func Builder() *cobra.Command { + const use = "aws" + cmd := &cobra.Command{ + Use: use, + Short: "Manage AWS private endpoints.", + } + cmd.AddCommand(ListBuilder()) + + return cmd +} diff --git a/internal/cli/atlas/privateendpoints/datalake/aws/aws_test.go b/internal/cli/atlas/privateendpoints/datalake/aws/aws_test.go new file mode 100644 index 0000000000..749621bb8c --- /dev/null +++ b/internal/cli/atlas/privateendpoints/datalake/aws/aws_test.go @@ -0,0 +1,33 @@ +// Copyright 2022 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 +// +build unit + +package aws + +import ( + "testing" + + "github.com/mongodb/mongocli/internal/test" +) + +func TestBuilder(t *testing.T) { + test.CmdValidator( + t, + Builder(), + 1, + []string{}, + ) +} diff --git a/internal/cli/atlas/privateendpoints/datalake/aws/list.go b/internal/cli/atlas/privateendpoints/datalake/aws/list.go new file mode 100644 index 0000000000..5cec51d2ef --- /dev/null +++ b/internal/cli/atlas/privateendpoints/datalake/aws/list.go @@ -0,0 +1,81 @@ +// Copyright 2022 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. + +package aws + +import ( + "context" + + "github.com/mongodb/mongocli/internal/cli" + "github.com/mongodb/mongocli/internal/cli/require" + "github.com/mongodb/mongocli/internal/config" + "github.com/mongodb/mongocli/internal/flag" + "github.com/mongodb/mongocli/internal/store" + "github.com/mongodb/mongocli/internal/usage" + "github.com/spf13/cobra" +) + +var listTemplate = `ID ENDPOINT PROVIDER TYPE COMMENT{{range .Results}} +{{.EndpointID}} {{.Provider}} {{.Type}} {{.Comment}}{{end}} +` + +type ListOpts struct { + cli.GlobalOpts + cli.OutputOpts + store store.DataLakePrivateEndpointLister +} + +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.DataLakePrivateEndpoints(opts.ConfigProjectID()) + + if err != nil { + return err + } + + return opts.Print(r) +} + +// mongocli atlas privateEndpoint(s)|privateendpoint(s) dataLakes aws list|ls [--projectId projectId]. +func ListBuilder() *cobra.Command { + opts := new(ListOpts) + cmd := &cobra.Command{ + Use: "list", + Aliases: []string{"ls"}, + Short: "List Data Lake private endpoints for your project.", + Args: require.NoArgs, + 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.ProjectID, flag.ProjectID, "", usage.ProjectID) + cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) + + return cmd +} diff --git a/internal/cli/atlas/privateendpoints/datalake/aws/list_test.go b/internal/cli/atlas/privateendpoints/datalake/aws/list_test.go new file mode 100644 index 0000000000..002eb9a2f6 --- /dev/null +++ b/internal/cli/atlas/privateendpoints/datalake/aws/list_test.go @@ -0,0 +1,59 @@ +// Copyright 2022 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 +// +build unit + +package aws + +import ( + "testing" + + "github.com/golang/mock/gomock" + "github.com/mongodb/mongocli/internal/flag" + "github.com/mongodb/mongocli/internal/mocks" + "github.com/mongodb/mongocli/internal/test" + "github.com/stretchr/testify/assert" + "go.mongodb.org/atlas/mongodbatlas" +) + +func TestList_Run(t *testing.T) { + ctrl := gomock.NewController(t) + mockStore := mocks.NewMockDataLakePrivateEndpointLister(ctrl) + defer ctrl.Finish() + + var expected *mongodbatlas.PrivateLinkEndpointDataLakeResponse + + listOpts := &ListOpts{ + store: mockStore, + } + + mockStore. + EXPECT(). + DataLakePrivateEndpoints(listOpts.ProjectID). + Return(expected, nil). + Times(1) + + err := listOpts.Run() + assert.NoError(t, err) +} + +func TestListBuilder(t *testing.T) { + test.CmdValidator( + t, + ListBuilder(), + 0, + []string{flag.ProjectID, flag.Output}, + ) +} diff --git a/internal/cli/atlas/privateendpoints/datalake/data_lake.go b/internal/cli/atlas/privateendpoints/datalake/data_lake.go new file mode 100644 index 0000000000..277a421ede --- /dev/null +++ b/internal/cli/atlas/privateendpoints/datalake/data_lake.go @@ -0,0 +1,34 @@ +// Copyright 2022 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. + +package datalake + +import ( + "github.com/mongodb/mongocli/internal/cli" + "github.com/mongodb/mongocli/internal/cli/atlas/privateendpoints/datalake/aws" + "github.com/spf13/cobra" +) + +func Builder() *cobra.Command { + const use = "dataLakes" + cmd := &cobra.Command{ + Use: use, + Aliases: cli.GenerateAliases(use), + Short: "Manage Data Lake private endpoints.", + } + + cmd.AddCommand(aws.Builder()) + + return cmd +} diff --git a/internal/cli/atlas/privateendpoints/datalake/data_lake_test.go b/internal/cli/atlas/privateendpoints/datalake/data_lake_test.go new file mode 100644 index 0000000000..d6a9dd3cea --- /dev/null +++ b/internal/cli/atlas/privateendpoints/datalake/data_lake_test.go @@ -0,0 +1,33 @@ +// Copyright 2022 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 +// +build unit + +package datalake + +import ( + "testing" + + "github.com/mongodb/mongocli/internal/test" +) + +func TestBuilder(t *testing.T) { + test.CmdValidator( + t, + Builder(), + 1, + []string{}, + ) +} diff --git a/internal/cli/atlas/privateendpoints/private_endpoint_test.go b/internal/cli/atlas/privateendpoints/private_endpoint_test.go index 46b5136be7..ff4f045b94 100644 --- a/internal/cli/atlas/privateendpoints/private_endpoint_test.go +++ b/internal/cli/atlas/privateendpoints/private_endpoint_test.go @@ -27,7 +27,7 @@ func TestBuilder(t *testing.T) { test.CmdValidator( t, Builder(), - 9, + 10, []string{}, ) } diff --git a/internal/cli/atlas/privateendpoints/private_endpoints.go b/internal/cli/atlas/privateendpoints/private_endpoints.go index 987df8285b..5db743e50b 100644 --- a/internal/cli/atlas/privateendpoints/private_endpoints.go +++ b/internal/cli/atlas/privateendpoints/private_endpoints.go @@ -18,6 +18,7 @@ import ( "github.com/mongodb/mongocli/internal/cli" "github.com/mongodb/mongocli/internal/cli/atlas/privateendpoints/aws" "github.com/mongodb/mongocli/internal/cli/atlas/privateendpoints/azure" + "github.com/mongodb/mongocli/internal/cli/atlas/privateendpoints/datalake" "github.com/mongodb/mongocli/internal/cli/atlas/privateendpoints/interfaces" "github.com/mongodb/mongocli/internal/cli/atlas/privateendpoints/regionalmodes" "github.com/spf13/cobra" @@ -40,6 +41,7 @@ func Builder() *cobra.Command { aws.Builder(), azure.Builder(), regionalmodes.Builder(), + datalake.Builder(), ) return cmd diff --git a/internal/mocks/mock_private_endpoints.go b/internal/mocks/mock_private_endpoints.go index 7e340814b1..385552d2da 100644 --- a/internal/mocks/mock_private_endpoints.go +++ b/internal/mocks/mock_private_endpoints.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/mongodb/mongocli/internal/store (interfaces: PrivateEndpointLister,PrivateEndpointDescriber,PrivateEndpointCreator,PrivateEndpointDeleter,InterfaceEndpointDescriber,InterfaceEndpointCreator,InterfaceEndpointDeleter,RegionalizedPrivateEndpointSettingUpdater,RegionalizedPrivateEndpointSettingDescriber) +// Source: github.com/mongodb/mongocli/internal/store (interfaces: PrivateEndpointLister,PrivateEndpointDescriber,PrivateEndpointCreator,PrivateEndpointDeleter,InterfaceEndpointDescriber,InterfaceEndpointCreator,InterfaceEndpointDeleter,RegionalizedPrivateEndpointSettingUpdater,RegionalizedPrivateEndpointSettingDescriber,DataLakePrivateEndpointLister) // Package mocks is a generated GoMock package. package mocks @@ -350,3 +350,41 @@ func (mr *MockRegionalizedPrivateEndpointSettingDescriberMockRecorder) Regionali mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegionalizedPrivateEndpointSetting", reflect.TypeOf((*MockRegionalizedPrivateEndpointSettingDescriber)(nil).RegionalizedPrivateEndpointSetting), arg0) } + +// MockDataLakePrivateEndpointLister is a mock of DataLakePrivateEndpointLister interface. +type MockDataLakePrivateEndpointLister struct { + ctrl *gomock.Controller + recorder *MockDataLakePrivateEndpointListerMockRecorder +} + +// MockDataLakePrivateEndpointListerMockRecorder is the mock recorder for MockDataLakePrivateEndpointLister. +type MockDataLakePrivateEndpointListerMockRecorder struct { + mock *MockDataLakePrivateEndpointLister +} + +// NewMockDataLakePrivateEndpointLister creates a new mock instance. +func NewMockDataLakePrivateEndpointLister(ctrl *gomock.Controller) *MockDataLakePrivateEndpointLister { + mock := &MockDataLakePrivateEndpointLister{ctrl: ctrl} + mock.recorder = &MockDataLakePrivateEndpointListerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDataLakePrivateEndpointLister) EXPECT() *MockDataLakePrivateEndpointListerMockRecorder { + return m.recorder +} + +// DataLakePrivateEndpoints mocks base method. +func (m *MockDataLakePrivateEndpointLister) DataLakePrivateEndpoints(arg0 string) (*mongodbatlas.PrivateLinkEndpointDataLakeResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DataLakePrivateEndpoints", arg0) + ret0, _ := ret[0].(*mongodbatlas.PrivateLinkEndpointDataLakeResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DataLakePrivateEndpoints indicates an expected call of DataLakePrivateEndpoints. +func (mr *MockDataLakePrivateEndpointListerMockRecorder) DataLakePrivateEndpoints(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DataLakePrivateEndpoints", reflect.TypeOf((*MockDataLakePrivateEndpointLister)(nil).DataLakePrivateEndpoints), arg0) +} diff --git a/internal/store/private_endpoints.go b/internal/store/private_endpoints.go index 8d57dd2d4a..1c3168938a 100644 --- a/internal/store/private_endpoints.go +++ b/internal/store/private_endpoints.go @@ -21,12 +21,16 @@ import ( atlas "go.mongodb.org/atlas/mongodbatlas" ) -//go:generate mockgen -destination=../mocks/mock_private_endpoints.go -package=mocks github.com/mongodb/mongocli/internal/store PrivateEndpointLister,PrivateEndpointDescriber,PrivateEndpointCreator,PrivateEndpointDeleter,InterfaceEndpointDescriber,InterfaceEndpointCreator,InterfaceEndpointDeleter,RegionalizedPrivateEndpointSettingUpdater,RegionalizedPrivateEndpointSettingDescriber +//go:generate mockgen -destination=../mocks/mock_private_endpoints.go -package=mocks github.com/mongodb/mongocli/internal/store PrivateEndpointLister,PrivateEndpointDescriber,PrivateEndpointCreator,PrivateEndpointDeleter,InterfaceEndpointDescriber,InterfaceEndpointCreator,InterfaceEndpointDeleter,RegionalizedPrivateEndpointSettingUpdater,RegionalizedPrivateEndpointSettingDescriber,DataLakePrivateEndpointLister type PrivateEndpointLister interface { PrivateEndpoints(string, string, *atlas.ListOptions) ([]atlas.PrivateEndpointConnection, error) } +type DataLakePrivateEndpointLister interface { + DataLakePrivateEndpoints(string) (*atlas.PrivateLinkEndpointDataLakeResponse, error) +} + type PrivateEndpointDescriber interface { PrivateEndpoint(string, string, string) (*atlas.PrivateEndpointConnection, error) } @@ -70,6 +74,17 @@ func (s *Store) PrivateEndpoints(projectID, provider string, opts *atlas.ListOpt } } +// DataLakePrivateEndpoints encapsulates the logic to manage different cloud providers. +func (s *Store) DataLakePrivateEndpoints(projectID string) (*atlas.PrivateLinkEndpointDataLakeResponse, error) { + switch s.service { + case config.CloudService, config.CloudGovService: + result, _, err := s.client.(*atlas.Client).DataLakes.ListPrivateLinkEndpoint(s.ctx, projectID) + return result, err + default: + return nil, fmt.Errorf("%w: %s", errUnsupportedService, s.service) + } +} + // PrivateEndpoint encapsulates the logic to manage different cloud providers. func (s *Store) PrivateEndpoint(projectID, provider, privateLinkID string) (*atlas.PrivateEndpointConnection, error) { switch s.service {