Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adds pagination in mongodbatlas_team resource & data source #2919

Merged
merged 11 commits into from
Dec 27, 2024

Conversation

maastha
Copy link
Collaborator

@maastha maastha commented Dec 20, 2024

Description

This PR fixes pagination logic whenever users in a team are retrieved in data source & resource.

Link to any related issue(s): CLOUDP-289122
#2871

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@github-actions github-actions bot added the bug label Dec 20, 2024
@maastha maastha changed the title fix: Fixes pagination in mongodbatlas_team data source fix: Improves pagination in mongodbatlas_team data source Dec 20, 2024
@maastha maastha marked this pull request as ready for review December 24, 2024 15:44
@maastha maastha requested review from a team as code owners December 24, 2024 15:44
Copy link
Contributor

APIx bot: a message has been sent to Docs Slack channel

@maastha maastha changed the title fix: Improves pagination in mongodbatlas_team data source fix: Improves pagination in mongodbatlas_team resource & data source Dec 24, 2024
@maastha maastha changed the title fix: Improves pagination in mongodbatlas_team resource & data source fix: Adds pagination in mongodbatlas_team resource & data source Dec 24, 2024
Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

users, _, err := connV2.TeamsApi.ListTeamUsers(ctx, orgID, team.GetId()).Execute()
teamUsers, err := dsschema.AllPages(ctx, func(ctx context.Context, pageNum int) (dsschema.PaginateResponse[admin.CloudAppUser], *http.Response, error) {
request := connV2.TeamsApi.ListTeamUsers(ctx, orgID, team.GetId())
request = request.PageNum(pageNum)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have to provide itemsPerPage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not required

@@ -77,21 +80,26 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.
}

if err := d.Set("team_id", team.GetId()); err != nil {
return diag.FromErr(fmt.Errorf(errorTeamSetting, "name", d.Id(), err))
return diag.FromErr(fmt.Errorf(errorTeamSetting, "team_id", d.Id(), err))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice spotted

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@erabil-mdb erabil-mdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@maastha maastha merged commit ff3064c into master Dec 27, 2024
40 checks passed
@maastha maastha deleted the CLOUDP-289122-teams-ds branch December 27, 2024 11:02
svc-apix-Bot added a commit that referenced this pull request Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants