Skip to content

Commit 4e47ff2

Browse files
authored
CLOUDP-127482: Add filter by name on list all groups by org (#302)
1 parent a2c8358 commit 4e47ff2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

mongodbatlas/organizations.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type OrganizationsService interface {
3030
Invitations(context.Context, string, *InvitationOptions) ([]*Invitation, *Response, error)
3131
Get(context.Context, string) (*Organization, *Response, error)
3232
Invitation(context.Context, string, string) (*Invitation, *Response, error)
33-
Projects(context.Context, string, *ListOptions) (*Projects, *Response, error)
33+
Projects(context.Context, string, *ProjectsListOptions) (*Projects, *Response, error)
3434
Users(context.Context, string, *ListOptions) (*AtlasUsersResponse, *Response, error)
3535
Delete(context.Context, string) (*Response, error)
3636
InviteUser(context.Context, string, *Invitation) (*Invitation, *Response, error)
@@ -51,6 +51,12 @@ type OrganizationsListOptions struct {
5151
ListOptions
5252
}
5353

54+
// ProjectsListOptions filtering options for projects.
55+
type ProjectsListOptions struct {
56+
Name string `url:"name,omitempty"`
57+
ListOptions
58+
}
59+
5460
// Organization represents the structure of an organization.
5561
type Organization struct {
5662
ID string `json:"id,omitempty"`
@@ -120,7 +126,7 @@ func (s *OrganizationsServiceOp) Get(ctx context.Context, orgID string) (*Organi
120126
// Projects gets all projects for the given organization ID.
121127
//
122128
// See more: https://docs.atlas.mongodb.com/reference/api/organization-get-all-projects/
123-
func (s *OrganizationsServiceOp) Projects(ctx context.Context, orgID string, opts *ListOptions) (*Projects, *Response, error) {
129+
func (s *OrganizationsServiceOp) Projects(ctx context.Context, orgID string, opts *ProjectsListOptions) (*Projects, *Response, error) {
124130
if orgID == "" {
125131
return nil, nil, NewArgError("orgID", "must be set")
126132
}

mongodbatlas/organizations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func TestOrganizationsServiceOp_Projects(t *testing.T) {
234234
}`)
235235
})
236236

237-
projects, _, err := client.Organizations.Projects(ctx, orgID, nil)
237+
projects, _, err := client.Organizations.Projects(ctx, orgID, &ProjectsListOptions{Name: "FooBar"})
238238
if err != nil {
239239
t.Fatalf("Organizations.GetProjects returned error: %v", err)
240240
}

0 commit comments

Comments
 (0)