Skip to content

vendor_connectors.google.workspace

Google Workspace (Admin Directory) operations.

This module provides operations for managing Google Workspace users and groups through the Admin Directory API.

GoogleWorkspaceMixinMixin providing Google Workspace operations.

class vendor_connectors.google.workspace.GoogleWorkspaceMixin

Section titled “class vendor_connectors.google.workspace.GoogleWorkspaceMixin”

Mixin providing Google Workspace operations.

This mixin requires the base GoogleConnector class to provide:

  • get_admin_directory_service()
  • get_service()
  • logger

List users from Google Workspace.

Args: domain: Optional domain to filter users. max_results: Maximum results per page. Defaults to 500. unhump_users: Convert keys to snake_case. Defaults to False. subject: Email to impersonate for domain-wide delegation.

Returns: List of user dictionaries.

Get a specific user from Google Workspace.

Args: user_key: Email or unique ID of the user. subject: Email to impersonate for domain-wide delegation.

Returns: User dictionary or None if not found.

Create a user in Google Workspace.

Args: primary_email: Primary email address. given_name: First name. family_name: Last name. password: Initial password. Generated if not provided. change_password_at_next_login: Force password change. Defaults to True. org_unit_path: Organizational unit path. Defaults to ‘/’. subject: Email to impersonate for domain-wide delegation. **additional_fields: Additional user fields.

Returns: Created user dictionary.

Update a user in Google Workspace.

Args: user_key: Email or unique ID of the user. subject: Email to impersonate for domain-wide delegation. **fields: Fields to update.

Returns: Updated user dictionary.

Delete a user from Google Workspace.

Args: user_key: Email or unique ID of the user. subject: Email to impersonate for domain-wide delegation.

List groups from Google Workspace.

Args: domain: Optional domain to filter groups. max_results: Maximum results per page. Defaults to 200. unhump_groups: Convert keys to snake_case. Defaults to False. subject: Email to impersonate for domain-wide delegation.

Returns: List of group dictionaries.

Get a specific group from Google Workspace.

Args: group_key: Email or unique ID of the group. subject: Email to impersonate for domain-wide delegation.

Returns: Group dictionary or None if not found.

Create a group in Google Workspace.

Args: email: Group email address. name: Display name. description: Group description. subject: Email to impersonate for domain-wide delegation.

Returns: Created group dictionary.

Delete a group from Google Workspace.

Args: group_key: Email or unique ID of the group. subject: Email to impersonate for domain-wide delegation.

List members of a Google Workspace group.

Args: group_key: Email or unique ID of the group. roles: Filter by roles (OWNER, MANAGER, MEMBER). Defaults to all. unhump_members: Convert keys to snake_case. Defaults to False. subject: Email to impersonate for domain-wide delegation.

Returns: List of member dictionaries.

Add a member to a Google Workspace group.

Args: group_key: Email or unique ID of the group. email: Email of the member to add. role: Member role (OWNER, MANAGER, MEMBER). Defaults to MEMBER. subject: Email to impersonate for domain-wide delegation.

Returns: Created member dictionary.

Remove a member from a Google Workspace group.

Args: group_key: Email or unique ID of the group. member_key: Email or unique ID of the member. subject: Email to impersonate for domain-wide delegation.

List organizational units in Google Workspace.

Args: org_unit_path: Parent org unit path. Defaults to ‘/’. org_unit_type: Type filter (all, children, allIncludingParent). subject: Email to impersonate for domain-wide delegation.

Returns: List of org unit dictionaries.

create_or_update_user(primary_email: str, given_name: str, family_name: str, password: str | None = None, update_if_exists: bool = False, change_password_at_next_login: bool = True, org_unit_path: str = ’/’, subject: str | None = None, **additional_fields) → dict[str, Any]

Section titled “create_or_update_user(primary_email: str, given_name: str, family_name: str, password: str | None = None, update_if_exists: bool = False, change_password_at_next_login: bool = True, org_unit_path: str = ’/’, subject: str | None = None, **additional_fields) → dict[str, Any]”

Create or update a user in Google Workspace.

This method provides terraform-style idempotent user management. If update_if_exists is True and the user exists, it updates instead of failing.

Args: primary_email: Primary email address. given_name: First name. family_name: Last name. password: Initial password. Generated if not provided. update_if_exists: If True, update existing user instead of failing. change_password_at_next_login: Force password change. Defaults to True. org_unit_path: Organizational unit path. Defaults to ‘/’. subject: Email to impersonate for domain-wide delegation. **additional_fields: Additional user fields.

Returns: Created or updated user dictionary.

Create or update a group in Google Workspace.

This method provides terraform-style idempotent group management. If update_if_exists is True and the group exists, it updates instead of failing.

Args: email: Group email address. name: Display name. description: Group description. update_if_exists: If True, update existing group instead of failing. subject: Email to impersonate for domain-wide delegation. **additional_fields: Additional group fields.

Returns: Created or updated group dictionary.

List available Google Workspace licenses.

Args: customer_id: Customer ID. Defaults to ‘my_customer’. product_id: Filter by product (e.g., ‘Google-Apps’, ‘Google-Vault’). subject: Email to impersonate for domain-wide delegation.

Returns: List of license dictionaries.

Get a summary of license usage by product.

Args: customer_id: Customer ID. Defaults to ‘my_customer’. subject: Email to impersonate for domain-wide delegation.

Returns: Dictionary mapping product IDs to usage counts.