Skip to content

Commit

Permalink
CLOUDP-127482: Add filter by name on list all groups by org (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmenezes authored Jul 1, 2022
1 parent a2c8358 commit 4e47ff2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions mongodbatlas/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type OrganizationsService interface {
Invitations(context.Context, string, *InvitationOptions) ([]*Invitation, *Response, error)
Get(context.Context, string) (*Organization, *Response, error)
Invitation(context.Context, string, string) (*Invitation, *Response, error)
Projects(context.Context, string, *ListOptions) (*Projects, *Response, error)
Projects(context.Context, string, *ProjectsListOptions) (*Projects, *Response, error)
Users(context.Context, string, *ListOptions) (*AtlasUsersResponse, *Response, error)
Delete(context.Context, string) (*Response, error)
InviteUser(context.Context, string, *Invitation) (*Invitation, *Response, error)
Expand All @@ -51,6 +51,12 @@ type OrganizationsListOptions struct {
ListOptions
}

// ProjectsListOptions filtering options for projects.
type ProjectsListOptions struct {
Name string `url:"name,omitempty"`
ListOptions
}

// Organization represents the structure of an organization.
type Organization struct {
ID string `json:"id,omitempty"`
Expand Down Expand Up @@ -120,7 +126,7 @@ func (s *OrganizationsServiceOp) Get(ctx context.Context, orgID string) (*Organi
// Projects gets all projects for the given organization ID.
//
// See more: https://docs.atlas.mongodb.com/reference/api/organization-get-all-projects/
func (s *OrganizationsServiceOp) Projects(ctx context.Context, orgID string, opts *ListOptions) (*Projects, *Response, error) {
func (s *OrganizationsServiceOp) Projects(ctx context.Context, orgID string, opts *ProjectsListOptions) (*Projects, *Response, error) {
if orgID == "" {
return nil, nil, NewArgError("orgID", "must be set")
}
Expand Down
2 changes: 1 addition & 1 deletion mongodbatlas/organizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func TestOrganizationsServiceOp_Projects(t *testing.T) {
}`)
})

projects, _, err := client.Organizations.Projects(ctx, orgID, nil)
projects, _, err := client.Organizations.Projects(ctx, orgID, &ProjectsListOptions{Name: "FooBar"})
if err != nil {
t.Fatalf("Organizations.GetProjects returned error: %v", err)
}
Expand Down

0 comments on commit 4e47ff2

Please sign in to comment.