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

🐛 Specify customer id for fetching user report usage. #4443

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions providers/google-workspace/resources/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (g *mqlGoogleworkspaceUser) usageReport() (*mqlGoogleworkspaceReportUsage,
now := time.Now()
tries := 10
for tries > 0 {
report, err := fetchUsageReport(reportsService, primaryEmail, now)
report, err := fetchUsageReport(reportsService, primaryEmail, conn.CustomerID(), now)
if err != nil && shouldCheckEarlierDateForReport(err) {
now = now.Add(-day)
tries--
Expand All @@ -138,8 +138,8 @@ func (g *mqlGoogleworkspaceUser) usageReport() (*mqlGoogleworkspaceReportUsage,
return nil, errors.New("could not fetch usage report for user, earliest tried date: " + now.Format(time.DateOnly))
}

func fetchUsageReport(svc *reports.Service, email string, date time.Time) (*reports.UsageReports, error) {
report, err := svc.UserUsageReport.Get(email, date.Format(time.DateOnly)).Do()
func fetchUsageReport(svc *reports.Service, email string, customerId string, date time.Time) (*reports.UsageReports, error) {
report, err := svc.UserUsageReport.Get(email, date.Format(time.DateOnly)).CustomerId(customerId).Do()
if err != nil {
return nil, err
}
Expand Down
Loading