vendor_connectors.google
Google Cloud and Workspace Connector using jbcom ecosystem packages.
Submodules
Section titled “Submodules”vendor_connectors.google.cloudvendor_connectors.google.servicesvendor_connectors.google.billingvendor_connectors.google.julesvendor_connectors.google.constantsvendor_connectors.google.toolsvendor_connectors.google.workspace
Package Contents
Section titled “Package Contents”Classes
Section titled “Classes”GoogleConnector | Google Cloud and Workspace base connector. |
|---|---|
GoogleConnectorFull | Full Google connector with all operations. |
DEFAULT_SCOPES |
|---|
vendor_connectors.google.DEFAULT_SCOPES
Section titled “vendor_connectors.google.DEFAULT_SCOPES”[‘https://www.googleapis.com/auth/cloud-platform’, ‘https://www.googleapis.com/auth/cloud-billing’, …
class vendor_connectors.google.GoogleConnector(service_account_info: dict[str, Any] | str | None = None, scopes: list[str] | None = None, subject: str | None = None, logger: lifecyclelogging.Logging | None = None, **kwargs)
Section titled “class vendor_connectors.google.GoogleConnector(service_account_info: dict[str, Any] | str | None = None, scopes: list[str] | None = None, subject: str | None = None, logger: lifecyclelogging.Logging | None = None, **kwargs)”Bases: vendor_connectors.base.VendorConnectorBase
Google Cloud and Workspace base connector.
This is the base connector class providing:
- Authentication via service account
- Service client creation and caching
- Subject impersonation for domain-wide delegation
Higher-level operations are provided via mixin classes from submodules.
Initialization
Section titled “Initialization”Initialize the Google connector.
Args: service_account_info: Service account JSON as dict or string. If not provided, reads from GOOGLE_SERVICE_ACCOUNT input. scopes: OAuth scopes to request. Defaults to common scopes. subject: Email to impersonate via domain-wide delegation. logger: Optional Logging instance. **kwargs: Additional arguments passed to VendorConnectorBase.
property credentials : google.oauth2.service_account.Credentials
Section titled “property credentials : google.oauth2.service_account.Credentials”Get or create Google credentials.
Returns: Authenticated service account credentials.
get_credentials_for_subject(subject: str) → google.oauth2.service_account.Credentials
Section titled “get_credentials_for_subject(subject: str) → google.oauth2.service_account.Credentials”Get credentials impersonating a specific user.
Args: subject: Email address to impersonate.
Returns: Credentials with the specified subject.
get_connector_for_user(primary_email: str, scopes: list[str] | None = None) → vendor_connectors.google.GoogleConnector
Section titled “get_connector_for_user(primary_email: str, scopes: list[str] | None = None) → vendor_connectors.google.GoogleConnector”Get a connector instance impersonating a specific user.
This is useful for terraform-style operations where you need to perform actions as a specific user rather than the service account.
Args: primary_email: Email address of the user to impersonate. scopes: Optional custom scopes. Defaults to current connector’s scopes.
Returns: A new GoogleConnector instance configured to impersonate the user.
get_service(service_name: str, version: str, subject: str | None = None) → Any
Section titled “get_service(service_name: str, version: str, subject: str | None = None) → Any”Get a Google API service client.
Args: service_name: Google API service name (e.g., ‘admin’, ‘cloudresourcemanager’). version: API version (e.g., ‘v1’, ‘directory_v1’). subject: Optional subject to impersonate for this service.
Returns: Google API service client.
get_admin_directory_service(subject: str | None = None) → Any
Section titled “get_admin_directory_service(subject: str | None = None) → Any”Get the Admin Directory API service.
get_cloud_resource_manager_service() → Any
Section titled “get_cloud_resource_manager_service() → Any”Get the Cloud Resource Manager API service.
get_iam_service() → Any
Section titled “get_iam_service() → Any”Get the IAM API service.
get_billing_service() → Any
Section titled “get_billing_service() → Any”Get the Cloud Billing API service.
get_compute_service() → Any
Section titled “get_compute_service() → Any”Get the Compute Engine API service.
get_container_service() → Any
Section titled “get_container_service() → Any”Get the GKE API service.
get_storage_service() → Any
Section titled “get_storage_service() → Any”Get the Cloud Storage API service.
get_sqladmin_service() → Any
Section titled “get_sqladmin_service() → Any”Get the Cloud SQL Admin API service.
get_pubsub_service() → Any
Section titled “get_pubsub_service() → Any”Get the Pub/Sub API service.
get_serviceusage_service() → Any
Section titled “get_serviceusage_service() → Any”Get the Service Usage API service.
get_cloudkms_service() → Any
Section titled “get_cloudkms_service() → Any”Get the Cloud KMS API service.
_resolve_bool_option(explicit: bool | None, input_key: str, default: bool) → bool
Section titled “_resolve_bool_option(explicit: bool | None, input_key: str, default: bool) → bool”Resolve boolean options from parameters or directed inputs.
_resolve_sequence_option(explicit: collections.abc.Sequence[str] | str | None, input_key: str) → list[str] | None
Section titled “_resolve_sequence_option(explicit: collections.abc.Sequence[str] | str | None, input_key: str) → list[str] | None”Resolve list-like options from parameters or directed inputs.
static _normalize_str_sequence(value: collections.abc.Sequence[Any] | str | None) → list[str] | None
Section titled “static _normalize_str_sequence(value: collections.abc.Sequence[Any] | str | None) → list[str] | None”Normalize comma-delimited strings or sequences into clean string lists.
static _normalize_org_unit_path(path: str | None) → str | None
Section titled “static _normalize_org_unit_path(path: str | None) → str | None”Normalize OrgUnit identifiers to leading-slash paths.
_normalize_org_unit_list(values: list[str] | None) → list[str] | None
Section titled “_normalize_org_unit_list(values: list[str] | None) → list[str] | None”Normalize org unit inputs and discard empties.
_is_org_unit_allowed(entry: dict[str, Any], allow_list: list[str] | None, deny_list: list[str] | None) → bool
Section titled “_is_org_unit_allowed(entry: dict[str, Any], allow_list: list[str] | None, deny_list: list[str] | None) → bool”Check whether an entry’s org unit is permitted by allow/deny lists.
static _is_bot_entry(entry: dict[str, Any]) → bool
Section titled “static _is_bot_entry(entry: dict[str, Any]) → bool”Detect Google Workspace bot/service accounts.
static _flatten_user_name(entry: dict[str, Any]) → None
Section titled “static _flatten_user_name(entry: dict[str, Any]) → None”Flatten the nested name structure for easier downstream consumption.
static _key_results_by_email(entries: list[dict[str, Any]], , primary_field: str, fallback_field: str | None = None) → dict[str, dict[str, Any]]
Section titled “static _key_results_by_email(entries: list[dict[str, Any]], , primary_field: str, fallback_field: str | None = None) → dict[str, dict[str, Any]]”Convert a list of directory entries into a dictionary keyed by email.
_filter_directory_entries(entries: list[dict[str, Any]], , ou_allow_list: list[str] | None, ou_deny_list: list[str] | None, include_suspended: bool, exclude_bots: bool, flatten_names: bool) → list[dict[str, Any]]
Section titled “_filter_directory_entries(entries: list[dict[str, Any]], , ou_allow_list: list[str] | None, ou_deny_list: list[str] | None, include_suspended: bool, exclude_bots: bool, flatten_names: bool) → list[dict[str, Any]]”Apply filtering and optional name flattening to directory results.
list_users(domain: str | None = None, max_results: int = 500, , ou_allow_list: collections.abc.Sequence[str] | str | None = None, ou_deny_list: collections.abc.Sequence[str] | str | None = None, include_suspended: bool | None = None, exclude_bots: bool | None = None, flatten_names: bool | None = None, key_by_email: bool | None = None) → list[dict[str, Any]] | dict[str, dict[str, Any]]
Section titled “list_users(domain: str | None = None, max_results: int = 500, , ou_allow_list: collections.abc.Sequence[str] | str | None = None, ou_deny_list: collections.abc.Sequence[str] | str | None = None, include_suspended: bool | None = None, exclude_bots: bool | None = None, flatten_names: bool | None = None, key_by_email: bool | None = None) → list[dict[str, Any]] | dict[str, dict[str, Any]]”List users from Google Workspace with optional filtering.
Args: domain: Domain to list users from. max_results: Maximum results per page. ou_allow_list: Only include users from these OUs. ou_deny_list: Exclude users from these OUs. include_suspended: Include suspended users (default False). exclude_bots: Exclude service/bot accounts (default True). flatten_names: Flatten nested name structure (default False). key_by_email: Return dict keyed by email instead of list (default False).
Returns: List of user dicts, or dict keyed by email if key_by_email=True.
list_groups(domain: str | None = None, max_results: int = 200, , ou_allow_list: collections.abc.Sequence[str] | str | None = None, ou_deny_list: collections.abc.Sequence[str] | str | None = None, include_suspended: bool | None = None, exclude_bots: bool | None = None, flatten_names: bool | None = None, key_by_email: bool | None = None) → list[dict[str, Any]] | dict[str, dict[str, Any]]
Section titled “list_groups(domain: str | None = None, max_results: int = 200, , ou_allow_list: collections.abc.Sequence[str] | str | None = None, ou_deny_list: collections.abc.Sequence[str] | str | None = None, include_suspended: bool | None = None, exclude_bots: bool | None = None, flatten_names: bool | None = None, key_by_email: bool | None = None) → list[dict[str, Any]] | dict[str, dict[str, Any]]”List groups from Google Workspace with optional filtering.
Args: domain: Domain to list groups from. max_results: Maximum results per page. ou_allow_list: Only include groups from these OUs. ou_deny_list: Exclude groups from these OUs. include_suspended: Include suspended groups (default False). exclude_bots: Exclude bot groups (default True). flatten_names: Flatten nested name structure (default False). key_by_email: Return dict keyed by email instead of list (default False).
Returns: List of group dicts, or dict keyed by email if key_by_email=True.
class vendor_connectors.google.GoogleConnectorFull(service_account_info: dict[str, Any] | str | None = None, scopes: list[str] | None = None, subject: str | None = None, logger: lifecyclelogging.Logging | None = None, **kwargs)
Section titled “class vendor_connectors.google.GoogleConnectorFull(service_account_info: dict[str, Any] | str | None = None, scopes: list[str] | None = None, subject: str | None = None, logger: lifecyclelogging.Logging | None = None, **kwargs)”Bases: vendor_connectors.google.GoogleConnector, vendor_connectors.google.workspace.GoogleWorkspaceMixin, vendor_connectors.google.cloud.GoogleCloudMixin, vendor_connectors.google.billing.GoogleBillingMixin, vendor_connectors.google.services.GoogleServicesMixin
Full Google connector with all operations.
This class combines the base GoogleConnector with all operation mixins. Use this for full functionality, or use GoogleConnector directly and import specific mixins as needed.
Initialization
Section titled “Initialization”Initialize the Google connector.
Args: service_account_info: Service account JSON as dict or string. If not provided, reads from GOOGLE_SERVICE_ACCOUNT input. scopes: OAuth scopes to request. Defaults to common scopes. subject: Email to impersonate via domain-wide delegation. logger: Optional Logging instance. **kwargs: Additional arguments passed to VendorConnectorBase.