Skip to content

feat!: Add pagination to Enterprise.ListBudgets and add GetUserStatesForBudget (#4408) - #4501

Merged
gmlewis merged 9 commits into
google:masterfrom
devaniketh:enterprise-budgets-pagination
Sep 4, 2026
Merged

feat!: Add pagination to Enterprise.ListBudgets and add GetUserStatesForBudget (#4408)#4501
gmlewis merged 9 commits into
google:masterfrom
devaniketh:enterprise-budgets-pagination

Conversation

@devaniketh

@devaniketh devaniketh commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

BREAKING CHANGE: EnterpriseService.ListBudgets now takes EnterpriseListBudgetsOptions.

Fixes #4408

Summary

  • Added EnterpriseListBudgetsOptions embedding ListOptions to enable pagination (page, per_page) in EnterpriseService.ListBudgets.
  • Added EnterpriseService.GetUserStatesForBudget along with EnterpriseBudgetUserState, EnterpriseBudgetUserStates, and EnterpriseGetUserStatesOptions for endpoint GET /enterprises/{enterprise}/settings/billing/budgets/{budget_id}/user-states.
  • Regenerated accessors, iterators (ListBudgetsIter), and stringifier test fixtures via script/generate.sh.
  • Added full unit test coverage in enterprise_budgets_test.go.

@google-cla

google-cla Bot commented Sep 1, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Sep 1, 2026
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.53%. Comparing base (b8acf75) to head (009c461).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4501   +/-   ##
=======================================
  Coverage   98.53%   98.53%           
=======================================
  Files         195      195           
  Lines       17795    17848   +53     
=======================================
+ Hits        17534    17587   +53     
  Misses        261      261           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis changed the title feat: Add pagination to Enterprise.ListBudgets and add GetUserStatesForBudget (#4408) feat!: Add pagination to Enterprise.ListBudgets and add GetUserStatesForBudget (#4408) Sep 2, 2026
@gmlewis gmlewis added the Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). label Sep 2, 2026
Comment thread github/enterprise_budgets.go
@devaniketh
devaniketh requested a review from gmlewis September 2, 2026 12:14
Comment thread github/enterprise_budgets.go Outdated
Comment thread github/enterprise_budgets.go
Comment thread github/enterprise_budgets.go
Comment thread github/enterprise_budgets.go
@devaniketh

Copy link
Copy Markdown
Contributor Author

Thanks for the review! @Not-Dhananjay-Mishra

I've updated:

1.EnterpriseBudgetUserState to use float64 for ConsumedAmount and TargetAmount without omitempty.
2. EnterpriseBudgetUserStates to use bool and int for HasNextPage and TotalCount without omitempty.
3.Added ListBudgetsOptions with Scope, User, and embedded ListOptions, and updated ListBudgets / ListBudgetsIter.
4. Fixed the spacing after fmt.Sprintf and regenerated all accessors, iterators, and stringifier test fixtures.

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @devaniketh.
testBadOptions always needs a non-nil value for opts to be passed in for it to work properly.

Comment thread github/enterprise_budgets_test.go Outdated
Comment thread github/enterprise_budgets_test.go Outdated

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Iterator for EnterpriseService.GetUserStatesForBudget isn't generated, Since it accepts ListOptions and is an exception case can you please update this

// customNames provides custom names for iterator methods where the default methodName + "Iter" would be confusing.
var customNames = map[string]string{
"RepositoriesService.GetCommit": "ListCommitFiles",
"RepositoriesService.CompareCommits": "ListCommitComparisonFiles",
"RepositoriesService.GetCombinedStatus": "ListCombinedStatus",
}

Comment thread github/enterprise_budgets_test.go
Comment thread github/enterprise_budgets_test.go Outdated
Comment thread github/enterprise_budgets.go Outdated
@devaniketh

Copy link
Copy Markdown
Contributor Author

Thank you for pointing that out! @gmlewis I've updated both testBadOptions calls in enterprise_budgets_test.go to pass opts instead of nil. All tests and linters are passing cleanly.

@devaniketh
devaniketh requested a review from gmlewis September 4, 2026 13:49

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @devaniketh!
LGTM.

cc: @Not-Dhananjay-Mishra

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@devaniketh
devaniketh requested a review from gmlewis September 4, 2026 17:25
@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Sep 4, 2026
@gmlewis

gmlewis commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Thank you, @Not-Dhananjay-Mishra!
Merging.

@gmlewis
gmlewis merged commit fcb9235 into google:master Sep 4, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add additional functionality for enterprise budgets

3 participants