feat: Add enterprise billing usage endpoints and response types#4288
feat: Add enterprise billing usage endpoints and response types#4288maishivamhoo123 wants to merge 7 commits into
Conversation
Signed-off-by: maishivamhoo123 <maishivamhoo@gmail.com>
Signed-off-by: maishivamhoo123 <maishivamhoo@gmail.com>
Signed-off-by: maishivamhoo123 <maishivamhoo@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4288 +/- ##
==========================================
- Coverage 97.49% 97.47% -0.03%
==========================================
Files 192 193 +1
Lines 19256 19308 +52
==========================================
+ Hits 18774 18820 +46
- Misses 267 269 +2
- Partials 215 219 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: maishivamhoo123 <maishivamhoo@gmail.com>
|
@alexandear @gmlewis @Not-Dhananjay-Mishra i made all the changes can you please review it ? |
| type EnterpriseUsageReportOptions struct { | ||
| Year int `url:"year,omitempty"` | ||
| Month int `url:"month,omitempty"` | ||
| Day int `url:"day,omitempty"` | ||
| CostCenterID string `url:"cost_center_id,omitempty"` | ||
| } | ||
|
|
||
| // EnterprisePremiumRequestUsageReportOptions specifies optional parameters for the BillingService.GetEnterprisePremiumRequestUsageReport and BillingService.GetEnterpriseAICreditUsage methods. | ||
| type EnterprisePremiumRequestUsageReportOptions struct { | ||
| Year int `url:"year,omitempty"` | ||
| Month int `url:"month,omitempty"` | ||
| Day int `url:"day,omitempty"` | ||
| Organization string `url:"organization,omitempty"` | ||
| User string `url:"user,omitempty"` | ||
| Model string `url:"model,omitempty"` | ||
| Product string `url:"product,omitempty"` | ||
| CostCenterID string `url:"cost_center_id,omitempty"` | ||
| } | ||
|
|
||
| // EnterpriseUsageSummaryOptions specifies optional parameters for the BillingService.GetEnterpriseUsageSummary method. | ||
| type EnterpriseUsageSummaryOptions struct { |
| } | ||
| } | ||
|
|
||
| func TestEnterpriseService_GetUsageSummary_WithRepository(t *testing.T) { |
There was a problem hiding this comment.
Why do we need this test? It duplicates TestEnterpriseService_GetUsageSummary_WithAllFilters
There was a problem hiding this comment.
Please review all tests and try not adding redundant tests that check the same functionality.
| // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/billing/usage?apiVersion=2022-11-28#get-billing-usage-summary-for-an-enterprise | ||
| // | ||
| //meta:operation GET /enterprises/{enterprise}/settings/billing/usage/summary | ||
| func (s *EnterpriseService) GetUsageSummary(ctx context.Context, enterprise string, opts *EnterpriseUsageSummaryOptions) (*EnterpriseAggregatedUsageReport, *Response, error) { |
There was a problem hiding this comment.
Response schema of GetUsageSummary is little bit different from GetPremiumRequestUsageReport and GetAICreditUsage. Its response schema doesn't contain user and model, In my opinion we should make a new struct for it.

Summary
Adds support for the GitHub Enterprise billing usage API endpoints.
#4262
New methods on BillingService
GetEnterpriseUsageReport
GetEnterpriseUsageSummary
GetEnterprisePremiumRequestUsageReport
GetEnterpriseAICreditUsage
And added test for all the new End points .