[FEAT] Add enterprise billing usage data sources#3293
Open
vmvarela wants to merge 7 commits intointegrations:mainfrom
Open
[FEAT] Add enterprise billing usage data sources#3293vmvarela wants to merge 7 commits intointegrations:mainfrom
vmvarela wants to merge 7 commits intointegrations:mainfrom
Conversation
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
3 tasks
Author
|
Updated acceptance tests (commit 9ebb722) to go beyond the trivial slug check:
All unit tests still pass ( |
Add three new data sources for GitHub enterprise billing: - github_enterprise_billing_usage - github_enterprise_billing_premium_request_usage - github_enterprise_billing_usage_summary
Register data sources in provider.go and add sidebar entries in github.erb.
- Dereference *string pointer fields (organization_name, repository_name) in flattenUsageItems to avoid storing pointers in TypeString schema fields - Replace deprecated ValidateFunc with ValidateDiagFunc for year/month/day integer validators across all three enterprise billing data sources - Replace fork-local buildID() with upstream-compatible buildTwoPartID() in all three data source Read functions - Update unit test assertions to match dereferenced string values
…ctural checks Add assertions for: - ID format using StringRegexp (e.g. 'slug:billing-usage') - usage_items and time_period are NotNull - Additional filter variants (year+month) for billing usage data source
The modernize/newexpr rule incorrectly suggests replacing github.Ptr(x) with new(x), but new() takes a type not an expression — the auto-fix generates invalid Go code. Exclude this specific rule pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds three new data sources for querying GitHub Enterprise billing
usage via the enhanced billing platform API:
github_enterprise_billing_usage— itemized usage report(
GET /enterprises/{enterprise}/settings/billing/usage)github_enterprise_billing_usage_summary— aggregated summary report(
GET /enterprises/{enterprise}/settings/billing/usage/summary)github_enterprise_billing_premium_request_usage— premium request (e.g.Copilot) usage report
(
GET /enterprises/{enterprise}/settings/billing/premium_request/usage)All three are read-only data sources. No resources are added.
Relates to #2739
Context
The enhanced billing platform endpoints for enterprises are not yet wrapped
by the
go-githubclient library. This PR implements manual HTTP requestsusing
client.NewRequest/client.Do, following the same pattern usedelsewhere in the provider for endpoints not yet covered by the SDK.
Data Sources
github_enterprise_billing_usageReturns itemized billing line items for an enterprise. Optional filters:
year,month,day,cost_center_id.github_enterprise_billing_usage_summaryReturns an aggregated summary of billing usage. Optional filters:
year,month,day,organization,repository,product,sku,cost_center_id.github_enterprise_billing_premium_request_usageReturns premium request usage (AI models, Copilot, etc.). Optional filters:
year,month,day,organization,user,model,product,cost_center_id.Testing
Acceptance tests are gated on
skipUnlessMode(t, enterprise)and requirea GitHub Enterprise token (
GITHUB_ENTERPRISE_SLUG,GITHUB_TOKEN).Unit tests for all helper functions are in
util_enterprise_billing_test.goand run without any credentials.
Checklist
ValidateDiagFuncused (not deprecatedValidateFunc)d.Set()errors checked and returneddiag.Errorfused instead ofdiag.FromErr(fmt.Errorf(...))buildTwoPartID)provider.goandwebsite/github.erbwebsite/docs/d/go test ./github/ -run TestFlatten...)