Skip to content

Commit

Permalink
✨ extend google workspace apps resource with admin data (#4286)
Browse files Browse the repository at this point in the history
* create func (g *mqlGoogleworkspaceReportApps) admin() ([]interface{}, error) {

Signed-off-by: Manuel Weber <[email protected]>

* add field to manifest

Signed-off-by: Manuel Weber <[email protected]>

* add field to manifest++

Signed-off-by: Manuel Weber <[email protected]>

* add descriptions

Signed-off-by: Manuel Weber <[email protected]>

---------

Signed-off-by: Manuel Weber <[email protected]>
  • Loading branch information
mm-weber authored Jun 24, 2024
1 parent 41f1991 commit 1253f6c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
3 changes: 3 additions & 0 deletions providers/google-workspace/resources/google-workspace.lr
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ private googleworkspace.role @defaults("name") {

// Google Workspace apps reports
private googleworkspace.report.apps {
// Retrieves a report for the settings of the Google Workspace app Drive
drive() []googleworkspace.report.activity
// Retrieves a report for the Google Workspace Admin settings
admin() []googleworkspace.report.activity
}

// Google Workspace app reports activity
Expand Down
24 changes: 24 additions & 0 deletions providers/google-workspace/resources/google-workspace.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ resources:
googleworkspace.report.apps:
fields:
drive: {}
admin: {}
is_private: true
min_mondoo_version: latest
min_mondoo_version: 9.0.0
googleworkspace.report.usage:
fields:
account: {}
Expand Down
37 changes: 37 additions & 0 deletions providers/google-workspace/resources/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,43 @@ func (g *mqlGoogleworkspaceReportApps) drive() ([]interface{}, error) {
return res, nil
}

func (g *mqlGoogleworkspaceReportApps) admin() ([]interface{}, error) {
conn := g.MqlRuntime.Connection.(*connection.GoogleWorkspaceConnection)
reportsService, err := reportsService(conn)
if err != nil {
return nil, err
}

res := []interface{}{}

activities, err := reportsService.Activities.List("all", "admin").CustomerId(conn.CustomerID()).Do()
if err != nil {
return nil, err
}

for {
for i := range activities.Items {
r, err := newMqlGoogleWorkspaceReportActivity(g.MqlRuntime, activities.Items[i])
if err != nil {
return nil, err
}
res = append(res, r)
}

if activities.NextPageToken == "" {
break
}

activities, err = reportsService.Activities.List("all", "admin").CustomerId(conn.CustomerID()).
PageToken(activities.NextPageToken).Do()
if err != nil {
return nil, err
}
}

return res, nil
}

func (g *mqlGoogleworkspaceReportActivity) id() (string, error) {
if g.Id.Error != nil {
return "", g.Id.Error
Expand Down

0 comments on commit 1253f6c

Please sign in to comment.