Skip to content

vendor_connectors.google.services

Google Cloud services discovery operations.

This module provides operations for discovering resources across Google Cloud services like GKE, Compute Engine, Cloud Storage, Cloud SQL, Pub/Sub, etc.

GoogleServicesMixinMixin providing Google Cloud services discovery operations.

class vendor_connectors.google.services.GoogleServicesMixin

Section titled “class vendor_connectors.google.services.GoogleServicesMixin”

Mixin providing Google Cloud services discovery operations.

This mixin requires the base GoogleConnector class to provide:

  • get_compute_service()
  • get_container_service()
  • get_storage_service()
  • get_sqladmin_service()
  • get_pubsub_service()
  • get_serviceusage_service()
  • get_cloudkms_service()
  • logger

List Compute Engine instances in a project.

Args: project_id: The project ID. zone: Optional zone filter. If not provided, lists all zones. unhump_instances: Convert keys to snake_case. Defaults to False.

Returns: List of instance dictionaries.

List GKE clusters in a project.

Args: project_id: The project ID. location: Zone or region. Use ‘-’ for all locations. unhump_clusters: Convert keys to snake_case. Defaults to False.

Returns: List of cluster dictionaries.

Get a specific GKE cluster.

Args: project_id: The project ID. location: Zone or region. cluster_id: The cluster ID.

Returns: Cluster dictionary or None if not found.

List Cloud Storage buckets in a project.

Args: project_id: The project ID. unhump_buckets: Convert keys to snake_case. Defaults to False.

Returns: List of bucket dictionaries.

List Cloud SQL instances in a project.

Args: project_id: The project ID. unhump_instances: Convert keys to snake_case. Defaults to False.

Returns: List of SQL instance dictionaries.

List Pub/Sub topics in a project.

Args: project_id: The project ID. unhump_topics: Convert keys to snake_case. Defaults to False.

Returns: List of topic dictionaries.

List Pub/Sub subscriptions in a project.

Args: project_id: The project ID. unhump_subscriptions: Convert keys to snake_case. Defaults to False.

Returns: List of subscription dictionaries.

List enabled APIs/services in a project.

Args: project_id: The project ID. unhump_services: Convert keys to snake_case. Defaults to False.

Returns: List of service dictionaries.

Enable an API/service in a project.

Args: project_id: The project ID. service_name: Service name (e.g., ‘compute.googleapis.com’).

Returns: Operation response dictionary.

Disable an API/service in a project.

Args: project_id: The project ID. service_name: Service name (e.g., ‘compute.googleapis.com’). force: Force disable even if dependencies exist.

Returns: Operation response dictionary.

Enable multiple APIs/services in a project.

Args: project_id: The project ID. service_names: List of service names to enable.

Returns: Operation response dictionary.

List KMS key rings in a project location.

Args: project_id: The project ID. location: The location (e.g., ‘us-central1’, ‘global’). unhump_keyrings: Convert keys to snake_case. Defaults to False.

Returns: List of key ring dictionaries.

Create a KMS key ring.

Args: project_id: The project ID. location: The location (e.g., ‘us-central1’, ‘global’). keyring_id: Unique key ring ID.

Returns: Created key ring dictionary.

create_kms_key(project_id: str, location: str, keyring_id: str, key_id: str, purpose: str = ‘ENCRYPT_DECRYPT’, algorithm: str = ‘GOOGLE_SYMMETRIC_ENCRYPTION’) → dict[str, Any]

Section titled “create_kms_key(project_id: str, location: str, keyring_id: str, key_id: str, purpose: str = ‘ENCRYPT_DECRYPT’, algorithm: str = ‘GOOGLE_SYMMETRIC_ENCRYPTION’) → dict[str, Any]”

Create a KMS crypto key.

Args: project_id: The project ID. location: The location. keyring_id: The key ring ID. key_id: Unique key ID. purpose: Key purpose (ENCRYPT_DECRYPT, ASYMMETRIC_SIGN, etc.). algorithm: Key algorithm.

Returns: Created crypto key dictionary.

Check if a project has no resources.

Args: project_id: The project ID. check_compute: Check for Compute Engine instances. check_gke: Check for GKE clusters. check_storage: Check for Cloud Storage buckets. check_sql: Check for Cloud SQL instances. check_pubsub: Check for Pub/Sub topics.

Returns: True if the project has no resources.

Get IAM users (members) with access to a project.

Args: project_id: The project ID.

Returns: Dictionary mapping member identifiers to their roles.

Get all Pub/Sub topics and subscriptions for a project.

Args: project_id: The project ID. include_subscriptions: Include subscription details. Defaults to True. unhump_resources: Convert keys to snake_case. Defaults to False.

Returns: Dictionary with ‘topics’ and ‘subscriptions’ lists.

Find projects that appear to be inactive or dead.

A project is considered inactive if:

  • It has no resources (compute, GKE, storage, etc.)
  • Its lifecycle state is not ACTIVE

Args: projects: Pre-fetched projects dict. Fetched if not provided. check_resources: Check if projects have resources. Defaults to True. days_since_activity: Days threshold for activity (not implemented yet).

Returns: List of inactive project dictionaries.