Skip to content

Commit

Permalink
CLOUDP-108667: Get all the private endpoints for the Data Lake in the…
Browse files Browse the repository at this point in the history
… specified project. (#917)
  • Loading branch information
andreaangiolillo authored Jan 13, 2022
1 parent f28c053 commit 53b6e8d
Show file tree
Hide file tree
Showing 16 changed files with 514 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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.

59 changes: 59 additions & 0 deletions docs/command/mongocli-atlas-privateEndpoints-dataLakes-aws.txt
Original file line number Diff line number Diff line change
@@ -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 </command/mongocli-atlas-privateEndpoints-dataLakes-aws-list>

59 changes: 59 additions & 0 deletions docs/command/mongocli-atlas-privateEndpoints-dataLakes.txt
Original file line number Diff line number Diff line change
@@ -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 </command/mongocli-atlas-privateEndpoints-dataLakes-aws>

2 changes: 2 additions & 0 deletions docs/command/mongocli-atlas-privateEndpoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand All @@ -59,5 +60,6 @@ Related Commands

aws </command/mongocli-atlas-privateEndpoints-aws>
azure </command/mongocli-atlas-privateEndpoints-azure>
dataLakes </command/mongocli-atlas-privateEndpoints-dataLakes>
regionalModes </command/mongocli-atlas-privateEndpoints-regionalModes>

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
30 changes: 30 additions & 0 deletions internal/cli/atlas/privateendpoints/datalake/aws/aws.go
Original file line number Diff line number Diff line change
@@ -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
}
33 changes: 33 additions & 0 deletions internal/cli/atlas/privateendpoints/datalake/aws/aws_test.go
Original file line number Diff line number Diff line change
@@ -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{},
)
}
81 changes: 81 additions & 0 deletions internal/cli/atlas/privateendpoints/datalake/aws/list.go
Original file line number Diff line number Diff line change
@@ -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
}
Loading

0 comments on commit 53b6e8d

Please sign in to comment.