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

other-clients.mddocs/clients/

Other Compute Clients

This document covers additional specialized clients for VPN, interconnects, node groups, reservations, addresses, and other Compute Engine resources.

VPN Clients

VPN Gateways Client

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)

VPN Tunnels Client

func NewVpnTunnelsRESTClient(ctx context.Context, opts ...option.ClientOption) (*VpnTunnelsClient, error)

Manages VPN tunnels that connect VPN gateways to external VPN endpoints.

Target VPN Gateways Client

func NewTargetVpnGatewaysRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetVpnGatewaysClient, error)

Manages classic VPN gateways (legacy, prefer VPN Gateways for new deployments).

External VPN Gateways Client

func NewExternalVpnGatewaysRESTClient(ctx context.Context, opts ...option.ClientOption) (*ExternalVpnGatewaysClient, error)

Manages external VPN gateway representations for peer VPN endpoints.

Interconnect Clients

Interconnects Client

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.

Interconnect Attachments Client

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)

Interconnect Locations Client

func NewInterconnectLocationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectLocationsClient, error)

Lists available Dedicated Interconnect locations.

Interconnect Remote Locations Client

func NewInterconnectRemoteLocationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectRemoteLocationsClient, error)

Lists available Partner Interconnect locations.

Interconnect Groups Client

func NewInterconnectGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectGroupsClient, error)

Manages interconnect groups.

Interconnect Attachment Groups Client

func NewInterconnectAttachmentGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectAttachmentGroupsClient, error)

Manages interconnect attachment groups.

Node Groups (Sole-Tenant Nodes)

Node Groups Client

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)

Node Templates Client

func NewNodeTemplatesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NodeTemplatesClient, error)

Manages node templates for sole-tenant node groups.

Node Types Client

func NewNodeTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NodeTypesClient, error)

Lists available sole-tenant node types.

Reservations

Reservations Client

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)

Future Reservations Client

func NewFutureReservationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*FutureReservationsClient, error)

Manages future compute capacity reservations.

Reservation Blocks Client

func NewReservationBlocksRESTClient(ctx context.Context, opts ...option.ClientOption) (*ReservationBlocksClient, error)

Manages reservation blocks.

Reservation Sub Blocks Client

func NewReservationSubBlocksRESTClient(ctx context.Context, opts ...option.ClientOption) (*ReservationSubBlocksClient, error)

Manages reservation sub-blocks.

Addresses

Addresses Client

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)

Global Addresses Client

func NewGlobalAddressesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalAddressesClient, error)

Manages global static IP addresses.

Global Forwarding Rules Client

func NewGlobalForwardingRulesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalForwardingRulesClient, error)

Manages global forwarding rules for load balancers.

Global Network Endpoint Groups Client

func NewGlobalNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalNetworkEndpointGroupsClient, error)

Manages global network endpoint groups.

Global Public Delegated Prefixes Client

func NewGlobalPublicDelegatedPrefixesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalPublicDelegatedPrefixesClient, error)

Manages global public delegated prefixes.

Machine and Disk Types

Machine Types Client

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)
}

Disk Types Client

func NewDiskTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*DiskTypesClient, error)

Lists available disk types in zones.

Accelerator Types Client

func NewAcceleratorTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*AcceleratorTypesClient, error)

Lists available GPU and TPU accelerator types.

Instance Groups and Templates

Instance Groups Client

func NewInstanceGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupsClient, error)

Manages unmanaged instance groups.

Instance Group Managers Client

func NewInstanceGroupManagersRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupManagersClient, error)

Manages zonal managed instance groups.

Instance Group Manager Resize Requests Client

func NewInstanceGroupManagerResizeRequestsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupManagerResizeRequestsClient, error)

Manages resize requests for managed instance groups.

Instance Templates Client

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)

Instance Settings Client

func NewInstanceSettingsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceSettingsClient, error)

Manages instance settings at the project/zone level.

Autoscalers Client

func NewAutoscalersRESTClient(ctx context.Context, opts ...option.ClientOption) (*AutoscalersClient, error)

Manages zonal autoscalers for managed instance groups.

Resource Policies

Resource Policies Client

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)

Network Endpoint Groups

Network Endpoint Groups Client

func NewNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkEndpointGroupsClient, error)

Manages zonal network endpoint groups.

Miscellaneous Clients

Packet Mirrorings Client

func NewPacketMirroringsRESTClient(ctx context.Context, opts ...option.ClientOption) (*PacketMirroringsClient, error)

Manages packet mirroring configurations for network traffic inspection.

Service Attachments Client

func NewServiceAttachmentsRESTClient(ctx context.Context, opts ...option.ClientOption) (*ServiceAttachmentsClient, error)

Manages Private Service Connect service attachments.

Network Attachments Client

func NewNetworkAttachmentsRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkAttachmentsClient, error)

Manages network attachments.

Network Profiles Client

func NewNetworkProfilesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkProfilesClient, error)

Manages network profiles.

Licenses Client

func NewLicensesRESTClient(ctx context.Context, opts ...option.ClientOption) (*LicensesClient, error)

Manages software licenses.

License Codes Client

func NewLicenseCodesRESTClient(ctx context.Context, opts ...option.ClientOption) (*LicenseCodesClient, error)

Retrieves license code information.

Public Advertised Prefixes Client

func NewPublicAdvertisedPrefixesRESTClient(ctx context.Context, opts ...option.ClientOption) (*PublicAdvertisedPrefixesClient, error)

Manages public advertised prefixes.

Public Delegated Prefixes Client

func NewPublicDelegatedPrefixesRESTClient(ctx context.Context, opts ...option.ClientOption) (*PublicDelegatedPrefixesClient, error)

Manages public delegated prefixes.

Projects Client

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.

Zones Client

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)
}

Advice Client

func NewAdviceRESTClient(ctx context.Context, opts ...option.ClientOption) (*AdviceClient, error)

Provides optimization recommendations for compute resources.

Preview Features Client

func NewPreviewFeaturesRESTClient(ctx context.Context, opts ...option.ClientOption) (*PreviewFeaturesClient, error)

Manages preview features.

Wire Groups Client

func NewWireGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*WireGroupsClient, error)

Manages wire groups.

Cross Site Networks Client

func NewCrossSiteNetworksRESTClient(ctx context.Context, opts ...option.ClientOption) (*CrossSiteNetworksClient, error)

Manages cross-site networks.

Backend Buckets Client

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

Manages Cloud Storage backend buckets for load balancers.

Target Instances Client

func NewTargetInstancesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetInstancesClient, error)

Manages target instances for load balancing to specific instances.

Target Pools Client

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

Manages legacy Network Load Balancer target pools.

Target gRPC Proxies Client

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

Manages target gRPC proxies for gRPC load balancing.

Storage Pool Types Client

func NewStoragePoolTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*StoragePoolTypesClient, error)

Lists available storage pool types.

Complete Client List

The package provides 109 client types total across all categories:

  1. Core Compute: Instances, Disks, Images, Snapshots, Machine Types
  2. Networking: Networks, Subnets, Firewalls, Routes, Routers
  3. Load Balancing: Backend Services, Health Checks, Target Proxies, URL Maps, Forwarding Rules
  4. Security: Security Policies, SSL Certificates, SSL Policies
  5. VPN: VPN Gateways, VPN Tunnels, External VPN Gateways
  6. Interconnect: Interconnects, Attachments, Locations
  7. Instance Groups: Instance Groups, Managers, Templates, Autoscalers
  8. Regional Resources: 23 regional client variants
  9. Operations: Global, Regional, Zonal operations
  10. Metadata and Info: Machine Types, Disk Types, Zones, Regions
  11. Specialized: Node Groups, Reservations, Packet Mirroring, Service Attachments

See the main documentation index for links to detailed documentation for each category.