Google Cloud Load Balancer is a fully distributed, software-defined managed service for distributing traffic across multiple instances, services, and regions. It supports HTTP(S), TCP/SSL, and UDP load balancing, integrates seamlessly with Google Cloud services, and provides high availability, scalability, and global reach. The GCPLoadBalancerHandler provides programmatic access to all load balancer components, including URL maps, backend services, proxies, forwarding rules, SSL certificates, and health checks.

Example

To create the GCPLoadBalancerHandler with Google Cloud credentials:
import os
from superagentx_handlers.gcp.load_balancer import GCPLoadBalancerHandler

# Initialize handler with a service account file
handler = GCPLoadBalancerHandler(
    creds=os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
)
List All Load Balancer Components:
Fetches all components (URL maps, backend services, proxies, SSL certs, health checks) concurrently.
components = await handler.list_all_load_balancer_components()
print(components.keys())
# Output: dict with url_maps, backend_services, proxies, ssl_certificates, health_checks
Get URL Maps (Application Load Balancers):
Retrieves URL maps including host rules, path matchers, and route actions.
url_maps = await handler.get_url_maps()
print(url_maps)
Get Backend Services:
Fetches backend services with protocols, ports, CDN settings, session affinity, and backend group details.
backends = await handler.get_backend_services()
print(backends)
Get Target HTTP Proxies:
Lists all HTTP proxies linked to URL maps.
http_proxies = await handler.get_target_http_proxies()
print(http_proxies)
Get Target HTTPS Proxies:
Lists all HTTPS proxies along with SSL certificates and QUIC override settings.
https_proxies = await handler.get_target_https_proxies()
print(https_proxies)
Get Global Forwarding Rules:
Fetches forwarding rules with IP addresses, protocols, port ranges, and targets.
rules = await handler.get_global_forwarding_rules()
print(rules)
Get SSL Certificates:
Retrieves SSL certificates (truncated for security) with SANs and expiration details.
certs = await handler.get_ssl_certificates()
print(certs)
Get Health Checks:
Lists health checks with thresholds, intervals, timeouts, and protocol-specific details (HTTP/HTTPS).
health_checks = await handler.get_health_checks()
print(health_checks)