or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
golangpkg:golang/cloud.google.com/go/compute@v1.53.0

docs

clients

disks.mdinstances.mdload-balancing.mdnetworks.mdoperations.mdother-clients.mdregional.mdsecurity.mdstorage.md
index.mdmetadata.mdtypes.md
tile.json

tessl/golang-cloud-google-com--go--compute

tessl install tessl/golang-cloud-google-com--go--compute@1.53.0

Go client library for Google Cloud Compute Engine API providing programmatic access to manage virtual machines, disks, networks, and other compute resources

load-balancing.mddocs/clients/

Load Balancing Clients

Load balancing clients configure and manage Google Cloud Load Balancers including HTTP(S) Load Balancers, SSL/TCP Proxy Load Balancers, Network Load Balancers, and their associated components.

Backend Services Client

The BackendServicesClient manages backend services that define how traffic is distributed to backend instances.

Client Creation

func NewBackendServicesRESTClient(ctx context.Context, opts ...option.ClientOption) (*BackendServicesClient, error)

Example:

import (
    "context"
    compute "cloud.google.com/go/compute/apiv1"
)

ctx := context.Background()
client, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
    // handle error
}
defer client.Close()

Backend Service Operations

// Get retrieves a backend service
func (c *BackendServicesClient) Get(ctx context.Context, req *computepb.GetBackendServiceRequest, opts ...gax.CallOption) (*computepb.BackendService, error)

// List returns an iterator over backend services
func (c *BackendServicesClient) List(ctx context.Context, req *computepb.ListBackendServicesRequest, opts ...gax.CallOption) *BackendServiceIterator

// AggregatedList returns an iterator over backend services across all regions
func (c *BackendServicesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListBackendServicesRequest, opts ...gax.CallOption) *BackendServicesScopedListPairIterator

// Insert creates a new backend service
func (c *BackendServicesClient) Insert(ctx context.Context, req *computepb.InsertBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)

// Update updates a backend service
func (c *BackendServicesClient) Update(ctx context.Context, req *computepb.UpdateBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)

// Patch partially updates a backend service
func (c *BackendServicesClient) Patch(ctx context.Context, req *computepb.PatchBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)

// Delete deletes a backend service
func (c *BackendServicesClient) Delete(ctx context.Context, req *computepb.DeleteBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)

Example - Create Backend Service:

import (
    "cloud.google.com/go/compute/apiv1/computepb"
    "google.golang.org/protobuf/proto"
)

insertReq := &computepb.InsertBackendServiceRequest{
    Project: "my-project",
    BackendServiceResource: &computepb.BackendService{
        Name:        proto.String("my-backend-service"),
        Protocol:    proto.String("HTTP"),
        Port:        proto.Int32(80),
        TimeoutSec:  proto.Int32(30),
        LoadBalancingScheme: proto.String("EXTERNAL"),
        HealthChecks: []string{
            "projects/my-project/global/healthChecks/my-health-check",
        },
        Backends: []*computepb.Backend{
            {
                Group: proto.String("projects/my-project/zones/us-central1-a/instanceGroups/my-ig"),
                BalancingMode: proto.String("UTILIZATION"),
                MaxUtilization: proto.Float64(0.8),
            },
        },
    },
}
op, err := client.Insert(ctx, insertReq)

Health Operations

// GetHealth retrieves health status of backends
func (c *BackendServicesClient) GetHealth(ctx context.Context, req *computepb.GetHealthBackendServiceRequest, opts ...gax.CallOption) (*computepb.BackendServiceGroupHealth, error)

IAM Operations

// GetIamPolicy retrieves the IAM policy
func (c *BackendServicesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyBackendServiceRequest, opts ...gax.CallOption) (*computepb.Policy, error)

// SetIamPolicy sets the IAM policy
func (c *BackendServicesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyBackendServiceRequest, opts ...gax.CallOption) (*computepb.Policy, error)

// TestIamPermissions tests IAM permissions
func (c *BackendServicesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsBackendServiceRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)

Health Checks Client

The HealthChecksClient manages health check configurations for load balancer backends.

Client Creation

func NewHealthChecksRESTClient(ctx context.Context, opts ...option.ClientOption) (*HealthChecksClient, error)

Health Check Operations

// Get retrieves a health check
func (c *HealthChecksClient) Get(ctx context.Context, req *computepb.GetHealthCheckRequest, opts ...gax.CallOption) (*computepb.HealthCheck, error)

// List returns an iterator over health checks
func (c *HealthChecksClient) List(ctx context.Context, req *computepb.ListHealthChecksRequest, opts ...gax.CallOption) *HealthCheckIterator

// AggregatedList returns an iterator over health checks across all regions
func (c *HealthChecksClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListHealthChecksRequest, opts ...gax.CallOption) *HealthChecksScopedListPairIterator

// Insert creates a new health check
func (c *HealthChecksClient) Insert(ctx context.Context, req *computepb.InsertHealthCheckRequest, opts ...gax.CallOption) (*Operation, error)

// Update updates a health check
func (c *HealthChecksClient) Update(ctx context.Context, req *computepb.UpdateHealthCheckRequest, opts ...gax.CallOption) (*Operation, error)

// Patch partially updates a health check
func (c *HealthChecksClient) Patch(ctx context.Context, req *computepb.PatchHealthCheckRequest, opts ...gax.CallOption) (*Operation, error)

// Delete deletes a health check
func (c *HealthChecksClient) Delete(ctx context.Context, req *computepb.DeleteHealthCheckRequest, opts ...gax.CallOption) (*Operation, error)

Example - Create HTTP Health Check:

insertReq := &computepb.InsertHealthCheckRequest{
    Project: "my-project",
    HealthCheckResource: &computepb.HealthCheck{
        Name:               proto.String("http-health-check"),
        Type:               proto.String("HTTP"),
        CheckIntervalSec:   proto.Int32(10),
        TimeoutSec:         proto.Int32(5),
        HealthyThreshold:   proto.Int32(2),
        UnhealthyThreshold: proto.Int32(3),
        HttpHealthCheck: &computepb.HTTPHealthCheck{
            Port:        proto.Int32(80),
            RequestPath: proto.String("/health"),
        },
    },
}
op, err := client.Insert(ctx, insertReq)

Example - Create HTTPS Health Check:

insertReq := &computepb.InsertHealthCheckRequest{
    Project: "my-project",
    HealthCheckResource: &computepb.HealthCheck{
        Name:               proto.String("https-health-check"),
        Type:               proto.String("HTTPS"),
        CheckIntervalSec:   proto.Int32(10),
        TimeoutSec:         proto.Int32(5),
        HealthyThreshold:   proto.Int32(2),
        UnhealthyThreshold: proto.Int32(3),
        HttpsHealthCheck: &computepb.HTTPSHealthCheck{
            Port:        proto.Int32(443),
            RequestPath: proto.String("/healthz"),
        },
    },
}
op, err := client.Insert(ctx, insertReq)

URL Maps Client

The UrlMapsClient manages URL routing maps for HTTP(S) Load Balancers.

Client Creation

func NewUrlMapsRESTClient(ctx context.Context, opts ...option.ClientOption) (*UrlMapsClient, error)

URL Map Operations

// Get retrieves a URL map
func (c *UrlMapsClient) Get(ctx context.Context, req *computepb.GetUrlMapRequest, opts ...gax.CallOption) (*computepb.UrlMap, error)

// List returns an iterator over URL maps
func (c *UrlMapsClient) List(ctx context.Context, req *computepb.ListUrlMapsRequest, opts ...gax.CallOption) *UrlMapIterator

// AggregatedList returns an iterator over URL maps across all regions
func (c *UrlMapsClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListUrlMapsRequest, opts ...gax.CallOption) *UrlMapsScopedListPairIterator

// Insert creates a new URL map
func (c *UrlMapsClient) Insert(ctx context.Context, req *computepb.InsertUrlMapRequest, opts ...gax.CallOption) (*Operation, error)

// Update updates a URL map
func (c *UrlMapsClient) Update(ctx context.Context, req *computepb.UpdateUrlMapRequest, opts ...gax.CallOption) (*Operation, error)

// Patch partially updates a URL map
func (c *UrlMapsClient) Patch(ctx context.Context, req *computepb.PatchUrlMapRequest, opts ...gax.CallOption) (*Operation, error)

// Delete deletes a URL map
func (c *UrlMapsClient) Delete(ctx context.Context, req *computepb.DeleteUrlMapRequest, opts ...gax.CallOption) (*Operation, error)

// Validate validates a URL map
func (c *UrlMapsClient) Validate(ctx context.Context, req *computepb.ValidateUrlMapRequest, opts ...gax.CallOption) (*computepb.UrlMapsValidateResponse, error)

Example - Create URL Map with Path Matching:

insertReq := &computepb.InsertUrlMapRequest{
    Project: "my-project",
    UrlMapResource: &computepb.UrlMap{
        Name:           proto.String("my-url-map"),
        DefaultService: proto.String("projects/my-project/global/backendServices/default-backend"),
        HostRules: []*computepb.HostRule{
            {
                Hosts:       []string{"example.com"},
                PathMatcher: proto.String("main-matcher"),
            },
        },
        PathMatchers: []*computepb.PathMatcher{
            {
                Name:           proto.String("main-matcher"),
                DefaultService: proto.String("projects/my-project/global/backendServices/default-backend"),
                PathRules: []*computepb.PathRule{
                    {
                        Paths:   []string{"/api/*"},
                        Service: proto.String("projects/my-project/global/backendServices/api-backend"),
                    },
                    {
                        Paths:   []string{"/static/*"},
                        Service: proto.String("projects/my-project/global/backendBuckets/static-bucket"),
                    },
                },
            },
        },
    },
}
op, err := client.Insert(ctx, insertReq)

Target HTTP Proxies Client

The TargetHttpProxiesClient manages target HTTP proxies for HTTP Load Balancers.

Client Creation

func NewTargetHttpProxiesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetHttpProxiesClient, error)

Target HTTP Proxy Operations

// Get retrieves a target HTTP proxy
func (c *TargetHttpProxiesClient) Get(ctx context.Context, req *computepb.GetTargetHttpProxyRequest, opts ...gax.CallOption) (*computepb.TargetHttpProxy, error)

// List returns an iterator over target HTTP proxies
func (c *TargetHttpProxiesClient) List(ctx context.Context, req *computepb.ListTargetHttpProxiesRequest, opts ...gax.CallOption) *TargetHttpProxyIterator

// AggregatedList returns an iterator over target HTTP proxies across all regions
func (c *TargetHttpProxiesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListTargetHttpProxiesRequest, opts ...gax.CallOption) *TargetHttpProxiesScopedListPairIterator

// Insert creates a new target HTTP proxy
func (c *TargetHttpProxiesClient) Insert(ctx context.Context, req *computepb.InsertTargetHttpProxyRequest, opts ...gax.CallOption) (*Operation, error)

// SetUrlMap changes the URL map for a target HTTP proxy
func (c *TargetHttpProxiesClient) SetUrlMap(ctx context.Context, req *computepb.SetUrlMapTargetHttpProxyRequest, opts ...gax.CallOption) (*Operation, error)

// Patch partially updates a target HTTP proxy
func (c *TargetHttpProxiesClient) Patch(ctx context.Context, req *computepb.PatchTargetHttpProxyRequest, opts ...gax.CallOption) (*Operation, error)

// Delete deletes a target HTTP proxy
func (c *TargetHttpProxiesClient) Delete(ctx context.Context, req *computepb.DeleteTargetHttpProxyRequest, opts ...gax.CallOption) (*Operation, error)

Example - Create Target HTTP Proxy:

insertReq := &computepb.InsertTargetHttpProxyRequest{
    Project: "my-project",
    TargetHttpProxyResource: &computepb.TargetHttpProxy{
        Name:   proto.String("my-http-proxy"),
        UrlMap: proto.String("projects/my-project/global/urlMaps/my-url-map"),
    },
}
op, err := client.Insert(ctx, insertReq)

Target HTTPS Proxies Client

The TargetHttpsProxiesClient manages target HTTPS proxies for HTTPS Load Balancers.

Client Creation

func NewTargetHttpsProxiesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetHttpsProxiesClient, error)

Target HTTPS Proxy Operations

// Get retrieves a target HTTPS proxy
func (c *TargetHttpsProxiesClient) Get(ctx context.Context, req *computepb.GetTargetHttpsProxyRequest, opts ...gax.CallOption) (*computepb.TargetHttpsProxy, error)

// List returns an iterator over target HTTPS proxies
func (c *TargetHttpsProxiesClient) List(ctx context.Context, req *computepb.ListTargetHttpsProxiesRequest, opts ...gax.CallOption) *TargetHttpsProxyIterator

// AggregatedList returns an iterator over target HTTPS proxies across all regions
func (c *TargetHttpsProxiesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListTargetHttpsProxiesRequest, opts ...gax.CallOption) *TargetHttpsProxiesScopedListPairIterator

// Insert creates a new target HTTPS proxy
func (c *TargetHttpsProxiesClient) Insert(ctx context.Context, req *computepb.InsertTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error)

// SetUrlMap changes the URL map for a target HTTPS proxy
func (c *TargetHttpsProxiesClient) SetUrlMap(ctx context.Context, req *computepb.SetUrlMapTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error)

// SetSslCertificates updates SSL certificates for a target HTTPS proxy
func (c *TargetHttpsProxiesClient) SetSslCertificates(ctx context.Context, req *computepb.SetSslCertificatesTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error)

// SetSslPolicy sets the SSL policy for a target HTTPS proxy
func (c *TargetHttpsProxiesClient) SetSslPolicy(ctx context.Context, req *computepb.SetSslPolicyTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error)

// Patch partially updates a target HTTPS proxy
func (c *TargetHttpsProxiesClient) Patch(ctx context.Context, req *computepb.PatchTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error)

// Delete deletes a target HTTPS proxy
func (c *TargetHttpsProxiesClient) Delete(ctx context.Context, req *computepb.DeleteTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error)

Example - Create Target HTTPS Proxy:

insertReq := &computepb.InsertTargetHttpsProxyRequest{
    Project: "my-project",
    TargetHttpsProxyResource: &computepb.TargetHttpsProxy{
        Name:   proto.String("my-https-proxy"),
        UrlMap: proto.String("projects/my-project/global/urlMaps/my-url-map"),
        SslCertificates: []string{
            "projects/my-project/global/sslCertificates/my-cert",
        },
    },
}
op, err := client.Insert(ctx, insertReq)

Target TCP Proxies Client

The TargetTcpProxiesClient manages target TCP proxies for TCP Proxy Load Balancers.

Client Creation

func NewTargetTcpProxiesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetTcpProxiesClient, error)

Target TCP Proxy Operations

// Get retrieves a target TCP proxy
func (c *TargetTcpProxiesClient) Get(ctx context.Context, req *computepb.GetTargetTcpProxyRequest, opts ...gax.CallOption) (*computepb.TargetTcpProxy, error)

// List returns an iterator over target TCP proxies
func (c *TargetTcpProxiesClient) List(ctx context.Context, req *computepb.ListTargetTcpProxiesRequest, opts ...gax.CallOption) *TargetTcpProxyIterator

// AggregatedList returns an iterator over target TCP proxies across all regions
func (c *TargetTcpProxiesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListTargetTcpProxiesRequest, opts ...gax.CallOption) *TargetTcpProxiesScopedListPairIterator

// Insert creates a new target TCP proxy
func (c *TargetTcpProxiesClient) Insert(ctx context.Context, req *computepb.InsertTargetTcpProxyRequest, opts ...gax.CallOption) (*Operation, error)

// SetBackendService changes the backend service for a target TCP proxy
func (c *TargetTcpProxiesClient) SetBackendService(ctx context.Context, req *computepb.SetBackendServiceTargetTcpProxyRequest, opts ...gax.CallOption) (*Operation, error)

// Delete deletes a target TCP proxy
func (c *TargetTcpProxiesClient) Delete(ctx context.Context, req *computepb.DeleteTargetTcpProxyRequest, opts ...gax.CallOption) (*Operation, error)

Target SSL Proxies Client

The TargetSslProxiesClient manages target SSL proxies for SSL Proxy Load Balancers.

Client Creation

func NewTargetSslProxiesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetSslProxiesClient, error)

Target SSL Proxy Operations

// Get retrieves a target SSL proxy
func (c *TargetSslProxiesClient) Get(ctx context.Context, req *computepb.GetTargetSslProxyRequest, opts ...gax.CallOption) (*computepb.TargetSslProxy, error)

// List returns an iterator over target SSL proxies
func (c *TargetSslProxiesClient) List(ctx context.Context, req *computepb.ListTargetSslProxiesRequest, opts ...gax.CallOption) *TargetSslProxyIterator

// Insert creates a new target SSL proxy
func (c *TargetSslProxiesClient) Insert(ctx context.Context, req *computepb.InsertTargetSslProxyRequest, opts ...gax.CallOption) (*Operation, error)

// SetBackendService changes the backend service for a target SSL proxy
func (c *TargetSslProxiesClient) SetBackendService(ctx context.Context, req *computepb.SetBackendServiceTargetSslProxyRequest, opts ...gax.CallOption) (*Operation, error)

// SetSslCertificates updates SSL certificates for a target SSL proxy
func (c *TargetSslProxiesClient) SetSslCertificates(ctx context.Context, req *computepb.SetSslCertificatesTargetSslProxyRequest, opts ...gax.CallOption) (*Operation, error)

// SetSslPolicy sets the SSL policy for a target SSL proxy
func (c *TargetSslProxiesClient) SetSslPolicy(ctx context.Context, req *computepb.SetSslPolicyTargetSslProxyRequest, opts ...gax.CallOption) (*Operation, error)

// Delete deletes a target SSL proxy
func (c *TargetSslProxiesClient) Delete(ctx context.Context, req *computepb.DeleteTargetSslProxyRequest, opts ...gax.CallOption) (*Operation, error)

Forwarding Rules Client

The ForwardingRulesClient manages forwarding rules that direct traffic to load balancer components.

Client Creation

func NewForwardingRulesRESTClient(ctx context.Context, opts ...option.ClientOption) (*ForwardingRulesClient, error)

Forwarding Rule Operations

// Get retrieves a forwarding rule
func (c *ForwardingRulesClient) Get(ctx context.Context, req *computepb.GetForwardingRuleRequest, opts ...gax.CallOption) (*computepb.ForwardingRule, error)

// List returns an iterator over forwarding rules in a region
func (c *ForwardingRulesClient) List(ctx context.Context, req *computepb.ListForwardingRulesRequest, opts ...gax.CallOption) *ForwardingRuleIterator

// AggregatedList returns an iterator over forwarding rules across all regions
func (c *ForwardingRulesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListForwardingRulesRequest, opts ...gax.CallOption) *ForwardingRulesScopedListPairIterator

// Insert creates a new forwarding rule
func (c *ForwardingRulesClient) Insert(ctx context.Context, req *computepb.InsertForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)

// SetTarget changes the target for a forwarding rule
func (c *ForwardingRulesClient) SetTarget(ctx context.Context, req *computepb.SetTargetForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)

// Patch partially updates a forwarding rule
func (c *ForwardingRulesClient) Patch(ctx context.Context, req *computepb.PatchForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)

// Delete deletes a forwarding rule
func (c *ForwardingRulesClient) Delete(ctx context.Context, req *computepb.DeleteForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)

Example - Create Forwarding Rule for HTTP Load Balancer:

insertReq := &computepb.InsertForwardingRuleRequest{
    Project: "my-project",
    Region:  "us-central1",
    ForwardingRuleResource: &computepb.ForwardingRule{
        Name:       proto.String("my-forwarding-rule"),
        IPProtocol: proto.String("TCP"),
        PortRange:  proto.String("80"),
        Target:     proto.String("projects/my-project/global/targetHttpProxies/my-http-proxy"),
        LoadBalancingScheme: proto.String("EXTERNAL"),
    },
}
op, err := client.Insert(ctx, insertReq)

Additional Load Balancing Clients

Target gRPC Proxies Client

func NewTargetGrpcProxiesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetGrpcProxiesClient, error)

Manages target gRPC proxies for gRPC Load Balancers.

Target Pools Client

func NewTargetPoolsRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetPoolsClient, error)

Manages legacy Network Load Balancer target pools.

Backend Buckets Client

func NewBackendBucketsRESTClient(ctx context.Context, opts ...option.ClientOption) (*BackendBucketsClient, error)

Manages Cloud Storage backend buckets for load balancers serving static content.

Regional Load Balancing

For regional load balancing resources, use the regional variants:

  • RegionBackendServicesClient - Regional backend services
  • RegionHealthChecksClient - Regional health checks
  • RegionUrlMapsClient - Regional URL maps
  • RegionTargetHttpProxiesClient - Regional HTTP proxies
  • RegionTargetHttpsProxiesClient - Regional HTTPS proxies
  • RegionTargetTcpProxiesClient - Regional TCP proxies

See Regional Clients Documentation for details.