Skip to content

Commit 452c38f

Browse files
authored
Merge pull request #36 from mongodb/peers-filter-provider
add providerName option in listoptions for containers service
2 parents 6be59f0 + 46c4b3f commit 452c38f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

mongodbatlas/containers.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const containersPath = "groups/%s/containers"
1313
// endpoints of the MongoDB Atlas API.
1414
//See more: https://docs.atlas.mongodb.com/reference/api/vpc/
1515
type ContainersService interface {
16-
List(context.Context, string, *ListOptions) ([]Container, *Response, error)
16+
List(context.Context, string, *ContainersListOptions) ([]Container, *Response, error)
1717
Get(context.Context, string, string) (*Container, *Response, error)
1818
Create(context.Context, string, *Container) (*Container, *Response, error)
1919
Update(context.Context, string, string, *Container) (*Container, *Response, error)
@@ -28,6 +28,11 @@ type ContainersServiceOp struct {
2828

2929
var _ ContainersService = &ContainersServiceOp{}
3030

31+
type ContainersListOptions struct {
32+
ProviderName string `url:"providerName,omitempty"`
33+
ListOptions
34+
}
35+
3136
// Container represents MongoDB network peering containter.
3237
type Container struct {
3338
AtlasCIDRBlock string `json:"atlasCidrBlock,omitempty"`
@@ -52,7 +57,7 @@ type containersResponse struct {
5257

5358
//List all containers in the project associated to {GROUP-ID}.
5459
//See more: https://docs.atlas.mongodb.com/reference/api/vpc-get-containers-list/
55-
func (s *ContainersServiceOp) List(ctx context.Context, groupID string, listOptions *ListOptions) ([]Container, *Response, error) {
60+
func (s *ContainersServiceOp) List(ctx context.Context, groupID string, listOptions *ContainersListOptions) ([]Container, *Response, error) {
5661
path := fmt.Sprintf(containersPath, groupID)
5762

5863
//Add query params from listOptions

mongodbatlas/containers_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ func TestContainers_RetrievePageByNumber(t *testing.T) {
151151

152152
mux.HandleFunc("/groups/1/containers", func(w http.ResponseWriter, r *http.Request) {
153153
testMethod(t, r, http.MethodGet)
154+
154155
fmt.Fprint(w, jBlob)
155156
})
156157

157-
opt := &ListOptions{PageNum: 2}
158+
opt := &ContainersListOptions{ListOptions: ListOptions{PageNum: 2}, ProviderName: "GCP"}
158159
_, resp, err := client.Containers.List(ctx, "1", opt)
159160

160161
if err != nil {

0 commit comments

Comments
 (0)