tessl install tessl/golang-cloud-google-com--go--compute@1.53.0Go client library for Google Cloud Compute Engine API providing programmatic access to manage virtual machines, disks, networks, and other compute resources
This document covers additional specialized clients for VPN, interconnects, node groups, reservations, addresses, and other Compute Engine resources.
func NewVpnGatewaysRESTClient(ctx context.Context, opts ...option.ClientOption) (*VpnGatewaysClient, error)Manages HA VPN gateways for secure VPN connections with automatic failover.
Key operations: Create HA VPN gateways; configure VPN interfaces; get gateway status.
Example:
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
"cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/protobuf/proto"
)
ctx := context.Background()
client, err := compute.NewVpnGatewaysRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
insertReq := &computepb.InsertVpnGatewayRequest{
Project: "my-project",
Region: "us-central1",
VpnGatewayResource: &computepb.VpnGateway{
Name: proto.String("my-vpn-gateway"),
Network: proto.String("projects/my-project/global/networks/my-vpc"),
},
}
op, err := client.Insert(ctx, insertReq)func NewVpnTunnelsRESTClient(ctx context.Context, opts ...option.ClientOption) (*VpnTunnelsClient, error)Manages VPN tunnels that connect VPN gateways to external VPN endpoints.
func NewTargetVpnGatewaysRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetVpnGatewaysClient, error)Manages classic VPN gateways (legacy, prefer VPN Gateways for new deployments).
func NewExternalVpnGatewaysRESTClient(ctx context.Context, opts ...option.ClientOption) (*ExternalVpnGatewaysClient, error)Manages external VPN gateway representations for peer VPN endpoints.
func NewInterconnectsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectsClient, error)Manages Dedicated Interconnect connections between on-premises networks and Google Cloud.
Key operations: List interconnects; get interconnect details; update interconnect configuration.
func NewInterconnectAttachmentsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectAttachmentsClient, error)Manages VLAN attachments (interconnect attachments) for Dedicated and Partner Interconnect.
Example:
client, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
insertReq := &computepb.InsertInterconnectAttachmentRequest{
Project: "my-project",
Region: "us-central1",
InterconnectAttachmentResource: &computepb.InterconnectAttachment{
Name: proto.String("my-vlan-attachment"),
Interconnect: proto.String("projects/my-project/global/interconnects/my-interconnect"),
Router: proto.String("projects/my-project/regions/us-central1/routers/my-router"),
VlanTag8021Q: proto.Int32(1000),
},
}
op, err := client.Insert(ctx, insertReq)func NewInterconnectLocationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectLocationsClient, error)Lists available Dedicated Interconnect locations.
func NewInterconnectRemoteLocationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectRemoteLocationsClient, error)Lists available Partner Interconnect locations.
func NewInterconnectGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectGroupsClient, error)Manages interconnect groups.
func NewInterconnectAttachmentGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectAttachmentGroupsClient, error)Manages interconnect attachment groups.
func NewNodeGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*NodeGroupsClient, error)Manages node groups for sole-tenant nodes.
Key operations: Create node groups; add/delete nodes; configure autoscaling; set node template.
Example:
client, err := compute.NewNodeGroupsRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
insertReq := &computepb.InsertNodeGroupRequest{
Project: "my-project",
Zone: "us-central1-a",
NodeGroupResource: &computepb.NodeGroup{
Name: proto.String("my-node-group"),
NodeTemplate: proto.String("projects/my-project/regions/us-central1/nodeTemplates/my-template"),
Size: proto.Int32(3),
},
}
op, err := client.Insert(ctx, insertReq)func NewNodeTemplatesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NodeTemplatesClient, error)Manages node templates for sole-tenant node groups.
func NewNodeTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NodeTypesClient, error)Lists available sole-tenant node types.
func NewReservationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*ReservationsClient, error)Manages compute capacity reservations.
Key operations: Create reservations; update reservation size; delete reservations.
Example:
client, err := compute.NewReservationsRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
insertReq := &computepb.InsertReservationRequest{
Project: "my-project",
Zone: "us-central1-a",
ReservationResource: &computepb.Reservation{
Name: proto.String("my-reservation"),
SpecificReservation: &computepb.AllocationSpecificSKUReservation{
Count: proto.Int64(10),
InstanceProperties: &computepb.AllocationSpecificSKUAllocationReservedInstanceProperties{
MachineType: proto.String("n1-standard-4"),
},
},
},
}
op, err := client.Insert(ctx, insertReq)func NewFutureReservationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*FutureReservationsClient, error)Manages future compute capacity reservations.
func NewReservationBlocksRESTClient(ctx context.Context, opts ...option.ClientOption) (*ReservationBlocksClient, error)Manages reservation blocks.
func NewReservationSubBlocksRESTClient(ctx context.Context, opts ...option.ClientOption) (*ReservationSubBlocksClient, error)Manages reservation sub-blocks.
func NewAddressesRESTClient(ctx context.Context, opts ...option.ClientOption) (*AddressesClient, error)Manages regional static IP addresses.
Key operations: Reserve static IPs; release addresses; list addresses.
Example:
client, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
insertReq := &computepb.InsertAddressRequest{
Project: "my-project",
Region: "us-central1",
AddressResource: &computepb.Address{
Name: proto.String("my-static-ip"),
AddressType: proto.String("EXTERNAL"),
Description: proto.String("Static IP for load balancer"),
},
}
op, err := client.Insert(ctx, insertReq)func NewGlobalAddressesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalAddressesClient, error)Manages global static IP addresses.
func NewGlobalForwardingRulesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalForwardingRulesClient, error)Manages global forwarding rules for load balancers.
func NewGlobalNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalNetworkEndpointGroupsClient, error)Manages global network endpoint groups.
func NewGlobalPublicDelegatedPrefixesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalPublicDelegatedPrefixesClient, error)Manages global public delegated prefixes.
func NewMachineTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*MachineTypesClient, error)Lists available machine types in zones.
Example:
import "google.golang.org/api/iterator"
client, err := compute.NewMachineTypesRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
listReq := &computepb.ListMachineTypesRequest{
Project: "my-project",
Zone: "us-central1-a",
}
it := client.List(ctx, listReq)
for {
machineType, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// handle error
}
fmt.Printf("Machine Type: %s, vCPUs: %d, Memory: %d MB\n",
*machineType.Name, *machineType.GuestCpus, *machineType.MemoryMb)
}func NewDiskTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*DiskTypesClient, error)Lists available disk types in zones.
func NewAcceleratorTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*AcceleratorTypesClient, error)Lists available GPU and TPU accelerator types.
func NewInstanceGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupsClient, error)Manages unmanaged instance groups.
func NewInstanceGroupManagersRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupManagersClient, error)Manages zonal managed instance groups.
func NewInstanceGroupManagerResizeRequestsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupManagerResizeRequestsClient, error)Manages resize requests for managed instance groups.
func NewInstanceTemplatesRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceTemplatesClient, error)Manages instance templates for creating instances and managed instance groups.
Example:
client, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
insertReq := &computepb.InsertInstanceTemplateRequest{
Project: "my-project",
InstanceTemplateResource: &computepb.InstanceTemplate{
Name: proto.String("my-template"),
Properties: &computepb.InstanceProperties{
MachineType: proto.String("n1-standard-1"),
Disks: []*computepb.AttachedDisk{
{
Boot: proto.Bool(true),
AutoDelete: proto.Bool(true),
InitializeParams: &computepb.AttachedDiskInitializeParams{
SourceImage: proto.String("projects/debian-cloud/global/images/family/debian-11"),
},
},
},
NetworkInterfaces: []*computepb.NetworkInterface{
{
Network: proto.String("global/networks/default"),
},
},
},
},
}
op, err := client.Insert(ctx, insertReq)func NewInstanceSettingsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceSettingsClient, error)Manages instance settings at the project/zone level.
func NewAutoscalersRESTClient(ctx context.Context, opts ...option.ClientOption) (*AutoscalersClient, error)Manages zonal autoscalers for managed instance groups.
func NewResourcePoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) (*ResourcePoliciesClient, error)Manages resource policies including snapshot schedules.
Example - Create Snapshot Schedule:
client, err := compute.NewResourcePoliciesRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
insertReq := &computepb.InsertResourcePolicyRequest{
Project: "my-project",
Region: "us-central1",
ResourcePolicyResource: &computepb.ResourcePolicy{
Name: proto.String("daily-snapshot"),
SnapshotSchedulePolicy: &computepb.ResourcePolicySnapshotSchedulePolicy{
Schedule: &computepb.ResourcePolicySnapshotSchedulePolicySchedule{
DailySchedule: &computepb.ResourcePolicyDailyCycle{
StartTime: proto.String("04:00"),
},
},
RetentionPolicy: &computepb.ResourcePolicySnapshotSchedulePolicyRetentionPolicy{
MaxRetentionDays: proto.Int32(7),
},
},
},
}
op, err := client.Insert(ctx, insertReq)func NewNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkEndpointGroupsClient, error)Manages zonal network endpoint groups.
func NewPacketMirroringsRESTClient(ctx context.Context, opts ...option.ClientOption) (*PacketMirroringsClient, error)Manages packet mirroring configurations for network traffic inspection.
func NewServiceAttachmentsRESTClient(ctx context.Context, opts ...option.ClientOption) (*ServiceAttachmentsClient, error)Manages Private Service Connect service attachments.
func NewNetworkAttachmentsRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkAttachmentsClient, error)Manages network attachments.
func NewNetworkProfilesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkProfilesClient, error)Manages network profiles.
func NewLicensesRESTClient(ctx context.Context, opts ...option.ClientOption) (*LicensesClient, error)Manages software licenses.
func NewLicenseCodesRESTClient(ctx context.Context, opts ...option.ClientOption) (*LicenseCodesClient, error)Retrieves license code information.
func NewPublicAdvertisedPrefixesRESTClient(ctx context.Context, opts ...option.ClientOption) (*PublicAdvertisedPrefixesClient, error)Manages public advertised prefixes.
func NewPublicDelegatedPrefixesRESTClient(ctx context.Context, opts ...option.ClientOption) (*PublicDelegatedPrefixesClient, error)Manages public delegated prefixes.
func NewProjectsRESTClient(ctx context.Context, opts ...option.ClientOption) (*ProjectsClient, error)Manages project-level settings and metadata.
Key operations: Get project settings; set common instance metadata; enable/disable features.
func NewZonesRESTClient(ctx context.Context, opts ...option.ClientOption) (*ZonesClient, error)Lists available zones and their properties.
Example:
client, err := compute.NewZonesRESTClient(ctx)
if err != nil {
// handle error
}
defer client.Close()
listReq := &computepb.ListZonesRequest{
Project: "my-project",
}
it := client.List(ctx, listReq)
for {
zone, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// handle error
}
fmt.Printf("Zone: %s, Region: %s, Status: %s\n",
*zone.Name, *zone.Region, *zone.Status)
}func NewAdviceRESTClient(ctx context.Context, opts ...option.ClientOption) (*AdviceClient, error)Provides optimization recommendations for compute resources.
func NewPreviewFeaturesRESTClient(ctx context.Context, opts ...option.ClientOption) (*PreviewFeaturesClient, error)Manages preview features.
func NewWireGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*WireGroupsClient, error)Manages wire groups.
func NewCrossSiteNetworksRESTClient(ctx context.Context, opts ...option.ClientOption) (*CrossSiteNetworksClient, error)Manages cross-site networks.
func NewBackendBucketsRESTClient(ctx context.Context, opts ...option.ClientOption) (*BackendBucketsClient, error)Manages Cloud Storage backend buckets for load balancers.
func NewTargetInstancesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetInstancesClient, error)Manages target instances for load balancing to specific instances.
func NewTargetPoolsRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetPoolsClient, error)Manages legacy Network Load Balancer target pools.
func NewTargetGrpcProxiesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetGrpcProxiesClient, error)Manages target gRPC proxies for gRPC load balancing.
func NewStoragePoolTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*StoragePoolTypesClient, error)Lists available storage pool types.
The package provides 109 client types total across all categories:
See the main documentation index for links to detailed documentation for each category.