feat(google-workspace-admin): add Admin SDK Directory and Reports integration - #6744
feat(google-workspace-admin): add Admin SDK Directory and Reports integration#6744waleedlatif1 wants to merge 5 commits into
Conversation
…egration Adds a Google Workspace Admin block covering the Directory API surfaces Google Groups never reached — users, org units, admin roles, and devices — plus the Reports API audit and usage endpoints. This is what joiner, mover, and leaver workflows were missing. 36 tools: - Users: list, get, create, update, delete, suspend, unsuspend, reset password, move org unit, make/revoke admin, sign out, aliases, and the OAuth application tokens a user has issued - Org units: list, get, create, update, delete - Roles: list roles, get role, list/create/delete role assignments - Devices: mobile list/get/action, ChromeOS list/get/update - Reports: activities.list, customerUsageReports.get, userUsageReport.get OAuth wiring mirrors google-groups: a google-workspace-admin service on the shared Google client, service-account fallback, and per-endpoint scopes (directory user/alias/security, orgunit, rolemanagement, device mobile and chromeos, reports audit and usage readonly). The icon is a placeholder monochrome glyph drawn with currentColor, marked TODO until the real brand mark lands. chromeosdevices.action is deliberately omitted: Google marks it deprecated in favor of BatchChangeChromeOsDeviceStatus.
…tead of replacing them
…hangeStatus chromeosdevices.action was dropped as deprecated, which left deprovision, disable, and re-enable — the whole Chromebook offboarding path — with no replacement. The successor Google points at, customer.devices.chromeos :batchChangeStatus, has a fully specified request and response in the Directory API discovery document, so implement it rather than leave the gap: up to 50 device IDs, the three real ChangeChromeOsDeviceStatusAction values, and the four non-deprecated DeprovisionReason values, which the block only sends when the action is DEPROVISION as the API requires. Also drop admin.directory.device.mobile.action from the declared scopes. mobiledevices.action accepts either it or admin.directory.device.mobile, and the latter is already declared for list and get, so the narrower scope only widened the consent screen without unlocking anything. Default the role-assignment scope dropdown to CUSTOMER so the common account-wide grant needs no extra choice.
The Directory API does not use one casing convention. Five query parameters were sent in SCREAMING_SNAKE while the discovery document declares them camelCase or lowercase, so every one of them would have come back 400 Invalid Value: - users.list orderBy: email, familyName, givenName - users.list / users.get projection: basic, custom, full - orgunits.list type: all, children, allIncludingParent - chromeosdevices.list orderBy: annotatedLocation, annotatedUser, ... - mobiledevices.list orderBy: deviceId, email, lastSync, ... The device collections really are uppercase for projection (BASIC, FULL) and every collection is uppercase for sortOrder, which is what made the users endpoints easy to get wrong. Each allowed set is now a constant taken verbatim from discovery, the param interfaces derive their unions from those constants, and normalizeEnumValue matches case-insensitively and ignores underscores so a caller writing either style still reaches the API with the spelling that endpoint wants. An unrecognized value now fails with the allowed set instead of a bare 400. Two related fixes: deprovisionReason was marked required on the subBlock but optional on the tool, and the serializer validates neither once a name is claimed by a tool param, so a DEPROVISION batch with no reason serialized fine and failed at Google. The body builder now gates on the action: required for DEPROVISION, never sent for the other two, which is what the API accepts. update_chromeos_device and update_org_unit guarded their optional strings with !== undefined while the rest of the integration guards on truthiness. A subBlock that was touched and cleared serializes as '', so those five PATCH fields would wipe the annotation, notes, or description rather than leave them alone.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryHigh Risk Overview Product surface: A large Auth & credentials: New OAuth provider Reviewed by Cursor Bugbot for commit 98c7ba7. Configure here. |
Greptile SummaryAdds a Google Workspace Admin integration spanning Directory and Reports APIs, including OAuth/service-account wiring, block registration, generated metadata, and documentation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported ChromeOS batch partial-failure path now returns a failed tool result and stops generic workflow continuation.
|
| Filename | Overview |
|---|---|
| apps/sim/tools/google_workspace_admin/batch_change_chromeos_device_status.ts | The prior partial-failure issue is addressed by detecting item-level errors, returning top-level failure, and preserving per-device outcomes and retry IDs. |
| apps/sim/blocks/blocks/google_workspace_admin.ts | Defines the new block’s operation-specific UI, parameter mapping, tool selection, and declared outputs. |
| apps/sim/tools/google_workspace_admin/types.ts | Provides shared parameter and response types for the new Google Workspace Admin tools. |
| apps/sim/lib/oauth/oauth.ts | Extends shared OAuth configuration for the Google Workspace Admin service. |
| apps/sim/tools/registry.ts | Registers the new Admin SDK and Reports API tools for runtime dispatch. |
Reviews (2): Last reviewed commit: "fix(google-workspace-admin): fail the Ch..." | Re-trigger Greptile
…es not change batchChangeStatus returns HTTP 200 for the batch as a whole and reports each device separately, so a device that stayed enabled is only visible through its per-result error. The tool returned success unconditionally, which meant an offboarding agent would carry on believing a Chromebook had been disabled or deprovisioned when it had not. The transform now partitions the results and fails the tool when any device errored, naming each failing device and Google's reason. Both sides of the split are also exposed as succeededDeviceIds and failedDeviceIds so a partial failure can be retried for just the remainder instead of re-running the whole batch — which matters for DEPROVISION, where a repeat on an already-deprovisioned device is not harmless.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 98c7ba7. Configure here.
Summary
Adds a Google Workspace Admin block covering the Admin SDK Directory API surfaces the Google Groups integration never reached — users, org units, admin roles, and devices — plus the Reports API audit and usage endpoints. This is what joiner/mover/leaver agents were missing.
37 tools:
activities.list,customerUsageReports.get,userUsageReport.getOAuth wiring mirrors
google-groups: agoogle-workspace-adminservice on the shared Google client, service-account fallback, and per-endpoint scopes.Notes for reviewers
GoogleWorkspaceAdminIconis a neutral monochrome directory glyph drawn withcurrentColor, markedTODOin the source until a real brand mark is supplied.BatchChangeChromeOsDeviceStatuswas added to restore ChromeOS offboarding. The deprecatedchromeosdevices.actionendpoint was deliberately not used; dropping it had left deprovision/disable/re-enable — the whole Chromebook offboarding path — with no replacement. The successor is fully specified in the discovery document: up to 50 device IDs, three status actions, four non-deprecated deprovision reasons.admin.directory.device.mobile.actionwas removed as redundant.mobiledevices.actionaccepts either it oradmin.directory.device.mobile, and the latter is already declared for list and get, so the narrower scope only widened the consent screen without unlocking anything.directory_v1andreports_v1) — not against prose docs and not against a live account. The one thing discovery cannot confirm is themobiledevices.actionaction values (MobileDeviceAction.actionis a bare string with no enum); those come from prose docs only and are called out here rather than presented as verified.Validation findings fixed in this PR
A final validation pass against the discovery documents caught seven real defects, all in the last commit:
Enum casing (would have returned
400 Invalid Valueon every call). The Directory API does not use one casing convention —users.listtakesfamilyNameandbasic, while the device collections takeSERIAL_NUMBERandBASIC, andsortOrderis uppercase everywhere. Five parameters were sent in the wrong style:users.list orderBy,users.list/users.get projection,orgunits.list type,chromeosdevices.list orderBy, andmobiledevices.list orderBy. Each allowed set is now a constant taken verbatim from discovery, the param interfaces derive their unions from those constants, andnormalizeEnumValuematches case-insensitively and ignores underscores so a caller writing either style still reaches the API with the spelling that endpoint wants. An unrecognized value now fails with the allowed set instead of a bare 400.deprovisionReasonwas never enforced. It wasrequired: trueon the subBlock butrequired: falseon the tool, and the serializer validates neither once a name is claimed by a tool param — so a DEPROVISION batch with a blank reason serialized fine and failed at Google. The body builder now gates on the action: required for DEPROVISION, never sent for the other two.Five PATCH fields could silently wipe data.
update_chromeos_deviceandupdate_org_unitguarded their optional strings with!== undefinedwhile the rest of the integration guards on truthiness. A subBlock that was touched and then cleared serializes as'', so those fields would erase the annotation, notes, or description rather than leave them alone.Test plan
bun run type-checkcleanbun run check:audits— 26 audits, all passing except four that need binaries this worktree lacks (turbo,tsc,biome)bun run tool-metadata:check,bun run integration-catalog:check,bun run check:api-validation:strictpassbun test apps/sim/lib/integrations/availability.server.test.ts apps/sim/lib/integrations/credential-display.test.ts— 50 passintegrations.json, and the docs icon mirror regenerated and byte-identical to the app copy